From nobody Tue Dec 16 18:20:10 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 C2AD5C4167B for ; Mon, 4 Dec 2023 09:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234909AbjLDJfR (ORCPT ); Mon, 4 Dec 2023 04:35:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234826AbjLDJfL (ORCPT ); Mon, 4 Dec 2023 04:35:11 -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 EA68D107 for ; Mon, 4 Dec 2023 01:35:14 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b538d5c4eso37617025e9.1 for ; Mon, 04 Dec 2023 01:35:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682513; x=1702287313; 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=uGHp/zivDD4UeGo/O0oZ0YEfeaPi8u0T0sTBfg7Gjaw=; b=y7FnlPpajpr8n8nucOvT8HBBlBNAKmKIhme1F3n6heV2mXjpufnCNqo1rMcbi6Jq6l PXVyMLf9hJeezi8ATsz7ZhKbe8k6RlTXr5S/ASXktAMyWNBEsYasdrQgrtAUl/K36wco UgR443z5q7FqNgUzuarTTq2hqeEVUeOFC1VtztZwMMEYQQrZ5IJIETGJcqlo7t6QEfs3 SR0Ie0/puufn+o6dSYhb1B36XQR/1T2AOG/ZtEeJbybbSmjJfEyx0RTIpO/km+l7B5I2 aDfKqtz1TeA8gGfbUPVP+78txBLdJkkvv76++vKGEo/+jW6PkAtdx/R6J8tVFYxTkXkb 41jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682513; x=1702287313; 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=uGHp/zivDD4UeGo/O0oZ0YEfeaPi8u0T0sTBfg7Gjaw=; b=v+wWtR4MFktI/eoPtuJ6cmF+YtIagyFNVh3JoTB1b45BxHamdQ/IL52Q4/NC6pfhzL FJ/oKeV8Z/TDOVhwV2AtKmYSRQ1swYY31WYhxN3kMTv+L7gQhOi/dG8aOCmMKWiIO+vw pG9OAe7nZVoGpraDpLY01SqzkhpJ1tUBd4AV0Q5klOcN3Phzeg2M1B9NaArayKrHqZIX AWJDV9bGEbzyrfJcEpfRouTnOuZKwyUluMdaSQ1siv3UcHHjRAn4e1DeMG/79ogCsw+W OI0DdSBXWtaSheBS2xLPU49H7AYKr1n/Um6xvRlks5+I/rXwnhZnhQp7InL20ZB+Tsej JDug== X-Gm-Message-State: AOJu0YyNuiiEfzZhF70KBfrkrsAzjgvPRwhuza8Y6qFyYU1BMdk1kAWp wO5t7v+l/EC/gP8b9+JrTAHgew== X-Google-Smtp-Source: AGHT+IHty3BbyOZtDzbcT1aXZLimxuywhqB43xcMqgA6c48GKHsKE4IJgMpVfVz1QHmQAv2GfiPWPg== X-Received: by 2002:a05:600c:2044:b0:40b:5e59:b7a2 with SMTP id p4-20020a05600c204400b0040b5e59b7a2mr2362002wmg.127.1701682513268; Mon, 04 Dec 2023 01:35:13 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:12 -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 v3 01/10] gpiolib: provide gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:00 +0100 Message-Id: <20231204093509.19225-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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..d4b33782cc10 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 *copy; + + label =3D gpiochip_is_requested(gc, offset); + if (!label) + return NULL; + + copy =3D kstrdup(label, GFP_KERNEL); + if (!copy) + return ERR_PTR(-ENOMEM); + + return copy; +} +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 18:20:10 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 B9F79C4167B for ; Mon, 4 Dec 2023 09:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234808AbjLDJfV (ORCPT ); Mon, 4 Dec 2023 04:35:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234818AbjLDJfM (ORCPT ); Mon, 4 Dec 2023 04:35:12 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0CD0124 for ; Mon, 4 Dec 2023 01:35:16 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3333224c7b9so2279244f8f.1 for ; Mon, 04 Dec 2023 01:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682515; x=1702287315; 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=i95wUyLNLZz5CTbGL8et8CKZjeP/avgInNMQvRUmE2P7Q5VDwnQvS675+d82tsyeBb PNl1qqSMK/Ev0BJbfhMauF3cOLd+m9dGGIzFca/BImEP0u5tTAeWP1e1XO/was82QZOl jLpSvp/fF0Xup/1p8u9SV2Aa4fiTMPC049o5gwM7+M3NyVpR62gldJCFnXGvXZOy0g6G Ywqlh22KyGpALjvdp0q7VjFR5E1XZI5hqK8vYii/U/j5uMxGphy/kCwhh1I5VCj7P19L b9K3gZWXcm4LzAUmubW38meDcSM0s02wj1XgszPx9BJlHMar4+u4A4nj6vI825qRutkt wOZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682515; x=1702287315; 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=ZYsoZlHeGSWFzllYunJr5eaqsIAyyv+V367QdH+yiCbLIw2/ZNhAkHa59FjsTVOmbc YFBuiCtGXKANaanuSTVkO+TM+dPxFYIEmEXvhLaNVrT/0W0zWKg6EZRYPBPBdGIjAReI JmRvF9XF0mMuGbICHN4wdijC7EyfI3hdyC4ypoa+E+0moI+wlvYVC+neFZJfh5g+fvMM X/b08HPu0W+wtgmLydeLMvmN78ammx+VR1o42FYWlTOHnHffcfZZqqglp2VowsGCoA53 sHv1XDhuxNCJFqRZ+J4oF4sTcia0JD5iL5A0jOEV5CtRQx+LV8JEg+fZJTCmBHuzYobV RMOg== X-Gm-Message-State: AOJu0YzkX09nxVjlVrcDcuPVMUhMkYYKe2DcoSkiJM5bG3p5xjp797fU ZJNSdkzTFnT4SnoPKNSY9H4CTQ== X-Google-Smtp-Source: AGHT+IEkT16aKATtFm55qcW57SlcB1x4wElzEN+uRylbf+NHozoN4a3+LLiRLsuohCIJmlgWa1OL4A== X-Received: by 2002:a7b:ca49:0:b0:40b:5e21:e276 with SMTP id m9-20020a7bca49000000b0040b5e21e276mr2343776wml.99.1701682514585; Mon, 04 Dec 2023 01:35:14 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:13 -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 v3 02/10] gpio: wm831x: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:01 +0100 Message-Id: <20231204093509.19225-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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 18:20:10 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 524A1C10DC3 for ; Mon, 4 Dec 2023 09:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235279AbjLDJfY (ORCPT ); Mon, 4 Dec 2023 04:35:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234824AbjLDJfN (ORCPT ); Mon, 4 Dec 2023 04:35:13 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08C8A134 for ; Mon, 4 Dec 2023 01:35:17 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40c0a0d068bso8917235e9.3 for ; Mon, 04 Dec 2023 01:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682516; x=1702287316; 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=Ljxd4lxaABYVLm5r3bNebUdRcZtxU7HsAZEFdR96QAbM7e1hNKQj1EtX+pUTN+EwuD iGAe9iMDj04DS3BZmEYfJOi1L0Qf2cDa+7xVBmNu7tReD9E/DPgVqMgfdY4BOTk6y3BH lbLzn7xTUb7fqYdkEsAjzvRtD7y7sAQCklJG804yZUwDcky4MUewHbCueT0WkSfiRtKl WpEK7EzWFiEZKXPepYbtIC9ODhn+7vMVre1kDHMh10VtGPacar9tJW7Z7PPJj+XkYnBY EQ08mLPpOibOdMOXK9YTnx9wAExCsmFaqBYj9v5Hxj5amH3+6ORUgKxt090bsWqmNQk6 pX5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682516; x=1702287316; 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=K4ibNpXvnG0cIU/YE6LtUe34XM8Y3vDLmn9v4IM8PpZZX3sWGoNVnSkcf0k3H/cKhP M0mafhX9A08vT+Dk/BItpR13H1Y7bhSBxseaD7pXPRehHzFfDBXyIC/MG7/rDYrF3fqp 0k2IF1NSCIin2LjcLChiNO1QvBWvphrLmSoS7O5ukPyXbfgMSCyKcJ+0yFEKmwIKNNAv s/EH4/aQrRNPQa0MFU7bkyag8ZOqVB2Z8lF6n6QoWfVDXtpbaooy5Db1My8CvgutNxzU Kz0i/UFfSa7q6FQGA41Qa1mtTTyYTG233Nmig5kVTt1gBIXMr6HLl9BCchZdZRtTnCfU qZ1Q== X-Gm-Message-State: AOJu0Yxcop/zQGnrXfdzFeJngw15excZn0WY3dzg/E6T/ORwDlg2fK4t 0Zz/UzsMvP3oNq6VlVRZbn2vNQ== X-Google-Smtp-Source: AGHT+IG8j6GgcmneGkekjMxaAVZAOQL5vjLVSjwSnVPrBrikm52pKL8RtyTbjt6kyLLQHmJwOHZ5/A== X-Received: by 2002:a05:600c:a41:b0:40c:d3a:2447 with SMTP id c1-20020a05600c0a4100b0040c0d3a2447mr288453wmq.87.1701682516457; Mon, 04 Dec 2023 01:35:16 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:15 -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 v3 03/10] gpio: wm8994: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:02 +0100 Message-Id: <20231204093509.19225-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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 18:20:10 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 82A5BC4167B for ; Mon, 4 Dec 2023 09:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234876AbjLDJf3 (ORCPT ); Mon, 4 Dec 2023 04:35:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234827AbjLDJfN (ORCPT ); Mon, 4 Dec 2023 04:35:13 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16B1BE6 for ; Mon, 4 Dec 2023 01:35:19 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40c08af319cso13311695e9.2 for ; Mon, 04 Dec 2023 01:35:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682517; x=1702287317; 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=JRRbyB69kiCLpu/4ZG4DzhiF/GZvns/kelMSC/ykVyX1XYkXMpRtb7VCDhqMZAKy+0 KJONePiulejgrDDvoe93uT4kd65FXJ0y70pjYxy353zUCKS/DuupHHtehJEqXnu2P7g7 p7Nz5i6aucvfuzR73L3HOgYHOfnVqiSPvWYm05h9hLOFMKAcM5cgB554Mv2AgeFsEM2W L+lHxtGoMTkH33cSqvVc/E7Yc/+WcImUEX/MyugubJ0u1SbkoO8cLbhLynpCK+mSQKqz Rz2QpBAoJ7o77LSAtFPDRKkvcudACDr/CP3OJ29I/7JXatavob0yJLuhkRix8i6GxX1E P2zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682517; x=1702287317; 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=L+f7m82c5HA3PWcZ0bzrwUt0LbHLHxLpRC2kzFpcRZzFWDdkaL01BsStQF0VQiWR6e vJDv4SmownF2F97BPnDg9lMv1A8oe4OWBW++0YqlwfBb6pUWmuBxMQdT+B4bHglNzkbd 21xCOwCveVm0rBlLOdpaBU26pvD4ksMlTMhzwhI3iHWYoMj62F7KGVondx+5DY4CNlm8 2DmyTwnKXCK6743juLB5WWHbJiS5CzHKoygXnNLLVhdB14TDbgeEBtGlh7e9M6udOrjn 9oCvu3lpuswWGeJ/QF7hQsyIDgoPcUQC168jVEcUwrzt5q9d2bT4A5h/gtrBjhnt8TR8 M0Qw== X-Gm-Message-State: AOJu0Yyvy6/McAHvcLEfqqLoo/2sT+KVJzkSW0Qn/nJiGdo6+pQ9Y7E6 h6ut1+feITw5PvarAaSVxVqWvA== X-Google-Smtp-Source: AGHT+IGdNMxWu9CAp1B8+hOKkvU9FEsYEEb9kAiU357IxEvD2zDpahJNZN4dV+3wpjhH/7lMeBVJ7A== X-Received: by 2002:a05:600c:524f:b0:40b:5e21:ec2a with SMTP id fc15-20020a05600c524f00b0040b5e21ec2amr2044570wmb.92.1701682517494; Mon, 04 Dec 2023 01:35:17 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:16 -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 v3 04/10] gpio: stmpe: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:03 +0100 Message-Id: <20231204093509.19225-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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 18:20:10 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 33ACBC4167B for ; Mon, 4 Dec 2023 09:35:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234838AbjLDJfd (ORCPT ); Mon, 4 Dec 2023 04:35:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234853AbjLDJfO (ORCPT ); Mon, 4 Dec 2023 04:35:14 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58149136 for ; Mon, 4 Dec 2023 01:35:20 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40c0a11a914so8843485e9.2 for ; Mon, 04 Dec 2023 01:35:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682519; x=1702287319; 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=aCxEbpksu1Qd6S2UOdyExLFlzGpiThUFwFt8nT+HZzKdS94b3g31TRo5NLa9jS5TGv bM/+8gCAJ9Lh9br0BGITvdg5ZLk+2e60EyjjsLBUPbOAAoR0UjhNBOSj+Dp/iazsTsMZ yXOaJbL4DiBoDcA7xpW5GIpn3kH5e4sW5c4ooc+irRENQH3j4DIPBMpFku8RfFoiykcU fdaJLhI32FHlyFXs0HW3yg1EpkK/bteqOQ+N53eznQThmQoAtVcq0wmddw6JK6T2rsua bmmBZdvVxcLRXia58OdJ+bxIKbuzrdrMnajs15Vxf80Y8cFyMhRcgw7NWlV3GxsSWUH4 ckaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682519; x=1702287319; 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=boAYYtdYgzLDgq2ffSWrA5AY7PsjFtd4rdCLw1txQ5uodKczxgix+neBfwIUhCcnzj 043Sj17fyQzqqI9gSPT7gXZGTEZXlWAtF1DeKsf/jflYuGDAgs35J2u26V9PUrKNXWZY 3vmAS2gAQvdMc0gBlHA8xqMfjFmmsocWyd5ZaWTSS/cL+Eym5z8pUdu1AljA9J/ygShe GuOve+Tl47jyeaRpKvoq/GC7EV0wMX7j1om6QwA/+t2NIsWG67UqjqcxqYhYnJgLEhzR EdxD9+5XFzKKCyUn6YQBezzldnS3qbPHZI/q78tVku6cOhjRWkLy4HAxBs9FeZyq5XFb t2dA== X-Gm-Message-State: AOJu0YywCu0rU87vFIzBWAXaPszoVLl6PHfgpuMIIgTtGhjqR2K7s+Mf 4tgQHN0Aufsk+sEynTrA/YkTkw== X-Google-Smtp-Source: AGHT+IG5zgdmvymXaEV/9HDjU94CDsHzttR6WEf8JW7wnFekYp+m3ngvnASxirGcw0oJzT9gwgOS7A== X-Received: by 2002:a05:600c:4708:b0:40b:3d9f:eedf with SMTP id v8-20020a05600c470800b0040b3d9feedfmr2257243wmo.15.1701682518591; Mon, 04 Dec 2023 01:35:18 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:17 -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 v3 05/10] pinctrl: abx500: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:04 +0100 Message-Id: <20231204093509.19225-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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 18:20:10 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 6DFEFC4167B for ; Mon, 4 Dec 2023 09:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235336AbjLDJfh (ORCPT ); Mon, 4 Dec 2023 04:35:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234826AbjLDJfT (ORCPT ); Mon, 4 Dec 2023 04:35:19 -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 08F30189 for ; Mon, 4 Dec 2023 01:35:22 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40b2ad4953cso32575675e9.0 for ; Mon, 04 Dec 2023 01:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682520; x=1702287320; 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=ZQseQcjjE+vW5TPsgSz5KrYkfQTCIA6JQRU8NbwG8EpVeNocOrwzqc7U0UJ60XS6Ql aZfduINkqhk14CIRz9EtuRkJ5HxXKgZziDI109WUmJbDC1FP3IvZBPKfab8JCMlmNiaS J4qsMBI0fG9gPt0xBUPdZBazOjrFPNb9opGkN6ouytFKynm5mr7Nk6DzsTDW7vltbpwh 6nxUBzZ76jyzMEH+jDpa13qurOt/e/CJjoH381HYQQVfhfNnlQZmK8H+F9fN4fjXvZTj lyB/i4P/1fsapV3gv/vhs8o3CEfjVm09AJRLjqMlncll6S6HsOqQ5Je2rLGE5LHxCtt+ EmJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682520; x=1702287320; 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=uLWM3Px5fQxgTRg4kLJCJIBv8+64w6g0Ejq0mI5L8NFFyYxrZRLGx5paocp7fJAAr8 KsaJgLnbA/JaaIVRiHhdh8t0rstwd0Mr+6eZw6c1jsSMJbmRzOP9CotD+Z2cnOQXS1To 2iKFPXMkm1ImF+Yxum1CCAYEpDIo7CF/O2d0fJ4z96qukyekfA0FoA9k4kFpoDRJoA3/ Weg6MF2fuBZJAcKFU+6oKb6WKJLN1L7AlMubah+3JMyRXsg8VVPWY55WQdAK+GLPR1Hg 5UhT7JYAfJI9kD5UssUVP3TQ5F1O3rlz5fA1ns7rWfF2BgDYUEm5Z4Zs1NaOjEhUsbHA TvpQ== X-Gm-Message-State: AOJu0YxWa/WMS+XDRSIXqHjElxr6SNd+VMcbpyOpbmKoGO9xIT8zuAJ1 o0EzZgNHJ2lTlfUbN6BypDwaSg== X-Google-Smtp-Source: AGHT+IGSQVKS9Qw36aNJcIn1j1pEaPabqfikmC6hB8VkbJSOX2WbEREh2ySrnlJFoeafL30Lhqj/pw== X-Received: by 2002:a05:600c:44c7:b0:40b:5e4a:2376 with SMTP id f7-20020a05600c44c700b0040b5e4a2376mr2513988wmo.120.1701682520303; Mon, 04 Dec 2023 01:35:20 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:19 -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 v3 06/10] pinctrl: nomadik: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:05 +0100 Message-Id: <20231204093509.19225-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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 18:20:10 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 EF7B8C10DC1 for ; Mon, 4 Dec 2023 09:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234822AbjLDJgG (ORCPT ); Mon, 4 Dec 2023 04:36:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234916AbjLDJfT (ORCPT ); Mon, 4 Dec 2023 04:35:19 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FDA4113 for ; Mon, 4 Dec 2023 01:35:22 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40838915cecso43125095e9.2 for ; Mon, 04 Dec 2023 01:35:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682521; x=1702287321; 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=k/nTLUCJ6LFc9jAbF3VrnIECocahF8qiCl/z5yo7XN8BhWPV4MqrYXm1vgrMQf9hKp Kx62gzrG2Bmqd1OM6YJAYO7ikSZKl9HmT+Mvpzl/OSOD8bNMIHISz+1u4FkHsRx96JMR /jSgoLGvuAOdP6Wu+UkZZGbM6k4KSqZ8NBXkhTG2LYbaix3MpYq+ePs/QeuMOlFoPb3a X9SaPchFsX+SoeesY2a/S9hA/JdZYspq1aLO77xjjKcc5Io8NY/aCRlKNr3Cg9Op7oU2 ae5fB2BUZkrzx/XCwYx1hGU7yjKVUg9jE/IXc5M1z6POSgyNGfPR5cxPDWvJbPNzj/15 vMcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682521; x=1702287321; 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=piL0/YtlJTfDzHwP+VaJjDAsbh9xDd8rmpYw3+6lYIBqtL8Kjr1jM7EaYJSJqxPZy1 rFN9RNNLG7FfJe8sXEx7vGYdj+oKMyoI6jQx66ns1cF0NdiRRArGpwN2FNLMTImG6WMa JFnF/gznC6PZL6x37owqom7nrxIRAfid1gdiV86f2BUvEgLfBvtojjEr0uv+o2KTqsmH m0z2SD1Hjlk59bpWCLBah4S5ifj44fO4vKkxXoovsUhjhol2nB9TX958jVRheLSOJrjL xsZtl7KU6thwDnT4DN9snXgXjQqiQDPoIl9lrp2Ev3VY7Ii624qD8CK/H73HbpxXTnfx /g4A== X-Gm-Message-State: AOJu0Yx2jqZLN7iZGMdPPmMFhleXoSpdrD4vEtmPKlsmUMF/B4ucNC0Q GO1lCX+rk4QkfgeLawEe2SeP1g== X-Google-Smtp-Source: AGHT+IFq4DBJmONbEWfXXbKiJ3kXh0xlYz/lUO6kayLYCeDzWPU9D0Wqi96fSt/UQSxXSGG9l7QZlg== X-Received: by 2002:a05:600c:4fce:b0:40c:902:dc25 with SMTP id o14-20020a05600c4fce00b0040c0902dc25mr1059951wmq.51.1701682521118; Mon, 04 Dec 2023 01:35:21 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:20 -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 v3 07/10] pinctrl: baytrail: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:06 +0100 Message-Id: <20231204093509.19225-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij Reviewed-by: Andy Shevchenko --- 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 18:20:10 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 06DE9C4167B for ; Mon, 4 Dec 2023 09:36:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234961AbjLDJgI (ORCPT ); Mon, 4 Dec 2023 04:36:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234990AbjLDJfU (ORCPT ); Mon, 4 Dec 2023 04:35:20 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 954B418F for ; Mon, 4 Dec 2023 01:35:23 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40b595bf5d2so43876615e9.2 for ; Mon, 04 Dec 2023 01:35:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682522; x=1702287322; 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=2XtL2CigwSKmszxqX7TLCepiNZc1A/RDwZbLaBV1rSI2CGaZUoZhUGD+2dzckphruv TyB3s640VALGZqTnYbnBFPIdMfMjtcu2E5mgdCnC35ynuyTHQ+JShEN3s6PE6ehJwpPf 4IL5ZveCjhFnXxTt4EcW66bGeQUOuukcBI9Ylwn+tZ25T31QPU/4ewd7WgPV0/2rZocm dCKOtYtRLJelTx5sp3E/n86WX5xPy+O7AaBEnKA/T+4T0v9RFj4mSPxYQWoXFP8nGh4M aMAdD/pjUL/VbC/5Vge7jvy29X9TxI2HX8nS5V82VD5G+ad4Lz2mplrJkdebWyP3UrIm 1lEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682522; x=1702287322; 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=M8gxjMPUyox+Flv19J+oogp2PHqVhmuu0Pl3wOG3jZZOAqukMaVMabATCBq55WomRw oCtES167rSzYGXFs3V1hUl+KIo3Cv2tzQrmLFhV8ky5DOupFTiw2I1cHCanGuIxfTu47 zChWP43c0UeYuDXg838pyTUO5xuDwlEnvwSizXba1lIfDm4hwIPEGk9wqE+Rz1f4Msfv G4cL70fyLxxtYLNpk+4DM9tYx6Idc50Efnhebj1kZ57pjo3W2jqYf+63Vnc8nCYhulO7 mjeZ14rvb14sQMMFSrv9BnIF9HFEYGw6i49UoyBEcsTFsvWgkpo/cBjkp7AB14dDQKew GtQQ== X-Gm-Message-State: AOJu0YywVrZR0R5dXvfj/ZLCvCZJikW8AdCYoWn5YN8bcj9J/y7Lks+a hWOCAqGT5SLygbXM1c8MGQlfGA== X-Google-Smtp-Source: AGHT+IHCuQnItV2lKs0M1bnxQ5NKnbh9Y4kTm+Isghykg16TLUiy7F8Pk77hB8yvqqxMFcrKeo7XlQ== X-Received: by 2002:a05:600c:3c8f:b0:40b:5e21:c5ab with SMTP id bg15-20020a05600c3c8f00b0040b5e21c5abmr1618979wmb.121.1701682521977; Mon, 04 Dec 2023 01:35:21 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:21 -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 v3 08/10] pinctrl: sppctl: use gpiochip_dup_line_label() Date: Mon, 4 Dec 2023 10:35:07 +0100 Message-Id: <20231204093509.19225-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- 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 18:20:10 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 95BB4C10DC3 for ; Mon, 4 Dec 2023 09:36:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235299AbjLDJgL (ORCPT ); Mon, 4 Dec 2023 04:36:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235310AbjLDJfa (ORCPT ); Mon, 4 Dec 2023 04:35:30 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7001F198 for ; Mon, 4 Dec 2023 01:35:24 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40c09f4814eso12382065e9.1 for ; Mon, 04 Dec 2023 01:35:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682523; x=1702287323; 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=HFuMwgQtxRBsqcDwlkNhBzIxKsoLICNRiZ90QrUgNUQ=; b=TyF8oO8Zgq6hfxPV1cMsjP9afRhf0hgNUOLbU4Rvb3ogaJCuwo2tbg9pTt3vb/IebM AROZcQCsq3zKUJZqkJvA/fEaIxOXKJjcEY6T6tvQg4RfBxMMkWwYrkG/6Y2w7hbESEN7 su11gsvp3FgytTg3ae+qC+lzENKTTqmjusFlxmrleMq4o8cB5QyzJNBbwlgm/W/MK0bn YkdfqaTBpL+zVAZDHpZyRPa5Vtxy7cyP0s5W4jrtvB/m+dZavr+DjeLyyYPbbdryuhXr ycGSXUWyqOvVk/mjPpKxnge3EzO6KwRO60THue+HMQ5hInhfNoUIR38bRvw0C15EIHPk Th4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682523; x=1702287323; 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=HFuMwgQtxRBsqcDwlkNhBzIxKsoLICNRiZ90QrUgNUQ=; b=WKHjY75RKiio7Sj0ZBXC6yVU2TA1XKlUeR5gWyHBUHWbE/Pt5VOS1//7BRscMnPqbX 7MG+SCJ9jutxdhLBz5k9YgjdN3Kp9nGedFdHiuyyHQBIUUntVoP+4G5gDsIVucjr3M52 SQaomlg058SBE7n6/x771yC0kz9mPLx0vJiHzXVSbsFora+PaeIQ+31TXytvAUGcvw0L a3s9qtILSsYFiq9lZrIDvhjo6Xk0Cml0dLxrj2a/wmd+yPQmHAeEHcUMN5hXD/Syb/vE LnlJUWQPNvkYGM77Cj67BQEltq3HuoMr6C9zHfOOTwZ0Kkpil9POk8HbuF3s/tmoIIK+ f5Tw== X-Gm-Message-State: AOJu0YxPCani+AFql6SeQNyLlgYMymhCb1RO5KOqEwH7Tq0ywDilYGgv myBoJYpPSTm1sGM1ewIMIh7r0I26YshUxFZNiS0= X-Google-Smtp-Source: AGHT+IFKo4W36xXyE4SejxNtVX66lYuHh3b28bjD0alZD+yoHQII9dsGu8t9qenz9PMKxEkEtHV4Yw== X-Received: by 2002:a7b:c397:0:b0:40b:5e21:dd1e with SMTP id s23-20020a7bc397000000b0040b5e21dd1emr1025046wmj.76.1701682522864; Mon, 04 Dec 2023 01:35:22 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:22 -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 v3 09/10] gpiolib: use gpiochip_dup_line_label() in for_each helpers Date: Mon, 4 Dec 2023 10:35:08 +0100 Message-Id: <20231204093509.19225-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- include/linux/gpio/driver.h | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 9796a34e2fee..910fc50d3ab5 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -534,17 +534,38 @@ 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; + unsigned 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 18:20:10 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 E0E89C4167B for ; Mon, 4 Dec 2023 09:36:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235328AbjLDJgN (ORCPT ); Mon, 4 Dec 2023 04:36:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235320AbjLDJfa (ORCPT ); Mon, 4 Dec 2023 04:35:30 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DC8C1A2 for ; Mon, 4 Dec 2023 01:35:25 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40c09d62b70so11320875e9.1 for ; Mon, 04 Dec 2023 01:35:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682524; x=1702287324; 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=qUM8/16TtFRuJWbQL1BXzPDgwc0PUnSgAFPYdXYTVlM=; b=FyFfMo7HI5+vw6MJIdRERUca43k5eYUzMMRtv3IJ4beevHXsYl/Xqdzg+hFR2UxqBz J/n61hAUMqRf/v4cT72e4fM4bYXXHmX1Emqunn7A4SYznehtvhhZifQbpDzZ3OYZ3gqh M+pN5bAFFzndXW333+WVRjNvFCj8dfEQyaatai5GicMThDfA5d/4qYwoCQ0MC51g2Rak 361wrFDOO3UjsYgg5K6dxfCP/hgque6u3vESzRJ80KJ6KkaEZ6TRG2CR/MG1LnEjQw1K KKem0GS4J2JuMCcMxnrrKcjReFVwcqyQ4KEKAxMaQyiKIvx6ebYrGGxpagOWbwGeq2wa 1YzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682524; x=1702287324; 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=qUM8/16TtFRuJWbQL1BXzPDgwc0PUnSgAFPYdXYTVlM=; b=IyHVFfH5KzrVOu/4nCHBlOK/MtjP8PYtwIgBFKUn+BWtDbMI/jX4S7+8RANJe3VmO/ AL4cvAw4abhR3DzUL9kr9R6OFfH4HNJa+qDKhYjrX8jkjQayC//Ub2ctzO60aYaFGDux T1u1OrXkvnP2dRaknnqubfviSuP3gQ+C48q1MiloiV498se+dkNlp0oHopi+4acUT3Np /FnZ1W1vCL4fIH4rPoX/0lqtLtrgIVx9aAWUlRl7CxRInxNC7C0KgLfDt9riBAKrk+GK L5jC0M8d040MMB2BJFrle7DCspT5sG3raF/OOIuZue6WePN1fux75xOqF3tDu6GbS9/C e7jw== X-Gm-Message-State: AOJu0Yy9XL+f4giF/gNbTH+iooSUkc3yMwtRVKFwWObegVdhH2+aPLYJ aNZ0Q1uqRvDlo/KgUm9+ZQZzmg== X-Google-Smtp-Source: AGHT+IFIyn9k8yICnEpxu1kT5sz0yPZeDdyS6pUYcY8kYaa7qco4dUZC7Fm9sqnREfN+Da2D/gi3iQ== X-Received: by 2002:a05:600c:364d:b0:40b:5e21:c5c7 with SMTP id y13-20020a05600c364d00b0040b5e21c5c7mr1679318wmq.149.1701682523813; Mon, 04 Dec 2023 01:35:23 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:23 -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 v3 10/10] gpiolib: remove gpiochip_is_requested() Date: Mon, 4 Dec 2023 10:35:09 +0100 Message-Id: <20231204093509.19225-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-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 Acked-by: Linus Walleij --- drivers/gpio/gpiolib.c | 48 ++++++++++--------------------------- include/linux/gpio/driver.h | 1 - 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d4b33782cc10..4e190be75dc2 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,18 +2387,23 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested); */ char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) { - const char *label; - char *copy; + struct gpio_desc *desc; + char *label; =20 - label =3D gpiochip_is_requested(gc, offset); - if (!label) + desc =3D gpiochip_get_desc(gc, offset); + if (IS_ERR(desc)) return NULL; =20 - copy =3D kstrdup(label, GFP_KERNEL); - if (!copy) + guard(spinlock_irqsave)(&gpio_lock); + + if (!test_bit(FLAG_REQUESTED, &desc->flags)) + return NULL; + + label =3D kstrdup(desc->label, GFP_KERNEL); + if (!label) return ERR_PTR(-ENOMEM); =20 - return copy; + return label; } EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); =20 diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 910fc50d3ab5..bd9bea7cb270 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