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()
Unified · Split
| @@ -37,7 +37,7 @@ properties: · 36 unmodified lines | |||
| 37 | const: 2 | 37 | const: 2 |
| 38 | 38 | ||
| 39 | "#interrupt-cells": | 39 | "#interrupt-cells": |
| 40 | const: 1 | 40 | const: 2 |
| 41 | 41 | ||
| 42 | ngpios: | 42 | ngpios: |
| 43 | description: | 43 | description: |
| @@ -86,7 +86,7 @@ examples: · 42 unmodified lines | |||
| 86 | gpio-controller; | 86 | gpio-controller; |
| 87 | #gpio-cells = <2>; | 87 | #gpio-cells = <2>; |
| 88 | interrupt-controller; | 88 | interrupt-controller; |
| 89 | #interrupt-cells = <1>; | 89 | #interrupt-cells = <2>; |
| 90 | interrupts = <53>, <53>, <53>, <53>, | 90 | interrupts = <53>, <53>, <53>, <53>, |
| 91 | <53>, <53>, <53>, <53>, | 91 | <53>, <53>, <53>, <53>, |
| 92 | <53>, <53>, <53>, <53>, | 92 | <53>, <53>, <53>, <53>, |
| @@ -584,12 +584,13 @@ static bool mxc_gpio_set_pad_wakeup(struct mxc_gpio_port *port, bool enable) · 583 unmodified lines | |||
| 584 | unsigned long config; | 584 | unsigned long config; |
| 585 | bool ret = false; | 585 | bool ret = false; |
| 586 | int i, type; | 586 | int i, type; |
| 587 | bool is_imx8qm = of_device_is_compatible(port->dev->of_node, "fsl,imx8qm-gpio"); | ||
| 587 | 588 | ||
| 588 | static const u32 pad_type_map[] = { | 589 | static const u32 pad_type_map[] = { |
| 589 | IMX_SCU_WAKEUP_OFF, /* 0 */ | 590 | IMX_SCU_WAKEUP_OFF, /* 0 */ |
| 590 | IMX_SCU_WAKEUP_RISE_EDGE, /* IRQ_TYPE_EDGE_RISING */ | 591 | IMX_SCU_WAKEUP_RISE_EDGE, /* IRQ_TYPE_EDGE_RISING */ |
| 591 | IMX_SCU_WAKEUP_FALL_EDGE, /* IRQ_TYPE_EDGE_FALLING */ | 592 | 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 */ |
| 593 | IMX_SCU_WAKEUP_HIGH_LVL, /* IRQ_TYPE_LEVEL_HIGH */ | 594 | IMX_SCU_WAKEUP_HIGH_LVL, /* IRQ_TYPE_LEVEL_HIGH */ |
| 594 | IMX_SCU_WAKEUP_OFF, /* 5 */ | 595 | IMX_SCU_WAKEUP_OFF, /* 5 */ |
| 595 | IMX_SCU_WAKEUP_OFF, /* 6 */ | 596 | IMX_SCU_WAKEUP_OFF, /* 6 */ |
| @@ -604,6 +605,13 @@ static bool mxc_gpio_set_pad_wakeup(struct mxc_gpio_port *port, bool enable) · 8 unmodified lines | |||
| 604 | config = pad_type_map[type]; | 605 | config = pad_type_map[type]; |
| 605 | else | 606 | else |
| 606 | config = IMX_SCU_WAKEUP_OFF; | 607 | 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 | |||
| 607 | ret |= mxc_gpio_generic_config(port, i, config); | 615 | ret |= mxc_gpio_generic_config(port, i, config); |
| 608 | } | 616 | } |
| 609 | } | 617 | } |
| @@ -60,8 +60,8 @@ static int qixis_cpld_gpio_probe(struct platform_device *pdev) · 59 unmodified lines | |||
| 60 | return PTR_ERR(reg); | 60 | return PTR_ERR(reg); |
| 61 | 61 | ||
| 62 | regmap = devm_regmap_init_mmio(&pdev->dev, reg, ®map_config_8r_8v); | 62 | regmap = devm_regmap_init_mmio(&pdev->dev, reg, ®map_config_8r_8v); |
| 63 | if (!regmap) | 63 | if (IS_ERR(regmap)) |
| 64 | return -ENODEV; | 64 | return PTR_ERR(regmap); |
| 65 | 65 | ||
| 66 | /* In this case, the offset of our register is 0 inside the | 66 | /* In this case, the offset of our register is 0 inside the |
| 67 | * regmap area that we just created. | 67 | * regmap area that we just created. |
| @@ -443,8 +443,8 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer, · 442 unmodified lines | |||
| 443 | } | 443 | } |
| 444 | #endif /* CONFIG_RESET_GPIO */ | 444 | #endif /* CONFIG_RESET_GPIO */ |
| 445 | 445 | ||
| 446 | int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id, | 446 | int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *fwnode, |
| 447 | unsigned long lflags) | 447 | const char *con_id, unsigned long lflags) |
| 448 | { | 448 | { |
| 449 | const char *dev_id = dev_name(consumer); | 449 | const char *dev_id = dev_name(consumer); |
| 450 | struct gpiod_lookup_table *lookup; | 450 | struct gpiod_lookup_table *lookup; |
| @@ -458,7 +458,7 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id, · 7 unmodified lines | |||
| 458 | if (!ref->fwnode && device_is_compatible(consumer, "reset-gpio")) { | 458 | if (!ref->fwnode && device_is_compatible(consumer, "reset-gpio")) { |
| 459 | if (!gpio_shared_dev_is_reset_gpio(consumer, entry, ref)) | 459 | if (!gpio_shared_dev_is_reset_gpio(consumer, entry, ref)) |
| 460 | continue; | 460 | continue; |
| 461 | } else if (!device_match_fwnode(consumer, ref->fwnode)) { | 461 | } else if (fwnode != ref->fwnode) { |
| 462 | continue; | 462 | continue; |
| 463 | } | 463 | } |
| 464 | 464 | ||
| @@ -506,8 +506,9 @@ static void gpio_shared_remove_adev(struct auxiliary_device *adev) · 41 unmodified lines | |||
| 506 | auxiliary_device_uninit(adev); | 506 | auxiliary_device_uninit(adev); |
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | int gpio_device_setup_shared(struct gpio_device *gdev) | 509 | int gpiochip_setup_shared(struct gpio_chip *gc) |
| 510 | { | 510 | { |
| 511 | struct gpio_device *gdev = gc->gpiodev; | ||
| 511 | struct gpio_shared_entry *entry; | 512 | struct gpio_shared_entry *entry; |
| 512 | struct gpio_shared_ref *ref; | 513 | struct gpio_shared_ref *ref; |
| 513 | struct gpio_desc *desc; | 514 | struct gpio_desc *desc; |
| @@ -538,20 +539,42 @@ int gpio_device_setup_shared(struct gpio_device *gdev) · 24 unmodified lines | |||
| 538 | if (list_count_nodes(&entry->refs) <= 1) | 539 | if (list_count_nodes(&entry->refs) <= 1) |
| 539 | continue; | 540 | continue; |
| 540 | 541 | ||
| 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 = { }; | ||
| 542 | 550 | ||
| 543 | __set_bit(GPIOD_FLAG_SHARED, &desc->flags); | 551 | gpiospec.np = to_of_node(entry->fwnode); |
| 544 | /* | 552 | gpiospec.args_count = 2; |
| 545 | * Shared GPIOs are not requested via the normal path. Make | 553 | gpiospec.args[0] = entry->offset; |
| 546 | * them inaccessible to anyone even before we register the | 554 | |
| 547 | * chip. | 555 | ret = gc->of_xlate(gc, &gpiospec, NULL); |
| 548 | */ | 556 | if (ret < 0) |
| 549 | ret = gpiod_request_commit(desc, "shared"); | 557 | return ret; |
| 550 | if (ret) | 558 | |
| 551 | return ret; | 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; | ||
| 552 | 574 | ||
| 553 | pr_debug("GPIO %u owned by %s is shared by multiple consumers\n", | 575 | pr_debug("GPIO %u owned by %s is shared by multiple consumers\n", |
| 554 | entry->offset, gpio_device_get_label(gdev)); | 576 | entry->offset, gpio_device_get_label(gdev)); |
| 577 | } | ||
| 555 | 578 | ||
| 556 | list_for_each_entry(ref, &entry->refs, list) { | 579 | list_for_each_entry(ref, &entry->refs, list) { |
| 557 | pr_debug("Setting up a shared GPIO entry for %s (con_id: '%s')\n", | 580 | 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) · 17 unmodified lines | |||
| 575 | struct gpio_shared_ref *ref; | 598 | struct gpio_shared_ref *ref; |
| 576 | 599 | ||
| 577 | list_for_each_entry(entry, &gpio_shared_list, list) { | 600 | list_for_each_entry(entry, &gpio_shared_list, list) { |
| 601 | guard(mutex)(&entry->lock); | ||
| 602 | |||
| 578 | if (!device_match_fwnode(&gdev->dev, entry->fwnode)) | 603 | if (!device_match_fwnode(&gdev->dev, entry->fwnode)) |
| 579 | continue; | 604 | continue; |
| 580 | 605 | ||
| @@ -11,17 +11,19 @@ · 10 unmodified lines | |||
| 11 | struct gpio_device; | 11 | struct gpio_device; |
| 12 | struct gpio_desc; | 12 | struct gpio_desc; |
| 13 | struct device; | 13 | struct device; |
| 14 | struct fwnode_handle; | ||
| 14 | 15 | ||
| 15 | #if IS_ENABLED(CONFIG_GPIO_SHARED) | 16 | #if IS_ENABLED(CONFIG_GPIO_SHARED) |
| 16 | 17 | ||
| 17 | int gpio_device_setup_shared(struct gpio_device *gdev); | 18 | int gpiochip_setup_shared(struct gpio_chip *gc); |
| 18 | void gpio_device_teardown_shared(struct gpio_device *gdev); | 19 | void gpio_device_teardown_shared(struct gpio_device *gdev); |
| 19 | int gpio_shared_add_proxy_lookup(struct device *consumer, const char *con_id, | 20 | int gpio_shared_add_proxy_lookup(struct device *consumer, |
| 20 | unsigned long lflags); | 21 | struct fwnode_handle *fwnode, |
| 22 | const char *con_id, unsigned long lflags); | ||
| 21 | 23 | ||
| 22 | #else | 24 | #else |
| 23 | 25 | ||
| 24 | static inline int gpio_device_setup_shared(struct gpio_device *gdev) | 26 | static inline int gpiochip_setup_shared(struct gpio_chip *gc) |
| 25 | { | 27 | { |
| 26 | return 0; | 28 | return 0; |
| 27 | } | 29 | } |
| @@ -29,6 +31,7 @@ static inline int gpio_device_setup_shared(struct gpio_device *gdev) · 1 unmodified line | |||
| 29 | static inline void gpio_device_teardown_shared(struct gpio_device *gdev) { } | 31 | static inline void gpio_device_teardown_shared(struct gpio_device *gdev) { } |
| 30 | 32 | ||
| 31 | static inline int gpio_shared_add_proxy_lookup(struct device *consumer, | 33 | static inline int gpio_shared_add_proxy_lookup(struct device *consumer, |
| 34 | struct fwnode_handle *fwnode, | ||
| 32 | const char *con_id, | 35 | const char *con_id, |
| 33 | unsigned long lflags) | 36 | unsigned long lflags) |
| 34 | { | 37 | { |
| @@ -892,13 +892,15 @@ static const struct device_type gpio_dev_type = { · 891 unmodified lines | |||
| 892 | #define gcdev_unregister(gdev) device_del(&(gdev)->dev) | 892 | #define gcdev_unregister(gdev) device_del(&(gdev)->dev) |
| 893 | #endif | 893 | #endif |
| 894 | 894 | ||
| 895 | /* | ||
| 896 | * An initial reference count has been held in gpiochip_add_data_with_key(). | ||
| 897 | * The caller should drop the reference via gpio_device_put() on errors. | ||
| 898 | */ | ||
| 895 | static int gpiochip_setup_dev(struct gpio_device *gdev) | 899 | static int gpiochip_setup_dev(struct gpio_device *gdev) |
| 896 | { | 900 | { |
| 897 | struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); | 901 | struct fwnode_handle *fwnode = dev_fwnode(&gdev->dev); |
| 898 | int ret; | 902 | int ret; |
| 899 | 903 | ||
| 900 | device_initialize(&gdev->dev); | ||
| 901 | |||
| 902 | /* | 904 | /* |
| 903 | * If fwnode doesn't belong to another device, it's safe to clear its | 905 | * If fwnode doesn't belong to another device, it's safe to clear its |
| 904 | * initialized flag. | 906 | * initialized flag. |
| @@ -964,9 +966,11 @@ static void gpiochip_setup_devs(void) · 59 unmodified lines | |||
| 964 | list_for_each_entry_srcu(gdev, &gpio_devices, list, | 966 | list_for_each_entry_srcu(gdev, &gpio_devices, list, |
| 965 | srcu_read_lock_held(&gpio_devices_srcu)) { | 967 | srcu_read_lock_held(&gpio_devices_srcu)) { |
| 966 | ret = gpiochip_setup_dev(gdev); | 968 | ret = gpiochip_setup_dev(gdev); |
| 967 | if (ret) | 969 | if (ret) { |
| 970 | gpio_device_put(gdev); | ||
| 968 | dev_err(&gdev->dev, | 971 | dev_err(&gdev->dev, |
| 969 | "Failed to initialize gpio device (%d)\n", ret); | 972 | "Failed to initialize gpio device (%d)\n", ret); |
| 973 | } | ||
| 970 | } | 974 | } |
| 971 | } | 975 | } |
| 972 | 976 | ||
| @@ -1047,71 +1051,72 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, · 74 unmodified lines | |||
| 1047 | int base = 0; | 1051 | int base = 0; |
| 1048 | int ret; | 1052 | int ret; |
| 1049 | 1053 | ||
| 1050 | /* | ||
| 1051 | * First: allocate and populate the internal stat container, and | ||
| 1052 | * set up the struct device. | ||
| 1053 | */ | ||
| 1054 | gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); | 1054 | gdev = kzalloc(sizeof(*gdev), GFP_KERNEL); |
| 1055 | if (!gdev) | 1055 | if (!gdev) |
| 1056 | return -ENOMEM; | 1056 | return -ENOMEM; |
| 1057 | |||
| 1058 | gdev->dev.type = &gpio_dev_type; | ||
| 1059 | gdev->dev.bus = &gpio_bus_type; | ||
| 1060 | gdev->dev.parent = gc->parent; | ||
| 1061 | rcu_assign_pointer(gdev->chip, gc); | ||
| 1062 | |||
| 1063 | gc->gpiodev = gdev; | 1057 | gc->gpiodev = gdev; |
| 1064 | gpiochip_set_data(gc, data); | 1058 | gpiochip_set_data(gc, data); |
| 1065 | 1059 | ||
| 1066 | device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc)); | ||
| 1067 | |||
| 1068 | ret = ida_alloc(&gpio_ida, GFP_KERNEL); | 1060 | ret = ida_alloc(&gpio_ida, GFP_KERNEL); |
| 1069 | if (ret < 0) | 1061 | if (ret < 0) |
| 1070 | goto err_free_gdev; | 1062 | goto err_free_gdev; |
| 1071 | gdev->id = ret; | 1063 | gdev->id = ret; |
| 1072 | 1064 | ||
| 1073 | ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); | 1065 | ret = init_srcu_struct(&gdev->srcu); |
| 1074 | if (ret) | 1066 | if (ret) |
| 1075 | goto err_free_ida; | 1067 | goto err_free_ida; |
| 1068 | rcu_assign_pointer(gdev->chip, gc); | ||
| 1076 | 1069 | ||
| 1077 | if (gc->parent && gc->parent->driver) | 1070 | ret = init_srcu_struct(&gdev->desc_srcu); |
| 1078 | gdev->owner = gc->parent->driver->owner; | 1071 | if (ret) |
| 1079 | else if (gc->owner) | 1072 | goto err_cleanup_gdev_srcu; |
| 1080 | /* TODO: remove chip->owner */ | 1073 | |
| 1081 | gdev->owner = gc->owner; | 1074 | ret = dev_set_name(&gdev->dev, GPIOCHIP_NAME "%d", gdev->id); |
| 1082 | else | 1075 | if (ret) |
| 1083 | gdev->owner = THIS_MODULE; | 1076 | goto err_cleanup_desc_srcu; |
| 1077 | |||
| 1078 | device_initialize(&gdev->dev); | ||
| 1079 | /* | ||
| 1080 | * After this point any allocated resources to `gdev` will be | ||
| 1081 | * free():ed by gpiodev_release(). If you add new resources | ||
| 1082 | * then make sure they get free():ed there. | ||
| 1083 | */ | ||
| 1084 | gdev->dev.type = &gpio_dev_type; | ||
| 1085 | gdev->dev.bus = &gpio_bus_type; | ||
| 1086 | gdev->dev.parent = gc->parent; | ||
| 1087 | device_set_node(&gdev->dev, gpiochip_choose_fwnode(gc)); | ||
| 1084 | 1088 | ||
| 1085 | ret = gpiochip_get_ngpios(gc, &gdev->dev); | 1089 | ret = gpiochip_get_ngpios(gc, &gdev->dev); |
| 1086 | if (ret) | 1090 | if (ret) |
| 1087 | goto err_free_dev_name; | 1091 | goto err_put_device; |
| 1092 | gdev->ngpio = gc->ngpio; | ||
| 1088 | 1093 | ||
| 1089 | gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); | 1094 | gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL); |
| 1090 | if (!gdev->descs) { | 1095 | if (!gdev->descs) { |
| 1091 | ret = -ENOMEM; | 1096 | ret = -ENOMEM; |
| 1092 | goto err_free_dev_name; | 1097 | goto err_put_device; |
| 1093 | } | 1098 | } |
| 1094 | 1099 | ||
| 1095 | gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); | 1100 | gdev->label = kstrdup_const(gc->label ?: "unknown", GFP_KERNEL); |
| 1096 | if (!gdev->label) { | 1101 | if (!gdev->label) { |
| 1097 | ret = -ENOMEM; | 1102 | ret = -ENOMEM; |
| 1098 | goto err_free_descs; | 1103 | goto err_put_device; |
| 1099 | } | 1104 | } |
| 1100 | 1105 | ||
| 1101 | gdev->ngpio = gc->ngpio; | ||
| 1102 | gdev->can_sleep = gc->can_sleep; | 1106 | gdev->can_sleep = gc->can_sleep; |
| 1103 | |||
| 1104 | rwlock_init(&gdev->line_state_lock); | 1107 | rwlock_init(&gdev->line_state_lock); |
| 1105 | RAW_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier); | 1108 | RAW_INIT_NOTIFIER_HEAD(&gdev->line_state_notifier); |
| 1106 | BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier); | 1109 | BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier); |
| 1107 | 1110 | #ifdef CONFIG_PINCTRL | |
| 1108 | ret = init_srcu_struct(&gdev->srcu); | 1111 | INIT_LIST_HEAD(&gdev->pin_ranges); |
| 1109 | if (ret) | 1112 | #endif |
| 1110 | goto err_free_label; | 1113 | if (gc->parent && gc->parent->driver) |
| 1111 | 1114 | gdev->owner = gc->parent->driver->owner; | |
| 1112 | ret = init_srcu_struct(&gdev->desc_srcu); | 1115 | else if (gc->owner) |
| 1113 | if (ret) | 1116 | /* TODO: remove chip->owner */ |
| 1114 | goto err_cleanup_gdev_srcu; | 1117 | gdev->owner = gc->owner; |
| 1118 | else | ||
| 1119 | gdev->owner = THIS_MODULE; | ||
| 1115 | 1120 | ||
| 1116 | scoped_guard(mutex, &gpio_devices_lock) { | 1121 | scoped_guard(mutex, &gpio_devices_lock) { |
| 1117 | /* | 1122 | /* |
| @@ -1127,7 +1132,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, · 9 unmodified lines | |||
| 1127 | if (base < 0) { | 1132 | if (base < 0) { |
| 1128 | ret = base; | 1133 | ret = base; |
| 1129 | base = 0; | 1134 | base = 0; |
| 1130 | goto err_cleanup_desc_srcu; | 1135 | goto err_put_device; |
| 1131 | } | 1136 | } |
| 1132 | 1137 | ||
| 1133 | /* | 1138 | /* |
| @@ -1147,14 +1152,10 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, · 13 unmodified lines | |||
| 1147 | ret = gpiodev_add_to_list_unlocked(gdev); | 1152 | ret = gpiodev_add_to_list_unlocked(gdev); |
| 1148 | if (ret) { | 1153 | if (ret) { |
| 1149 | gpiochip_err(gc, "GPIO integer space overlap, cannot add chip\n"); | 1154 | gpiochip_err(gc, "GPIO integer space overlap, cannot add chip\n"); |
| 1150 | goto err_cleanup_desc_srcu; | 1155 | goto err_put_device; |
| 1151 | } | 1156 | } |
| 1152 | } | 1157 | } |
| 1153 | 1158 | ||
| 1154 | #ifdef CONFIG_PINCTRL | ||
| 1155 | INIT_LIST_HEAD(&gdev->pin_ranges); | ||
| 1156 | #endif | ||
| 1157 | |||
| 1158 | if (gc->names) | 1159 | if (gc->names) |
| 1159 | gpiochip_set_desc_names(gc); | 1160 | gpiochip_set_desc_names(gc); |
| 1160 | 1161 | ||
| @@ -1210,7 +1211,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, · 49 unmodified lines | |||
| 1210 | if (ret) | 1211 | if (ret) |
| 1211 | goto err_remove_irqchip_mask; | 1212 | goto err_remove_irqchip_mask; |
| 1212 | 1213 | ||
| 1213 | ret = gpio_device_setup_shared(gdev); | 1214 | ret = gpiochip_setup_shared(gc); |
| 1214 | if (ret) | 1215 | if (ret) |
| 1215 | goto err_remove_irqchip; | 1216 | goto err_remove_irqchip; |
| 1216 | 1217 | ||
| @@ -1248,25 +1249,19 @@ err_remove_from_list: · 31 unmodified lines | |||
| 1248 | scoped_guard(mutex, &gpio_devices_lock) | 1249 | scoped_guard(mutex, &gpio_devices_lock) |
| 1249 | list_del_rcu(&gdev->list); | 1250 | list_del_rcu(&gdev->list); |
| 1250 | synchronize_srcu(&gpio_devices_srcu); | 1251 | synchronize_srcu(&gpio_devices_srcu); |
| 1251 | if (gdev->dev.release) { | 1252 | err_put_device: |
| 1252 | /* release() has been registered by gpiochip_setup_dev() */ | 1253 | gpio_device_put(gdev); |
| 1253 | gpio_device_put(gdev); | 1254 | goto err_print_message; |
| 1254 | goto err_print_message; | 1255 | |
| 1255 | } | ||
| 1256 | err_cleanup_desc_srcu: | 1256 | err_cleanup_desc_srcu: |
| 1257 | cleanup_srcu_struct(&gdev->desc_srcu); | 1257 | cleanup_srcu_struct(&gdev->desc_srcu); |
| 1258 | err_cleanup_gdev_srcu: | 1258 | err_cleanup_gdev_srcu: |
| 1259 | cleanup_srcu_struct(&gdev->srcu); | 1259 | cleanup_srcu_struct(&gdev->srcu); |
| 1260 | err_free_label: | ||
| 1261 | kfree_const(gdev->label); | ||
| 1262 | err_free_descs: | ||
| 1263 | kfree(gdev->descs); | ||
| 1264 | err_free_dev_name: | ||
| 1265 | kfree(dev_name(&gdev->dev)); | ||
| 1266 | err_free_ida: | 1260 | err_free_ida: |
| 1267 | ida_free(&gpio_ida, gdev->id); | 1261 | ida_free(&gpio_ida, gdev->id); |
| 1268 | err_free_gdev: | 1262 | err_free_gdev: |
| 1269 | kfree(gdev); | 1263 | kfree(gdev); |
| 1264 | |||
| 1270 | err_print_message: | 1265 | err_print_message: |
| 1271 | /* failures here can mean systems won't boot... */ | 1266 | /* failures here can mean systems won't boot... */ |
| 1272 | if (ret != -EPROBE_DEFER) { | 1267 | if (ret != -EPROBE_DEFER) { |
| @@ -2465,8 +2460,10 @@ int gpiod_request_commit(struct gpio_desc *desc, const char *label) · 1192 unmodified lines | |||
| 2465 | return -EBUSY; | 2460 | return -EBUSY; |
| 2466 | 2461 | ||
| 2467 | offset = gpiod_hwgpio(desc); | 2462 | offset = gpiod_hwgpio(desc); |
| 2468 | if (!gpiochip_line_is_valid(guard.gc, offset)) | 2463 | if (!gpiochip_line_is_valid(guard.gc, offset)) { |
| 2469 | return -EINVAL; | 2464 | ret = -EINVAL; |
| 2465 | goto out_clear_bit; | ||
| 2466 | } | ||
| 2470 | 2467 | ||
| 2471 | /* NOTE: gpio_request() can be called in early boot, | 2468 | /* NOTE: gpio_request() can be called in early boot, |
| 2472 | * before IRQs are enabled, for non-sleeping (SOC) GPIOs. | 2469 | * before IRQs are enabled, for non-sleeping (SOC) GPIOs. |
| @@ -4717,8 +4714,8 @@ struct gpio_desc *gpiod_find_and_request(struct device *consumer, · 2244 unmodified lines | |||
| 4717 | * lookup table for the proxy device as previously | 4714 | * lookup table for the proxy device as previously |
| 4718 | * we only knew the consumer's fwnode. | 4715 | * we only knew the consumer's fwnode. |
| 4719 | */ | 4716 | */ |
| 4720 | ret = gpio_shared_add_proxy_lookup(consumer, con_id, | 4717 | ret = gpio_shared_add_proxy_lookup(consumer, fwnode, |
| 4721 | lookupflags); | 4718 | con_id, lookupflags); |
| 4722 | if (ret) | 4719 | if (ret) |
| 4723 | return ERR_PTR(ret); | 4720 | return ERR_PTR(ret); |
| 4724 | 4721 | ||
| @@ -114,8 +114,7 @@ struct nmk_gpio_chip { · 113 unmodified lines | |||
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | /** | 116 | /** |
| 117 | * enum prcm_gpiocr_reg_index | 117 | * enum prcm_gpiocr_reg_index - Used to reference a PRCM GPIOCR register address. |
| 118 | * Used to reference an PRCM GPIOCR register address. | ||
| 119 | */ | 118 | */ |
| 120 | enum prcm_gpiocr_reg_index { | 119 | enum prcm_gpiocr_reg_index { |
| 121 | PRCM_IDX_GPIOCR1, | 120 | PRCM_IDX_GPIOCR1, |
| @@ -123,8 +122,7 @@ enum prcm_gpiocr_reg_index { · 1 unmodified line | |||
| 123 | PRCM_IDX_GPIOCR3 | 122 | PRCM_IDX_GPIOCR3 |
| 124 | }; | 123 | }; |
| 125 | /** | 124 | /** |
| 126 | * enum prcm_gpiocr_altcx_index | 125 | * enum prcm_gpiocr_altcx_index - Used to reference an Other alternate-C function. |
| 127 | * Used to reference an Other alternate-C function. | ||
| 128 | */ | 126 | */ |
| 129 | enum prcm_gpiocr_altcx_index { | 127 | enum prcm_gpiocr_altcx_index { |
| 130 | PRCM_IDX_GPIOCR_ALTC1, | 128 | PRCM_IDX_GPIOCR_ALTC1, |
| @@ -135,7 +133,7 @@ enum prcm_gpiocr_altcx_index { · 4 unmodified lines | |||
| 135 | }; | 133 | }; |
| 136 | 134 | ||
| 137 | /** | 135 | /** |
| 138 | * struct prcm_gpio_altcx - Other alternate-C function | 136 | * struct prcm_gpiocr_altcx - Other alternate-C function |
| 139 | * @used: other alternate-C function availability | 137 | * @used: other alternate-C function availability |
| 140 | * @reg_index: PRCM GPIOCR register index used to control the function | 138 | * @reg_index: PRCM GPIOCR register index used to control the function |
| 141 | * @control_bit: PRCM GPIOCR bit used to control the function | 139 | * @control_bit: PRCM GPIOCR bit used to control the function |
| @@ -147,7 +145,7 @@ struct prcm_gpiocr_altcx { · 5 unmodified lines | |||
| 147 | } __packed; | 145 | } __packed; |
| 148 | 146 | ||
| 149 | /** | 147 | /** |
| 150 | * struct prcm_gpio_altcx_pin_desc - Other alternate-C pin | 148 | * struct prcm_gpiocr_altcx_pin_desc - Other alternate-C pin |
| 151 | * @pin: The pin number | 149 | * @pin: The pin number |
| 152 | * @altcx: array of other alternate-C[1-4] functions | 150 | * @altcx: array of other alternate-C[1-4] functions |
| 153 | */ | 151 | */ |
| @@ -193,7 +191,7 @@ struct nmk_pingroup { · 39 unmodified lines | |||
| 193 | * numbering. | 191 | * numbering. |
| 194 | * @npins: The number of entries in @pins. | 192 | * @npins: The number of entries in @pins. |
| 195 | * @functions: The functions supported on this SoC. | 193 | * @functions: The functions supported on this SoC. |
| 196 | * @nfunction: The number of entries in @functions. | 194 | * @nfunctions: The number of entries in @functions. |
| 197 | * @groups: An array describing all pin groups the pin SoC supports. | 195 | * @groups: An array describing all pin groups the pin SoC supports. |
| 198 | * @ngroups: The number of entries in @groups. | 196 | * @ngroups: The number of entries in @groups. |
| 199 | * @altcx_pins: The pins that support Other alternate-C function on this SoC | 197 | * @altcx_pins: The pins that support Other alternate-C function on this SoC |
| @@ -9,10 +9,10 @@ · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | /** | 10 | /** |
| 11 | * struct timbgpio_platform_data - Platform data of the Timberdale GPIO driver | 11 | * struct timbgpio_platform_data - Platform data of the Timberdale GPIO driver |
| 12 | * @gpio_base The number of the first GPIO pin, set to -1 for | 12 | * @gpio_base: The number of the first GPIO pin, set to -1 for |
| 13 | * dynamic number allocation. | 13 | * dynamic number allocation. |
| 14 | * @nr_pins Number of pins that is supported by the hardware (1-32) | 14 | * @nr_pins: Number of pins that is supported by the hardware (1-32) |
| 15 | * @irq_base If IRQ is supported by the hardware, this is the base | 15 | * @irq_base: If IRQ is supported by the hardware, this is the base |
| 16 | * number of IRQ:s. One IRQ per pin will be used. Set to | 16 | * number of IRQ:s. One IRQ per pin will be used. Set to |
| 17 | * -1 if IRQ:s is not supported. | 17 | * -1 if IRQ:s is not supported. |
| 18 | */ | 18 | */ |