From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Wanlong Gao <wanlong.gao@gmail.com>, Greg KH <gregkh@suse.de>,
linux-input@vger.kernel.org
Subject: Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
Date: Tue, 26 Jul 2011 09:29:59 +0800 [thread overview]
Message-ID: <4E2E1897.9020808@cn.fujitsu.com> (raw)
In-Reply-To: <20110725183746.GD6876@core.coreip.homeip.net>
On 07/26/2011 02:37 AM, Dmitry Torokhov wrote:
> On Mon, Jul 25, 2011 at 07:29:28PM +0100, Mark Brown wrote:
>> On Mon, Jul 25, 2011 at 11:19:16AM -0700, Dmitry Torokhov wrote:
>>
>>> Right, like i2c bus we could just have platform core clean up platform
>>> drvdata pointer after calling ->remove() and also if ->probe() errors
>>> out.
>>
>> I2C doesn't do this (at least not any more).
>>
>
> Sure does. See drivers/i2c/i2c-core.c::i2c_device_probe() and
> i2c_device_remove().
Yeah, I see it. Sure i2c does.
Let the Core to do the pointer's clean up is very good idea.
So, Dmitry, do you means this ?
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
drivers/base/platform.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6040717..349e71b 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -405,8 +405,21 @@ static int platform_drv_probe(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
+ int status;
- return drv->probe(dev);
+ if (!dev)
+ return 0;
+
+ if (!drv->probe)
+ return -ENODEV;
+
+ dev_dbg(_dev, "probe\n");
+
+ status = drv->probe(dev);
+ if (status)
+ platform_set_drvdata(dev, NULL);
+
+ return status;
}
static int platform_drv_probe_fail(struct device *_dev)
@@ -418,8 +431,21 @@ static int platform_drv_remove(struct device *_dev)
{
struct platform_driver *drv = to_platform_driver(_dev->driver);
struct platform_device *dev = to_platform_device(_dev);
+ int status;
+
+ if (!dev)
+ return 0;
+
+ if (drv->remove) {
+ dev_dbg(_dev, "remove\n");
+ status = drv->remove(dev);
+ } else {
+ status = 0;
+ }
+ if (status == 0)
+ platform_set_drvdata(dev, NULL);
- return drv->remove(dev);
+ return status;
}
static void platform_drv_shutdown(struct device *_dev)
--
1.7.6
--
Thanks
Best Regards
Wanlong Gao
next prev parent reply other threads:[~2011-07-26 1:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 15:34 [PATCH] drivers:input:set driver data to NULL for pcap_keys Wanlong Gao
2011-07-25 8:30 ` Dmitry Torokhov
2011-07-25 9:14 ` Wanlong Gao
2011-07-25 15:21 ` Greg KH
2011-07-25 15:34 ` Wanlong Gao
2011-07-25 18:19 ` Dmitry Torokhov
2011-07-25 18:29 ` Mark Brown
2011-07-25 18:37 ` Dmitry Torokhov
2011-07-26 1:29 ` Wanlong Gao [this message]
2011-07-26 4:39 ` Greg KH
2011-07-26 5:36 ` Wanlong Gao
2011-07-26 6:02 ` Greg KH
2011-07-26 6:25 ` Wanlong Gao
2011-07-26 6:45 ` Dmitry Torokhov
2011-07-26 16:41 ` Greg KH
2011-07-26 17:26 ` Dmitry Torokhov
2011-07-25 18:26 ` Mark Brown
2011-07-25 23:25 ` Greg KH
2011-07-26 8:54 ` Mark Brown
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=4E2E1897.9020808@cn.fujitsu.com \
--to=gaowanlong@cn.fujitsu.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@suse.de \
--cc=linux-input@vger.kernel.org \
--cc=wanlong.gao@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.