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-v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio

Pull GPIO fixes from Linus Walleij:
"Some GPIO fixes, most of them for the PCA953x that Andy worked hard to
fix up.

- Fix two runtime PM errorpath problems in the Arizona GPIO driver.

- Fix three interrupt issues in the PCA953x driver.

- Fix the automatic address increment handling in the PCA953x driver
again.

- Add a quirk to the PCA953x that fixes a problem in the Intel
Galileo Gen 2"

* tag 'gpio-v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: pca953x: Fix GPIO resource leak on Intel Galileo Gen 2
gpio: pca953x: disable regmap locking for automatic address incrementing
gpio: pca953x: Fix direction setting when configure an IRQ
gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2
gpio: pca953x: Synchronize interrupt handler properly
gpio: arizona: put pm_runtime in case of failure
gpio: arizona: handle pm_runtime_get_sync failure case

+100 -6
+6 -1
drivers/gpio/gpio-arizona.c
··· 64 64 ret = pm_runtime_get_sync(chip->parent); 65 65 if (ret < 0) { 66 66 dev_err(chip->parent, "Failed to resume: %d\n", ret); 67 + pm_runtime_put_autosuspend(chip->parent); 67 68 return ret; 68 69 } 69 70 ··· 73 72 if (ret < 0) { 74 73 dev_err(chip->parent, "Failed to drop cache: %d\n", 75 74 ret); 75 + pm_runtime_put_autosuspend(chip->parent); 76 76 return ret; 77 77 } 78 78 79 79 ret = regmap_read(arizona->regmap, reg, &val); 80 - if (ret < 0) 80 + if (ret < 0) { 81 + pm_runtime_put_autosuspend(chip->parent); 81 82 return ret; 83 + } 82 84 83 85 pm_runtime_mark_last_busy(chip->parent); 84 86 pm_runtime_put_autosuspend(chip->parent); ··· 110 106 ret = pm_runtime_get_sync(chip->parent); 111 107 if (ret < 0) { 112 108 dev_err(chip->parent, "Failed to resume: %d\n", ret); 109 + pm_runtime_put(chip->parent); 113 110 return ret; 114 111 } 115 112 }
+94 -5
drivers/gpio/gpio-pca953x.c
··· 107 107 }; 108 108 MODULE_DEVICE_TABLE(i2c, pca953x_id); 109 109 110 + #ifdef CONFIG_GPIO_PCA953X_IRQ 111 + 112 + #include <linux/dmi.h> 113 + #include <linux/gpio.h> 114 + #include <linux/list.h> 115 + 116 + static const struct dmi_system_id pca953x_dmi_acpi_irq_info[] = { 117 + { 118 + /* 119 + * On Intel Galileo Gen 2 board the IRQ pin of one of 120 + * the I²C GPIO expanders, which has GpioInt() resource, 121 + * is provided as an absolute number instead of being 122 + * relative. Since first controller (gpio-sch.c) and 123 + * second (gpio-dwapb.c) are at the fixed bases, we may 124 + * safely refer to the number in the global space to get 125 + * an IRQ out of it. 126 + */ 127 + .matches = { 128 + DMI_EXACT_MATCH(DMI_BOARD_NAME, "GalileoGen2"), 129 + }, 130 + }, 131 + {} 132 + }; 133 + 134 + #ifdef CONFIG_ACPI 135 + static int pca953x_acpi_get_pin(struct acpi_resource *ares, void *data) 136 + { 137 + struct acpi_resource_gpio *agpio; 138 + int *pin = data; 139 + 140 + if (acpi_gpio_get_irq_resource(ares, &agpio)) 141 + *pin = agpio->pin_table[0]; 142 + return 1; 143 + } 144 + 145 + static int pca953x_acpi_find_pin(struct device *dev) 146 + { 147 + struct acpi_device *adev = ACPI_COMPANION(dev); 148 + int pin = -ENOENT, ret; 149 + LIST_HEAD(r); 150 + 151 + ret = acpi_dev_get_resources(adev, &r, pca953x_acpi_get_pin, &pin); 152 + acpi_dev_free_resource_list(&r); 153 + if (ret < 0) 154 + return ret; 155 + 156 + return pin; 157 + } 158 + #else 159 + static inline int pca953x_acpi_find_pin(struct device *dev) { return -ENXIO; } 160 + #endif 161 + 162 + static int pca953x_acpi_get_irq(struct device *dev) 163 + { 164 + int pin, ret; 165 + 166 + pin = pca953x_acpi_find_pin(dev); 167 + if (pin < 0) 168 + return pin; 169 + 170 + dev_info(dev, "Applying ACPI interrupt quirk (GPIO %d)\n", pin); 171 + 172 + if (!gpio_is_valid(pin)) 173 + return -EINVAL; 174 + 175 + ret = gpio_request(pin, "pca953x interrupt"); 176 + if (ret) 177 + return ret; 178 + 179 + ret = gpio_to_irq(pin); 180 + 181 + /* When pin is used as an IRQ, no need to keep it requested */ 182 + gpio_free(pin); 183 + 184 + return ret; 185 + } 186 + #endif 187 + 110 188 static const struct acpi_device_id pca953x_acpi_ids[] = { 111 189 { "INT3491", 16 | PCA953X_TYPE | PCA_LATCH_INT, }, 112 190 { } ··· 400 322 .writeable_reg = pca953x_writeable_register, 401 323 .volatile_reg = pca953x_volatile_register, 402 324 325 + .disable_locking = true, 403 326 .cache_type = REGCACHE_RBTREE, 404 327 .max_register = 0x7f, 405 328 }; ··· 702 623 DECLARE_BITMAP(reg_direction, MAX_LINE); 703 624 int level; 704 625 705 - pca953x_read_regs(chip, chip->regs->direction, reg_direction); 706 - 707 626 if (chip->driver_data & PCA_PCAL) { 708 627 /* Enable latch on interrupt-enabled inputs */ 709 628 pca953x_write_regs(chip, PCAL953X_IN_LATCH, chip->irq_mask); ··· 712 635 pca953x_write_regs(chip, PCAL953X_INT_MASK, irq_mask); 713 636 } 714 637 638 + /* Switch direction to input if needed */ 639 + pca953x_read_regs(chip, chip->regs->direction, reg_direction); 640 + 715 641 bitmap_or(irq_mask, chip->irq_trig_fall, chip->irq_trig_raise, gc->ngpio); 642 + bitmap_complement(reg_direction, reg_direction, gc->ngpio); 716 643 bitmap_and(irq_mask, irq_mask, reg_direction, gc->ngpio); 717 644 718 645 /* Look for any newly setup interrupt */ ··· 815 734 struct gpio_chip *gc = &chip->gpio_chip; 816 735 DECLARE_BITMAP(pending, MAX_LINE); 817 736 int level; 737 + bool ret; 818 738 819 - if (!pca953x_irq_pending(chip, pending)) 820 - return IRQ_NONE; 739 + mutex_lock(&chip->i2c_lock); 740 + ret = pca953x_irq_pending(chip, pending); 741 + mutex_unlock(&chip->i2c_lock); 821 742 822 743 for_each_set_bit(level, pending, gc->ngpio) 823 744 handle_nested_irq(irq_find_mapping(gc->irq.domain, level)); 824 745 825 - return IRQ_HANDLED; 746 + return IRQ_RETVAL(ret); 826 747 } 827 748 828 749 static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base) ··· 834 751 DECLARE_BITMAP(reg_direction, MAX_LINE); 835 752 DECLARE_BITMAP(irq_stat, MAX_LINE); 836 753 int ret; 754 + 755 + if (dmi_first_match(pca953x_dmi_acpi_irq_info)) { 756 + ret = pca953x_acpi_get_irq(&client->dev); 757 + if (ret > 0) 758 + client->irq = ret; 759 + } 837 760 838 761 if (!client->irq) 839 762 return 0;