From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Linus Walleij <linusw@kernel.org>,
AKASHI Takahiro <akashi.tkhro@gmail.com>,
Bartosz Golaszewski <brgl@kernel.org>,
linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
arm-scmi@vger.kernel.org,
Vincent Guittot <vincent.guittot@linaro.org>,
Khaled Ali Ahmed <Khaled.AliAhmed@arm.com>,
Michal Simek <michal.simek@amd.com>
Subject: Re: [PATCH v4 7/7] gpio: add pinctrl based generic gpio driver
Date: Tue, 17 Mar 2026 17:52:31 +0200 [thread overview]
Message-ID: <abl4v6iuzcGRg_C0@ashevche-desk.local> (raw)
In-Reply-To: <e154f1573e82bb96085cf3a256456fddd3738ce7.1773757772.git.dan.carpenter@linaro.org>
On Tue, Mar 17, 2026 at 05:41:02PM +0300, Dan Carpenter wrote:
> The ARM SCMI pinctrl protocol allows GPIO access. Instead of creating
> a new SCMI gpio driver, this driver is a generic GPIO driver that uses
GPIO
> standard pinctrl interfaces.
...
> +config GPIO_BY_PINCTRL
> + tristate "GPIO support based on a pure pin control backend"
> + depends on GPIOLIB
> + help
> + Select this option to support GPIO devices based solely on pin
> + control. This is used to do GPIO over the ARM SCMI protocol.
This is not enough to understand (as discussion in previous round showed).
Can we have added a Documentation/driver-api/gpio/... (to the existing one
or a new one)?
...
> +// Copyright (C) 2023 Linaro Inc.
2026 (as well)?
...
+ errno.h // -ENOMEM, et cetera
> +#include <linux/gpio/driver.h>
> +#include <linux/list.h>
?! Cargo cult?
+ mod_devicetable.h // of_device_id
> +#include <linux/module.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/platform_device.h>
> +#include <linux/types.h>
+ blank line.
> +#include "gpiolib.h"
...
> +struct pin_control_gpio_priv {
> + struct gpio_chip chip;
> +};
Unneeded, you can use struct gpio_chip directly. No?
...
> +static int pin_control_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
> +{
> + unsigned long config;
> + bool in, out;
> + int ret;
> +
> + config = PIN_CONFIG_INPUT_ENABLE;
> + ret = pinctrl_gpio_get_config(gc, offset, &config);
> + if (ret)
> + return ret;
> + in = config;
> +
> + config = PIN_CONFIG_OUTPUT_ENABLE;
> + ret = pinctrl_gpio_get_config(gc, offset, &config);
> + if (ret)
> + return ret;
> + out = config;
> + /* Consistency check - in theory both can be enabled! */
> + if (in && !out)
> + return GPIO_LINE_DIRECTION_IN;
> + if (!in && out)
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return -EINVAL;
When both are enabled it's out direction, so the entire piece
can be simplified to
if (out)
return GPIO_LINE_DIRECTION_OUT;
if (in)
return GPIO_LINE_DIRECTION_IN;
return ...something...; ideally it should be HiZ.
So, even more simplified will be just
if (out)
return GPIO_LINE_DIRECTION_OUT;
else
return GPIO_LINE_DIRECTION_IN;
> +}
...
> + ret = devm_gpiochip_add_data(dev, chip, priv);
> + if (ret)
> + return ret;
> +
> + platform_set_drvdata(pdev, priv);
Not used.
> + return 0;
Hence, the entire piece is just
return devm_gpiochip_add_data(dev, chip, priv);
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-03-17 15:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 14:40 [PATCH v4 0/7] " Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 1/7] pinctrl: introduce pinctrl_gpio_get_config() Dan Carpenter
2026-03-17 15:40 ` Andy Shevchenko
2026-03-17 14:40 ` [PATCH v4 2/7] pinctrl: scmi: Add SCMI_PIN_INPUT_VALUE Dan Carpenter
2026-03-17 15:38 ` Andy Shevchenko
2026-03-18 7:19 ` Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 3/7] pinctrl: Delete PIN_CONFIG_OUTPUT_IMPEDANCE_OHMS support Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 4/7] pinctrl-scmi: ignore PIN_CONFIG_PERSIST_STATE Dan Carpenter
2026-03-17 14:40 ` [PATCH v4 5/7] arm_scmi: pinctrl: allow PINCTRL_REQUEST to return EOPNOTSUPP Dan Carpenter
2026-03-18 11:07 ` Cristian Marussi
2026-03-17 14:40 ` [PATCH v4 6/7] dt-bindings: gpio: Add bindings for pinctrl based generic gpio driver Dan Carpenter
2026-03-18 7:14 ` Krzysztof Kozlowski
2026-03-17 14:41 ` [PATCH v4 7/7] gpio: add " Dan Carpenter
2026-03-17 15:52 ` Andy Shevchenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=abl4v6iuzcGRg_C0@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Khaled.AliAhmed@arm.com \
--cc=akashi.tkhro@gmail.com \
--cc=arm-scmi@vger.kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®