Commit 4b91188d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240819142945.327808-6-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent a975a646
...@@ -90,8 +90,7 @@ DEFINE_STATIC_SRCU(gpio_devices_srcu); ...@@ -90,8 +90,7 @@ DEFINE_STATIC_SRCU(gpio_devices_srcu);
static DEFINE_MUTEX(gpio_machine_hogs_mutex); static DEFINE_MUTEX(gpio_machine_hogs_mutex);
static LIST_HEAD(gpio_machine_hogs); static LIST_HEAD(gpio_machine_hogs);
const char *const gpio_suffixes[] = { "gpios", "gpio" }; const char *const gpio_suffixes[] = { "gpios", "gpio", NULL };
const size_t gpio_suffix_count = ARRAY_SIZE(gpio_suffixes);
static void gpiochip_free_hogs(struct gpio_chip *gc); static void gpiochip_free_hogs(struct gpio_chip *gc);
static int gpiochip_add_irqchip(struct gpio_chip *gc, static int gpiochip_add_irqchip(struct gpio_chip *gc,
......
...@@ -89,14 +89,13 @@ static inline struct gpio_device *to_gpio_device(struct device *dev) ...@@ -89,14 +89,13 @@ static inline struct gpio_device *to_gpio_device(struct device *dev)
return container_of(dev, struct gpio_device, dev); return container_of(dev, struct gpio_device, dev);
} }
/* gpio suffixes used for ACPI and device tree lookup */ /* GPIO suffixes used for ACPI and device tree lookup */
extern const char *const gpio_suffixes[]; extern const char *const gpio_suffixes[];
extern const size_t gpio_suffix_count;
#define for_each_gpio_property_name(propname, con_id) \ #define for_each_gpio_property_name(propname, con_id) \
for (unsigned int __i = 0; \ for (const char * const *__suffixes = gpio_suffixes; \
__i < gpio_suffix_count && ({ \ *__suffixes && ({ \
const char *__gs = gpio_suffixes[__i]; \ const char *__gs = *__suffixes; \
\ \
if (con_id) \ if (con_id) \
snprintf(propname, sizeof(propname), "%s-%s", con_id, __gs); \ snprintf(propname, sizeof(propname), "%s-%s", con_id, __gs); \
...@@ -104,7 +103,7 @@ extern const size_t gpio_suffix_count; ...@@ -104,7 +103,7 @@ extern const size_t gpio_suffix_count;
snprintf(propname, sizeof(propname), "%s", __gs); \ snprintf(propname, sizeof(propname), "%s", __gs); \
1; \ 1; \
}); \ }); \
__i++) __suffixes++)
/** /**
* struct gpio_array - Opaque descriptor for a structure of GPIO array attributes * struct gpio_array - Opaque descriptor for a structure of GPIO array attributes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment