linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 1/4] gpiolib: define gpio suffixes globally
@ 2015-02-11 16:27 Rojhalat Ibrahim
  2015-02-26  9:46 ` Alexandre Courbot
  2015-03-05  8:49 ` Linus Walleij
  0 siblings, 2 replies; 4+ messages in thread
From: Rojhalat Ibrahim @ 2015-02-11 16:27 UTC (permalink / raw)
  To: linux-gpio@vger.kernel.org
  Cc: Alexandre Courbot, Alexandre Courbot, Linus Walleij,
	Mika Westerberg, Rafael J. Wysocki, David Miller, netdev

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>
---
Change log:
  v5: move the global definition to drivers/gpio/gpiolib.h
  v4: no change
  v3: add this change as a separate patch

 drivers/gpio/gpiolib.c | 14 ++++++--------
 drivers/gpio/gpiolib.h |  3 +++
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bf6016d..b71c351 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1657,19 +1657,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 +1689,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 +1696,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);
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index e3a5211..3cbf3dd 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -27,6 +27,9 @@ struct acpi_gpio_info {
 	bool active_low;
 };
 
+/* gpio suffixes used for ACPI and device tree lookup */
+static const char * const gpio_suffixes[] = { "gpios", "gpio" };
+
 #ifdef CONFIG_ACPI
 void acpi_gpiochip_add(struct gpio_chip *chip);
 void acpi_gpiochip_remove(struct gpio_chip *chip);
-- 
2.0.5



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

* Re: [PATCH v5 1/4] gpiolib: define gpio suffixes globally
  2015-02-11 16:27 [PATCH v5 1/4] gpiolib: define gpio suffixes globally Rojhalat Ibrahim
@ 2015-02-26  9:46 ` Alexandre Courbot
  2015-03-05  8:50   ` Linus Walleij
  2015-03-05  8:49 ` Linus Walleij
  1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Courbot @ 2015-02-26  9:46 UTC (permalink / raw)
  To: Linus Walleij, Rojhalat Ibrahim
  Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Mika Westerberg,
	Rafael J. Wysocki, David Miller, netdev

On Thu, Feb 12, 2015 at 1:27 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>

Linus, let's get this good stuff in while it still applies to your tree! :)

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

* Re: [PATCH v5 1/4] gpiolib: define gpio suffixes globally
  2015-02-11 16:27 [PATCH v5 1/4] gpiolib: define gpio suffixes globally Rojhalat Ibrahim
  2015-02-26  9:46 ` Alexandre Courbot
@ 2015-03-05  8:49 ` Linus Walleij
  1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-03-05  8:49 UTC (permalink / raw)
  To: Rojhalat Ibrahim
  Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Alexandre Courbot,
	Mika Westerberg, Rafael J. Wysocki, David Miller,
	netdev@vger.kernel.org

On Wed, Feb 11, 2015 at 5:27 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>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> Change log:
>   v5: move the global definition to drivers/gpio/gpiolib.h
>   v4: no change
>   v3: add this change as a separate patch

Patch applied. This v5 version. Sorry about the other fuzzy message.

Yours,
Linus Walleij

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

* Re: [PATCH v5 1/4] gpiolib: define gpio suffixes globally
  2015-02-26  9:46 ` Alexandre Courbot
@ 2015-03-05  8:50   ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-03-05  8:50 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Rojhalat Ibrahim, linux-gpio@vger.kernel.org, Alexandre Courbot,
	Mika Westerberg, Rafael J. Wysocki, David Miller, netdev

On Thu, Feb 26, 2015 at 10:46 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> On Thu, Feb 12, 2015 at 1:27 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>
>
> Linus, let's get this good stuff in while it still applies to your tree! :)

Yeah it's in... been moving and conferencing and stuff, sorry.

Yours,
Linus Walleij

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-11 16:27 [PATCH v5 1/4] gpiolib: define gpio suffixes globally Rojhalat Ibrahim
2015-02-26  9:46 ` Alexandre Courbot
2015-03-05  8:50   ` Linus Walleij
2015-03-05  8:49 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).