From patchwork Fri Feb 26 13:06:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bamvor Zhang X-Patchwork-Id: 63043 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp706929lbc; Fri, 26 Feb 2016 05:06:55 -0800 (PST) X-Received: by 10.67.5.68 with SMTP id ck4mr1870511pad.3.1456492014898; Fri, 26 Feb 2016 05:06:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p84si19897337pfi.134.2016.02.26.05.06.54; Fri, 26 Feb 2016 05:06:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@gmail.com; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647AbcBZNGy (ORCPT + 4 others); Fri, 26 Feb 2016 08:06:54 -0500 Received: from mail-pf0-f171.google.com ([209.85.192.171]:32962 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbcBZNGx (ORCPT ); Fri, 26 Feb 2016 08:06:53 -0500 Received: by mail-pf0-f171.google.com with SMTP id q63so51993878pfb.0 for ; Fri, 26 Feb 2016 05:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=cR365SXQgT5isJ4DVqeZV5D8/csCOI9kDX077kHefPk=; b=iPbtiBXZOXeI6ldJoFTT/QYw2cK0MfB30nh4Ge+RiNgpFBw5VRo/yH7fkexI1LdodX 5Oq7pBoMxgGLwJQial6mj8B4hu5aZ2qdxwn0invZ4Tlo/poRdTJ0EhAzaXyEM/lNOOdR +qK7FP1+H8Qn3C+0XR2PVxqOlMzX7QbWSTyP0ad+JOsnwR3mEU80kPLOc3c/dR0ptnqp K+XhCuUIV0yPI+PPx+8Vs9Tv11Ixj3F6/6mLf0srps89jwTVDUcyyc38h15sdp9upLxj 6ZsTG4yR20XEZUkt6fsaHe+UM62cDptLGcK0PDASMDPNAh8O8de5MRrnxZXK3COkM95P 1C/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cR365SXQgT5isJ4DVqeZV5D8/csCOI9kDX077kHefPk=; b=IgvaVJGMMJG/a4CWG6HzDe7GPAdNtotl1XnAskL/ZsonP90IiB0i9edFptcenugD1i QxbFnT2vlFv5SaxoIz482fM0kaIAP2I7VKua3y7+tbcz6rX5uN19tC/VGz/j+xcRfCw5 +cpTcSakC+qVNqwO4MGzxmpY9w19u6CLAO83KvBzCtivbOkVP08JIyOFepgN4gTBpmsh SXV9oKQtFuiw1t0D54KJ9jm1D4prNrEOWyz0BpTbefIlg29e7LauqMjAiyQfF0wZgn+H jG15vm3OBwhMKfGXthvIRnbxYY5CFgZVOOh9DojKVUaS0IknlR3Ar7FmhMWGNKOhPoAH xp0Q== X-Gm-Message-State: AD7BkJKLgYVQq63lOq73TdKLIwz8paIg9BoUO/HuXYjp10PVuyYghGRsUI/CcNKXgDvO1g== X-Received: by 10.98.65.203 with SMTP id g72mr1037231pfd.138.1456492012624; Fri, 26 Feb 2016 05:06:52 -0800 (PST) Received: from linux-5iys.lan ([211.100.31.20]) by smtp.gmail.com with ESMTPSA id x1sm19452223pfi.42.2016.02.26.05.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Feb 2016 05:06:51 -0800 (PST) From: Bamvor Jian Zhang To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, broonie@kernel.org, Bamvor Jian Zhang Subject: [RFD] gpiolib: gpiochip is always dangling after remove Date: Fri, 26 Feb 2016 21:06:14 +0800 Message-Id: <1456491974-26997-1-git-send-email-bamv2005@gmail.com> X-Mailer: git-send-email 2.6.2 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Bamvor Jian Zhang 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 --- drivers/gpio/gpiolib.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);