Skip to content

Commit 661e4b1

Browse files
peda-rfourmone
authored andcommitted
gpiolib: allow line names from device props to override driver names
Some GPIO providers set names for GPIO lines that match the names of the pins on the SoC, or variations on that theme. These names are generic more often that not, such as pioC12 in the at91 case. These generic names block the possibility to set more useful GPIO line names with device properties (i.e. gpio-line-names). Allow overriding a generic name given by the GPIO driver if there is a name given to the GPIO line using device properties, but leave the generic name alone if no better name is available. However, there is a risk. If user space is depending on the above mentioned fixed GPIO names, AND there are device properties that previously did not reach the surface, the name change might cause regressions. But hopefully this stays below the radar... Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Tested-by: Alexander Dahl <ada@thorsis.com> Signed-off-by: Peter Rosin <peda@axentia.se> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Valentin Caron <valentin.caron@foss.st.com> Change-Id: I26f7f2e1dcc49a7496da0d36ee526a4594189890 Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/271951 Reviewed-by: CITOOLS <MDG-smet-aci-reviews@list.st.com> Reviewed-by: CIBUILD <MDG-smet-aci-builds@list.st.com> Reviewed-by: Amelie DELAUNAY <amelie.delaunay@foss.st.com> Reviewed-by: Antonio Maria BORNEO <antonio.borneo@st.com> Reviewed-by: Eric FOURMONT <eric.fourmont-ext@st.com> Domain-Review: Amelie DELAUNAY <amelie.delaunay@foss.st.com>
1 parent 8a71c8c commit 661e4b1

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,16 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
422422
if (count > chip->ngpio)
423423
count = chip->ngpio;
424424

425-
for (i = 0; i < count; i++)
426-
gdev->descs[i].name = names[chip->offset + i];
425+
for (i = 0; i < count; i++) {
426+
/*
427+
* Allow overriding "fixed" names provided by the GPIO
428+
* provider. The "fixed" names are more often than not
429+
* generic and less informative than the names given in
430+
* device properties.
431+
*/
432+
if (names[chip->offset + i] && names[chip->offset + i][0])
433+
gdev->descs[i].name = names[chip->offset + i];
434+
}
427435

428436
kfree(names);
429437

@@ -708,10 +716,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
708716
INIT_LIST_HEAD(&gdev->pin_ranges);
709717
#endif
710718

711-
if (gc->names)
719+
if (gc->names) {
712720
ret = gpiochip_set_desc_names(gc);
713-
else
714-
ret = devprop_gpiochip_set_names(gc);
721+
if (ret)
722+
goto err_remove_from_list;
723+
}
724+
ret = devprop_gpiochip_set_names(gc);
715725
if (ret)
716726
goto err_remove_from_list;
717727

0 commit comments

Comments
 (0)