Skip to content

Commit 116a330

Browse files
committed
Merge tag 'gpio-fixes-for-v7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: - fix kerneldocs for gpio-timberdale and gpio-nomadik - clear the "requested" flag in error path in gpiod_request_commit() - call of_xlate() if provided when setting up shared GPIOs - handle pins shared by child firmware nodes of consumer devices - fix return value check in gpio-qixis-fpga - fix suspend on gpio-mxc - fix gpio-microchip DT bindings * tag 'gpio-fixes-for-v7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: dt-bindings: gpio: fix microchip #interrupt-cells gpio: shared: shorten the critical section in gpiochip_setup_shared() gpio: mxc: map Both Edge pad wakeup to Rising Edge gpio: qixis-fpga: Fix error handling for devm_regmap_init_mmio() gpio: shared: handle pins shared by child nodes of devices gpio: shared: call gpio_chip::of_xlate() if set gpiolib: clear requested flag if line is invalid gpio: nomadik: repair some kernel-doc comments gpio: timberdale: repair kernel-doc comments gpio: Fix resource leaks on errors in gpiochip_add_data_with_key()
2 parents 441c63f + 6b5ef8c commit 116a330

8 files changed

Lines changed: 124 additions & 93 deletions

File tree

Documentation/devicetree/bindings/gpio/microchip,mpfs-gpio.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ properties:
3737
const: 2
3838

3939
"#interrupt-cells":
40-
const: 1
40+
const: 2
4141

4242
ngpios:
4343
description:
@@ -86,7 +86,7 @@ examples:
8686
gpio-controller;
8787
#gpio-cells = <2>;
8888
interrupt-controller;
89-
#interrupt-cells = <1>;
89+
#interrupt-cells = <2>;
9090
interrupts = <53>, <53>, <53>, <53>,
9191
<53>, <53>, <53>, <53>,
9292
<53>, <53>, <53>, <53>,

drivers/gpio/gpio-mxc.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,13 @@ static bool mxc_gpio_set_pad_wakeup(struct mxc_gpio_port *port, bool enable)
584584
unsigned long config;
585585
bool ret = false;
586586
int i, type;
587+
bool is_imx8qm = of_device_is_compatible(port->dev->of_node, "fsl,imx8qm-gpio");
587588

588589
static const u32 pad_type_map[] = {
589590
IMX_SCU_WAKEUP_OFF, /* 0 */
590591
IMX_SCU_WAKEUP_RISE_EDGE, /* IRQ_TYPE_EDGE_RISING */
591592
IMX_SCU_WAKEUP_FALL_EDGE, /* IRQ_TYPE_EDGE_FALLING */
592-
IMX_SCU_WAKEUP_FALL_EDGE, /* IRQ_TYPE_EDGE_BOTH */
593+
IMX_SCU_WAKEUP_RISE_EDGE, /* IRQ_TYPE_EDGE_BOTH */
593594
IMX_SCU_WAKEUP_HIGH_LVL, /* IRQ_TYPE_LEVEL_HIGH */
594595
IMX_SCU_WAKEUP_OFF, /* 5 */
595596
IMX_SCU_WAKEUP_OFF, /* 6 */
@@ -604,6 +605,13 @@ static bool mxc_gpio_set_pad_wakeup(struct mxc_gpio_port *port, bool enable)
604605
config = pad_type_map[type];
605606
else
606607
config = IMX_SCU_WAKEUP_OFF;
608+
609+
if (is_imx8qm && config == IMX_SCU_WAKEUP_FALL_EDGE) {
610+
dev_warn_once(port->dev,
611+
"No falling-edge support for wakeup on i.MX8QM\n");
612+
config = IMX_SCU_WAKEUP_OFF;
613+
}
614+
607615
ret |= mxc_gpio_generic_config(port, i, config);
608616
}
609617
}

drivers/gpio/gpio-qixis-fpga.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ static int qixis_cpld_gpio_probe(struct platform_device *pdev)
6060
return PTR_ERR(reg);
6161

6262
regmap = devm_regmap_init_mmio(&pdev->dev, reg, &regmap_config_8r_8v);
63-
if (!regmap)
64-
return -ENODEV;
63+
if (IS_ERR(regmap))
64+
return PTR_ERR(regmap);
6565

6666
/* In this case, the offset of our register is 0 inside the
6767
* regmap area that we just created.

drivers/gpio/gpiolib-shared.c

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,
443443
}
444444
#endif /* CONFIG_RESET_GPIO */
445445

446-
int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
447-
unsigned long lflags)
446+
int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *fwnode,
447+
const char *con_id, unsigned long lflags)
448448
{
449449
const char *dev_id = dev_name(consumer);
450450
struct gpiod_lookup_table *lookup;
@@ -458,7 +458,7 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
458458
if (!ref->fwnode && device_is_compatible(consumer, "reset-gpio")) {
459459
if (!gpio_shared_dev_is_reset_gpio(consumer, entry, ref))
460460
continue;
461-
} else if (!device_match_fwnode(consumer, ref->fwnode)) {
461+
} else if (fwnode != ref->fwnode) {
462462
continue;
463463
}
464464

@@ -506,8 +506,9 @@ static void gpio_shared_remove_adev(struct auxiliary_device *adev)
506506
auxiliary_device_uninit(adev);
507507
}
508508

509-
int gpio_device_setup_shared(struct gpio_device *gdev)
509+
int gpiochip_setup_shared(struct gpio_chip *gc)
510510
{
511+
struct gpio_device *gdev = gc->gpiodev;
511512
struct gpio_shared_entry *entry;
512513
struct gpio_shared_ref *ref;
513514
struct gpio_desc *desc;
@@ -538,20 +539,42 @@ int gpio_device_setup_shared(struct gpio_device *gdev)
538539
if (list_count_nodes(&entry->refs) <= 1)
539540
continue;
540541

541-
desc = &gdev->descs[entry->offset];
542+
scoped_guard(mutex, &entry->lock) {
543+
#if IS_ENABLED(CONFIG_OF)
544+
if (is_of_node(entry->fwnode) && gc->of_xlate) {
545+
/*
546+
* This is the earliest that we can tranlate the
547+
* devicetree offset to the chip offset.
548+
*/
549+
struct of_phandle_args gpiospec = { };
542550

543-
__set_bit(GPIOD_FLAG_SHARED, &desc->flags);
544-
/*
545-
* Shared GPIOs are not requested via the normal path. Make
546-
* them inaccessible to anyone even before we register the
547-
* chip.
548-
*/
549-
ret = gpiod_request_commit(desc, "shared");
550-
if (ret)
551-
return ret;
551+
gpiospec.np = to_of_node(entry->fwnode);
552+
gpiospec.args_count = 2;
553+
gpiospec.args[0] = entry->offset;
554+
555+
ret = gc->of_xlate(gc, &gpiospec, NULL);
556+
if (ret < 0)
557+
return ret;
558+
559+
entry->offset = ret;
560+
}
561+
#endif /* CONFIG_OF */
562+
563+
desc = &gdev->descs[entry->offset];
564+
565+
__set_bit(GPIOD_FLAG_SHARED, &desc->flags);
566+
/*
567+
* Shared GPIOs are not requested via the normal path. Make
568+
* them inaccessible to anyone even before we register the
569+
* chip.
570+
*/
571+
ret = gpiod_request_commit(desc, "shared");
572+
if (ret)
573+
return ret;
552574

553-
pr_debug("GPIO %u owned by %s is shared by multiple consumers\n",
554-
entry->offset, gpio_device_get_label(gdev));
575+
pr_debug("GPIO %u owned by %s is shared by multiple consumers\n",
576+
entry->offset, gpio_device_get_label(gdev));
577+
}
555578

556579
list_for_each_entry(ref, &entry->refs, list) {
557580
pr_debug("Setting up a shared GPIO entry for %s (con_id: '%s')\n",
@@ -575,6 +598,8 @@ void gpio_device_teardown_shared(struct gpio_device *gdev)
575598
struct gpio_shared_ref *ref;
576599

577600
list_for_each_entry(entry, &gpio_shared_list, list) {
601+
guard(mutex)(&entry->lock);
602+
578603
if (!device_match_fwnode(&gdev->dev, entry->fwnode))
579604
continue;
580605

drivers/gpio/gpiolib-shared.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@
1111
struct gpio_device;
1212
struct gpio_desc;
1313
struct device;
14+
struct fwnode_handle;
1415

1516
#if IS_ENABLED(CONFIG_GPIO_SHARED)
1617

17-
int gpio_device_setup_shared(struct gpio_device *gdev);
18+
int gpiochip_setup_shared(struct gpio_chip *gc);
1819
void gpio_device_teardown_shared(struct gpio_device *gdev);
19-
int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id,
20-
unsigned long lflags);
20+
int gpio_shared_add_proxy_lookup(struct device *consumer,
21+
struct fwnode_handle *fwnode,
22+
const char *con_id, unsigned long lflags);
2123

2224
#else
2325

24-
static inline int gpio_device_setup_shared(struct gpio_device *gdev)
26+
static inline int gpiochip_setup_shared(struct gpio_chip *gc)
2527
{
2628
return 0;
2729
}
2830

2931
static inline void gpio_device_teardown_shared(struct gpio_device *gdev) { }
3032

3133
static inline int gpio_shared_add_proxy_lookup(struct device *consumer,
34+
struct fwnode_handle *fwnode,
3235
const char *con_id,
3336
unsigned long lflags)
3437
{

0 commit comments

Comments
 (0)