* [RFC PATCH v2] gpio: sysfs: make the sysfs export behavior consistent
@ 2024-09-30 8:30 Bartosz Golaszewski
2024-10-02 14:31 ` Bartosz Golaszewski
0 siblings, 1 reply; 2+ messages in thread
From: Bartosz Golaszewski @ 2024-09-30 8:30 UTC (permalink / raw)
To: Linus Walleij, Kent Gibson; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
For drivers or board files that set gpio_chip->names, the links to the
GPIO attribute group created on sysfs export will be named after the
line's name set in that array. For lines that are named using device
properties, the names pointer of the gpio_chip struct is never assigned
so they are exported as if they're not named.
The ABI documentation does not mention the former behavior and given
that the majority of modern systems use device-tree, ACPI or other way
of passing GPIO names using device properties - bypassing gc->names -
it's better to make the behavior consistent by always exporting lines as
"gpioXYZ".
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
v1 -> v2:
- remove the no longer needed ioname variable
drivers/gpio/gpiolib-sysfs.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 17ed229412af..20426d6e04d5 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -573,11 +573,10 @@ static struct class gpio_class = {
*/
int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
{
- const char *ioname = NULL;
struct gpio_device *gdev;
struct gpiod_data *data;
struct device *dev;
- int status, offset;
+ int status;
/* can't export until sysfs is available ... */
if (!class_is_registered(&gpio_class)) {
@@ -626,14 +625,9 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
else
data->direction_can_change = false;
- offset = gpio_chip_hwgpio(desc);
- if (guard.gc->names && guard.gc->names[offset])
- ioname = guard.gc->names[offset];
-
dev = device_create_with_groups(&gpio_class, &gdev->dev,
MKDEV(0, 0), data, gpio_groups,
- ioname ? ioname : "gpio%u",
- desc_to_gpio(desc));
+ "gpio%u", desc_to_gpio(desc));
if (IS_ERR(dev)) {
status = PTR_ERR(dev);
goto err_free_data;
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFC PATCH v2] gpio: sysfs: make the sysfs export behavior consistent
2024-09-30 8:30 [RFC PATCH v2] gpio: sysfs: make the sysfs export behavior consistent Bartosz Golaszewski
@ 2024-10-02 14:31 ` Bartosz Golaszewski
0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2024-10-02 14:31 UTC (permalink / raw)
To: Linus Walleij, Kent Gibson, Bartosz Golaszewski
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
On Mon, 30 Sep 2024 10:30:29 +0200, Bartosz Golaszewski wrote:
> For drivers or board files that set gpio_chip->names, the links to the
> GPIO attribute group created on sysfs export will be named after the
> line's name set in that array. For lines that are named using device
> properties, the names pointer of the gpio_chip struct is never assigned
> so they are exported as if they're not named.
>
> The ABI documentation does not mention the former behavior and given
> that the majority of modern systems use device-tree, ACPI or other way
> of passing GPIO names using device properties - bypassing gc->names -
> it's better to make the behavior consistent by always exporting lines as
> "gpioXYZ".
>
> [...]
Applied, thanks!
[1/1] gpio: sysfs: make the sysfs export behavior consistent
commit: 700cdf7ed00f0cf20fdcef33d56e862768eb1008
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-02 14:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-30 8:30 [RFC PATCH v2] gpio: sysfs: make the sysfs export behavior consistent Bartosz Golaszewski
2024-10-02 14:31 ` Bartosz Golaszewski
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®