All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/4] gpiolib: define gpio suffixes globally
@ 2015-02-09 17:07 Rojhalat Ibrahim
  2015-02-10  6:18 ` Alexandre Courbot
  2015-03-05  8:47 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Rojhalat Ibrahim @ 2015-02-09 17:07 UTC (permalink / raw)
  To: linux-gpio; +Cc: Alexandre Courbot, Alexandre Courbot, Linus Walleij

Avoid multiple identical definitions of the gpio suffix strings by putting
them into a global constant array.

Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
---
v3: add this change as a separate patch

 drivers/gpio/gpiolib.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bf6016d..ff2b80d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -53,6 +53,9 @@ static DEFINE_MUTEX(gpio_lookup_lock);
 static LIST_HEAD(gpio_lookup_list);
 LIST_HEAD(gpio_chips);
 
+/* gpio suffixes used for ACPI and device tree lookup */
+static const char * const gpio_suffixes[] = { "gpios", "gpio" };
+
 static inline void desc_set_label(struct gpio_desc *d, const char *label)
 {
 	d->label = label;
@@ -1657,19 +1660,18 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id,
 				      unsigned int idx,
 				      enum gpio_lookup_flags *flags)
 {
-	static const char * const suffixes[] = { "gpios", "gpio" };
 	char prop_name[32]; /* 32 is max size of property name */
 	enum of_gpio_flags of_flags;
 	struct gpio_desc *desc;
 	unsigned int i;
 
-	for (i = 0; i < ARRAY_SIZE(suffixes); i++) {
+	for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
 		if (con_id)
 			snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id,
-							       suffixes[i]);
+				 gpio_suffixes[i]);
 		else
 			snprintf(prop_name, sizeof(prop_name), "%s",
-							       suffixes[i]);
+				 gpio_suffixes[i]);
 
 		desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx,
 						&of_flags);
@@ -1690,7 +1692,6 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
 					unsigned int idx,
 					enum gpio_lookup_flags *flags)
 {
-	static const char * const suffixes[] = { "gpios", "gpio" };
 	struct acpi_device *adev = ACPI_COMPANION(dev);
 	struct acpi_gpio_info info;
 	struct gpio_desc *desc;
@@ -1698,13 +1699,13 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id,
 	int i;
 
 	/* Try first from _DSD */
-	for (i = 0; i < ARRAY_SIZE(suffixes); i++) {
+	for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
 		if (con_id && strcmp(con_id, "gpios")) {
 			snprintf(propname, sizeof(propname), "%s-%s",
-				 con_id, suffixes[i]);
+				 con_id, gpio_suffixes[i]);
 		} else {
 			snprintf(propname, sizeof(propname), "%s",
-				 suffixes[i]);
+				 gpio_suffixes[i]);
 		}
 
 		desc = acpi_get_gpiod_by_index(adev, propname, idx, &info);
-- 
2.0.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/4] gpiolib: define gpio suffixes globally
  2015-02-09 17:07 [PATCH v3 1/4] gpiolib: define gpio suffixes globally Rojhalat Ibrahim
@ 2015-02-10  6:18 ` Alexandre Courbot
  2015-03-05  8:47 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2015-02-10  6:18 UTC (permalink / raw)
  To: Rojhalat Ibrahim; +Cc: linux-gpio, Alexandre Courbot, Linus Walleij

On Tue, Feb 10, 2015 at 2:07 AM, Rojhalat Ibrahim <imr@rtschenk.de> wrote:
> Avoid multiple identical definitions of the gpio suffix strings by putting
> them into a global constant array.
>
> Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3 1/4] gpiolib: define gpio suffixes globally
  2015-02-09 17:07 [PATCH v3 1/4] gpiolib: define gpio suffixes globally Rojhalat Ibrahim
  2015-02-10  6:18 ` Alexandre Courbot
@ 2015-03-05  8:47 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-03-05  8:47 UTC (permalink / raw)
  To: Rojhalat Ibrahim; +Cc: linux-gpio, Alexandre Courbot, Alexandre Courbot

On Mon, Feb 9, 2015 at 6:07 PM, Rojhalat Ibrahim <imr@rtschenk.de> wrote:

> Avoid multiple identical definitions of the gpio suffix strings by putting
> them into a global constant array.
>
> Signed-off-by: Rojhalat Ibrahim <imr@rtschenk.de>
> ---
> v3: add this change as a separate patch

Patch applied, now I'm not even a month behind on my mail, yay.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-05  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-09 17:07 [PATCH v3 1/4] gpiolib: define gpio suffixes globally Rojhalat Ibrahim
2015-02-10  6:18 ` Alexandre Courbot
2015-03-05  8:47 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.