Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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()

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