Skip to content

Commit e4df1eb

Browse files
author
Linus Walleij
committed
Merge branch 'ib-gpiod-flags' into devel
2 parents e8e1a5b + 537b94d commit e4df1eb

7 files changed

Lines changed: 58 additions & 40 deletions

File tree

‎drivers/gpio/devres.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev,
125125
EXPORT_SYMBOL(devm_gpiod_get_index);
126126

127127
/**
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
129130
* @dev: GPIO consumer
130131
* @con_id: function within the GPIO consumer
132+
* @index: index of the GPIO to obtain in the consumer
131133
* @child: firmware node (child of @dev)
132134
* @flags: GPIO initialization flags
133135
*
@@ -137,11 +139,11 @@ EXPORT_SYMBOL(devm_gpiod_get_index);
137139
* On successfull request the GPIO pin is configured in accordance with
138140
* provided @flags.
139141
*/
140-
struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
141-
const char *con_id,
142-
struct fwnode_handle *child,
143-
enum gpiod_flags flags,
144-
const char *label)
142+
struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
143+
const char *con_id, int index,
144+
struct fwnode_handle *child,
145+
enum gpiod_flags flags,
146+
const char *label)
145147
{
146148
char prop_name[32]; /* 32 is max size of property name */
147149
struct gpio_desc **dr;
@@ -161,7 +163,8 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
161163
snprintf(prop_name, sizeof(prop_name), "%s",
162164
gpio_suffixes[i]);
163165

164-
desc = fwnode_get_named_gpiod(child, prop_name, flags, label);
166+
desc = fwnode_get_named_gpiod(child, prop_name, index, flags,
167+
label);
165168
if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
166169
break;
167170
}
@@ -175,7 +178,7 @@ struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
175178

176179
return desc;
177180
}
178-
EXPORT_SYMBOL(devm_get_gpiod_from_child);
181+
EXPORT_SYMBOL(devm_fwnode_get_index_gpiod_from_child);
179182

180183
/**
181184
* devm_gpiod_get_index_optional - Resource-managed gpiod_get_index_optional()

‎drivers/gpio/gpiolib.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,6 +3316,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
33163316
* fwnode_get_named_gpiod - obtain a GPIO from firmware node
33173317
* @fwnode: handle of the firmware node
33183318
* @propname: name of the firmware property representing the GPIO
3319+
* @index: index of the GPIO to obtain in the consumer
33193320
* @dflags: GPIO initialization flags
33203321
*
33213322
* This function can be used for drivers that get their configuration
@@ -3331,7 +3332,7 @@ EXPORT_SYMBOL_GPL(gpiod_get_index);
33313332
* In case of error an ERR_PTR() is returned.
33323333
*/
33333334
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
3334-
const char *propname,
3335+
const char *propname, int index,
33353336
enum gpiod_flags dflags,
33363337
const char *label)
33373338
{
@@ -3347,16 +3348,16 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
33473348
if (is_of_node(fwnode)) {
33483349
enum of_gpio_flags flags;
33493350

3350-
desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname, 0,
3351-
&flags);
3351+
desc = of_get_named_gpiod_flags(to_of_node(fwnode), propname,
3352+
index, &flags);
33523353
if (!IS_ERR(desc)) {
33533354
active_low = flags & OF_GPIO_ACTIVE_LOW;
33543355
single_ended = flags & OF_GPIO_SINGLE_ENDED;
33553356
}
33563357
} else if (is_acpi_node(fwnode)) {
33573358
struct acpi_gpio_info info;
33583359

3359-
desc = acpi_node_get_gpiod(fwnode, propname, 0, &info);
3360+
desc = acpi_node_get_gpiod(fwnode, propname, index, &info);
33603361
if (!IS_ERR(desc))
33613362
active_low = info.polarity == GPIO_ACTIVE_LOW;
33623363
}

‎drivers/input/keyboard/gpio_keys.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,10 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
481481
spin_lock_init(&bdata->lock);
482482

483483
if (child) {
484-
bdata->gpiod = devm_get_gpiod_from_child(dev, NULL, child,
485-
GPIOD_IN, desc);
484+
bdata->gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL,
485+
child,
486+
GPIOD_IN,
487+
desc);
486488
if (IS_ERR(bdata->gpiod)) {
487489
error = PTR_ERR(bdata->gpiod);
488490
if (error == -ENOENT) {

‎drivers/input/keyboard/gpio_keys_polled.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
303303
return -EINVAL;
304304
}
305305

306-
bdata->gpiod = devm_get_gpiod_from_child(dev, NULL,
307-
child,
308-
GPIOD_IN,
309-
button->desc);
306+
bdata->gpiod = devm_fwnode_get_gpiod_from_child(dev,
307+
NULL, child,
308+
GPIOD_IN,
309+
button->desc);
310310
if (IS_ERR(bdata->gpiod)) {
311311
error = PTR_ERR(bdata->gpiod);
312312
if (error != -EPROBE_DEFER)

‎drivers/leds/leds-gpio.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev)
182182
return ERR_PTR(-EINVAL);
183183
}
184184

185-
led.gpiod = devm_get_gpiod_from_child(dev, NULL, child,
186-
GPIOD_ASIS, led.name);
185+
led.gpiod = devm_fwnode_get_gpiod_from_child(dev, NULL, child,
186+
GPIOD_ASIS,
187+
led.name);
187188
if (IS_ERR(led.gpiod)) {
188189
fwnode_handle_put(child);
189190
return ERR_CAST(led.gpiod);

‎drivers/video/fbdev/amba-clcd-nomadik.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,26 +185,26 @@ static void tpg110_init(struct device *dev, struct device_node *np,
185185
dev_info(dev, "TPG110 display init\n");
186186

187187
/* This asserts the GRESTB signal, putting the display into reset */
188-
grestb = devm_get_gpiod_from_child(dev, "grestb", &np->fwnode,
189-
GPIOD_OUT_HIGH, "grestb");
188+
grestb = devm_fwnode_get_gpiod_from_child(dev, "grestb", &np->fwnode,
189+
GPIOD_OUT_HIGH, "grestb");
190190
if (IS_ERR(grestb)) {
191191
dev_err(dev, "no GRESTB GPIO\n");
192192
return;
193193
}
194-
scen = devm_get_gpiod_from_child(dev, "scen", &np->fwnode,
195-
GPIOD_OUT_LOW, "scen");
194+
scen = devm_fwnode_get_gpiod_from_child(dev, "scen", &np->fwnode,
195+
GPIOD_OUT_LOW, "scen");
196196
if (IS_ERR(scen)) {
197197
dev_err(dev, "no SCEN GPIO\n");
198198
return;
199199
}
200-
scl = devm_get_gpiod_from_child(dev, "scl", &np->fwnode, GPIOD_OUT_LOW,
201-
"scl");
200+
scl = devm_fwnode_get_gpiod_from_child(dev, "scl", &np->fwnode,
201+
GPIOD_OUT_LOW, "scl");
202202
if (IS_ERR(scl)) {
203203
dev_err(dev, "no SCL GPIO\n");
204204
return;
205205
}
206-
sda = devm_get_gpiod_from_child(dev, "sda", &np->fwnode, GPIOD_OUT_LOW,
207-
"sda");
206+
sda = devm_fwnode_get_gpiod_from_child(dev, "sda", &np->fwnode,
207+
GPIOD_OUT_LOW, "sda");
208208
if (IS_ERR(sda)) {
209209
dev_err(dev, "no SDA GPIO\n");
210210
return;

‎include/linux/gpio/consumer.h‎

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ int desc_to_gpio(const struct gpio_desc *desc);
135135
struct fwnode_handle;
136136

137137
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
138-
const char *propname,
138+
const char *propname, int index,
139139
enum gpiod_flags dflags,
140140
const char *label);
141-
struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
142-
const char *con_id,
143-
struct fwnode_handle *child,
144-
enum gpiod_flags flags,
145-
const char *label);
141+
struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
142+
const char *con_id, int index,
143+
struct fwnode_handle *child,
144+
enum gpiod_flags flags,
145+
const char *label);
146146
#else /* CONFIG_GPIOLIB */
147147

148148
static inline int gpiod_count(struct device *dev, const char *con_id)
@@ -417,25 +417,36 @@ struct fwnode_handle;
417417

418418
static inline
419419
struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
420-
const char *propname,
420+
const char *propname, int index,
421421
enum gpiod_flags dflags,
422422
const char *label)
423423
{
424424
return ERR_PTR(-ENOSYS);
425425
}
426426

427427
static inline
428-
struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
429-
const char *con_id,
430-
struct fwnode_handle *child,
431-
enum gpiod_flags flags,
432-
const char *label)
428+
struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
429+
const char *con_id, int index,
430+
struct fwnode_handle *child,
431+
enum gpiod_flags flags,
432+
const char *label)
433433
{
434434
return ERR_PTR(-ENOSYS);
435435
}
436436

437437
#endif /* CONFIG_GPIOLIB */
438438

439+
static inline
440+
struct 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+
439450
#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
440451

441452
int gpiod_export(struct gpio_desc *desc, bool direction_may_change);

0 commit comments

Comments
 (0)