These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / pinctrl / bcm / pinctrl-bcm2835.c
index 8d908e3..2e6ca69 100644 (file)
@@ -330,16 +330,6 @@ static inline void bcm2835_pinctrl_fsel_set(
        bcm2835_gpio_wr(pc, FSEL_REG(pin), val);
 }
 
-static int bcm2835_gpio_request(struct gpio_chip *chip, unsigned offset)
-{
-       return pinctrl_request_gpio(chip->base + offset);
-}
-
-static void bcm2835_gpio_free(struct gpio_chip *chip, unsigned offset)
-{
-       pinctrl_free_gpio(chip->base + offset);
-}
-
 static int bcm2835_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 {
        return pinctrl_gpio_direction_input(chip->base + offset);
@@ -352,12 +342,6 @@ static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset)
        return bcm2835_gpio_get_bit(pc, GPLEV0, offset);
 }
 
-static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
-               unsigned offset, int value)
-{
-       return pinctrl_gpio_direction_output(chip->base + offset);
-}
-
 static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
        struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev);
@@ -365,6 +349,13 @@ static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
        bcm2835_gpio_set_bit(pc, value ? GPSET0 : GPCLR0, offset);
 }
 
+static int bcm2835_gpio_direction_output(struct gpio_chip *chip,
+               unsigned offset, int value)
+{
+       bcm2835_gpio_set(chip, offset, value);
+       return pinctrl_gpio_direction_output(chip->base + offset);
+}
+
 static int bcm2835_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
        struct bcm2835_pinctrl *pc = dev_get_drvdata(chip->dev);
@@ -375,8 +366,8 @@ static int bcm2835_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 static struct gpio_chip bcm2835_gpio_chip = {
        .label = MODULE_NAME,
        .owner = THIS_MODULE,
-       .request = bcm2835_gpio_request,
-       .free = bcm2835_gpio_free,
+       .request = gpiochip_generic_request,
+       .free = gpiochip_generic_free,
        .direction_input = bcm2835_gpio_direction_input,
        .direction_output = bcm2835_gpio_direction_output,
        .get = bcm2835_gpio_get,
@@ -473,6 +464,8 @@ static void bcm2835_gpio_irq_disable(struct irq_data *data)
 
        spin_lock_irqsave(&pc->irq_lock[bank], flags);
        bcm2835_gpio_irq_config(pc, gpio, false);
+       /* Clear events that were latched prior to clearing event sources */
+       bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
        clear_bit(offset, &pc->enabled_irq_map[bank]);
        spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
 }
@@ -584,9 +577,9 @@ static int bcm2835_gpio_irq_set_type(struct irq_data *data, unsigned int type)
                ret = __bcm2835_gpio_irq_set_type_disabled(pc, gpio, type);
 
        if (type & IRQ_TYPE_EDGE_BOTH)
-               __irq_set_handler_locked(data->irq, handle_edge_irq);
+               irq_set_handler_locked(data, handle_edge_irq);
        else
-               __irq_set_handler_locked(data->irq, handle_level_irq);
+               irq_set_handler_locked(data, handle_level_irq);
 
        spin_unlock_irqrestore(&pc->irq_lock[bank], flags);
 
@@ -987,7 +980,6 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
                irq_set_chip_and_handler(irq, &bcm2835_gpio_irq_chip,
                                handle_level_irq);
                irq_set_chip_data(irq, pc);
-               set_irq_flags(irq, IRQF_VALID);
        }
 
        for (i = 0; i < BCM2835_NUM_BANKS; i++) {
@@ -1036,9 +1028,9 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
        }
 
        pc->pctl_dev = pinctrl_register(&bcm2835_pinctrl_desc, dev, pc);
-       if (!pc->pctl_dev) {
+       if (IS_ERR(pc->pctl_dev)) {
                gpiochip_remove(&pc->gpio_chip);
-               return -EINVAL;
+               return PTR_ERR(pc->pctl_dev);
        }
 
        pc->gpio_range = bcm2835_pinctrl_gpio_range;