diff options
author | Alexander Stein <alexander.stein@systec-electronic.com> | 2017-01-12 11:39:24 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-26 03:59:52 -0500 |
commit | b2987d7438e0ca949d81774ca8b43d370a1f9947 (patch) | |
tree | 21fb2c0cfb36fed138bc1660e0de75cb017c9b13 | |
parent | a264d10ff45c688293d9112fddd8d29c819e0853 (diff) |
gpio: Pass GPIO label down to gpiod_request
Currently all users of fwnode_get_named_gpiod() have no way to
specify a label for the GPIO. So GPIOs listed in debugfs are shown
with label "?". With this change a proper label is used.
Also adjust all users so they can pass a label, properly retrieved
from device tree properties.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/devres.c | 5 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 5 | ||||
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 3 | ||||
-rw-r--r-- | drivers/input/keyboard/gpio_keys_polled.c | 3 | ||||
-rw-r--r-- | drivers/leds/leds-gpio.c | 13 | ||||
-rw-r--r-- | drivers/video/fbdev/amba-clcd-nomadik.c | 12 | ||||
-rw-r--r-- | include/linux/gpio/consumer.h | 12 |
7 files changed, 33 insertions, 20 deletions
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c index 5e0b41b5e554..89969e887e5d 100644 --- a/drivers/gpio/devres.c +++ b/drivers/gpio/devres.c | |||
@@ -138,7 +138,8 @@ EXPORT_SYMBOL(devm_gpiod_get_index); | |||
138 | struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, | 138 | struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, |
139 | const char *con_id, | 139 | const char *con_id, |
140 | struct fwnode_handle *child, | 140 | struct fwnode_handle *child, |
141 | enum gpiod_flags flags) | 141 | enum gpiod_flags flags, |
142 | const char *label) | ||
142 | { | 143 | { |
143 | static const char * const suffixes[] = { "gpios", "gpio" }; | 144 | static const char * const suffixes[] = { "gpios", "gpio" }; |
144 | char prop_name[32]; /* 32 is max size of property name */ | 145 | char prop_name[32]; /* 32 is max size of property name */ |
@@ -159,7 +160,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, | |||
159 | snprintf(prop_name, sizeof(prop_name), "%s", | 160 | snprintf(prop_name, sizeof(prop_name), "%s", |
160 | suffixes[i]); | 161 | suffixes[i]); |
161 | 162 | ||
162 | desc = fwnode_get_named_gpiod(child, prop_name, flags); | 163 | desc = fwnode_get_named_gpiod(child, prop_name, flags, label); |
163 | if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) | 164 | if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) |
164 | break; | 165 | break; |
165 | } | 166 | } |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index bb3d3a7edc45..20c6c51cbe10 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -3325,7 +3325,8 @@ EXPORT_SYMBOL_GPL(gpiod_get_index); | |||
3325 | */ | 3325 | */ |
3326 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | 3326 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, |
3327 | const char *propname, | 3327 | const char *propname, |
3328 | enum gpiod_flags dflags) | 3328 | enum gpiod_flags dflags, |
3329 | const char *label) | ||
3329 | { | 3330 | { |
3330 | struct gpio_desc *desc = ERR_PTR(-ENODEV); | 3331 | struct gpio_desc *desc = ERR_PTR(-ENODEV); |
3331 | unsigned long lflags = 0; | 3332 | unsigned long lflags = 0; |
@@ -3356,7 +3357,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | |||
3356 | if (IS_ERR(desc)) | 3357 | if (IS_ERR(desc)) |
3357 | return desc; | 3358 | return desc; |
3358 | 3359 | ||
3359 | ret = gpiod_request(desc, NULL); | 3360 | ret = gpiod_request(desc, label); |
3360 | if (ret) | 3361 | if (ret) |
3361 | return ERR_PTR(ret); | 3362 | return ERR_PTR(ret); |
3362 | 3363 | ||
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 9de4b876100a..2ec74d90ef78 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -481,7 +481,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev, | |||
481 | spin_lock_init(&bdata->lock); | 481 | spin_lock_init(&bdata->lock); |
482 | 482 | ||
483 | if (child) { | 483 | if (child) { |
484 | bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, child, GPIOD_IN); | 484 | bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, child, |
485 | GPIOD_IN, desc); | ||
485 | if (IS_ERR(bdata->gpiod)) { | 486 | if (IS_ERR(bdata->gpiod)) { |
486 | error = PTR_ERR(bdata->gpiod); | 487 | error = PTR_ERR(bdata->gpiod); |
487 | if (error == -ENOENT) { | 488 | if (error == -ENOENT) { |
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c index fd7ab4dad87b..5e35c565e341 100644 --- a/drivers/input/keyboard/gpio_keys_polled.c +++ b/drivers/input/keyboard/gpio_keys_polled.c | |||
@@ -305,7 +305,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev) | |||
305 | 305 | ||
306 | bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, | 306 | bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, |
307 | child, | 307 | child, |
308 | GPIOD_IN); | 308 | GPIOD_IN, |
309 | button->desc); | ||
309 | if (IS_ERR(bdata->gpiod)) { | 310 | if (IS_ERR(bdata->gpiod)) { |
310 | error = PTR_ERR(bdata->gpiod); | 311 | error = PTR_ERR(bdata->gpiod); |
311 | if (error != -EPROBE_DEFER) | 312 | if (error != -EPROBE_DEFER) |
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 00cc671cddcc..6c4825d96693 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c | |||
@@ -174,12 +174,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) | |||
174 | const char *state = NULL; | 174 | const char *state = NULL; |
175 | struct device_node *np = to_of_node(child); | 175 | struct device_node *np = to_of_node(child); |
176 | 176 | ||
177 | led.gpiod = devm_get_gpiod_from_child(dev, NULL, child, GPIOD_ASIS); | ||
178 | if (IS_ERR(led.gpiod)) { | ||
179 | fwnode_handle_put(child); | ||
180 | return ERR_CAST(led.gpiod); | ||
181 | } | ||
182 | |||
183 | ret = fwnode_property_read_string(child, "label", &led.name); | 177 | ret = fwnode_property_read_string(child, "label", &led.name); |
184 | if (ret && IS_ENABLED(CONFIG_OF) && np) | 178 | if (ret && IS_ENABLED(CONFIG_OF) && np) |
185 | led.name = np->name; | 179 | led.name = np->name; |
@@ -188,6 +182,13 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) | |||
188 | return ERR_PTR(-EINVAL); | 182 | return ERR_PTR(-EINVAL); |
189 | } | 183 | } |
190 | 184 | ||
185 | led.gpiod = devm_get_gpiod_from_child(dev, NULL, child, | ||
186 | GPIOD_ASIS, led.name); | ||
187 | if (IS_ERR(led.gpiod)) { | ||
188 | fwnode_handle_put(child); | ||
189 | return ERR_CAST(led.gpiod); | ||
190 | } | ||
191 | |||
191 | fwnode_property_read_string(child, "linux,default-trigger", | 192 | fwnode_property_read_string(child, "linux,default-trigger", |
192 | &led.default_trigger); | 193 | &led.default_trigger); |
193 | 194 | ||
diff --git a/drivers/video/fbdev/amba-clcd-nomadik.c b/drivers/video/fbdev/amba-clcd-nomadik.c index 2e800d70b0e5..9175ad9034e1 100644 --- a/drivers/video/fbdev/amba-clcd-nomadik.c +++ b/drivers/video/fbdev/amba-clcd-nomadik.c | |||
@@ -185,22 +185,26 @@ static void tpg110_init(struct device *dev, struct device_node *np, | |||
185 | dev_info(dev, "TPG110 display init\n"); | 185 | dev_info(dev, "TPG110 display init\n"); |
186 | 186 | ||
187 | /* This asserts the GRESTB signal, putting the display into reset */ | 187 | /* This asserts the GRESTB signal, putting the display into reset */ |
188 | grestb = devm_get_gpiod_from_child(dev, "grestb", &np->fwnode, GPIOD_OUT_HIGH); | 188 | grestb = devm_get_gpiod_from_child(dev, "grestb", &np->fwnode, |
189 | GPIOD_OUT_HIGH, "grestb"); | ||
189 | if (IS_ERR(grestb)) { | 190 | if (IS_ERR(grestb)) { |
190 | dev_err(dev, "no GRESTB GPIO\n"); | 191 | dev_err(dev, "no GRESTB GPIO\n"); |
191 | return; | 192 | return; |
192 | } | 193 | } |
193 | scen = devm_get_gpiod_from_child(dev, "scen", &np->fwnode, GPIOD_OUT_LOW); | 194 | scen = devm_get_gpiod_from_child(dev, "scen", &np->fwnode, |
195 | GPIOD_OUT_LOW, "scen"); | ||
194 | if (IS_ERR(scen)) { | 196 | if (IS_ERR(scen)) { |
195 | dev_err(dev, "no SCEN GPIO\n"); | 197 | dev_err(dev, "no SCEN GPIO\n"); |
196 | return; | 198 | return; |
197 | } | 199 | } |
198 | scl = devm_get_gpiod_from_child(dev, "scl", &np->fwnode, GPIOD_OUT_LOW); | 200 | scl = devm_get_gpiod_from_child(dev, "scl", &np->fwnode, GPIOD_OUT_LOW, |
201 | "scl"); | ||
199 | if (IS_ERR(scl)) { | 202 | if (IS_ERR(scl)) { |
200 | dev_err(dev, "no SCL GPIO\n"); | 203 | dev_err(dev, "no SCL GPIO\n"); |
201 | return; | 204 | return; |
202 | } | 205 | } |
203 | sda = devm_get_gpiod_from_child(dev, "sda", &np->fwnode, GPIOD_OUT_LOW); | 206 | sda = devm_get_gpiod_from_child(dev, "sda", &np->fwnode, GPIOD_OUT_LOW, |
207 | "sda"); | ||
204 | if (IS_ERR(sda)) { | 208 | if (IS_ERR(sda)) { |
205 | dev_err(dev, "no SDA GPIO\n"); | 209 | dev_err(dev, "no SDA GPIO\n"); |
206 | return; | 210 | return; |
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 930d10049d8d..80bad7ebde04 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h | |||
@@ -136,11 +136,13 @@ struct fwnode_handle; | |||
136 | 136 | ||
137 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | 137 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, |
138 | const char *propname, | 138 | const char *propname, |
139 | enum gpiod_flags dflags); | 139 | enum gpiod_flags dflags, |
140 | const char *label); | ||
140 | struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, | 141 | struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, |
141 | const char *con_id, | 142 | const char *con_id, |
142 | struct fwnode_handle *child, | 143 | struct fwnode_handle *child, |
143 | enum gpiod_flags flags); | 144 | enum gpiod_flags flags, |
145 | const char *label); | ||
144 | #else /* CONFIG_GPIOLIB */ | 146 | #else /* CONFIG_GPIOLIB */ |
145 | 147 | ||
146 | static inline int gpiod_count(struct device *dev, const char *con_id) | 148 | static inline int gpiod_count(struct device *dev, const char *con_id) |
@@ -416,7 +418,8 @@ struct fwnode_handle; | |||
416 | static inline | 418 | static inline |
417 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, | 419 | struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, |
418 | const char *propname, | 420 | const char *propname, |
419 | enum gpiod_flags dflags) | 421 | enum gpiod_flags dflags, |
422 | const char *label) | ||
420 | { | 423 | { |
421 | return ERR_PTR(-ENOSYS); | 424 | return ERR_PTR(-ENOSYS); |
422 | } | 425 | } |
@@ -425,7 +428,8 @@ static inline | |||
425 | struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, | 428 | struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, |
426 | const char *con_id, | 429 | const char *con_id, |
427 | struct fwnode_handle *child, | 430 | struct fwnode_handle *child, |
428 | enum gpiod_flags flags) | 431 | enum gpiod_flags flags, |
432 | const char *label) | ||
429 | { | 433 | { |
430 | return ERR_PTR(-ENOSYS); | 434 | return ERR_PTR(-ENOSYS); |
431 | } | 435 | } |