From patchwork Wed Nov 15 16:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 744497 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D6B528DBD for ; Wed, 15 Nov 2023 16:50:10 +0000 (UTC) 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="XkuusTBH" Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF94419E for ; Wed, 15 Nov 2023 08:50:05 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-6779fb43e5cso32799356d6.2 for ; Wed, 15 Nov 2023 08:50:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700067005; x=1700671805; 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=vc2uuTZzlGTGKEpxHmVUvwPiBGhZ61eMxIga50Is5Fw=; b=XkuusTBHn8B2hnTOerw4/6xlZ9ZWIUFmQ1oKhS1SW9ZDRGpHrhhn4uZ0uNT8qqIPYe oDSFpAQTP9qlq4NXMxzXHCUC9gvHVbUSW9hBAO/SkvdAAFi/5fF8gk9tM+E9knrT9Nd4 ju62hBBll4lyXxs+13o1+IOUQTA8tuGVrXKXm2W3whWF2OdyxSUMCLahGnB5CfyqgdbB Q+T20NGEuVBEsbihPPsjIJhHLg82orZiEDlFmuL6BD7ZMdOqjGU6/6zSdo3+wfgnrAJM o9v4y211rCxztIA0vD4qSHw2k1iRciUrkp5OQRv28H25pfn+rq4lnLqepo5lPC/Btfmx mvLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700067005; x=1700671805; 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=vc2uuTZzlGTGKEpxHmVUvwPiBGhZ61eMxIga50Is5Fw=; b=SD/uLjvhSPbs8xqcfdAObcAlGDN4w5FS8JpgMS8Th3rYQ9T/+EueLK89V5VANxTAOf Zb+MmYJeB1CsFwD7xYfPi/yogrxJ3OpakQ2In9gJkCqcp4lNVm3+I1H8iPzAzSRGu2sL jW7yrtPEwJ5bSBvrokI8xTnXKA9WF+zSpuvh/H3CNpygGxQOtFtJJq8KVZVDodhxr03w RLxbjnOPVi1VcX96oiWGdI/7+1GiNheLipej/NFKfxyt5Ld+mohCM7SbpJgeedpuAQZ0 9lWUgWqcZYe+sDLxH/FcqnuvwQiHLqmpwB5oi+z8wlX0mV2ZlWa4wZIvwme9nq60BjCo FrpA== X-Gm-Message-State: AOJu0YzM+Dp5hQ9GO2RekfvIbD5YLLnOC1wjW0UgwZ4pbDxo9JHQCheU YmxulfcXhsZOylQ1xdYhYwkvGQ== X-Google-Smtp-Source: AGHT+IFz4DMZPFCc0axXCLers6mb90y64kt+KnZAZ09JG9DWqdGGF4MW6AF1dSPrKb6dRAw/PuIyvg== X-Received: by 2002:a05:6214:4104:b0:65d:4840:6eb4 with SMTP id kc4-20020a056214410400b0065d48406eb4mr7154624qvb.6.1700067004848; Wed, 15 Nov 2023 08:50:04 -0800 (PST) Received: from brgl-uxlite.. ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id mn16-20020a0562145ed000b00670a8921170sm658781qvb.112.2023.11.15.08.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 08:50:04 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 1/3] gpiolib: provide gpio_devie_get_label() Date: Wed, 15 Nov 2023 17:49:59 +0100 Message-Id: <20231115165001.2932350-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231115165001.2932350-1-brgl@bgdev.pl> References: <20231115165001.2932350-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 Provide a getter for the GPIO device label string so that users don't have to dereference struct gpio_chip directly. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 14 ++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 95d2a7b2ea3e..a5faaea6915d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -254,6 +254,20 @@ int gpio_device_get_base(struct gpio_device *gdev) } EXPORT_SYMBOL_GPL(gpio_device_get_base); +/** + * gpio_device_get_label() - Get the label of this GPIO device + * @gdev: GPIO device + * + * Returns: + * Pointer to the string containing the GPIO device label. The string's + * lifetime is tied to that of the underlying GPIO device. + */ +const char *gpio_device_get_label(struct gpio_device *gdev) +{ + return gdev->label; +} +EXPORT_SYMBOL(gpio_device_get_label); + /** * gpio_device_get_chip() - Get the gpio_chip implementation of this GPIO device * @gdev: GPIO device diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 0aed62f0c633..100c329dc986 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -786,6 +786,7 @@ struct gpio_device *gpiod_to_gpio_device(struct gpio_desc *desc); /* struct gpio_device getters */ int gpio_device_get_base(struct gpio_device *gdev); +const char *gpio_device_get_label(struct gpio_device *gdev); #else /* CONFIG_GPIOLIB */ From patchwork Wed Nov 15 16:50: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: 744261 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67EDC28E2C for ; Wed, 15 Nov 2023 16:50:10 +0000 (UTC) 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="pZ3F0WMx" Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96FF7126 for ; Wed, 15 Nov 2023 08:50:06 -0800 (PST) Received: by mail-vs1-xe2b.google.com with SMTP id ada2fe7eead31-460f623392fso2243117137.0 for ; Wed, 15 Nov 2023 08:50:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700067005; x=1700671805; 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=6/+c2VO8PV1RqLkhAzMdFyQNC3apc5LK2X9ZNQJCpQY=; b=pZ3F0WMxzknwX8Erg7N0MyTRtZdHeP/CSYxMYlbTW9KCnXX/GG6t7wT44v649yh3B6 CMQBbFLPqEV6iQL/wmkHytQ6SjG98W1iUIL+E86SPT528c0JIdWPVXPQtl0tiHKQw+v2 qrBWrgAxJ63rLPqpV55Orzog3Hl8cwF8EE+GjXl2lpoBxTjHKuHzZlh2ah0Pk8iaCV7r BNIyI4JsZ6SJbg2p/DxA2n+2d90tZSzeC8qO+UIpb6Wrnw24bo3ri1EQJrTSO03NYWPz By2gFNxqwrPgPk61wzqB5iY9LwKXeJqMIeSWIA2HSxxWIucZHfRmW80uF/Yz62vSc7nQ cv2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700067005; x=1700671805; 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=6/+c2VO8PV1RqLkhAzMdFyQNC3apc5LK2X9ZNQJCpQY=; b=ttLIqjpzlZ/OZ9KCHehVMP8zWBs0lC/hxle5Y9DL4qyRafXZ12T6GD1s8k9sHk/CWM WJuCtNTjNVFQWSb+IRXukKdvjfW7myp85XEaO8Xlo4YYSF6R2DkOYr0ey9EzMBYsNqM9 AvVemjLehUa6H/HnHso0y772p54IkaeNKUsvjLFsD/Ymw4NUN8eptHjoSgwyq47yMDfu CxRipLSPBbB5KyWq2xjYcpvfCZAfFCgOom+1LFTXTEwYHDKp1PlchJ3Z5z9CSWF2xnQb tjHplSs3q9PKkIHDaq6dSAvBxqGYi/2Hh+WwQ2ombd9gVaa0ZQtXYxlEwh2c58dcX8cM nvCQ== X-Gm-Message-State: AOJu0YxYIc1pnVryXneRSL+jkCPiLcJZTyBBPiv0g24mMKGO4zADxeBB 5a1DTVVf8BF0TAjRUbRd6ZzzGYxp/bkyzXlRRDpV2Q== X-Google-Smtp-Source: AGHT+IHOoVUBbpIgEyTvnyBKJGvAGhVu9Qj2aYtvhzH+QlMA+xwk5+Qd8WOs/1fmHihY3nCWNEfULQ== X-Received: by 2002:a67:c218:0:b0:45d:9224:a898 with SMTP id i24-20020a67c218000000b0045d9224a898mr13122998vsj.16.1700067005671; Wed, 15 Nov 2023 08:50:05 -0800 (PST) Received: from brgl-uxlite.. ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id mn16-20020a0562145ed000b00670a8921170sm658781qvb.112.2023.11.15.08.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 08:50:05 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 2/3] pinctrl: stop using gpiod_to_chip() Date: Wed, 15 Nov 2023 17:50:00 +0100 Message-Id: <20231115165001.2932350-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231115165001.2932350-1-brgl@bgdev.pl> References: <20231115165001.2932350-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 Don't dereference struct gpio_chip directly, use dedicated gpio_device getters instead. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/core.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 1fa89be29b8f..0b4d07aea387 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -13,6 +13,7 @@ #define pr_fmt(fmt) "pinctrl core: " fmt #include +#include #include #include #include @@ -1649,8 +1650,8 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) const struct pinctrl_ops *ops = pctldev->desc->pctlops; unsigned i, pin; #ifdef CONFIG_GPIOLIB + struct gpio_device *gdev __free(gpio_device_put) = NULL; struct pinctrl_gpio_range *range; - struct gpio_chip *chip; int gpio_num; #endif @@ -1685,11 +1686,11 @@ static int pinctrl_pins_show(struct seq_file *s, void *what) * we need to get rid of the range->base eventually and * get the descriptor directly from the gpio_chip. */ - chip = gpiod_to_chip(gpio_to_desc(gpio_num)); - else - chip = NULL; - if (chip) - seq_printf(s, "%u:%s ", gpio_num - chip->gpiodev->base, chip->label); + gdev = gpiod_to_gpio_device(gpio_to_desc(gpio_num)); + if (gdev) + seq_printf(s, "%u:%s ", + gpio_num - gpio_device_get_base(gdev), + gpio_device_get_label(gdev)); else seq_puts(s, "0:? "); #endif From patchwork Wed Nov 15 16:50: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: 744496 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67F5D2D799 for ; Wed, 15 Nov 2023 16:50:10 +0000 (UTC) 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="vPjtHPlX" Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6960819F for ; Wed, 15 Nov 2023 08:50:07 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-675b844adc7so39400056d6.0 for ; Wed, 15 Nov 2023 08:50:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1700067006; x=1700671806; 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=cBzGno4D43Ros4hSmP6lFXf2RSbEodgJworHzjxav/U=; b=vPjtHPlX9qo45SMY2An0s5cvFgsnc/DPWwwA2fJ1H699LAhLmFqvN9ZREOmfxJEvD6 lIYshiSUIIGnk4L4x+OoukIqcMQPcet+NYQCIdEmvY2mMeiQVEFiV0+97QEJ4x9lhwUH G3vKgtovD8Zz9P6M4GmiQXbsdA/e+ypyxY5Zb1Nb0TLmEtB9W1GFf9qYF4ZpnVFq/epP fXxi3XogmlqY3hkw3QB8Gx+hdQan9R96g1hlPcWC5r456nDMlEweg3a0cOm6KAHO6GZ0 XENGoI0ms6MXbfB9H1LFfCisZfY2vq1y/n3rJLwOQXP8B54VDgsGIOX7gfgG3Ngub1uP l3lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700067006; x=1700671806; 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=cBzGno4D43Ros4hSmP6lFXf2RSbEodgJworHzjxav/U=; b=jZs1nYZGKLG+Xiz2NRnibcrtKHtqESqUYvuD7mILAjQbEWOGKGeHtEToqStLeXI/H1 gnkiFUzUgY3NSzpRQqS0k5KqIZ/v61NhKanRDQ2d8vyI9HoXUQy1yhxQw3JsQD6VhQIQ mbkstGhGk1qiMOamJpTpAlRt2Xr83epUKppS3si/0OyqNtLorPQ24pnijQPS6IzxBidx antzAcyc9b+QLn3XFb3efOjiRjGkw06kKYEP0Cos8lrJuB1gqdEvt2TIfNvcKZ0aaaTw xLpU9QwWI/PyaacHUvOsu4sJv5v8DXolT0nT6BGhnIE8rfU117+OsH3qF+g7wJaXnZQQ rrFw== X-Gm-Message-State: AOJu0YxtU0y5F6CbeIEnIjvkgtvHPOUMsw+bUaRHYhF0BeqfumdwYVLY s8kVd8Ii/at8UfHTO1ySDxjlbw== X-Google-Smtp-Source: AGHT+IFRu8UzuC2/0PimlUZ+XtnZn4xYNBiel6D8QAFpK0dkZkTmuT6QrPD8tNJRmUck9qf84yYvwA== X-Received: by 2002:a05:6214:5497:b0:677:a1d5:4331 with SMTP id lg23-20020a056214549700b00677a1d54331mr6464857qvb.33.1700067006554; Wed, 15 Nov 2023 08:50:06 -0800 (PST) Received: from brgl-uxlite.. ([12.186.190.1]) by smtp.gmail.com with ESMTPSA id mn16-20020a0562145ed000b00670a8921170sm658781qvb.112.2023.11.15.08.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 08:50:06 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 3/3] pinctrl: don't include GPIOLIB private header Date: Wed, 15 Nov 2023 17:50:01 +0100 Message-Id: <20231115165001.2932350-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231115165001.2932350-1-brgl@bgdev.pl> References: <20231115165001.2932350-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 gpio_to_desc() is declared in linux/gpio.h so there's no need to include gpiolib.h directly. Signed-off-by: Bartosz Golaszewski --- drivers/pinctrl/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 0b4d07aea387..e55959e1af5a 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -31,10 +32,6 @@ #include #include -#ifdef CONFIG_GPIOLIB -#include "../gpio/gpiolib.h" -#endif - #include "core.h" #include "devicetree.h" #include "pinconf.h"