diff options
author | Rojhalat Ibrahim <imr@rtschenk.de> | 2015-02-11 11:27:55 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-03-05 03:48:51 -0500 |
commit | 7f2e553a7173b485db41a52060f91fb8e5ab1c69 (patch) | |
tree | ac11c7536c8873103a67560fe2321e224675fd2b | |
parent | 1feb57a245a4910b03202a814ffc51a900bd4aca (diff) |
gpiolib: define gpio suffixes globally
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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpiolib.c | 14 | ||||
-rw-r--r-- | 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 15837263dbb3..2f8296c021e5 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -1662,19 +1662,18 @@ static struct gpio_desc *of_find_gpio(struct device *dev, const char *con_id, | |||
1662 | unsigned int idx, | 1662 | unsigned int idx, |
1663 | enum gpio_lookup_flags *flags) | 1663 | enum gpio_lookup_flags *flags) |
1664 | { | 1664 | { |
1665 | static const char * const suffixes[] = { "gpios", "gpio" }; | ||
1666 | char prop_name[32]; /* 32 is max size of property name */ | 1665 | char prop_name[32]; /* 32 is max size of property name */ |
1667 | enum of_gpio_flags of_flags; | 1666 | enum of_gpio_flags of_flags; |
1668 | struct gpio_desc *desc; | 1667 | struct gpio_desc *desc; |
1669 | unsigned int i; | 1668 | unsigned int i; |
1670 | 1669 | ||
1671 | for (i = 0; i < ARRAY_SIZE(suffixes); i++) { | 1670 | for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { |
1672 | if (con_id) | 1671 | if (con_id) |
1673 | snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id, | 1672 | snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id, |
1674 | suffixes[i]); | 1673 | gpio_suffixes[i]); |
1675 | else | 1674 | else |
1676 | snprintf(prop_name, sizeof(prop_name), "%s", | 1675 | snprintf(prop_name, sizeof(prop_name), "%s", |
1677 | suffixes[i]); | 1676 | gpio_suffixes[i]); |
1678 | 1677 | ||
1679 | desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, | 1678 | desc = of_get_named_gpiod_flags(dev->of_node, prop_name, idx, |
1680 | &of_flags); | 1679 | &of_flags); |
@@ -1695,7 +1694,6 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, | |||
1695 | unsigned int idx, | 1694 | unsigned int idx, |
1696 | enum gpio_lookup_flags *flags) | 1695 | enum gpio_lookup_flags *flags) |
1697 | { | 1696 | { |
1698 | static const char * const suffixes[] = { "gpios", "gpio" }; | ||
1699 | struct acpi_device *adev = ACPI_COMPANION(dev); | 1697 | struct acpi_device *adev = ACPI_COMPANION(dev); |
1700 | struct acpi_gpio_info info; | 1698 | struct acpi_gpio_info info; |
1701 | struct gpio_desc *desc; | 1699 | struct gpio_desc *desc; |
@@ -1703,13 +1701,13 @@ static struct gpio_desc *acpi_find_gpio(struct device *dev, const char *con_id, | |||
1703 | int i; | 1701 | int i; |
1704 | 1702 | ||
1705 | /* Try first from _DSD */ | 1703 | /* Try first from _DSD */ |
1706 | for (i = 0; i < ARRAY_SIZE(suffixes); i++) { | 1704 | for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { |
1707 | if (con_id && strcmp(con_id, "gpios")) { | 1705 | if (con_id && strcmp(con_id, "gpios")) { |
1708 | snprintf(propname, sizeof(propname), "%s-%s", | 1706 | snprintf(propname, sizeof(propname), "%s-%s", |
1709 | con_id, suffixes[i]); | 1707 | con_id, gpio_suffixes[i]); |
1710 | } else { | 1708 | } else { |
1711 | snprintf(propname, sizeof(propname), "%s", | 1709 | snprintf(propname, sizeof(propname), "%s", |
1712 | suffixes[i]); | 1710 | gpio_suffixes[i]); |
1713 | } | 1711 | } |
1714 | 1712 | ||
1715 | desc = acpi_get_gpiod_by_index(adev, propname, idx, &info); | 1713 | desc = acpi_get_gpiod_by_index(adev, propname, idx, &info); |
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index cadba26c45a6..205dd12659c0 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h | |||
@@ -27,6 +27,9 @@ struct acpi_gpio_info { | |||
27 | bool active_low; | 27 | bool active_low; |
28 | }; | 28 | }; |
29 | 29 | ||
30 | /* gpio suffixes used for ACPI and device tree lookup */ | ||
31 | static const char * const gpio_suffixes[] = { "gpios", "gpio" }; | ||
32 | |||
30 | #ifdef CONFIG_ACPI | 33 | #ifdef CONFIG_ACPI |
31 | void acpi_gpiochip_add(struct gpio_chip *chip); | 34 | void acpi_gpiochip_add(struct gpio_chip *chip); |
32 | void acpi_gpiochip_remove(struct gpio_chip *chip); | 35 | void acpi_gpiochip_remove(struct gpio_chip *chip); |