diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-05-08 22:42:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-05-08 22:42:59 -0400 |
commit | 41c64bb19c740b5433f768032ecaf05375c955ee (patch) | |
tree | c94507138f0019897faa032d707a0b5bb3cdf2ff | |
parent | a8a0811314db714ae23ab9f0ea707711a076bf18 (diff) | |
parent | d2d05c65c40e067ca5898399069053f095c67d6f (diff) |
Merge tag 'gpio-v4.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij:
"Here is a bunch of GPIO fixes that I collected since -rc1, nothing
controversial, nothing special:
- fix a memory leak for GPIO hotplug.
- fix a signedness bug in the ACPI GPIO pin validation.
- driver fixes: Qualcomm SPMI and OMAP MPUIO IRQ issues"
* tag 'gpio-v4.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: omap: Fix regression for MPUIO interrupts
gpio: sysfs: fix memory leaks and device hotplug
pinctrl: qcom-spmi-gpio: Fix input value report
pinctrl: qcom-spmi-gpio: Fix output type configuration
gpiolib: change gpio pin from unsigned to signed in acpi callback
-rw-r--r-- | drivers/gpio/gpio-omap.c | 48 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-acpi.c | 2 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-sysfs.c | 19 | ||||
-rw-r--r-- | drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 13 |
4 files changed, 36 insertions, 46 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index cd1d5bf48f36..b232397ad7ec 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -1054,38 +1054,8 @@ static void omap_gpio_mod_init(struct gpio_bank *bank) | |||
1054 | dev_err(bank->dev, "Could not get gpio dbck\n"); | 1054 | dev_err(bank->dev, "Could not get gpio dbck\n"); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | static void | ||
1058 | omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start, | ||
1059 | unsigned int num) | ||
1060 | { | ||
1061 | struct irq_chip_generic *gc; | ||
1062 | struct irq_chip_type *ct; | ||
1063 | |||
1064 | gc = irq_alloc_generic_chip("MPUIO", 1, irq_start, bank->base, | ||
1065 | handle_simple_irq); | ||
1066 | if (!gc) { | ||
1067 | dev_err(bank->dev, "Memory alloc failed for gc\n"); | ||
1068 | return; | ||
1069 | } | ||
1070 | |||
1071 | ct = gc->chip_types; | ||
1072 | |||
1073 | /* NOTE: No ack required, reading IRQ status clears it. */ | ||
1074 | ct->chip.irq_mask = irq_gc_mask_set_bit; | ||
1075 | ct->chip.irq_unmask = irq_gc_mask_clr_bit; | ||
1076 | ct->chip.irq_set_type = omap_gpio_irq_type; | ||
1077 | |||
1078 | if (bank->regs->wkup_en) | ||
1079 | ct->chip.irq_set_wake = omap_gpio_wake_enable; | ||
1080 | |||
1081 | ct->regs.mask = OMAP_MPUIO_GPIO_INT / bank->stride; | ||
1082 | irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, | ||
1083 | IRQ_NOREQUEST | IRQ_NOPROBE, 0); | ||
1084 | } | ||
1085 | |||
1086 | static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | 1057 | static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) |
1087 | { | 1058 | { |
1088 | int j; | ||
1089 | static int gpio; | 1059 | static int gpio; |
1090 | int irq_base = 0; | 1060 | int irq_base = 0; |
1091 | int ret; | 1061 | int ret; |
@@ -1132,6 +1102,15 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1132 | } | 1102 | } |
1133 | #endif | 1103 | #endif |
1134 | 1104 | ||
1105 | /* MPUIO is a bit different, reading IRQ status clears it */ | ||
1106 | if (bank->is_mpuio) { | ||
1107 | irqc->irq_ack = dummy_irq_chip.irq_ack; | ||
1108 | irqc->irq_mask = irq_gc_mask_set_bit; | ||
1109 | irqc->irq_unmask = irq_gc_mask_clr_bit; | ||
1110 | if (!bank->regs->wkup_en) | ||
1111 | irqc->irq_set_wake = NULL; | ||
1112 | } | ||
1113 | |||
1135 | ret = gpiochip_irqchip_add(&bank->chip, irqc, | 1114 | ret = gpiochip_irqchip_add(&bank->chip, irqc, |
1136 | irq_base, omap_gpio_irq_handler, | 1115 | irq_base, omap_gpio_irq_handler, |
1137 | IRQ_TYPE_NONE); | 1116 | IRQ_TYPE_NONE); |
@@ -1145,15 +1124,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) | |||
1145 | gpiochip_set_chained_irqchip(&bank->chip, irqc, | 1124 | gpiochip_set_chained_irqchip(&bank->chip, irqc, |
1146 | bank->irq, omap_gpio_irq_handler); | 1125 | bank->irq, omap_gpio_irq_handler); |
1147 | 1126 | ||
1148 | for (j = 0; j < bank->width; j++) { | ||
1149 | int irq = irq_find_mapping(bank->chip.irqdomain, j); | ||
1150 | if (bank->is_mpuio) { | ||
1151 | omap_mpuio_alloc_gc(bank, irq, bank->width); | ||
1152 | irq_set_chip_and_handler(irq, NULL, NULL); | ||
1153 | set_irq_flags(irq, 0); | ||
1154 | } | ||
1155 | } | ||
1156 | |||
1157 | return 0; | 1127 | return 0; |
1158 | } | 1128 | } |
1159 | 1129 | ||
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index d2303d50f561..725d16138b74 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c | |||
@@ -550,7 +550,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, | |||
550 | 550 | ||
551 | length = min(agpio->pin_table_length, (u16)(pin_index + bits)); | 551 | length = min(agpio->pin_table_length, (u16)(pin_index + bits)); |
552 | for (i = pin_index; i < length; ++i) { | 552 | for (i = pin_index; i < length; ++i) { |
553 | unsigned pin = agpio->pin_table[i]; | 553 | int pin = agpio->pin_table[i]; |
554 | struct acpi_gpio_connection *conn; | 554 | struct acpi_gpio_connection *conn; |
555 | struct gpio_desc *desc; | 555 | struct gpio_desc *desc; |
556 | bool found; | 556 | bool found; |
diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 7722ed53bd65..af3bc7a8033b 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c | |||
@@ -551,6 +551,7 @@ static struct class gpio_class = { | |||
551 | */ | 551 | */ |
552 | int gpiod_export(struct gpio_desc *desc, bool direction_may_change) | 552 | int gpiod_export(struct gpio_desc *desc, bool direction_may_change) |
553 | { | 553 | { |
554 | struct gpio_chip *chip; | ||
554 | unsigned long flags; | 555 | unsigned long flags; |
555 | int status; | 556 | int status; |
556 | const char *ioname = NULL; | 557 | const char *ioname = NULL; |
@@ -568,8 +569,16 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change) | |||
568 | return -EINVAL; | 569 | return -EINVAL; |
569 | } | 570 | } |
570 | 571 | ||
572 | chip = desc->chip; | ||
573 | |||
571 | mutex_lock(&sysfs_lock); | 574 | mutex_lock(&sysfs_lock); |
572 | 575 | ||
576 | /* check if chip is being removed */ | ||
577 | if (!chip || !chip->exported) { | ||
578 | status = -ENODEV; | ||
579 | goto fail_unlock; | ||
580 | } | ||
581 | |||
573 | spin_lock_irqsave(&gpio_lock, flags); | 582 | spin_lock_irqsave(&gpio_lock, flags); |
574 | if (!test_bit(FLAG_REQUESTED, &desc->flags) || | 583 | if (!test_bit(FLAG_REQUESTED, &desc->flags) || |
575 | test_bit(FLAG_EXPORT, &desc->flags)) { | 584 | test_bit(FLAG_EXPORT, &desc->flags)) { |
@@ -783,12 +792,15 @@ void gpiochip_unexport(struct gpio_chip *chip) | |||
783 | { | 792 | { |
784 | int status; | 793 | int status; |
785 | struct device *dev; | 794 | struct device *dev; |
795 | struct gpio_desc *desc; | ||
796 | unsigned int i; | ||
786 | 797 | ||
787 | mutex_lock(&sysfs_lock); | 798 | mutex_lock(&sysfs_lock); |
788 | dev = class_find_device(&gpio_class, NULL, chip, match_export); | 799 | dev = class_find_device(&gpio_class, NULL, chip, match_export); |
789 | if (dev) { | 800 | if (dev) { |
790 | put_device(dev); | 801 | put_device(dev); |
791 | device_unregister(dev); | 802 | device_unregister(dev); |
803 | /* prevent further gpiod exports */ | ||
792 | chip->exported = false; | 804 | chip->exported = false; |
793 | status = 0; | 805 | status = 0; |
794 | } else | 806 | } else |
@@ -797,6 +809,13 @@ void gpiochip_unexport(struct gpio_chip *chip) | |||
797 | 809 | ||
798 | if (status) | 810 | if (status) |
799 | chip_dbg(chip, "%s: status %d\n", __func__, status); | 811 | chip_dbg(chip, "%s: status %d\n", __func__, status); |
812 | |||
813 | /* unregister gpiod class devices owned by sysfs */ | ||
814 | for (i = 0; i < chip->ngpio; i++) { | ||
815 | desc = &chip->desc[i]; | ||
816 | if (test_and_clear_bit(FLAG_SYSFS, &desc->flags)) | ||
817 | gpiod_free(desc); | ||
818 | } | ||
800 | } | 819 | } |
801 | 820 | ||
802 | static int __init gpiolib_sysfs_init(void) | 821 | static int __init gpiolib_sysfs_init(void) |
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c index de684ca93b5a..ae4115e4b4ef 100644 --- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | |||
@@ -418,7 +418,7 @@ static int pmic_gpio_config_set(struct pinctrl_dev *pctldev, unsigned int pin, | |||
418 | return ret; | 418 | return ret; |
419 | 419 | ||
420 | val = pad->buffer_type << PMIC_GPIO_REG_OUT_TYPE_SHIFT; | 420 | val = pad->buffer_type << PMIC_GPIO_REG_OUT_TYPE_SHIFT; |
421 | val = pad->strength << PMIC_GPIO_REG_OUT_STRENGTH_SHIFT; | 421 | val |= pad->strength << PMIC_GPIO_REG_OUT_STRENGTH_SHIFT; |
422 | 422 | ||
423 | ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL, val); | 423 | ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL, val); |
424 | if (ret < 0) | 424 | if (ret < 0) |
@@ -467,12 +467,13 @@ static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev, | |||
467 | seq_puts(s, " ---"); | 467 | seq_puts(s, " ---"); |
468 | } else { | 468 | } else { |
469 | 469 | ||
470 | if (!pad->input_enabled) { | 470 | if (pad->input_enabled) { |
471 | ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS); | 471 | ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS); |
472 | if (!ret) { | 472 | if (ret < 0) |
473 | ret &= PMIC_MPP_REG_RT_STS_VAL_MASK; | 473 | return; |
474 | pad->out_value = ret; | 474 | |
475 | } | 475 | ret &= PMIC_MPP_REG_RT_STS_VAL_MASK; |
476 | pad->out_value = ret; | ||
476 | } | 477 | } |
477 | 478 | ||
478 | seq_printf(s, " %-4s", pad->output_enabled ? "out" : "in"); | 479 | seq_printf(s, " %-4s", pad->output_enabled ? "out" : "in"); |