Skip to content

Commit 32fc5aa

Browse files
committed
gpiolib: unexport devprop_gpiochip_set_names()
Now that devprop_gpiochip_set_names() is only used in a single place inside drivers/gpio/gpiolib.c, there's no need anymore for it to be exported or to even live in its own source file. Pull this function into the core source file for gpiolib. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
1 parent 7cba1a4 commit 32fc5aa

4 files changed

Lines changed: 47 additions & 66 deletions

File tree

‎drivers/gpio/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ccflags-$(CONFIG_DEBUG_GPIO) += -DDEBUG
66
obj-$(CONFIG_GPIOLIB) += gpiolib.o
77
obj-$(CONFIG_GPIOLIB) += gpiolib-devres.o
88
obj-$(CONFIG_GPIOLIB) += gpiolib-legacy.o
9-
obj-$(CONFIG_GPIOLIB) += gpiolib-devprop.o
109
obj-$(CONFIG_GPIOLIB) += gpiolib-cdev.o
1110
obj-$(CONFIG_OF_GPIO) += gpiolib-of.o
1211
obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o

‎drivers/gpio/gpiolib-devprop.c‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎drivers/gpio/gpiolib.c‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,53 @@ static int gpiochip_set_desc_names(struct gpio_chip *gc)
358358
return 0;
359359
}
360360

361+
/*
362+
* devprop_gpiochip_set_names - Set GPIO line names using device properties
363+
* @chip: GPIO chip whose lines should be named, if possible
364+
*
365+
* Looks for device property "gpio-line-names" and if it exists assigns
366+
* GPIO line names for the chip. The memory allocated for the assigned
367+
* names belong to the underlying software node and should not be released
368+
* by the caller.
369+
*/
370+
static int devprop_gpiochip_set_names(struct gpio_chip *chip)
371+
{
372+
struct gpio_device *gdev = chip->gpiodev;
373+
struct device *dev = chip->parent;
374+
const char **names;
375+
int ret, i;
376+
int count;
377+
378+
count = device_property_string_array_count(dev, "gpio-line-names");
379+
if (count < 0)
380+
return 0;
381+
382+
if (count > gdev->ngpio) {
383+
dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d",
384+
count, gdev->ngpio);
385+
count = gdev->ngpio;
386+
}
387+
388+
names = kcalloc(count, sizeof(*names), GFP_KERNEL);
389+
if (!names)
390+
return -ENOMEM;
391+
392+
ret = device_property_read_string_array(dev, "gpio-line-names",
393+
names, count);
394+
if (ret < 0) {
395+
dev_warn(&gdev->dev, "failed to read GPIO line names\n");
396+
kfree(names);
397+
return ret;
398+
}
399+
400+
for (i = 0; i < count; i++)
401+
gdev->descs[i].name = names[i];
402+
403+
kfree(names);
404+
405+
return 0;
406+
}
407+
361408
static unsigned long *gpiochip_allocate_mask(struct gpio_chip *gc)
362409
{
363410
unsigned long *p;

‎include/linux/gpio/driver.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,6 @@ struct gpio_desc *gpiochip_request_own_desc(struct gpio_chip *gc,
756756
enum gpiod_flags dflags);
757757
void gpiochip_free_own_desc(struct gpio_desc *desc);
758758

759-
int devprop_gpiochip_set_names(struct gpio_chip *gc);
760-
761759
#ifdef CONFIG_GPIOLIB
762760

763761
/* lock/unlock as IRQ */

0 commit comments

Comments
 (0)