From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB18C4167B for ; Thu, 30 Nov 2023 13:46:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345711AbjK3Nqs (ORCPT ); Thu, 30 Nov 2023 08:46:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345645AbjK3Nqf (ORCPT ); Thu, 30 Nov 2023 08:46:35 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C1B171F for ; Thu, 30 Nov 2023 05:46:38 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b40423df8so7571795e9.0 for ; Thu, 30 Nov 2023 05:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701351996; x=1701956796; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W2vlGJhIze8sK7FhkyHeBLiiHYWZ044RLoNjc90UYtQ=; b=xnzRGXZHUO536H37aA4aVxzXMn/0jPSSxDsRlZNK/vAbxLQO5k80W3vfoQ6DmXJ5EK U21nQmo4ExlJNmJI6uf1m0QPNyqYsl/f20xqsogua6afWtpS0eCMzidIsBDqHDAouXj9 mlp9NT1kBjOIFpYpevaR6FO6qXu855c0vkxrGqrJTa1eVjjjb645vuKHb/c7QSzkLyLY 0BOBtKlCZnbatRxvwWlhiCZgRrNaayzu/nJ5bIO3+olDVDntE4TPeGUnB8Ov7dDc8PtZ T6oYK/ewnzFAh5Cosmt4nES34/+C3nnsvurq5H6LN7WdNpAchP6jKyWvS6MDyQrSWa0H 9G7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701351996; x=1701956796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W2vlGJhIze8sK7FhkyHeBLiiHYWZ044RLoNjc90UYtQ=; b=lG2lEJGV53ERKAMnSJ04ACOqHUf7Cr9Dvm+ahIwYxmeKAI6+qDY9JVSRa0F4rGuSGt S85TSoW8Jdk1YhbY+DvnXvVwyCaLh+jVVnskPILR04/ROYZvmABOgOJ+Aq7IAN5LrYMl ctwhsaAAwhqexKiWdXjo6+voAaKg+UAy7vMBAe5nwpIqdM/m/tVvS6WyEMBmg4cBPoFC axj30ZXirXTpvlKjpk0k05oFVwt+cxvVE9oawbDdsi74ySLzEzF7W8CzgV8Mr+zHE/5/ nsUXU5cqY6hROo8xotHB5UJO8ZUNMc2gUAzNhjuu8pYiz4/x4hXep+LL11eW9NJLDPyJ gRaQ== X-Gm-Message-State: AOJu0YwJZPfSI+QPgb+FG3d/obIIrn28kD2o4+n6UJFr1dMLT1xhCujQ azo9U0dOe/2NQW2qNHEiryDt6SJG+1OBrR/apmA= X-Google-Smtp-Source: AGHT+IGtdd0VMXL+p2c6eyqLy6MItc8V4wcu+0Ncauj4wLWwBbw5ot6jZfezOIhzkjhPuljZoeg+Vg== X-Received: by 2002:adf:f64a:0:b0:333:12f9:d37a with SMTP id x10-20020adff64a000000b0033312f9d37amr5219213wrp.65.1701351996563; Thu, 30 Nov 2023 05:46:36 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:35 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 01/10] gpiolib: provide gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:21 +0100 Message-Id: <20231130134630.18198-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski gpiochip_is_requested() not only has a misleading name but it returns a pointer to a string that is freed when the descriptor is released. Provide a new helper meant to replace it, which returns a copy of the label string instead. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 29 +++++++++++++++++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 30 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index a5faaea6915d..8e932e6a6a8d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2400,6 +2400,35 @@ const char *gpiochip_is_requested(struct gpio_chip *= gc, unsigned int offset) } EXPORT_SYMBOL_GPL(gpiochip_is_requested); =20 +/** + * gpiochip_dup_line_label - Get a copy of the consumer label. + * @gc: GPIO chip controlling this line. + * @offset: Hardware offset of the line. + * + * Returns: + * Pointer to a copy of the consumer label if the line is requested or NULL + * if it's not. If a valid pointer was returned, it must be freed using + * kfree(). In case of a memory allocation error, the function returns %EN= OMEM. + * + * Must not be called from atomic context. + */ +char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) +{ + const char *label; + char *cpy; + + label =3D gpiochip_is_requested(gc, offset); + if (!label) + return NULL; + + cpy =3D kstrdup(label, GFP_KERNEL); + if (!cpy) + return ERR_PTR(-ENOMEM); + + return cpy; +} +EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); + /** * gpiochip_request_own_desc - Allow GPIO chip to request its own descript= or * @gc: GPIO chip diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 100c329dc986..9796a34e2fee 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -532,6 +532,7 @@ struct gpio_chip { }; =20 const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offse= t); +char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset); =20 /** * for_each_requested_gpio_in_range - iterates over requested GPIOs in a g= iven range --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDAD9C10DAA for ; Thu, 30 Nov 2023 13:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345720AbjK3Nqv (ORCPT ); Thu, 30 Nov 2023 08:46:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345787AbjK3Nqg (ORCPT ); Thu, 30 Nov 2023 08:46:36 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51B0F1725 for ; Thu, 30 Nov 2023 05:46:39 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-33321a70bd9so391806f8f.2 for ; Thu, 30 Nov 2023 05:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701351998; x=1701956798; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Sv99NjQCF32QfqStrxQNV++EDXzWOND44xPhDEPFwA=; b=RzoE4DJWVF3W3nkJlOJRdv4+NmcgoXiLB+gg1BmbJAdSjXdO6QHD0KtdwJ+12Fl3My 55WXpqcLmbIhqfB6EXiyC3TOB4t4821ZMjkrX2BgMv+g/RKT0pGNt4btfGBlA661c49i FWG4egQtdxheJcTMecL/3iHGJ2F1A1sf55X5HMWQdtzYxnvUyZNHOhC6YeX1Oq//Y8H5 xAEmCuCmY6y/ndwSGq8O4w9WCzjyLssVqySoFOm4Hw/o6elLOYT3mx5hy9+t3+IkLrWJ 0jtXDfm3avWCkFD/JE6oXDJz91f74VpKSPmW8XzyKygh1SgtzXazFW4CeZw+rW9VmLlA HcYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701351998; x=1701956798; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Sv99NjQCF32QfqStrxQNV++EDXzWOND44xPhDEPFwA=; b=eN8CmiT5jIO/6xAYq4UrgGCOMH2uS4UECqNQHfBQRLtsM9BUNNcoB+3iXHIkRClyOb SvtFYBa0dr72ElPxC2txRmM4RhAuWk3+Zf+lJv5YTxmgkXWq28IotfPAr1wnV7Q3x9FX WhKng36PlQLlHgDZgeKEGyK3m4EcnEJ/Lc9yhiYRtWf8pORPgKCcgklhGlDyk6u27zZ7 ruzuW9gje6BYAm0ZBTD4YVHIUjZzSwBykfZDRig+gd7IOdwkPbzKJJafdX8l/hBsjGe8 iPWGD34l6PzKSq69gu0ucvfmPTwJv7JYl3DZ+xfXTGDhwXkq1J7cgglx0Fg8csTfarcC gUpg== X-Gm-Message-State: AOJu0YwhMthGcgaQSDJ/we8B3JzKhrj2AKthRbWyIRCRN5RXivQ+tzy3 9ZL1lXMPnHBURDlaYAw805i+/g== X-Google-Smtp-Source: AGHT+IFFXiw8d4gEC87uJuGJeNe0IjCzYDScTUcvPWnXguWxDUdRf/gDmALnF5depRlp+rrGf1ryhQ== X-Received: by 2002:a5d:6dcb:0:b0:332:fcd2:87fa with SMTP id d11-20020a5d6dcb000000b00332fcd287famr8728856wrz.27.1701351997780; Thu, 30 Nov 2023 05:46:37 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:36 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 02/10] gpio: wm831x: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:22 +0100 Message-Id: <20231130134630.18198-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-wm831x.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-wm831x.c b/drivers/gpio/gpio-wm831x.c index 7eaf8a28638c..f7d5120ff8f1 100644 --- a/drivers/gpio/gpio-wm831x.c +++ b/drivers/gpio/gpio-wm831x.c @@ -8,6 +8,7 @@ * */ =20 +#include #include #include #include @@ -160,18 +161,21 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, = struct gpio_chip *chip) for (i =3D 0; i < chip->ngpio; i++) { int gpio =3D i + chip->base; int reg; - const char *label, *pull, *powerdomain; + const char *pull, *powerdomain; =20 /* We report the GPIO even if it's not requested since * we're also reporting things like alternate * functions which apply even when the GPIO is not in * use as a GPIO. */ - label =3D gpiochip_is_requested(chip, i); - if (!label) - label =3D "Unrequested"; + char *label __free(kfree) =3D gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) { + dev_err(wm831x->dev, "Failed to duplicate label\n"); + continue; + } =20 - seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label); + seq_printf(s, " gpio-%-3d (%-20.20s) ", + gpio, label ?: "Unrequested"); =20 reg =3D wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL + i); if (reg < 0) { --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 922F7C4167B for ; Thu, 30 Nov 2023 13:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345748AbjK3Nqy (ORCPT ); Thu, 30 Nov 2023 08:46:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345795AbjK3Nqg (ORCPT ); Thu, 30 Nov 2023 08:46:36 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82550D40 for ; Thu, 30 Nov 2023 05:46:40 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b31232bf0so7768965e9.1 for ; Thu, 30 Nov 2023 05:46:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701351999; x=1701956799; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FDkm1mz5JKda1Ie70um5gnCumWIdGzqKbagKhi4Mqgw=; b=zO8d/RkZCozzHJ1jQKXdjSYznCbMIc23SHbSreyOKRFdYVhP+l2K2kxpdx5TeawVYM VObqZNzZkS73Kgy2UHewywsdJy3thgug3aq1ahTKAS2Oi61OSGMT8uHiliaZMkCBqGKH c/EkgFyKTTd878s3uk4QQTsN4e9IODJ/PNeZq24BOYkTKTyQYtJQExNUIUiCGvf+2tSo xdavwY5etTRVDax7kAnqhIAWMcrNnOQWIEyv/JuUXmRpPS6qHavUxpja+hqxJqokGvMP rnkdRhh4xz5psfSzzIlgywWJONcSfUzV2v8aoKx4MrWMERKU0/fYnxP8nCNj2vGPnRzF qJIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701351999; x=1701956799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FDkm1mz5JKda1Ie70um5gnCumWIdGzqKbagKhi4Mqgw=; b=E9w89mgLY6Azld3+Rk5WDLfHJuRWLjn0tQBmM6Dlxb+C80pfbFTtnHhkax74bxV70q aB7tuL7PvVU/FMdB0IA3LwcYB50+YIDqvBBam2QcaWIvPiyVFAEVq1mV07vJjXRtiGOV 9BQFj7KFss+J4hKa0MDoc3ZHuo/8BAJlTaHqTPjgwZuUaRT0hLfMCrXANUmK2xGl0Dtl 8IuHZKV36xPUpAi4jT3jji6zVwGDqYCBLSP9cV61uzebJ2xQI+y7GSsuhXKWvH48g/7H KJ+1uFsJBmnhjs3QlSAPwimB2myPDtxWQvctgNHPAFKV03xuKOg46ya0tUOJam8/VOSc ADZA== X-Gm-Message-State: AOJu0YzsYp1l8RFE+Reej2AipEzKmXHMZDpahhZWe+mIrIr8TRG4Kb8m F5DLxjyPdCDMt+oGLIn2cPCdeg== X-Google-Smtp-Source: AGHT+IH1lRBcUubHIz93kQOurCo+8m3nu0EZoQalJ3ieURmwlYH3CSTv+IgoVsqKPZPB7xaOjJ2hAQ== X-Received: by 2002:a05:600c:290:b0:40b:377a:2ac1 with SMTP id 16-20020a05600c029000b0040b377a2ac1mr15522069wmk.20.1701351998814; Thu, 30 Nov 2023 05:46:38 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:38 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 03/10] gpio: wm8994: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:23 +0100 Message-Id: <20231130134630.18198-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-wm8994.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-wm8994.c b/drivers/gpio/gpio-wm8994.c index f4a474cef32d..bf05c9b5882b 100644 --- a/drivers/gpio/gpio-wm8994.c +++ b/drivers/gpio/gpio-wm8994.c @@ -8,6 +8,7 @@ * */ =20 +#include #include #include #include @@ -193,18 +194,20 @@ static void wm8994_gpio_dbg_show(struct seq_file *s, = struct gpio_chip *chip) for (i =3D 0; i < chip->ngpio; i++) { int gpio =3D i + chip->base; int reg; - const char *label; =20 /* We report the GPIO even if it's not requested since * we're also reporting things like alternate * functions which apply even when the GPIO is not in * use as a GPIO. */ - label =3D gpiochip_is_requested(chip, i); - if (!label) - label =3D "Unrequested"; + char *label __free(kfree) =3D gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) { + dev_err(wm8994->dev, "Failed to duplicate label\n"); + continue; + } =20 - seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label); + seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, + label ?: "Unrequested"); =20 reg =3D wm8994_reg_read(wm8994, WM8994_GPIO_1 + i); if (reg < 0) { --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AA5FC4167B for ; Thu, 30 Nov 2023 13:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345804AbjK3Nq4 (ORCPT ); Thu, 30 Nov 2023 08:46:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345798AbjK3Nqg (ORCPT ); Thu, 30 Nov 2023 08:46:36 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC1010F2 for ; Thu, 30 Nov 2023 05:46:41 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40b472f98b1so7713355e9.3 for ; Thu, 30 Nov 2023 05:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352000; x=1701956800; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S7P6Y0m2hGBRRFmWFTt/dmCRHf+pQxLzAw7kKW52hRs=; b=VIRvQo3RT4aiG5EG4mKWHcQyV7GPvY5DBdbAPcDXbhbaKucRHdzGN4jts4uum9Yp+h MXxwwlcBEY3tAjPfQqiPovgDFo0WhertxXzvHgTixfkA0XUejUFeScHRjNg/EJChvwTM C2L/0X88tdGU7Bz7WOl/KsiMq0mPmLWbjBsSOo63tmZleFRRZuHITTFIOHtPv6NUfEOr xV/VbgrHCmiPRQqcPOyIcV9hAANERBqVAVPSzCN8CrMcD2YKh2c8GeNfTGzqwPTXG/Ea fxBMjec+osOQDklpJDk29qj42/3FkypLIViummhPNnLTqjmr2S0QSN3+hEK/Nzz0Srcy dCvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352000; x=1701956800; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S7P6Y0m2hGBRRFmWFTt/dmCRHf+pQxLzAw7kKW52hRs=; b=Ylhn6DqHZOtREWuZXabPe7bAPyyXI4hIMySwVQhxVeJINsveoNQjt66dN3Mr5NNUn1 L+PSRlfy1TTMYrjyYkO3EZbffGzTHKQzp2Yw4w3sh6x0wU47yqeQ61TJsiunshD7yr2j HDUUpb59scLCGTms5njs0osXAnSpvxqfny7LUOX4FZ/uobQM0fTGL7zUhvAl2nChy46b y/zAGKCq23LtlG+vUhgQyq1JLm8GuJlh8OFqbZ5GkgpnhNmYLxgEMyOjBAdoLr6O3eD6 B+zHn8fzeoTzKEiliheLwdM2vkEXtERwLeGXu+0D7csPZgSz+MwGHUUB0IxWXAnenU/G TsUg== X-Gm-Message-State: AOJu0Ywi5h4iS9SzEjH/ezIxZMPuNxBj8rlrpnslFexSOyJ1kGqoclqd l0YqmGf5feGpX6MBVUMLIz552w== X-Google-Smtp-Source: AGHT+IGWQ3w4OgWs+eiKlT4hgKInIw5/57JyahFF8EAqF3mDoy9KOsBP9slLYl+6MDnBdXrI1X7t4g== X-Received: by 2002:a05:600c:46ce:b0:405:37bb:d942 with SMTP id q14-20020a05600c46ce00b0040537bbd942mr16123768wmo.4.1701352000315; Thu, 30 Nov 2023 05:46:40 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:39 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 04/10] gpio: stmpe: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:24 +0100 Message-Id: <20231130134630.18198-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-stmpe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index 27cc4da53565..6c5ee81d71b3 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -5,6 +5,7 @@ * Author: Rabin Vincent for ST-Ericsson */ =20 +#include #include #include #include @@ -255,7 +256,6 @@ static void stmpe_dbg_show_one(struct seq_file *s, { struct stmpe_gpio *stmpe_gpio =3D gpiochip_get_data(gc); struct stmpe *stmpe =3D stmpe_gpio->stmpe; - const char *label =3D gpiochip_is_requested(gc, offset); bool val =3D !!stmpe_gpio_get(gc, offset); u8 bank =3D offset / 8; u8 dir_reg =3D stmpe->regs[STMPE_IDX_GPDR_LSB + bank]; @@ -263,6 +263,10 @@ static void stmpe_dbg_show_one(struct seq_file *s, int ret; u8 dir; =20 + char *label __free(kfree) =3D gpiochip_dup_line_label(gc, offset); + if (IS_ERR(label)) + return; + ret =3D stmpe_reg_read(stmpe, dir_reg); if (ret < 0) return; --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10242C4167B for ; Thu, 30 Nov 2023 13:47:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345847AbjK3Nq7 (ORCPT ); Thu, 30 Nov 2023 08:46:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345722AbjK3Nqh (ORCPT ); Thu, 30 Nov 2023 08:46:37 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEA4A10F1 for ; Thu, 30 Nov 2023 05:46:43 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3331974c2d2so684020f8f.2 for ; Thu, 30 Nov 2023 05:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352002; x=1701956802; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cffjJvUFWsxdgp9qJiLVkij+XoF+TZsz38c1WQZlyho=; b=gdSOQtaof93nM5ia61UhuHXlJsyRqcru/G05JG7W8V1FssY7r+DAfHzJne1PEcTXsF YM5G9ExjsMk8Rr5qeYZ13DnVH3LBZCQMj91lpzi1sq1n066WUmZfO8ebjceDWiYMUv63 lR+I6OhQSHuJ7HdTb24IX7LNdfcigyIVh0OtdsIfxfxVerKJuoblT1VITrUSZAyDf3n8 S9l6zab1Q+hY+sewGCicanmYoVopw2XSSY026wmft/15dYC9N6tFojxW75jjA6olC7I8 tkKVCiKU5496/SECyJMIPJAZc/ae9xT5PaCCWzEqo4elcsHb04oLQPIm7dmojCrOQrKQ Y0hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352002; x=1701956802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cffjJvUFWsxdgp9qJiLVkij+XoF+TZsz38c1WQZlyho=; b=YIfhfUEUJ8NIoHM5RyIAoQS7O5093KTytYoDiwe0qPku0K+KAKSQfbEf6iuMWAiSOg GywWYoyaIKtbNDhiZp6oGZBY1ACOUSTyFR5uOdHdIyqkSiiHXMM2/a2KZ4+kYcdCo5Ch 41FrGd/ZFCLlDgqyOHINhrNuHgOyXP1l8V2/2/Zm9RyFm2+32zlV5q1ZD9Nj4FfPDtGX g8mqBp/WDkhn8DIwhGNFIMzD9fS57F+X3gC9wEGwPQBMJWgVFSAIC72xEW3HMG27Xpf0 TaVPOiDQAIs+ND2WI/gf7qcx10NeOaZ3rh5hsqluE9/rwpqYQC67nmcdFwPlxJEHpGW9 SJtA== X-Gm-Message-State: AOJu0YyXJlqyYKKegpt7oNEZ6T8p74m92Jw2VygibLjrVJMkdjy+cY6G n2XLZdJ5VXKCTzAIJD+ZHOG6XA== X-Google-Smtp-Source: AGHT+IFqmZA1KQhwkSPcUaNoBMtUmaEHugbvUiR1Onas5XzwXX7zZR0pNya8Ie3NAxw5LM70WUUmrA== X-Received: by 2002:a05:6000:36c:b0:333:18b9:27a6 with SMTP id f12-20020a056000036c00b0033318b927a6mr3490982wrf.30.1701352002295; Thu, 30 Nov 2023 05:46:42 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:40 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 05/10] pinctrl: abx500: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:25 +0100 Message-Id: <20231130134630.18198-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/nomadik/pinctrl-abx500.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-abx500.c b/drivers/pinctrl/nom= adik/pinctrl-abx500.c index d3c32d809bac..80e3ac333136 100644 --- a/drivers/pinctrl/nomadik/pinctrl-abx500.c +++ b/drivers/pinctrl/nomadik/pinctrl-abx500.c @@ -6,7 +6,9 @@ * * Driver allows to use AxB5xx unused pins to be used as GPIO */ + #include +#include #include #include #include @@ -453,12 +455,11 @@ static void abx500_gpio_dbg_show_one(struct seq_file = *s, unsigned offset, unsigned gpio) { struct abx500_pinctrl *pct =3D pinctrl_dev_get_drvdata(pctldev); - const char *label =3D gpiochip_is_requested(chip, offset - 1); u8 gpio_offset =3D offset - 1; int mode =3D -1; bool is_out; bool pd; - int ret; + int ret =3D -ENOMEM; =20 const char *modes[] =3D { [ABX500_DEFAULT] =3D "default", @@ -474,6 +475,10 @@ static void abx500_gpio_dbg_show_one(struct seq_file *= s, [ABX500_GPIO_PULL_UP] =3D "pull up", }; =20 + char *label __free(kfree) =3D gpiochip_dup_line_label(chip, offset - 1); + if (IS_ERR(label)) + goto out; + ret =3D abx500_gpio_get_bit(chip, AB8500_GPIO_DIR1_REG, gpio_offset, &is_out); if (ret < 0) --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1E57C4167B for ; Thu, 30 Nov 2023 13:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345876AbjK3NrC (ORCPT ); Thu, 30 Nov 2023 08:47:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345694AbjK3Nqi (ORCPT ); Thu, 30 Nov 2023 08:46:38 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAF9C1703 for ; Thu, 30 Nov 2023 05:46:44 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40b4c2ef584so7730185e9.3 for ; Thu, 30 Nov 2023 05:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352003; x=1701956803; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/NPguL+egm1B/3hLyNOqRomxlJRtvAY3YVXSaylJwM0=; b=ZTsTAUO8Q5uQn33PwH90C0RCvf/d9jvERfPGPlJwgjE2f2UWjBaVy5KPIOpfvtUzOL zVA6S0UoM195MZr7cRWQz2g24tFJp/tg7DoN8qRtUd5mgr6+RyDZPgNjQyqUhz8L5xwn RTqqNYQmW2M8BUpfuNiuZD9pYl5oEjgoIgxfilf75+UGvc680VAok4QuHfiG7F0YjsKW PfSk7UW55TqmKvuykMhlZbryg7mX72hRc0Mv+Cd4NGbnQtRIcDWPe3poYU2U8Bw1Kecf +q+EuACXDr2HjP4pLhX990eAUw7h4rT0VLIUIeQptXzc5wKY3l+FNqkxDN0p0D6f4Rrl lj5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352003; x=1701956803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/NPguL+egm1B/3hLyNOqRomxlJRtvAY3YVXSaylJwM0=; b=ExytPLBNBejymZbZ+3fpw4dLQOH3+ADSRly/rlEFMoHserpy4LDHk0ELgUYuhmmJ4C m2c7KTYJ2XxNw5QRM8Kvlq9m2zc5BRFPJjj3LkYXkk15SI9NnddUwQXLaG5eU7wdI5pV OIOTZy29HZKotXOQf8cPtm3o3cfafnAYIBSHis23OirE59OvAT9XQ2eZYSR8T1hOfH8H 4J5om7yplcdhKL0QPO1O0q/t9FrLoTG7iNqHNgruxZ/Umlvk4edvgM2lgTg0qd1HwQzO 9nt0do9WHy/6Idks8Q8t6pE7QS4ykKBwCUCvIBs4upY3127fMLuEZiajMJBVJNfxZORq jHvg== X-Gm-Message-State: AOJu0Yw98OiHrBbijsab7YEFhIYup4zROSdhVIjVfx0cVTlVIQ2eXPMH y082mMnlW5TzlZ29pLgGZ7c5uQ== X-Google-Smtp-Source: AGHT+IF49lqrlVpVqkD0E02GQZF9bH8Vo6dbPgCqchTj1uNhj8pD7rKcwX/9BEAelWIERBkgSTt5dw== X-Received: by 2002:a05:600c:4592:b0:40b:26f1:57a2 with SMTP id r18-20020a05600c459200b0040b26f157a2mr16362430wmo.27.1701352003401; Thu, 30 Nov 2023 05:46:43 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:42 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 06/10] pinctrl: nomadik: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:26 +0100 Message-Id: <20231130134630.18198-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/no= madik/pinctrl-nomadik.c index 863732287b1e..7911353ac97d 100644 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c @@ -8,6 +8,7 @@ * Copyright (C) 2011-2013 Linus Walleij */ #include +#include #include #include #include @@ -917,7 +918,6 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev, struct gpio_chip *chip, unsigned offset, unsigned gpio) { - const char *label =3D gpiochip_is_requested(chip, offset); struct nmk_gpio_chip *nmk_chip =3D gpiochip_get_data(chip); int mode; bool is_out; @@ -934,6 +934,10 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, [NMK_GPIO_ALT_C+4] =3D "altC4", }; =20 + char *label =3D gpiochip_dup_line_label(chip, offset); + if (IS_ERR(label)) + return; + clk_enable(nmk_chip->clk); is_out =3D !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & BIT(offset)); pull =3D !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & BIT(offset)); --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56700C4167B for ; Thu, 30 Nov 2023 13:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345653AbjK3NrE (ORCPT ); Thu, 30 Nov 2023 08:47:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345721AbjK3Nqj (ORCPT ); Thu, 30 Nov 2023 08:46:39 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A4D10E5 for ; Thu, 30 Nov 2023 05:46:45 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-332ed1bd4cbso605720f8f.2 for ; Thu, 30 Nov 2023 05:46:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352004; x=1701956804; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lX1sqlEJJ4vEUK91SFq6mj5SEAnM+ha5YxcxRVGS6+w=; b=hPzNjZP3MiHNlaiBNK5uHoOFDkljjmXAmcylnoFm60bgMec4QC4X5skCapr3qftKoj PgR9V1jJg3RAPnvw7nxRVZGHqVMrpqrAtH0pxO71h7Ihfy7hGyL700YhG6gWF4cIHFux +eCppziCbu5N52REsxeqWAonVjw497Af7hLBVoD/6VUFEbZ01bPwA4iMUAGUIJqsHNT/ b1biUc5LuPW2PI3W0Yk+RSMcUmYAQoTPnAv24qPVsboxDUO12E915sDm9jcu18CYRRVl H8rjZCZFUlBL4z1GdJk6pSEkm282W9ZIiIotZQY9ZbNwicOCJOyxEc/qVeOi5ywpjYbi RgBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352004; x=1701956804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lX1sqlEJJ4vEUK91SFq6mj5SEAnM+ha5YxcxRVGS6+w=; b=PpAm0tyCeLW9IDrhoV4/Tm+yGwB7Mv1Yqaj498AteiXRYDt1e38Q4/MmE7ko0l4GF0 12V2EOmcKz19lpWd2M3KKpyT+VH4FoKxJRZ/N4f7/jrHJA0wSXvMEo/zC9KjstX+NhgH 1z08lrn9SVRMH0qI7m/HOS8DA/IIwv/4m7z4EK5X1FxrL908/4K5gTnq+sxzELuk+itm 7b7rwjQzE6FyAAOB+Iwu4WyjD8CIk+CXR87wyKBrs1zg+uudf3q/uhPuLGAk93bxqnbo 0waqqZ0MVdfj7MKGxYJgaqg2HwOl0/Hk4blRUqFCHhgYhwTU1dQQPIxsrhu7actOp/aO TmGA== X-Gm-Message-State: AOJu0YzjByANexlW2gjDgXeqg5vuJ3uR/AW/VkctXSC/XL8AsuuMuleu bzAePPeiwQDaSMYcahDDvGr/yQ== X-Google-Smtp-Source: AGHT+IEH8Mh7PFLu28rLEMPsJfxeGaU60dL2Y/lrZsr6Vmf/W1e5mS0Xhbaro9bpQTm02q7tKBDu7A== X-Received: by 2002:adf:f305:0:b0:333:2e28:46f5 with SMTP id i5-20020adff305000000b003332e2846f5mr53628wro.1.1701352004522; Thu, 30 Nov 2023 05:46:44 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:43 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 07/10] pinctrl: baytrail: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:27 +0100 Message-Id: <20231130134630.18198-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/intel/pinctrl-baytrail.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/int= el/pinctrl-baytrail.c index 3cd0798ee631..3c8c02043481 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1173,7 +1174,6 @@ static void byt_gpio_dbg_show(struct seq_file *s, str= uct gpio_chip *chip) const char *pull_str =3D NULL; const char *pull =3D NULL; unsigned long flags; - const char *label; unsigned int pin; =20 pin =3D vg->soc->pins[i].number; @@ -1200,9 +1200,10 @@ static void byt_gpio_dbg_show(struct seq_file *s, st= ruct gpio_chip *chip) seq_printf(s, "Pin %i: can't retrieve community\n", pin); continue; } - label =3D gpiochip_is_requested(chip, i); - if (!label) - label =3D "Unrequested"; + + char *label __free(kfree) =3D gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) + continue; =20 switch (conf0 & BYT_PULL_ASSIGN_MASK) { case BYT_PULL_ASSIGN_UP: @@ -1231,7 +1232,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, str= uct gpio_chip *chip) seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s pad-%-3d offset:0x%03x mux:%d %s%s%s= ", pin, - label, + label ?: "Unrequested", val & BYT_INPUT_EN ? " " : "in", val & BYT_OUTPUT_EN ? " " : "out", str_hi_lo(val & BYT_LEVEL), --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E4C1C4167B for ; Thu, 30 Nov 2023 13:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345727AbjK3NrH (ORCPT ); Thu, 30 Nov 2023 08:47:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345683AbjK3Nqk (ORCPT ); Thu, 30 Nov 2023 08:46:40 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA46C1709 for ; Thu, 30 Nov 2023 05:46:46 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-333229dcebdso431198f8f.0 for ; Thu, 30 Nov 2023 05:46:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352005; x=1701956805; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rQ4oN2yBzcOb1+JXtPZKrl0tpOl2eK1zlq9JfJmTld4=; b=O52R2/k6OkskTQsBSvj/PTMwCFu3+2ETaBaUKYlr+AhO7mU950wIaLOvdbkqLYXtwC FNvvbW3vJwBDY3GGVBdFrWqhhyEMcch0+u6A0q15Y75qGntWN18Get/3ZWiFhENlIhN3 H6ysmJdqT/OpBJ5JJjZblDE+8kvFtNZ3qMR9shrQaLnzaHJikcNbrlONwhY/QZikoMLR oS4NFXrfd1MrbaOdTfeqUcbccWPDpjJfX4vDpwz6l2bvYS5/Pb6VkTfM4GUYZ4g2TH/B wd75FZh9asf6VPD+U+0j/OPy3pBgKPkkV5zFUqcThO16qjsTshRWrDgTuvbmfP8MDeB2 MNSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352005; x=1701956805; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rQ4oN2yBzcOb1+JXtPZKrl0tpOl2eK1zlq9JfJmTld4=; b=L+nU+A3c5syINU2m1XWt54wktwVdiNbJBUvXKz4DF2coLYlymp7ppgsTN2hCShWHPl y6bSMy5DOcCE0yk/g2qrz8QfiX9hZp27NyLywjk3MmQct0dOy9B3sKlfI6cp6b8Qs2PM J8pagZcp081TLel+z7jiRR7Ju3Yn4DbkLwpc/+XT3DaMvcS2Brnz29IUl1ApGw0ouW+x FgZuJQwMGbd9BDB1X4QkgsOY1irindg6Ig/ldHFdR2yLHcyqNXQ3thGVzWd50fIc0Wx2 zwcRmCoL5a9A9lF0kYUiXo5MT35sfgYZKkxn9dNh9jY8ej5UXZ9rQPQS3FkgacCkIHdV qk8A== X-Gm-Message-State: AOJu0YwKuownJM1DBlT7xluazitQNjCWCcNKTfvbuYlGyXzynhTaBoJe ykK0lJ8Tr2X6zyOhD5qffjY/Vw== X-Google-Smtp-Source: AGHT+IGPtG+1uFAas3OVjot2zm3XVUDLgeyXhw2GAlVFtUSUYqhhRLnAvXvRp9OLXomSy5i1jZKXyA== X-Received: by 2002:a05:6000:114d:b0:333:2736:1e55 with SMTP id d13-20020a056000114d00b0033327361e55mr640974wrx.38.1701352005511; Thu, 30 Nov 2023 05:46:45 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:44 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 08/10] pinctrl: sppctl: use gpiochip_dup_line_label() Date: Thu, 30 Nov 2023 14:46:28 +0100 Message-Id: <20231130134630.18198-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/sunplus/sppctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/sunplus/sppctl.c b/drivers/pinctrl/sunplus/spp= ctl.c index bb5ef391dbe4..ae156f779a16 100644 --- a/drivers/pinctrl/sunplus/sppctl.c +++ b/drivers/pinctrl/sunplus/sppctl.c @@ -4,6 +4,7 @@ * Copyright (C) Sunplus Tech / Tibbo Tech. */ =20 +#include #include #include #include @@ -500,16 +501,15 @@ static int sppctl_gpio_set_config(struct gpio_chip *c= hip, unsigned int offset, =20 static void sppctl_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chi= p) { - const char *label; int i; =20 for (i =3D 0; i < chip->ngpio; i++) { - label =3D gpiochip_is_requested(chip, i); - if (!label) - label =3D ""; + char *label __free(kfree) =3D gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) + continue; =20 seq_printf(s, " gpio-%03d (%-16.16s | %-16.16s)", i + chip->base, - chip->names[i], label); + chip->names[i], label ?: ""); seq_printf(s, " %c", sppctl_gpio_get_direction(chip, i) ? 'I' : 'O'); seq_printf(s, ":%d", sppctl_gpio_get(chip, i)); seq_printf(s, " %s", sppctl_first_get(chip, i) ? "gpi" : "mux"); --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97EBFC4167B for ; Thu, 30 Nov 2023 13:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345900AbjK3NrJ (ORCPT ); Thu, 30 Nov 2023 08:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345581AbjK3Nql (ORCPT ); Thu, 30 Nov 2023 08:46:41 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DDE1715 for ; Thu, 30 Nov 2023 05:46:47 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40b4c2ef584so7730645e9.3 for ; Thu, 30 Nov 2023 05:46:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352006; x=1701956806; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5JkcbylM7pAQh/R7rY3XvCoFJsyCRp+V27URZHzTJKg=; b=1zTRCSLgTdXz21Tn6xXOIRLL1FQTefqdWPzzetBIrrXOHVet7/oNgmIzaIBVxl3qBX Kj3oL0NiDJNwESGPukPK2xH/icTMM5wWoiB0atmwi8clfbVprTI0VtgWUXqodHjwjap2 xqF2Z2UHBkeb5N/DnI+zWuIhfBZQJXjJF9UXDRkFmW5tPBYAzKRVwuEroL9OucU8WCuS mxtcE23Qnwj2fOktg+5XCBwhmsTc5qAwOUOJkOVQiWRzyMNJhO6J5D222fzlW7NIarg+ n922xRYJYaRlAAR0IXKfVyXrgEdBx49HrnBTFkY206UW9UB2Ae8BvCmtSBK3w3B/ppsR CfCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352006; x=1701956806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5JkcbylM7pAQh/R7rY3XvCoFJsyCRp+V27URZHzTJKg=; b=Es2PD6iBlPHmsuo9tV4rgvKBq6JnbnyKx5dYuXfcNZH5OhTAnOYeBfd22u6PP0xF0A a+jKtdG1u/5tbQ/ZxNlSVN5qvTyrhqPCreMDxJS6a+TlNaudH/T/xy8B7Cbb8p0fptZ6 9DV0CSy5OLgqxYnobshOOEp4Tpq6c4D37+1CXCQFYhy//Gsz9kX3zZKuhUp9kU4Cxhvd Ub5rmVX5aHvy7acuRnzQ2OwW4LuzsJbwE7SGfl6eXVo94yMM3BM5za+O6pJR9oPrYkzu Fyijk9OONKozWu+tTc1Nlz7qgaIQ8IK65hnPrt2MgEkV62IW4csm+gnHQEmrkR4aEib5 r1OQ== X-Gm-Message-State: AOJu0Yz3IdCw3+2ltW0+eHok6BzcVEaQmwjnVR4S9cY1UrcFuaXjt9Ih InNBYSB3Tb4/Qxer0vjJKnQ0XNJqqkp7NXZn5Xs= X-Google-Smtp-Source: AGHT+IFrUo2pYjPmikAyxVnU28S07nWrd/CCV9cpK7VFkHjyiiXqIwOTpiNbElhJRnnawaDyhekvAw== X-Received: by 2002:a5d:4c84:0:b0:32f:b407:5b77 with SMTP id z4-20020a5d4c84000000b0032fb4075b77mr15296007wrs.64.1701352006413; Thu, 30 Nov 2023 05:46:46 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:45 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 09/10] gpiolib: use gpiochip_dup_line_label() in for_each helpers Date: Thu, 30 Nov 2023 14:46:29 +0100 Message-Id: <20231130134630.18198-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski Rework for_each_requested_gpio_in_range() to use the new helper to retrieve a dynamically allocated copy of the descriptor label and free it at the end of each iteration. We need to leverage the CLASS()' destructor to make sure that the label is freed even when breaking out of the loop. Signed-off-by: Bartosz Golaszewski --- include/linux/gpio/driver.h | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 9796a34e2fee..b1ed501e9ee0 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -534,17 +534,36 @@ struct gpio_chip { const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offse= t); char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset); =20 + +struct _gpiochip_for_each_data { + const char **label; + int *i; +}; + +DEFINE_CLASS(_gpiochip_for_each_data, + struct _gpiochip_for_each_data, + if (*_T.label) kfree(*_T.label), + ({ struct _gpiochip_for_each_data _data =3D { label, i }; + *_data.i =3D 0; + _data; }), + const char **label, int *i) + /** * for_each_requested_gpio_in_range - iterates over requested GPIOs in a g= iven range - * @chip: the chip to query - * @i: loop variable - * @base: first GPIO in the range - * @size: amount of GPIOs to check starting from @base - * @label: label of current GPIO + * @_chip: the chip to query + * @_i: loop variable + * @_base: first GPIO in the range + * @_size: amount of GPIOs to check starting from @base + * @_label: label of current GPIO */ -#define for_each_requested_gpio_in_range(chip, i, base, size, label) \ - for (i =3D 0; i < size; i++) \ - if ((label =3D gpiochip_is_requested(chip, base + i)) =3D=3D NULL) {} el= se +#define for_each_requested_gpio_in_range(_chip, _i, _base, _size, _label) = \ + for (CLASS(_gpiochip_for_each_data, _data)(&_label, &_i); \ + *_data.i < _size; \ + (*_data.i)++, kfree(*(_data.label)), *_data.label =3D NULL) \ + if ((*_data.label =3D \ + gpiochip_dup_line_label(_chip, _base + *_data.i)) =3D=3D NULL) {} \ + else if (IS_ERR(*_data.label)) {} \ + else =20 /* Iterates over all requested GPIO of the given @chip */ #define for_each_requested_gpio(chip, i, label) \ --=20 2.40.1 From nobody Tue Dec 16 16:38:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15272C4167B for ; Thu, 30 Nov 2023 13:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345904AbjK3NrM (ORCPT ); Thu, 30 Nov 2023 08:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345678AbjK3Nqn (ORCPT ); Thu, 30 Nov 2023 08:46:43 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AF2319F for ; Thu, 30 Nov 2023 05:46:49 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40b472f98b1so7714635e9.3 for ; Thu, 30 Nov 2023 05:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701352007; x=1701956807; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z1Jm7DZtmPUI+tkjKaFM9ATO3Ta/nvLDLxNBysClivQ=; b=rZ0hzX8DL/w4ofgdyAKw05NRnXAh3WfKF/i92JxrjSdCSEbeP20De8vn/ZyfI6qx7v /VOPVgXWnKDAVb0dujZBwXRnyRYc6FjdA92jeh0rL2TrPk2yWzySVk7T5EQja3HTzQN5 LDIIvg3T//aNV0hNOYOkjQdaLWGfe3cuPLnqbT66h+LzaRmmU1CjvLquivalVyVwISzB 4KedLcpic7A/6C8Nfl4SBaAnNxyyhDZlii0QwwukYc8JZthuO++wdVS9Q9Q3SspeyZXM vPEb34uuWqu5Of1ne7RyLjkG+kZMGnbt3ZpELSeKocsTZCciib7HMrJyeIky7Pz+HLOc 0OUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701352007; x=1701956807; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z1Jm7DZtmPUI+tkjKaFM9ATO3Ta/nvLDLxNBysClivQ=; b=ab9OU/zq5Oxgzz0Ea/5daGw9arFrDhvHv7fRg65u+738ooz7bgG+hteDAW7XzTFtPX Rt4u5AN/de6WC0kYISumBpjpbOL2F8UAbTHB6eeLD2vXqM6szNA7GUL27faejF1zWi2N VmE7Plt5dff8axQizk//EvhEkSLWm/Pf287AzdHXFYefO2rp0F56N1yYzrin94ZxjWwy h0YnzAYtAoW8E951pYXcHSWD1W97YDkXE6jDwvJlzliP++2SftCFVfww52UeiLJc0Jo+ nkYi9IPFHZL7PG8s8+ckrlGcYahoc305MZKL/OinKicd8TZ7oY/+VRQjMG7kWthF5Mni /ZxA== X-Gm-Message-State: AOJu0YxoQSBkBePhUVC7A1IVylPgltLkcSpFDHdmY4MznwzXb8LRwcQL Dqj7qh5yXOjv3odRfnEB8NilPA== X-Google-Smtp-Source: AGHT+IEAj1farO/m8WTaPZy/0DRdVPSgaZ/tTSVTZIibBXNvNig5A36Zldn7TIaNUdtS3M0Pnn/seQ== X-Received: by 2002:adf:f283:0:b0:333:273f:1cd with SMTP id k3-20020adff283000000b00333273f01cdmr811971wro.36.1701352007562; Thu, 30 Nov 2023 05:46:47 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:ae84:904:6602:ec1e]) by smtp.gmail.com with ESMTPSA id n18-20020adffe12000000b0032d2489a399sm1574824wrr.49.2023.11.30.05.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 05:46:47 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 10/10] gpiolib: remove gpiochip_is_requested() Date: Thu, 30 Nov 2023 14:46:30 +0100 Message-Id: <20231130134630.18198-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231130134630.18198-1-brgl@bgdev.pl> References: <20231130134630.18198-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Bartosz Golaszewski We have no external users of gpiochip_is_requested(). Let's remove it and replace its internal calls with direct testing of the REQUESTED flag. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 46 ++++++++++--------------------------- include/linux/gpio/driver.h | 1 - 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8e932e6a6a8d..3070a4f7bbb1 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1085,7 +1085,7 @@ void gpiochip_remove(struct gpio_chip *gc) =20 spin_lock_irqsave(&gpio_lock, flags); for (i =3D 0; i < gdev->ngpio; i++) { - if (gpiochip_is_requested(gc, i)) + if (test_bit(FLAG_REQUESTED, &gdev->descs[i].flags)) break; } spin_unlock_irqrestore(&gpio_lock, flags); @@ -2373,33 +2373,6 @@ void gpiod_free(struct gpio_desc *desc) gpio_device_put(desc->gdev); } =20 -/** - * gpiochip_is_requested - return string iff signal was requested - * @gc: controller managing the signal - * @offset: of signal within controller's 0..(ngpio - 1) range - * - * Returns NULL if the GPIO is not currently requested, else a string. - * The string returned is the label passed to gpio_request(); if none has = been - * passed it is a meaningless, non-NULL constant. - * - * This function is for use by GPIO controller drivers. The label can - * help with diagnostics, and knowing that the signal is used as a GPIO - * can help avoid accidentally multiplexing it to another controller. - */ -const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offse= t) -{ - struct gpio_desc *desc; - - desc =3D gpiochip_get_desc(gc, offset); - if (IS_ERR(desc)) - return NULL; - - if (test_bit(FLAG_REQUESTED, &desc->flags) =3D=3D 0) - return NULL; - return desc->label; -} -EXPORT_SYMBOL_GPL(gpiochip_is_requested); - /** * gpiochip_dup_line_label - Get a copy of the consumer label. * @gc: GPIO chip controlling this line. @@ -2414,16 +2387,21 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested); */ char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) { - const char *label; + struct gpio_desc *desc; char *cpy; =20 - label =3D gpiochip_is_requested(gc, offset); - if (!label) + desc =3D gpiochip_get_desc(gc, offset); + if (IS_ERR(desc)) return NULL; =20 - cpy =3D kstrdup(label, GFP_KERNEL); - if (!cpy) - return ERR_PTR(-ENOMEM); + scoped_guard(spinlock_irqsave, &gpio_lock) { + if (!test_bit(FLAG_REQUESTED, &desc->flags)) + return NULL; + + cpy =3D kstrdup(desc->label, GFP_KERNEL); + if (!cpy) + return ERR_PTR(-ENOMEM); + } =20 return cpy; } diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index b1ed501e9ee0..9a44016789c8 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -531,7 +531,6 @@ struct gpio_chip { #endif /* CONFIG_OF_GPIO */ }; =20 -const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offse= t); char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset); =20 =20 --=20 2.40.1