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

Pull GPIO fixes from Linus Walleij:
"A new bunch of GPIO fixes for v4.7.

This time I am very grateful that Ricardo Ribalda Delgado went in and
fixed my stupid refcounting mistakes in the removal path for GPIO
chips. I had a feeling something was wrong here and so it was. It
exploded on OMAP and it fixes their problem. Now it should be (more)
solid.

The rest i compilation, Kconfig and driver fixes. Some tagged for
stable.

Summary:

- Fix a NULL pointer dereference when we are searching the GPIO
device list but one of the devices have been removed (struct
gpio_chip pointer is NULL).

- Fix unaligned reference counters: we were ending on +3 after all
said and done. It should be 0. Remove an extraneous get_device(),
and call cdev_del() followed by device_del() in gpiochip_remove()
instead and the count goes to zero and calls the release() function
properly.

- Fix a compile warning due to a missing #include in the OF/device
tree portions.

- Select ANON_INODES for GPIOLIB, we're using that for our character
device. Some randconfig tests disclosed the problem.

- Make sure the Zynq driver clock runs also without CONFIG_PM enabled

- Fix an off-by-one error in the 104-DIO-48E driver

- Fix warnings in bcm_kona_gpio_reset()"

* tag 'gpio-v4.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
gpio: bcm-kona: fix bcm_kona_gpio_reset() warnings
gpio: select ANON_INODES
gpio: include <linux/io-mapping.h> in gpiolib-of
gpiolib: Fix unaligned used of reference counters
gpiolib: Fix NULL pointer deference
gpio: zynq: initialize clock even without CONFIG_PM
gpio: 104-dio-48e: Fix control port offset computation off-by-one error

+16 -7
+1
drivers/gpio/Kconfig
··· 33 33 34 34 menuconfig GPIOLIB 35 35 bool "GPIO Support" 36 + select ANON_INODES 36 37 help 37 38 This enables GPIO support through the generic GPIO library. 38 39 You only need to enable this, if you also want to enable
+2 -2
drivers/gpio/gpio-104-dio-48e.c
··· 75 75 { 76 76 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 77 77 const unsigned io_port = offset / 8; 78 - const unsigned control_port = io_port / 2; 78 + const unsigned int control_port = io_port / 3; 79 79 const unsigned control_addr = dio48egpio->base + 3 + control_port*4; 80 80 unsigned long flags; 81 81 unsigned control; ··· 115 115 { 116 116 struct dio48e_gpio *const dio48egpio = gpiochip_get_data(chip); 117 117 const unsigned io_port = offset / 8; 118 - const unsigned control_port = io_port / 2; 118 + const unsigned int control_port = io_port / 3; 119 119 const unsigned mask = BIT(offset % 8); 120 120 const unsigned control_addr = dio48egpio->base + 3 + control_port*4; 121 121 const unsigned out_port = (io_port > 2) ? io_port + 1 : io_port;
+2 -2
drivers/gpio/gpio-bcm-kona.c
··· 547 547 /* disable interrupts and clear status */ 548 548 for (i = 0; i < kona_gpio->num_bank; i++) { 549 549 /* Unlock the entire bank first */ 550 - bcm_kona_gpio_write_lock_regs(kona_gpio, i, UNLOCK_CODE); 550 + bcm_kona_gpio_write_lock_regs(reg_base, i, UNLOCK_CODE); 551 551 writel(0xffffffff, reg_base + GPIO_INT_MASK(i)); 552 552 writel(0xffffffff, reg_base + GPIO_INT_STATUS(i)); 553 553 /* Now re-lock the bank */ 554 - bcm_kona_gpio_write_lock_regs(kona_gpio, i, LOCK_CODE); 554 + bcm_kona_gpio_write_lock_regs(reg_base, i, LOCK_CODE); 555 555 } 556 556 } 557 557
+7
drivers/gpio/gpio-zynq.c
··· 709 709 dev_err(&pdev->dev, "input clock not found.\n"); 710 710 return PTR_ERR(gpio->clk); 711 711 } 712 + ret = clk_prepare_enable(gpio->clk); 713 + if (ret) { 714 + dev_err(&pdev->dev, "Unable to enable clock.\n"); 715 + return ret; 716 + } 712 717 718 + pm_runtime_set_active(&pdev->dev); 713 719 pm_runtime_enable(&pdev->dev); 714 720 ret = pm_runtime_get_sync(&pdev->dev); 715 721 if (ret < 0) ··· 753 747 pm_runtime_put(&pdev->dev); 754 748 err_pm_dis: 755 749 pm_runtime_disable(&pdev->dev); 750 + clk_disable_unprepare(gpio->clk); 756 751 757 752 return ret; 758 753 }
+1
drivers/gpio/gpiolib-of.c
··· 16 16 #include <linux/errno.h> 17 17 #include <linux/module.h> 18 18 #include <linux/io.h> 19 + #include <linux/io-mapping.h> 19 20 #include <linux/gpio/consumer.h> 20 21 #include <linux/of.h> 21 22 #include <linux/of_address.h>
+3 -3
drivers/gpio/gpiolib.c
··· 449 449 { 450 450 struct gpio_device *gdev = dev_get_drvdata(dev); 451 451 452 - cdev_del(&gdev->chrdev); 453 452 list_del(&gdev->list); 454 453 ida_simple_remove(&gpio_ida, gdev->id); 455 454 kfree(gdev->label); ··· 481 482 482 483 /* From this point, the .release() function cleans up gpio_device */ 483 484 gdev->dev.release = gpiodevice_release; 484 - get_device(&gdev->dev); 485 485 pr_debug("%s: registered GPIOs %d to %d on device: %s (%s)\n", 486 486 __func__, gdev->base, gdev->base + gdev->ngpio - 1, 487 487 dev_name(&gdev->dev), gdev->chip->label ? : "generic"); ··· 768 770 * be removed, else it will be dangling until the last user is 769 771 * gone. 770 772 */ 773 + cdev_del(&gdev->chrdev); 774 + device_del(&gdev->dev); 771 775 put_device(&gdev->dev); 772 776 } 773 777 EXPORT_SYMBOL_GPL(gpiochip_remove); ··· 869 869 870 870 spin_lock_irqsave(&gpio_lock, flags); 871 871 list_for_each_entry(gdev, &gpio_devices, list) 872 - if (match(gdev->chip, data)) 872 + if (gdev->chip && match(gdev->chip, data)) 873 873 break; 874 874 875 875 /* No match? */