aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2017-02-05 17:14:23 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-02-05 17:14:23 -0500
commite4df1ebdfeb4c68523046667b2d8ef8ab20ae066 (patch)
tree9a518146b64289e304412279b59466fad3799ed6
parente8e1a5b5679b1ae1ff03a3883b011b84e7226171 (diff)
parent537b94dafce29af6a3e923d216472cfc2f3659af (diff)
Merge branch 'ib-gpiod-flags' into devel
-rw-r--r--drivers/gpio/devres.c19
-rw-r--r--drivers/gpio/gpiolib.c9
-rw-r--r--drivers/input/keyboard/gpio_keys.c6
-rw-r--r--drivers/input/keyboard/gpio_keys_polled.c8
-rw-r--r--drivers/leds/leds-gpio.c5
-rw-r--r--drivers/video/fbdev/amba-clcd-nomadik.c16
-rw-r--r--include/linux/gpio/consumer.h35
7 files changed, 58 insertions, 40 deletions
diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
index d196be7ac352..7031eea165c9 100644
--- a/drivers/gpio/devres.c
+++ b/drivers/gpio/devres.c
@@ -125,9 +125,11 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
125EXPORT_SYMBOL(devm_gpiod_get_index); 125EXPORT_SYMBOL(devm_gpiod_get_index);
126 126
127/** 127/**
128 * devm_get_gpiod_from_child - get a GPIO descriptor from a device's child node 128 * devm_fwnode_get_index_gpiod_from_child - get a GPIO descriptor from a
129 * device's child node
129 * @dev: GPIO consumer 130 * @dev: GPIO consumer
130 * @con_id: function within the GPIO consumer 131 * @con_id: function within the GPIO consumer
132 * @index: index of the GPIO to obtain in the consumer
131 * @child: firmware node (child of @dev) 133 * @child: firmware node (child of @dev)
132 * @flags: GPIO initialization flags 134 * @flags: GPIO initialization flags
133 * 135 *
@@ -137,11 +139,11 @@ EXPORT_SYMBOL(devm_gpiod_get_index);
137 * On successfull request the GPIO pin is configured in accordance with 139 * On successfull request the GPIO pin is configured in accordance with
138 * provided @flags. 140 * provided @flags.
139 */ 141 */
140struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, 142struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
141 const char *con_id, 143 const char *con_id, int index,
142 struct fwnode_handle *child, 144 struct fwnode_handle *child,
143 enum gpiod_flags flags, 145 enum gpiod_flags flags,
144 const char *label) 146 const char *label)
145{ 147{
146 char prop_name[32]; /* 32 is max size of property name */ 148 char prop_name[32]; /* 32 is max size of property name */
147 struct gpio_desc **dr; 149 struct gpio_desc **dr;
@@ -161,7 +163,8 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
161 snprintf(prop_name, sizeof(prop_name), "%s", 163 snprintf(prop_name, sizeof(prop_name), "%s",
162 gpio_suffixes[i]); 164 gpio_suffixes[i]);
163 165
164 desc = fwnode_get_named_gpiod(child, prop_name, flags, label); 166 desc = fwnode_get_named_gpiod(child, prop_name, index, flags,
167 label);
165 if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT)) 168 if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
166 break; 169 break;
167 } 170 }
@@ -175,7 +178,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
175 178
176 return desc; 179 return desc;
177} 180}
178EXPORT_SYMBOL(devm_get_gpiod_from_child); 181EXPORT_SYMBOL(devm_fwnode_get_index_gpiod_from_child);
179 182
180/** 183/**
181 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional() 184 * devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 385df5241e5d..19fce24ea4a0 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3316,6 +3316,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
3316 * fwnode_get_named_gpiod - obtain a GPIO from firmware node 3316 * fwnode_get_named_gpiod - obtain a GPIO from firmware node
3317 * @fwnode: handle of the firmware node 3317 * @fwnode: handle of the firmware node
3318 * @propname: name of the firmware property representing the GPIO 3318 * @propname: name of the firmware property representing the GPIO
3319 * @index: index of the GPIO to obtain in the consumer
3319 * @dflags: GPIO initialization flags 3320 * @dflags: GPIO initialization flags
3320 * 3321 *
3321 * This function can be used for drivers that get their configuration 3322 * This function can be used for drivers that get their configuration
@@ -3331,7 +3332,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
3331 * In case of error an ERR_PTR() is returned. 3332 * In case of error an ERR_PTR() is returned.
3332 */ 3333 */
3333struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 3334struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3334 const char *propname, 3335 const char *propname, int index,
3335 enum gpiod_flags dflags, 3336 enum gpiod_flags dflags,
3336 const char *label) 3337 const char *label)
3337{ 3338{
@@ -3347,8 +3348,8 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3347 if (is_of_node(fwnode)) { 3348 if (is_of_node(fwnode)) {
3348 enum of_gpio_flags flags; 3349 enum of_gpio_flags flags;
3349 3350
3350 desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname, 0, 3351 desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname,
3351 &flags); 3352 index, &flags);
3352 if (!IS_ERR(desc)) { 3353 if (!IS_ERR(desc)) {
3353 active_low = flags & OF_GPIO_ACTIVE_LOW; 3354 active_low = flags & OF_GPIO_ACTIVE_LOW;
3354 single_ended = flags & OF_GPIO_SINGLE_ENDED; 3355 single_ended = flags & OF_GPIO_SINGLE_ENDED;
@@ -3356,7 +3357,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3356 } else if (is_acpi_node(fwnode)) { 3357 } else if (is_acpi_node(fwnode)) {
3357 struct acpi_gpio_info info; 3358 struct acpi_gpio_info info;
3358 3359
3359 desc = acpi_node_get_gpiod(fwnode, propname, 0, &info); 3360 desc = acpi_node_get_gpiod(fwnode, propname, index, &info);
3360 if (!IS_ERR(desc)) 3361 if (!IS_ERR(desc))
3361 active_low = info.polarity == GPIO_ACTIVE_LOW; 3362 active_low = info.polarity == GPIO_ACTIVE_LOW;
3362 } 3363 }
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 2ec74d90ef78..13372782dffe 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -481,8 +481,10 @@ 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, 484 bdata->gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL,
485 GPIOD_IN, desc); 485 child,
486 GPIOD_IN,
487 desc);
486 if (IS_ERR(bdata->gpiod)) { 488 if (IS_ERR(bdata->gpiod)) {
487 error = PTR_ERR(bdata->gpiod); 489 error = PTR_ERR(bdata->gpiod);
488 if (error == -ENOENT) { 490 if (error == -ENOENT) {
diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index 5e35c565e341..b3c8d5e7985c 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -303,10 +303,10 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
303 return -EINVAL; 303 return -EINVAL;
304 } 304 }
305 305
306 bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, 306 bdata->gpiod = devm_fwnode_get_gpiod_from_child(dev,
307 child, 307 NULL, child,
308 GPIOD_IN, 308 GPIOD_IN,
309 button->desc); 309 button->desc);
310 if (IS_ERR(bdata->gpiod)) { 310 if (IS_ERR(bdata->gpiod)) {
311 error = PTR_ERR(bdata->gpiod); 311 error = PTR_ERR(bdata->gpiod);
312 if (error != -EPROBE_DEFER) 312 if (error != -EPROBE_DEFER)
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 6c4825d96693..066fc7590729 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -182,8 +182,9 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
182 return ERR_PTR(-EINVAL); 182 return ERR_PTR(-EINVAL);
183 } 183 }
184 184
185 led.gpiod = devm_get_gpiod_from_child(dev, NULL, child, 185 led.gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, child,
186 GPIOD_ASIS, led.name); 186 GPIOD_ASIS,
187 led.name);
187 if (IS_ERR(led.gpiod)) { 188 if (IS_ERR(led.gpiod)) {
188 fwnode_handle_put(child); 189 fwnode_handle_put(child);
189 return ERR_CAST(led.gpiod); 190 return ERR_CAST(led.gpiod);
diff --git a/drivers/video/fbdev/amba-clcd-nomadik.c b/drivers/video/fbdev/amba-clcd-nomadik.c
index 9175ad9034e1..476ff3f4d466 100644
--- a/drivers/video/fbdev/amba-clcd-nomadik.c
+++ b/drivers/video/fbdev/amba-clcd-nomadik.c
@@ -185,26 +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, 188 grestb = devm_fwnode_get_gpiod_from_child(dev, "grestb", &np->fwnode,
189 GPIOD_OUT_HIGH, "grestb"); 189 GPIOD_OUT_HIGH, "grestb");
190 if (IS_ERR(grestb)) { 190 if (IS_ERR(grestb)) {
191 dev_err(dev, "no GRESTB GPIO\n"); 191 dev_err(dev, "no GRESTB GPIO\n");
192 return; 192 return;
193 } 193 }
194 scen = devm_get_gpiod_from_child(dev, "scen", &np->fwnode, 194 scen = devm_fwnode_get_gpiod_from_child(dev, "scen", &np->fwnode,
195 GPIOD_OUT_LOW, "scen"); 195 GPIOD_OUT_LOW, "scen");
196 if (IS_ERR(scen)) { 196 if (IS_ERR(scen)) {
197 dev_err(dev, "no SCEN GPIO\n"); 197 dev_err(dev, "no SCEN GPIO\n");
198 return; 198 return;
199 } 199 }
200 scl = devm_get_gpiod_from_child(dev, "scl", &np->fwnode, GPIOD_OUT_LOW, 200 scl = devm_fwnode_get_gpiod_from_child(dev, "scl", &np->fwnode,
201 "scl"); 201 GPIOD_OUT_LOW, "scl");
202 if (IS_ERR(scl)) { 202 if (IS_ERR(scl)) {
203 dev_err(dev, "no SCL GPIO\n"); 203 dev_err(dev, "no SCL GPIO\n");
204 return; 204 return;
205 } 205 }
206 sda = devm_get_gpiod_from_child(dev, "sda", &np->fwnode, GPIOD_OUT_LOW, 206 sda = devm_fwnode_get_gpiod_from_child(dev, "sda", &np->fwnode,
207 "sda"); 207 GPIOD_OUT_LOW, "sda");
208 if (IS_ERR(sda)) { 208 if (IS_ERR(sda)) {
209 dev_err(dev, "no SDA GPIO\n"); 209 dev_err(dev, "no SDA GPIO\n");
210 return; 210 return;
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 80bad7ebde04..ea9b01d40017 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -135,14 +135,14 @@ int desc_to_gpio(const struct gpio_desc *desc);
135struct fwnode_handle; 135struct fwnode_handle;
136 136
137struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 137struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
138 const char *propname, 138 const char *propname, int index,
139 enum gpiod_flags dflags, 139 enum gpiod_flags dflags,
140 const char *label); 140 const char *label);
141struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, 141struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
142 const char *con_id, 142 const char *con_id, int index,
143 struct fwnode_handle *child, 143 struct fwnode_handle *child,
144 enum gpiod_flags flags, 144 enum gpiod_flags flags,
145 const char *label); 145 const char *label);
146#else /* CONFIG_GPIOLIB */ 146#else /* CONFIG_GPIOLIB */
147 147
148static inline int gpiod_count(struct device *dev, const char *con_id) 148static inline int gpiod_count(struct device *dev, const char *con_id)
@@ -417,7 +417,7 @@ struct fwnode_handle;
417 417
418static inline 418static inline
419struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode, 419struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
420 const char *propname, 420 const char *propname, int index,
421 enum gpiod_flags dflags, 421 enum gpiod_flags dflags,
422 const char *label) 422 const char *label)
423{ 423{
@@ -425,17 +425,28 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
425} 425}
426 426
427static inline 427static inline
428struct gpio_desc *devm_get_gpiod_from_child(struct device *dev, 428struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
429 const char *con_id, 429 const char *con_id, int index,
430 struct fwnode_handle *child, 430 struct fwnode_handle *child,
431 enum gpiod_flags flags, 431 enum gpiod_flags flags,
432 const char *label) 432 const char *label)
433{ 433{
434 return ERR_PTR(-ENOSYS); 434 return ERR_PTR(-ENOSYS);
435} 435}
436 436
437#endif /* CONFIG_GPIOLIB */ 437#endif /* CONFIG_GPIOLIB */
438 438
439static inline
440struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
441 const char *con_id,
442 struct fwnode_handle *child,
443 enum gpiod_flags flags,
444 const char *label)
445{
446 return devm_fwnode_get_index_gpiod_from_child(dev, con_id, 0, child,
447 flags, label);
448}
449
439#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS) 450#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
440 451
441int gpiod_export(struct gpio_desc *desc, bool direction_may_change); 452int gpiod_export(struct gpio_desc *desc, bool direction_may_change);