Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpiolib: Replace gpio_suffix_count with NULL-terminated array

There is no need to have and export the count variable for the array
in question. Instead, make it NULL-terminated.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240819142945.327808-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Andy Shevchenko and committed by
Bartosz Golaszewski
4b91188d a975a646

+6 -8
+1 -2
drivers/gpio/gpiolib.c
··· 90 90 static DEFINE_MUTEX(gpio_machine_hogs_mutex); 91 91 static LIST_HEAD(gpio_machine_hogs); 92 92 93 - const char *const gpio_suffixes[] = { "gpios", "gpio" }; 94 - const size_t gpio_suffix_count = ARRAY_SIZE(gpio_suffixes); 93 + const char *const gpio_suffixes[] = { "gpios", "gpio", NULL }; 95 94 96 95 static void gpiochip_free_hogs(struct gpio_chip *gc); 97 96 static int gpiochip_add_irqchip(struct gpio_chip *gc,
+5 -6
drivers/gpio/gpiolib.h
··· 89 89 return container_of(dev, struct gpio_device, dev); 90 90 } 91 91 92 - /* gpio suffixes used for ACPI and device tree lookup */ 92 + /* GPIO suffixes used for ACPI and device tree lookup */ 93 93 extern const char *const gpio_suffixes[]; 94 - extern const size_t gpio_suffix_count; 95 94 96 95 #define for_each_gpio_property_name(propname, con_id) \ 97 - for (unsigned int __i = 0; \ 98 - __i < gpio_suffix_count && ({ \ 99 - const char *__gs = gpio_suffixes[__i]; \ 96 + for (const char * const *__suffixes = gpio_suffixes; \ 97 + *__suffixes && ({ \ 98 + const char *__gs = *__suffixes; \ 100 99 \ 101 100 if (con_id) \ 102 101 snprintf(propname, sizeof(propname), "%s-%s", con_id, __gs); \ ··· 103 104 snprintf(propname, sizeof(propname), "%s", __gs); \ 104 105 1; \ 105 106 }); \ 106 - __i++) 107 + __suffixes++) 107 108 108 109 /** 109 110 * struct gpio_array - Opaque descriptor for a structure of GPIO array attributes