From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A9E928E609; Tue, 15 Apr 2025 11:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715559; cv=none; b=hSKca1g2P+mMUJv+Ui5DcbCOVAZeqmqxdx8pgGR3DnBnrGOO8/UvlvmZ+VI/KbC2cW+TJSRABH3enUeEC6/1R893yTfrc0FtYnEp/ucaH86U/rRlv074nsJP8Vp9/eMAuCymojVNUnY1JTNKl4LCAS+ceI7mqmjnnPkYeTGZaHQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715559; c=relaxed/simple; bh=gB8yrvSA/Ovks1vLezMGhbV76PrOeLE5o74xpf5wfbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8PJfBj10SqlyNsqoa8hsAvtcE2JxtwoqxFVpB2AO1dxm/URwcPrKKxJs9AG1boNZQJdx2yY7E1RUzvfZUdcxU5WuQGlkSBEyfI83tQNHo1jggnPeSTJTqa8v18aij+fLtSX1MQYZD8wUpNwk1QeQuGFLsxyFB0l0Ke/1pv2fEw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=houx5ImR; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="houx5ImR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715558; x=1776251558; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gB8yrvSA/Ovks1vLezMGhbV76PrOeLE5o74xpf5wfbA=; b=houx5ImRSK6Pck0HAdc42opG6Ydb+II6gAEn1w5Q9O2pPKD1se8XcSZ1 /+oBRIyv0e09yvptMIXSF0UurjqmZbGohFC/A2d67wC8sAT/knWtoqU9R mQPj2Cds+NrSkyVh7eQlNB+oYA0ucziLFS64py9NVvi/6BPYV3sgrUyX/ Z9QzuUuDfzw5qzE2qZ/EscCSIUzFZNpM+rHa1JxmHQNN+pyZbTR6rlpmI N2dIDWWGRLqr5wCbFmzPh701laj4hfwLh75cBAy2sWLbIozdN1nC/OvVM I9MVhUjqoE3rTtfDF46fiJd0n/IBMb5NvHhjgQF0E2n69DfsjVT6lAluA Q==; X-CSE-ConnectionGUID: u4r/CQ1IRiyD2jkexUFDOQ== X-CSE-MsgGUID: G5icWeb0Sn6l79MTKUy5XA== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="57601856" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="57601856" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:29 -0700 X-CSE-ConnectionGUID: 31tnkVkfTvqRcAogELzw4Q== X-CSE-MsgGUID: a8x0+hsrQfCne1w0ySI/Sw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="161071611" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa002.jf.intel.com with ESMTP; 15 Apr 2025 04:11:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AA57517B; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 1/7] gpiolib: Print actual error when descriptor contains an error pointer Date: Tue, 15 Apr 2025 14:10:00 +0300 Message-ID: <20250415111124.1539366-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Print the actual error when descriptor contains an error pointer. This might help debugging those rare cases. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index eb94428af6c0..0089745b381f 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2445,7 +2445,7 @@ static int validate_desc(const struct gpio_desc *desc= , const char *func) return 0; =20 if (IS_ERR(desc)) { - pr_warn("%s: invalid GPIO (errorpointer)\n", func); + pr_warn("%s: invalid GPIO (errorpointer: %pe)\n", func, desc); return PTR_ERR(desc); } =20 --=20 2.47.2 From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14E0928DF17; Tue, 15 Apr 2025 11:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715493; cv=none; b=OZDh0b0NlnH7cOCHNpTDeF/IjhaP5aSHeNb7EitYBYVYbZko0CpxajBjYqV9HcFFkJd/DrFVabfzHDlD0OCIqsfxY349Z6m6WZEU3WpZCt+c9o6JzmbrMdmabyRoSkf8z2s+cm2IVR/Hi06zMYqladMj2xpti0sbzYcmmFeY+nE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715493; c=relaxed/simple; bh=LjmqfPsWEcMdIat4tKcgJ54RpqfMMCi+Zo+oY6oUkzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sW1iu1wu3AIRgb0foNGcZByVh2LmKdzO1gro1J7JBaHn6a2TUZqrtPxoISzTeerC/UjlQxaPFlFlEI5cCvs+C1lXCtsrQMFrRgfUApdCcyl153IHFhBeqqfm9ConWhWUo+j4Um5STUqNsOSVjM7oMmzxm8y+p4TxtImVMzZL4Og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ZOpDqypI; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZOpDqypI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715492; x=1776251492; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LjmqfPsWEcMdIat4tKcgJ54RpqfMMCi+Zo+oY6oUkzM=; b=ZOpDqypIaVARjzrN4uQTo8DoplVKL9Qrryq56AYnuF8hheQdD2bTwvi2 sC9dodQfIRz0pS6mscutmelj81DvmJjbFxxzCMaKAGo5pOwrcLA/b3WHT RcpIYTmH201wj9skhX9zEfIbbnFL9qoDv0N1EbdoZLkjz17gYOoUIIxV3 4GxmzrrpaSFJhFmEqYK42zWZWLikGC3T4fA57FGOrLuzQ+mys2mPQZtC2 IT0O/Dn2sGE7K47XxwTodouNL7qGJ2faJknbNZBNg00tYRFoj1UBpeJ1v Xc9e+PKfMX4rPHhapWtRZ00/L6sDpFhPikK+7RGJ++I0SS3a8TwOhDDaM w==; X-CSE-ConnectionGUID: Gm5D0tOtRECsoTD4LbSqMw== X-CSE-MsgGUID: iT8r3G+HSL23pFhWRROwLw== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="46382943" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="46382943" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:29 -0700 X-CSE-ConnectionGUID: ZpjttxKoTCmbpPzJfhiYvg== X-CSE-MsgGUID: Mn0+ktS+TRC4ECXC1POJaw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="135072303" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 15 Apr 2025 04:11:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id B50F5AD4; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 2/7] gpiolib: Revert "Don't WARN on gpiod_put() for optional GPIO" Date: Tue, 15 Apr 2025 14:10:01 +0300 Message-ID: <20250415111124.1539366-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" No need to double check the pointer for NULL since gpiod_free() is using VALIDATE_DESC_VOID() which simply returns in that case. This reverts commit 1d7765ba15aca68f3bc52f59434c1c34855bbb54. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0089745b381f..8ea5ddf4704d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -5156,8 +5156,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_array_optional); */ void gpiod_put(struct gpio_desc *desc) { - if (desc) - gpiod_free(desc); + gpiod_free(desc); } EXPORT_SYMBOL_GPL(gpiod_put); =20 --=20 2.47.2 From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48F5328E606; Tue, 15 Apr 2025 11:12:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715557; cv=none; b=s9jRjrw4afm8eYlf/h41dYy0YnNYslZzJnxEArV3kmH0hi9XPnn9+sYSwkf55lpUjpJQKY6c9xjfegfPaSp5FS+eD9RVvZqNyyA3tbuFJgTWEAFdjCwbcPFNsY51tI2IgmcMtJEIRdej8yLe/E/JynaGd8UsAm7/U3+aCUsLhyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715557; c=relaxed/simple; bh=20S7oTr7Bre2LiZQqbYrm2hkVz72OdJ/TST6h/CzgZQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hLHs7Zw1baJrG6aqDJom77zFuubRK6lVN8MXrJ1NPdV77vFMZairVM7w5W9ZpNU5QR2U4H/FiPIb00Z8B4ZapP3Xe7gab/Hnh5yEOJZJ+yfqVA1qaV3COALkjZZRCOgG4Jc64VGP5xhVq3OEZFjfmKzQEdxMv07k14R5cRi5UAE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JZtFSnDj; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="JZtFSnDj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715556; x=1776251556; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=20S7oTr7Bre2LiZQqbYrm2hkVz72OdJ/TST6h/CzgZQ=; b=JZtFSnDj3+jxse7gLHKwYaTzUqKfrco6iS+E+hcNBf323xomuBpUpnKa KE95g1HaozvJJM4glb7G7+MMuZSKOMxi/M2qbgbQSL08prYEIA68OqsPV IUMz4pMEeU42+fLimd8jhyJRq8SUJEt5b76zzISL4TBJWkTq+jGB0AO25 7EmsUOYslPK2CR2+/eQwZfTb1kjJdaDIiZy9wnSyYIu4d5jhzJm0PA/d8 b1OFjIUatFoEZFoVRwwrwNc280dSs2zgOgrF1PP0SGv2180d4rXJRJyKw JXimrrVshuzoIEXSDV45j4/WZxrV+uMsDstB9MwSAOUjhxWYxjkhsOdzy Q==; X-CSE-ConnectionGUID: 6QqG0jq8QLKNafuDQadKcg== X-CSE-MsgGUID: KUDlKXvjTc+ZZRDnOfPQYw== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="57601853" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="57601853" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:29 -0700 X-CSE-ConnectionGUID: lkDKgJLYQmiJiMaRa/O0dA== X-CSE-MsgGUID: 8ZXmUTLVTz+CPlmx6uHmSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="161071610" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa002.jf.intel.com with ESMTP; 15 Apr 2025 04:11:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C39ADAF1; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 3/7] gpiolib: Move validate_desc() and Co upper in the code Date: Tue, 15 Apr 2025 14:10:02 +0300 Message-ID: <20250415111124.1539366-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move validate_desc() and Co upper in the code to be able to use in the further changes. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 62 +++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8ea5ddf4704d..1fdf4d2ceb36 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -356,6 +356,37 @@ static int gpiochip_find_base_unlocked(u16 ngpio) } } =20 +/* + * This descriptor validation needs to be inserted verbatim into each + * function taking a descriptor, so we need to use a preprocessor + * macro to avoid endless duplication. If the desc is NULL it is an + * optional GPIO and calls should just bail out. + */ +static int validate_desc(const struct gpio_desc *desc, const char *func) +{ + if (!desc) + return 0; + + if (IS_ERR(desc)) { + pr_warn("%s: invalid GPIO (errorpointer: %pe)\n", func, desc); + return PTR_ERR(desc); + } + + return 1; +} + +#define VALIDATE_DESC(desc) do { \ + int __valid =3D validate_desc(desc, __func__); \ + if (__valid <=3D 0) \ + return __valid; \ + } while (0) + +#define VALIDATE_DESC_VOID(desc) do { \ + int __valid =3D validate_desc(desc, __func__); \ + if (__valid <=3D 0) \ + return; \ + } while (0) + static int gpiochip_get_direction(struct gpio_chip *gc, unsigned int offse= t) { int ret; @@ -2433,37 +2464,6 @@ static int gpiod_request_commit(struct gpio_desc *de= sc, const char *label) return ret; } =20 -/* - * This descriptor validation needs to be inserted verbatim into each - * function taking a descriptor, so we need to use a preprocessor - * macro to avoid endless duplication. If the desc is NULL it is an - * optional GPIO and calls should just bail out. - */ -static int validate_desc(const struct gpio_desc *desc, const char *func) -{ - if (!desc) - return 0; - - if (IS_ERR(desc)) { - pr_warn("%s: invalid GPIO (errorpointer: %pe)\n", func, desc); - return PTR_ERR(desc); - } - - return 1; -} - -#define VALIDATE_DESC(desc) do { \ - int __valid =3D validate_desc(desc, __func__); \ - if (__valid <=3D 0) \ - return __valid; \ - } while (0) - -#define VALIDATE_DESC_VOID(desc) do { \ - int __valid =3D validate_desc(desc, __func__); \ - if (__valid <=3D 0) \ - return; \ - } while (0) - int gpiod_request(struct gpio_desc *desc, const char *label) { int ret =3D -EPROBE_DEFER; --=20 2.47.2 From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CA9E4594A; Tue, 15 Apr 2025 11:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715491; cv=none; b=Z3HzCqW2Q6YFELJuqlmy6K3ViEar3yzuK6q4y6rdNrQ/23Yi+be/h5l2zC9wneQrzWNOloJQkcal9f/QC3jbtcwXLpzROIByLOBPmSt2dKC6Gg1j93vWubunRk/IIzIXgSk+2RdiKZknWuy38w0McHSIcmKvWYhwfnStYq3WGnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715491; c=relaxed/simple; bh=5O+TWwoTGF0fOCQ4q3zxi3Zh2dtvprSSI8FzJtxkkmY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FVpQnaBVgJUXAIij3v7wkFmElIEOJgJiPreH1oBhYih+0FhRFqg0D1xGrS+3ZTzUPhXCUdnKTanaXJIlluAlWvi0U2QCSbdXdx35aBht0iQJbmKj7OSbCwiYYcLkt/LZR+ZZlxIH/VYDIVghB8gfDc/6MSyQxzP3fHOrvTwKQwo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SEkG4SUe; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SEkG4SUe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715489; x=1776251489; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5O+TWwoTGF0fOCQ4q3zxi3Zh2dtvprSSI8FzJtxkkmY=; b=SEkG4SUe/LGzd7mNXEtv3HR3ueyBJQO9EYTdciO91YZFKlDClS3aunWu Uke+MwaCsokAxISuMzIwu5bXARghtP9wX0hWsgMO9fmYFYR0HbgtkRdMV Pwwy8oBZRoE0Sy2A2jUgPKF4zNJH2UpMrisQ+snGELDqTgfh7JXextIPR sAV7QBvRY5e0Ig46pMYKqVad9sRPezX1EvNfN9Ei1F/6RLHJGzZrWpnkO iOjTv1SAikOvjiq6VJ0G1QUzWbT+pOCmx4aqpiw6dyhddzOXyDpJOSTIh TAfgAMXkD2wqI68HGjRmqBnpI/ULuKjA8+Ecs3jUY6V6Nib/EvaNDH3H6 w==; X-CSE-ConnectionGUID: ju8KkC9LS/SiecPNz6Gceg== X-CSE-MsgGUID: nDgbRDRtTHO3+gj/xZHxqQ== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="46382936" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="46382936" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:28 -0700 X-CSE-ConnectionGUID: 4MJ2KOshSaCtMl0ZXtTbSA== X-CSE-MsgGUID: 3wrXVwMMR1CnKgAVfRiPqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="135072301" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 15 Apr 2025 04:11:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id CC7FAB0A; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 4/7] gpiolib: Call validate_desc() when VALIDATE_DESC() can't be used Date: Tue, 15 Apr 2025 14:10:03 +0300 Message-ID: <20250415111124.1539366-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Call validate_desc() directly when VALIDATE_DESC() can't be used. It will print additional information useful for debugging. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 1fdf4d2ceb36..6b307144e41a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -421,11 +421,8 @@ int gpiod_get_direction(struct gpio_desc *desc) unsigned int offset; int ret; =20 - /* - * We cannot use VALIDATE_DESC() as we must not return 0 for a NULL - * descriptor like we usually do. - */ - if (IS_ERR_OR_NULL(desc)) + ret =3D validate_desc(desc, __func__); + if (ret <=3D 0) return -EINVAL; =20 CLASS(gpio_chip_guard, guard)(desc); @@ -3992,13 +3989,10 @@ int gpiod_to_irq(const struct gpio_desc *desc) struct gpio_device *gdev; struct gpio_chip *gc; int offset; + int ret; =20 - /* - * Cannot VALIDATE_DESC() here as gpiod_to_irq() consumer semantics - * requires this function to not return zero on an invalid descriptor - * but rather a negative error number. - */ - if (IS_ERR_OR_NULL(desc)) + ret =3D validate_desc(desc, __func__); + if (ret <=3D 0) return -EINVAL; =20 gdev =3D desc->gdev; @@ -4010,13 +4004,12 @@ int gpiod_to_irq(const struct gpio_desc *desc) =20 offset =3D gpio_chip_hwgpio(desc); if (gc->to_irq) { - int retirq =3D gc->to_irq(gc, offset); + ret =3D gc->to_irq(gc, offset); + if (ret) + return ret; =20 /* Zero means NO_IRQ */ - if (!retirq) - return -ENXIO; - - return retirq; + return -ENXIO; } #ifdef CONFIG_GPIOLIB_IRQCHIP if (gc->irq.chip) { --=20 2.47.2 From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C6A0291144; Tue, 15 Apr 2025 11:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715494; cv=none; b=d09LCkYEpfck0EE0p+fX8gfE+p2LLIT1kaJz1xxhH9chPqsC/TXqX15w+w7xIOB3T5bZMxYCpITvIoRbFxw1QOy5+KHLWQE/yNV0wmN7uGevKd424is/FfW/7KubmiuBRa2GI3m7cquowbDNHk28QWrdekcxpoPjaPKY+6jTMLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715494; c=relaxed/simple; bh=5HELnZXILMLdeLE/tBLoPsoX5uUQXcyPwSW+vFDpizU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k2/NWEBv5Jg8yCHOlTKJSFWYYO8zJ5u1uzDt5KiDqmPC+zjlCqMyYhGIdHEn1fI4RR9wxz7zVeyiOv+aSF9YnZ4FRVlPVprux+L09YNP16xkYWMIHPvcP0hqxvEsVxtm9iFh/Ig6fMrkyWyDSuqxndTwWuI+3NJTtGeveGwdV9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lUrME+22; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lUrME+22" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715493; x=1776251493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5HELnZXILMLdeLE/tBLoPsoX5uUQXcyPwSW+vFDpizU=; b=lUrME+22F1YJ6UanXJnbjY4usXmIIT6I7/u1G7AFmIcHrpSgSHUqhylH S66DjQZJpKaB0eejs84YxN5mZ7rvFYmGoXjafmgu78QTO8UV3KuwVjuPL CRqVRYLXG7gENt4+ETEDU34tgf3VgQHmXXYjjaVfJ3ZEss6IDTGw3UhFW aoOHS41GDdWVSVsL6Eyzx2fNgWUrXo4FEwIVyfdxduJg5WJmB+T2Q2fjm qHHZp03uMG3x3weOADfReCzQy8DMvG69XicCXw6APSgR+9/yyN4Rj3mCn 2gVp0LZ0ICv6J14YGaQL6uNmIwOSndkGvXIAOuyNL92IpCS054S+AZ8jF g==; X-CSE-ConnectionGUID: MCDdSc0wRCqG9Qg+W4X2Ow== X-CSE-MsgGUID: 6gVez3UAScanfnn99XzH/w== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="46382949" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="46382949" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:31 -0700 X-CSE-ConnectionGUID: ZY/RSKY8S92dEXSPMhT9fg== X-CSE-MsgGUID: THA5DlJpQUCid5O67nMYYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="135072309" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 15 Apr 2025 04:11:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id DA7BBB0C; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 5/7] gpiolib: Make taking gpio_lookup_lock consistent Date: Tue, 15 Apr 2025 14:10:04 +0300 Message-ID: <20250415111124.1539366-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There are two ways to take a lock: plain call to the mutex_lock() or using guard()() / scoped_guard(). The driver inconsistently uses both. Make taking gpio_lookup_lock consistent. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 6b307144e41a..cc12f274ccda 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4364,12 +4364,10 @@ void gpiod_add_lookup_tables(struct gpiod_lookup_ta= ble **tables, size_t n) { unsigned int i; =20 - mutex_lock(&gpio_lookup_lock); + guard(mutex)(&gpio_lookup_lock); =20 for (i =3D 0; i < n; i++) list_add_tail(&tables[i]->list, &gpio_lookup_list); - - mutex_unlock(&gpio_lookup_lock); } =20 /** @@ -4428,11 +4426,9 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_t= able *table) if (!table) return; =20 - mutex_lock(&gpio_lookup_lock); + guard(mutex)(&gpio_lookup_lock); =20 list_del(&table->list); - - mutex_unlock(&gpio_lookup_lock); } EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table); =20 --=20 2.47.2 From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A17BC28F53A; Tue, 15 Apr 2025 11:12:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715561; cv=none; b=REMkYe0Gdl39pxDov1wFN88mjXUb9ADHVxEdcs7mC6qlXF0CJz7l436RBaZo2lMHPEY6sfElz0ImM5zVZIc+ps2WJqnCZZbQpXgr+ndhe4/o3D8AMPA7QacOWjaTUQ/aAemueJ21Xx1O0XYLDEvRzudGI6VUHEwvgQ3kBEFj8UM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715561; c=relaxed/simple; bh=yFDUH7vRo7zP7rsczdpfm1FLDJHRdQfsh5hGz0uSguA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KOEe4p7IyPPL665tTguPGw5PXpTbD+99sQsEv+5y4jaFvUEL9oJn/k1A7KbykfhCg33V5kNccbV5Oon0jKwv4ViMaZUaRvGeZhN04ebhIaV90Z2raMV01jvL/tNCyTWTZMfaQIuSk5xFGoarQVtDHhTog5+26oZPYDNTCwcxO0w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YGI3ebsC; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YGI3ebsC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715560; x=1776251560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yFDUH7vRo7zP7rsczdpfm1FLDJHRdQfsh5hGz0uSguA=; b=YGI3ebsCnFEI5LFDUHN7cAm/EEpBjwYNa3C4MV43xbiZ+ephu3a13Arv cqVBJm6sTx9G7LF9kxYz1hceT14yi6wCMFgnS2UVt5wuf94ybnFsoM+2o sZYkotDIWYRB0iwxNBSFPtkJ4ZFJrazrr231bGGCaxgIwYFts6Uvjpcg3 YksTdbJCPWk94PVR9+80ixZ9wZAEnDWr00QiYEuLvPSdUnqKikPtQOZEd WWeslHvrMFqzXv3rGnwN4SdnOXj6R7eLdl2DtpjSEkbJ24lPQQKRwhttl eNa1zGuUyVCqasSl96JG+hSib6KfYai6W3m/w3I17581HrQDZKuZ6JDfG w==; X-CSE-ConnectionGUID: VHZVVdp3Sju0x4tPTLUIkw== X-CSE-MsgGUID: ZHSs6QYSTEqczsr1kfnExg== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="57601865" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="57601865" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:31 -0700 X-CSE-ConnectionGUID: D/zrq4n4RXWpHz5nbWrL0w== X-CSE-MsgGUID: lgerGfNVS5SXRdKCrn82oA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="161071616" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa002.jf.intel.com with ESMTP; 15 Apr 2025 04:11:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E7BCFB48; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 6/7] gpiolib: Convert to use guard()() for gpio_machine_hogs_mutex Date: Tue, 15 Apr 2025 14:10:05 +0300 Message-ID: <20250415111124.1539366-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The driver uses guard()()/scoped_guard() for the rest of the synchronisation calls. Convert to use the same for gpio_machine_hogs_mutex. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cc12f274ccda..8d525e9d4319 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -916,14 +916,12 @@ static void machine_gpiochip_add(struct gpio_chip *gc) { struct gpiod_hog *hog; =20 - mutex_lock(&gpio_machine_hogs_mutex); + guard(mutex)(&gpio_machine_hogs_mutex); =20 list_for_each_entry(hog, &gpio_machine_hogs, list) { if (!strcmp(gc->label, hog->chip_label)) gpiochip_machine_hog(gc, hog); } - - mutex_unlock(&gpio_machine_hogs_mutex); } =20 static void gpiochip_setup_devs(void) @@ -4440,7 +4438,7 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) { struct gpiod_hog *hog; =20 - mutex_lock(&gpio_machine_hogs_mutex); + guard(mutex)(&gpio_machine_hogs_mutex); =20 for (hog =3D &hogs[0]; hog->chip_label; hog++) { list_add_tail(&hog->list, &gpio_machine_hogs); @@ -4454,8 +4452,6 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) if (gdev) gpiochip_machine_hog(gpio_device_get_chip(gdev), hog); } - - mutex_unlock(&gpio_machine_hogs_mutex); } EXPORT_SYMBOL_GPL(gpiod_add_hogs); =20 @@ -4463,10 +4459,10 @@ void gpiod_remove_hogs(struct gpiod_hog *hogs) { struct gpiod_hog *hog; =20 - mutex_lock(&gpio_machine_hogs_mutex); + guard(mutex)(&gpio_machine_hogs_mutex); + for (hog =3D &hogs[0]; hog->chip_label; hog++) list_del(&hog->list); - mutex_unlock(&gpio_machine_hogs_mutex); } EXPORT_SYMBOL_GPL(gpiod_remove_hogs); =20 --=20 2.47.2 From nobody Fri Dec 19 17:36:11 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 927AA28A1DE; Tue, 15 Apr 2025 11:12:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715560; cv=none; b=opUG7/vKNBESlr7iHQwFWL/KZc/8LpdisxQcbywe8PF648iURLzZt4a99/ljDsCt4wLIVW++oKNgd3Swb6AYG22H94mgo2ofV13Xb9vswESXZ69HXLGav4ZgW45q/wr3qcu3nXdVkNq1NNewsGUaRqfWFy/ZCxBR/MQK6wpR7jU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744715560; c=relaxed/simple; bh=tGluuzOIf4RSoAxttiEviz2AC2kBM+vtOzaXgge2A94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c8G6Cm0CdavAlD3v5lY2KuUEayPr8MU0b2tI8zElRJpXBzN3RjdNF2C5zFguUS7gxZ6EalSR678T7stl1/82uSGcIBYmmx6rh8kZCllem1yau08k9dGENYXb586yFeb8egVKuTpF6XqYyRksPR8vva7oDrHATlGCfb01MdO2h5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Fja75t5J; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Fja75t5J" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1744715559; x=1776251559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tGluuzOIf4RSoAxttiEviz2AC2kBM+vtOzaXgge2A94=; b=Fja75t5JiRQ6xMBo2EhsjjNlzCmDegKItrEGCpIYINs1UehpMl95WPJh ZxY1EiHiJGl8h4MmERpBZaMsSF8GgHEosWJVQSigr56TTQRlhWBRK/Cyl KmZsMqIGEgKNSGdKJOAI9nbx/YptcZTjr2/lThdQBLvQmn3B2OCF4qojE UYeR2JweV/tCab6ueFCGKEBcGruA2m3ZMF0Y0XDRK7XyH7vhRsD7e/X35 uP6p7n5A++gPGNw5UzTjFQkbNQe5ssq8p3Q76JAeWZK1EBTsnXBBSN6NK QM0qgVdDU6oqT6v49nI5JXhfRQ7gqK+doOchavJyE4Uh+KNRAiEftYohK Q==; X-CSE-ConnectionGUID: oJ2s/DuhQmOh6+89C03kQg== X-CSE-MsgGUID: jCMJor+JQ6q4ncc86GiLyw== X-IronPort-AV: E=McAfee;i="6700,10204,11403"; a="57601862" X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="57601862" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2025 04:11:31 -0700 X-CSE-ConnectionGUID: 5W3I2lqvSguJd0gINyuGbw== X-CSE-MsgGUID: dIXdQMf1SDCBbSaRcXY5vw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,213,1739865600"; d="scan'208";a="161071615" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa002.jf.intel.com with ESMTP; 15 Apr 2025 04:11:30 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 01D50B53; Tue, 15 Apr 2025 14:11:25 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v1 7/7] gpiolib: Remove redundant assignment of return variable Date: Tue, 15 Apr 2025 14:10:06 +0300 Message-ID: <20250415111124.1539366-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> References: <20250415111124.1539366-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In some functions the returned variable is assigned to 0 and then reassigned to the actual value. Remove redundant assignments. In one case make it more clear that the assignment is not needed. Signed-off-by: Andy Shevchenko Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8d525e9d4319..cca987addc0e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1015,7 +1015,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, = void *data, struct gpio_device *gdev; unsigned int desc_index; int base =3D 0; - int ret =3D 0; + int ret; =20 /* Only allow one set() and one set_multiple(). */ if ((gc->set && gc->set_rv) || @@ -1040,11 +1040,10 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc= , void *data, =20 device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc)); =20 - gdev->id =3D ida_alloc(&gpio_ida, GFP_KERNEL); - if (gdev->id < 0) { - ret =3D gdev->id; + ret =3D ida_alloc(&gpio_ida, GFP_KERNEL); + if (ret < 0) goto err_free_gdev; - } + gdev->id =3D ret; =20 ret =3D dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); if (ret) @@ -3075,7 +3074,7 @@ int gpiod_direction_output_nonotify(struct gpio_desc = *desc, int value) */ int gpiod_enable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long fla= gs) { - int ret =3D 0; + int ret; =20 VALIDATE_DESC(desc); =20 @@ -3108,7 +3107,7 @@ EXPORT_SYMBOL_GPL(gpiod_enable_hw_timestamp_ns); */ int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc, unsigned long fl= ags) { - int ret =3D 0; + int ret; =20 VALIDATE_DESC(desc); =20 --=20 2.47.2