From patchwork Mon Dec 4 09:35:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750232 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="y7FnlPpa" Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05003109 for ; Mon, 4 Dec 2023 01:35:15 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40b538d5c4eso37617035e9.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=eVdnGgn+cDZjei8iQQsm/gP3/6J6muAvZ3hDbWE+S9FesQs2DMAK9+UbgIfmvF70uo wYJr9LU7kXVYPZiNB8AVLVYfZHUtztv5ODpbTaWX3n/vQHJUuSC9sX/qT/SoJ40+GVJP xaKOjZR8QRwZ4vvUm4XCp3DL76h850npzXTeJj2odFU84a7rENM5oMfj7yN22/slcX8i Bh+CezpMkO+kQex8FsvQd9Q25iCTajhwpiKr4o5YWQq+BVTwglKJK7Cq7ZlvmIAVqXzg O1XeXmULNiYbl90ETuri0qJncVVwT2PW9VYBrlKXoVWYaP5W2W63OoCqohN7cPLxSnCF D+eg== X-Gm-Message-State: AOJu0YxxsC3RYDFicb1uwREFVfAGb+4Bm0zqe8RLYgtKalW5fcV7Uu0P Y8s4XaSF2K+YhHliGOo5OWDOWHEkJhpouHbFsCk= 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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..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); +/** + * 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 %ENOMEM. + * + * 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 = gpiochip_is_requested(gc, offset); + if (!label) + return NULL; + + copy = 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 descriptor * @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 { }; const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset); +char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset); /** * for_each_requested_gpio_in_range - iterates over requested GPIOs in a given range From patchwork Mon Dec 4 09:35:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750809 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="i95wUyLN" 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 DFCF111F for ; Mon, 4 Dec 2023 01:35:16 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40b2ddab817so43087925e9.3 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=OmR6ZL+muExmjlqtFbAZukL1FDCDa0C1SCBYpfIsqqP2nrQoPS7wiwxeS4eR3TdmXm AOkjgbQzO4dfI94kNBgdHPzwPlNA8fBimbbydx7Cop+2X2nCstB3PVJCS66MGJqBGcbp yNlfrawstE3mJLbriwzojcr2oMjoDafyuMiA8Zxh2JmVFjz3VyPQ4YmkuVNSu1uSv3Jl 21tRcCw9rJCHa9oAcyf30OOg0ux254xpsxU9O3mgxzrkLCJ1KAimZdNMvz2WEds13GZR 8ks3cT7oAagQoDXytiqpa5HkOUNvWivrgzIFqkCtsYxLQWX0GGhOQez/DbvS0ShTcpDH GBrw== X-Gm-Message-State: AOJu0YzXxlzQsvOOTCF3qe3yXHUwx9+t5Cr/wCNWnEnBZy2fN5XLn4Vb XEAWWtjI878UClP9F51sXUi5nQ== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 @@ * */ +#include #include #include #include @@ -160,18 +161,21 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) for (i = 0; i < chip->ngpio; i++) { int gpio = i + chip->base; int reg; - const char *label, *pull, *powerdomain; + const char *pull, *powerdomain; /* 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 = gpiochip_is_requested(chip, i); - if (!label) - label = "Unrequested"; + char *label __free(kfree) = gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) { + dev_err(wm831x->dev, "Failed to duplicate label\n"); + continue; + } - seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label); + seq_printf(s, " gpio-%-3d (%-20.20s) ", + gpio, label ?: "Unrequested"); reg = wm831x_reg_read(wm831x, WM831X_GPIO1_CONTROL + i); if (reg < 0) { From patchwork Mon Dec 4 09:35:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750231 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="Ljxd4lxa" 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 08B71129 for ; Mon, 4 Dec 2023 01:35:17 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40859dee28cso42303775e9.0 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=mVor7jqmGgHxYyihDN7gQjy1Pztn9H+iEg4hLQV3dry6PIjs3yQwfXs4Jst7Wki5j1 pDfk4+G6SLQMjBwsL8EKjULUj14rR+HSN8BjUJVGxLOlJ0Tu5ZPKeTSJeM04zph+5EKl oy8Nv9PyHFjvh6TtOdSrwduRQ5JVVkNpvdTRDb+B5GW+2CXvq/2zi5PgbeWJoXPSk9de RKO+5YoVptf397LlVZSvqTcrmatfVCfMthxOAe9Fg6h3RQiBGjo0p7pRPFRbvNH2zY/E zdm2ThcmmMA6hgpGIXqmCAsUptRhiFqHC74D7tHmdDCgE1aH0PInzwTPTN+3cSQ/gBsb 9DfQ== X-Gm-Message-State: AOJu0Yz5au3F6ANe8mgnzySXZ2tpcjhgp6aSN/Hqlzze1BIVmC5bUsFD SGqQREzsLnaOD0aLCL5kc04v0g== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 @@ * */ +#include #include #include #include @@ -193,18 +194,20 @@ static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) for (i = 0; i < chip->ngpio; i++) { int gpio = i + chip->base; int reg; - const char *label; /* 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 = gpiochip_is_requested(chip, i); - if (!label) - label = "Unrequested"; + char *label __free(kfree) = gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) { + dev_err(wm8994->dev, "Failed to duplicate label\n"); + continue; + } - seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, label); + seq_printf(s, " gpio-%-3d (%-20.20s) ", gpio, + label ?: "Unrequested"); reg = wm8994_reg_read(wm8994, WM8994_GPIO_1 + i); if (reg < 0) { From patchwork Mon Dec 4 09:35:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750230 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="JRRbyB69" 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 16B8D109 for ; Mon, 4 Dec 2023 01:35:19 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40c039e9719so20646345e9.1 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=nNrqxeQ3gataBWkxEIGoU75y6BcWs6jTvPVoPjuFqq0aZXO1ZvZQ/78vIrikLK1kIP HSvFR4+LeFzShVTeLLeQCtoMQ1PIjEhOJPEf1FdYYUfCM/Mm2Ote1PbxhjDzdsdRee4i Y2TbpddwKIGBn3CV+mwwmtJo600jMs7NMLtnDoBqLMumBGhJ+VWrM5j6HUD+yKrf4AGK bA7ADNFXWsP2nwoeXm1YgOhtQqEOy9IA+havOP4vNtnzGil2Oi87ecykb2H8i9/QRTfy P1u0zhcpeigdvX/yQj2EnGoH2nIW409UaIoP8LoeqbLg8pNKqzXmpdf8NsPpwP3WBg+C ZOCw== X-Gm-Message-State: AOJu0YxMQz8ITE5kK0x9mQHRNfQx15wU9NFnZYVdPPKmaFZOkaFBHMpS 8eJvB9FUES1G5+uHMtABKvXjcA== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 */ +#include #include #include #include @@ -255,7 +256,6 @@ static void stmpe_dbg_show_one(struct seq_file *s, { struct stmpe_gpio *stmpe_gpio = gpiochip_get_data(gc); struct stmpe *stmpe = stmpe_gpio->stmpe; - const char *label = gpiochip_is_requested(gc, offset); bool val = !!stmpe_gpio_get(gc, offset); u8 bank = offset / 8; u8 dir_reg = 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; + char *label __free(kfree) = gpiochip_dup_line_label(gc, offset); + if (IS_ERR(label)) + return; + ret = stmpe_reg_read(stmpe, dir_reg); if (ret < 0) return; From patchwork Mon Dec 4 09:35:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750808 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="aCxEbpks" 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 47C3411F for ; Mon, 4 Dec 2023 01:35:20 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40b4746ae3bso37649195e9.0 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=cdRmTTGRaGH5XOYkTlHLjJI/4/MHuRAdGTUUdOBAFPkJvhsO/YSTzoteCVwk4S8u80 hd4fA/JzQk3oS0vNvvfMY75mvrqUsUQizMstunbQf7lMfVM0irdZeAZvwvFHyxjp2oHI 3pPvNYqX+wRBze3oB65FxGZba5fjCTmhmVs5zTdZujHrPYlLvcf2kfxKm4iBa/Env4FU DCuBollfpLy4GaDQrrje3vbKubV5q74WeeqjJzIcOsFWyXrMkRNbgJ0te+Osc1c7EXol cilVniWRcW+dbCGaA5oQ+q/8o+5dRxnydpfgyzcWNKKOlVKe5U0ubGWPNsEzVM9guUHJ R2ZQ== X-Gm-Message-State: AOJu0YzY6pViFPAA/fY0l8Ss1qtTL2pD7j673h6a0GpyOxkln8UPfhiV pqtzvsPPcez+wtFgJh1djagt7w== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/nomadik/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 = pinctrl_dev_get_drvdata(pctldev); - const char *label = gpiochip_is_requested(chip, offset - 1); u8 gpio_offset = offset - 1; int mode = -1; bool is_out; bool pd; - int ret; + int ret = -ENOMEM; const char *modes[] = { [ABX500_DEFAULT] = "default", @@ -474,6 +475,10 @@ static void abx500_gpio_dbg_show_one(struct seq_file *s, [ABX500_GPIO_PULL_UP] = "pull up", }; + char *label __free(kfree) = gpiochip_dup_line_label(chip, offset - 1); + if (IS_ERR(label)) + goto out; + ret = abx500_gpio_get_bit(chip, AB8500_GPIO_DIR1_REG, gpio_offset, &is_out); if (ret < 0) From patchwork Mon Dec 4 09:35:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750807 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="ZQseQcjj" 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 E616A188 for ; Mon, 4 Dec 2023 01:35:21 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40b399a6529so32413665e9.1 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=u8f3Xc1Z/1T5M9/lZ4Jggc/OQpglJAmOm5FiMhoKpe0NBGcHAS8fzoOfYn5p38wmiJ m8ct1jwktjq26w93fLKZ3rHhsmsyKwNbTkXRFrZ80VClAQe7k7TebbjUnthwp+Riux1a wPb9bd5I57Fgwg/CE9dVC6kkWwEOGkB3CGzxWcWh9lUAqJGWJF23xLMLh/OI4MuPywuO xIPOafILV6YzhVXa9ETTqgGzG7FIDLU274ligz7cnboiUbfXmG8rJSYFUNW/gygeYypS hAOxq9YutYtu7cV2vMYFM5ByJVrbncj1XNFXn9k/1kCfwTjVll8IhJS+rshJxWRJl7Th npRA== X-Gm-Message-State: AOJu0YxndkAIvECi45j9pxigjZgaQPPj+I/wdI3ZnUJcQVpXvE6nKYEn 5yEfdkPjxBdUPerF8Udy2r6Wuut6moL+fcifkHk= 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/nomadik/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 = gpiochip_is_requested(chip, offset); struct nmk_gpio_chip *nmk_chip = 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] = "altC4", }; + char *label = gpiochip_dup_line_label(chip, offset); + if (IS_ERR(label)) + return; + clk_enable(nmk_chip->clk); is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & BIT(offset)); pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & BIT(offset)); From patchwork Mon Dec 4 09:35:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750229 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="k/nTLUCJ" 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 8D8DA10E for ; Mon, 4 Dec 2023 01:35:22 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40b27726369so43225525e9.0 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=KFKu23Z45JZEmqBwDcQlp0myrxD5bVKNBkuF83mx765gOdxmu4JXew8fpwRS+j+x+r uO5NTjZTNPbA7gDRoXucvO1yp0uZ+DH891Xx6G4/eKmzHWtb4gvDz0hNeV7vCzhvZMbE bdhbX9+cw2sQc20OLBEb8Gv1TCR/i2a5+/+0K79ZU8xadKpr5rjCVKh/OZxeuLbpfh0P yobiWd1JM7aIB6AuvOF7a7W2V2Ef00Zwa9b8A4yzmKpcKJ1EEF8Jq8JcQi+Ua5aWgHSS fhJyEczfGNa56IrRyisy1NHA63W7N2oDCU6G+5rMVQwsW77MBbF9/leNdOXdISI6TpvN 1EVA== X-Gm-Message-State: AOJu0YwXZwHIYPi/kpzFGLJVjNqDvFLCmEqZy5eamrvdSIrHDeAGQa+q I0eyjAWfp0II7VLnfVhoFK0JTi6PuYoBU/D+IwA= 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Use the new gpiochip_dup_line_label() helper to safely retrieve the descriptor label. Signed-off-by: Bartosz Golaszewski 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/intel/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, struct gpio_chip *chip) const char *pull_str = NULL; const char *pull = NULL; unsigned long flags; - const char *label; unsigned int pin; pin = vg->soc->pins[i].number; @@ -1200,9 +1200,10 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) seq_printf(s, "Pin %i: can't retrieve community\n", pin); continue; } - label = gpiochip_is_requested(chip, i); - if (!label) - label = "Unrequested"; + + char *label __free(kfree) = gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) + continue; 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, struct 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), From patchwork Mon Dec 4 09:35:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750806 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="2XtL2Cig" 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 8DF9CF2 for ; Mon, 4 Dec 2023 01:35:23 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40c09d62b70so11320565e9.1 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=q86tMWO3UeovJ9n0UbAyE90FG0SuEHpR6wwTgNzLUzBLFnBrvq+yGocYJUcdXcW8wF NNd9Dp7X7e78oiwrVCGp7GbPjhRZSoeduN2oOjdrW/dVcO7gv1FotEJDD2ZmNe7j0AuQ BBapcjx7IPn6srofg/gLpJwoOGVkwxbuVwctF3BzAkdjSVs7Xh+ZLQ3gv47aKX5d8xtm URpNVuM9mP5Il2X466X4vOrsUKmFpi1hBTx8txx94AnFqUPxCZln4Qhcn6oBNgm1ccTq fXL/uxDh/1vE8+Q8c1qSpHSShyeuD0d0lrsZnN2nYeKx2OCJroHPO8sylcC4quQc4215 B+ug== X-Gm-Message-State: AOJu0YzIFyYWPCgRbdyOTxrKfcaHayx1p0zVCnSO2fv6KdgQVMKVHox/ rp9fmvTnlKddcJYp69eBwdPeJw== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/sppctl.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. */ +#include #include #include #include @@ -500,16 +501,15 @@ static int sppctl_gpio_set_config(struct gpio_chip *chip, unsigned int offset, static void sppctl_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { - const char *label; int i; for (i = 0; i < chip->ngpio; i++) { - label = gpiochip_is_requested(chip, i); - if (!label) - label = ""; + char *label __free(kfree) = gpiochip_dup_line_label(chip, i); + if (IS_ERR(label)) + continue; 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"); From patchwork Mon Dec 4 09:35:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750228 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="TyF8oO8Z" 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 5504C11F for ; Mon, 4 Dec 2023 01:35:24 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40c09dfd82aso12468705e9.0 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=rl7lBMNw8buVbONDdShDoQwW3Cl2U+Ej4tFiS+r20vLCsEe88P/nyxlEDdjs+Fp6o3 kjIpQLMOYUqpNhOBMERVmT8gAsrlxy56zbFk0ltS0kcxIsyU+1Kqa72IH8bUWCD+45oo xie2EClfmrZKsYrcA7GWrqrv2Vj3OHj1yaZIqyeoMUR+JUf+nMoj0qEej2piLiBLmrem sbLAUn8hrYr2cDi5VBKa9QFZsd4wI2nWDCLTfMUvLbmQFdUmdsGDZ86kabFrmjXzqDhR kmEkBkyiQQ7g6iT1A/CZRCpKFyNnLEx81kn48pXAoOq5Sfvv19s60bFr/qM3toRDbBrM ZgkQ== X-Gm-Message-State: AOJu0YwZZdo8sHtiXy997ATnbWRxs04ELpaJPAuGsnjPt90jCr3MTs/w Ay26TW71AdH5OY/nCekx0iQqYw== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 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 offset); char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset); + +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 = { label, i }; + *_data.i = 0; + _data; + }), + const char **label, int *i) + /** * for_each_requested_gpio_in_range - iterates over requested GPIOs in a given 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 = 0; i < size; i++) \ - if ((label = gpiochip_is_requested(chip, base + i)) == NULL) {} else +#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 = NULL) \ + if ((*_data.label = \ + gpiochip_dup_line_label(_chip, _base + *_data.i)) == NULL) {} \ + else if (IS_ERR(*_data.label)) {} \ + else /* Iterates over all requested GPIO of the given @chip */ #define for_each_requested_gpio(chip, i, label) \ From patchwork Mon Dec 4 09:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 750805 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="FyFfMo7H" 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 8DFDE1A4 for ; Mon, 4 Dec 2023 01:35:25 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40c09d0b045so11439775e9.0 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=s9Xe++xtdCC0aDA0mypZsmSh70fiTCwOvSrmuM0JwlbWrbEPZUzJGeor5HHzjdUb4I 3JgX9kNZBOcTd53Mfdr5iIU5MA/PG9NhsylB/ahs8nARG522XAwLOAcj4QWmG/dx8pb9 UddVhdkMmt0+OqR7y2B+u8KahXdXBVG9Q892o2pRzr9PjwQX4Sx3n7M2ugkrwt3IDtym G6MxIKqchMrf0bwEhRpKuHZffsWHIUEsYvMymNSUOSEklbz5VfzTcZfo1Uu6G9lFcJMq 3o9D2AHBxg31B1fpAAM+ip/vBXnn4tE3KXzv18UnGGDkDFYulBkRmu6hSkNTCbu9s6yb 2WPA== X-Gm-Message-State: AOJu0YxELrUgyv/3iLmLQEixSlzKf8x8ETvRtflSGTmI7bU5r1ZsBEnq 6Z5ibuWZdyiIr9Ezj1Z48peiWQ== 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> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 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) spin_lock_irqsave(&gpio_lock, flags); for (i = 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); } -/** - * 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 offset) -{ - struct gpio_desc *desc; - - desc = gpiochip_get_desc(gc, offset); - if (IS_ERR(desc)) - return NULL; - - if (test_bit(FLAG_REQUESTED, &desc->flags) == 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; - label = gpiochip_is_requested(gc, offset); - if (!label) + desc = gpiochip_get_desc(gc, offset); + if (IS_ERR(desc)) return NULL; - copy = kstrdup(label, GFP_KERNEL); - if (!copy) + guard(spinlock_irqsave)(&gpio_lock); + + if (!test_bit(FLAG_REQUESTED, &desc->flags)) + return NULL; + + label = kstrdup(desc->label, GFP_KERNEL); + if (!label) return ERR_PTR(-ENOMEM); - return copy; + return label; } EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); 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 */ }; -const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset); char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset);