From patchwork Tue Apr 15 11:10:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 881470 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-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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; 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); } From patchwork Tue Apr 15 11:10:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 881471 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-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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_table **tables, size_t n) { unsigned int i; - mutex_lock(&gpio_lookup_lock); + guard(mutex)(&gpio_lookup_lock); for (i = 0; i < n; i++) list_add_tail(&tables[i]->list, &gpio_lookup_list); - - mutex_unlock(&gpio_lookup_lock); } /** @@ -4428,11 +4426,9 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) if (!table) return; - mutex_lock(&gpio_lookup_lock); + guard(mutex)(&gpio_lookup_lock); list_del(&table->list); - - mutex_unlock(&gpio_lookup_lock); } EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table); From patchwork Tue Apr 15 11:10:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 881469 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-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; - mutex_lock(&gpio_machine_hogs_mutex); + guard(mutex)(&gpio_machine_hogs_mutex); 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); } static void gpiochip_setup_devs(void) @@ -4440,7 +4438,7 @@ void gpiod_add_hogs(struct gpiod_hog *hogs) { struct gpiod_hog *hog; - mutex_lock(&gpio_machine_hogs_mutex); + guard(mutex)(&gpio_machine_hogs_mutex); for (hog = &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); @@ -4463,10 +4459,10 @@ void gpiod_remove_hogs(struct gpiod_hog *hogs) { struct gpiod_hog *hog; - mutex_lock(&gpio_machine_hogs_mutex); + guard(mutex)(&gpio_machine_hogs_mutex); + for (hog = &hogs[0]; hog->chip_label; hog++) list_del(&hog->list); - mutex_unlock(&gpio_machine_hogs_mutex); } EXPORT_SYMBOL_GPL(gpiod_remove_hogs);