From: Bamvor Jian Zhang <bamv2005@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: linus.walleij@linaro.org, broonie@kernel.org,
Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
Subject: [RFD] gpiolib: gpiochip is always dangling after remove
Date: Fri, 26 Feb 2016 21:06:14 +0800 [thread overview]
Message-ID: <1456491974-26997-1-git-send-email-bamv2005@gmail.com> (raw)
From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
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@linaro.org>
---
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
next reply other threads:[~2016-02-26 13:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 13:06 Bamvor Jian Zhang [this message]
2016-02-26 14:05 ` [RFD] gpiolib: gpiochip is always dangling after remove Mark Brown
2016-02-27 3:08 ` Bamvor Zhang Jian
2016-03-08 8:53 ` Linus Walleij
2016-03-09 5:32 ` Bamvor Zhang Jian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456491974-26997-1-git-send-email-bamv2005@gmail.com \
--to=bamv2005@gmail.com \
--cc=bamvor.zhangjian@linaro.org \
--cc=broonie@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).