[RFD] gpiolib: gpiochip is always dangling after remove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Bamvor Jian Zhang <bamvor.zhangjian@xxxxxxxxxx>

In my gpiochip mockup driver, after call gpiochip_remove, the
gpipchip is not actually removed even if there is no clients in
userspace. It could be removed if remove the corresonding reference
count in this patch.

But such gpiochip will be removed even if user space open the
corresponding chardev. I am not sure If I do not right thing.
Please correct me if I am wrong.

Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@xxxxxxxxxx>
---
 drivers/gpio/gpiolib.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bc788b9..862b574 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -452,7 +452,6 @@ static void gpiodevice_release(struct device *dev)
 {
 	struct gpio_device *gdev = dev_get_drvdata(dev);
 
-	cdev_del(&gdev->chrdev);
 	list_del(&gdev->list);
 	ida_simple_remove(&gpio_ida, gdev->id);
 	kfree(gdev);
@@ -633,7 +632,6 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data)
 
 	/* From this point, the .release() function cleans up gpio_device */
 	gdev->dev.release = gpiodevice_release;
-	get_device(&gdev->dev);
 	pr_debug("%s: registered GPIOs %d to %d on device: %s (%s)\n",
 		 __func__, gdev->base, gdev->base + gdev->ngpio - 1,
 		 dev_name(&gdev->dev), chip->label ? : "generic");
@@ -713,12 +711,8 @@ void gpiochip_remove(struct gpio_chip *chip)
 		dev_crit(&gdev->dev,
 			 "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n");
 
-	/*
-	 * The gpiochip side puts its use of the device to rest here:
-	 * if there are no userspace clients, the chardev and device will
-	 * be removed, else it will be dangling until the last user is
-	 * gone.
-	 */
+	device_del(&gdev->dev);
+	cdev_del(&gdev->chrdev);
 	put_device(&gdev->dev);
 }
 EXPORT_SYMBOL_GPL(gpiochip_remove);
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux