linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers:input:set driver data to NULL for pcap_keys
@ 2011-07-20 15:34 Wanlong Gao
  2011-07-25  8:30 ` Dmitry Torokhov
  0 siblings, 1 reply; 19+ messages in thread
From: Wanlong Gao @ 2011-07-20 15:34 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, Wanlong Gao, Wanlong Gao

It's better to set the device's driver data to NULL
when remove it.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 drivers/input/misc/pcap_keys.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c
index 99335c2..6c670f5 100644
--- a/drivers/input/misc/pcap_keys.c
+++ b/drivers/input/misc/pcap_keys.c
@@ -114,6 +114,8 @@ static int __devexit pcap_keys_remove(struct platform_device *pdev)
 	input_unregister_device(pcap_keys->input);
 	kfree(pcap_keys);
 
+	platform_set_drvdata(pdev, NULL);
+
 	return 0;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  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
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2011-07-25  8:30 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: linux-input, Wanlong Gao

On Wed, Jul 20, 2011 at 11:34:28PM +0800, Wanlong Gao wrote:
> It's better to set the device's driver data to NULL
> when remove it.
> 

I'd rather have platform devices core clean up this pointer, then we
could stop caring about it in all drivers...

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25  8:30 ` Dmitry Torokhov
@ 2011-07-25  9:14   ` Wanlong Gao
  2011-07-25 15:21     ` Greg KH
  0 siblings, 1 reply; 19+ messages in thread
From: Wanlong Gao @ 2011-07-25  9:14 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Wanlong Gao, linux-input, gregkh

On 07/25/2011 04:30 PM, Dmitry Torokhov wrote:
> On Wed, Jul 20, 2011 at 11:34:28PM +0800, Wanlong Gao wrote:
>> It's better to set the device's driver data to NULL
>> when remove it.
>>
>
> I'd rather have platform devices core clean up this pointer, then we
> could stop caring about it in all drivers...
But the platform devices core just call the method of each own.
And don't care about the details like pdata, etc.

Meanwhile, I think the platform core need not care about these details.

and Greg, what do you think about this?

-- 
Thanks
Best Regards
Wanlong Gao

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  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:26       ` Mark Brown
  0 siblings, 2 replies; 19+ messages in thread
From: Greg KH @ 2011-07-25 15:21 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Dmitry Torokhov, Wanlong Gao, linux-input

On Mon, Jul 25, 2011 at 05:14:11PM +0800, Wanlong Gao wrote:
> On 07/25/2011 04:30 PM, Dmitry Torokhov wrote:
> >On Wed, Jul 20, 2011 at 11:34:28PM +0800, Wanlong Gao wrote:
> >>It's better to set the device's driver data to NULL
> >>when remove it.
> >>
> >
> >I'd rather have platform devices core clean up this pointer, then we
> >could stop caring about it in all drivers...
> But the platform devices core just call the method of each own.
> And don't care about the details like pdata, etc.
> 
> Meanwhile, I think the platform core need not care about these details.
> 
> and Greg, what do you think about this?

I don't understand what you are asking me.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  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:26       ` Mark Brown
  1 sibling, 1 reply; 19+ messages in thread
From: Wanlong Gao @ 2011-07-25 15:34 UTC (permalink / raw)
  To: Greg KH; +Cc: Wanlong Gao, Dmitry Torokhov, linux-input

On Mon, 2011-07-25 at 08:21 -0700, Greg KH wrote:
> On Mon, Jul 25, 2011 at 05:14:11PM +0800, Wanlong Gao wrote:
> > On 07/25/2011 04:30 PM, Dmitry Torokhov wrote:
> > >On Wed, Jul 20, 2011 at 11:34:28PM +0800, Wanlong Gao wrote:
> > >>It's better to set the device's driver data to NULL
> > >>when remove it.
> > >>
> > >
> > >I'd rather have platform devices core clean up this pointer, then we
> > >could stop caring about it in all drivers...
> > But the platform devices core just call the method of each own.
> > And don't care about the details like pdata, etc.
> > 
> > Meanwhile, I think the platform core need not care about these details.
> > 
> > and Greg, what do you think about this?
> 
> I don't understand what you are asking me.
Sorry, that's below:
firt for this patch:

> It's better to set the device's driver data to NULL
> when remove it.
> 
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  drivers/input/misc/pcap_keys.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/input/misc/pcap_keys.c
> b/drivers/input/misc/pcap_keys.c
> index 99335c2..6c670f5 100644
> --- a/drivers/input/misc/pcap_keys.c
> +++ b/drivers/input/misc/pcap_keys.c
> @@ -114,6 +114,8 @@ static int __devexit pcap_keys_remove(struct
> platform_device *pdev)
>         input_unregister_device(pcap_keys->input);
>         kfree(pcap_keys);
>  
> +       platform_set_drvdata(pdev, NULL);
> +
>         return 0;
>  }
> 
then, Dmitry said that:

> I'd rather have platform devices core clean up this pointer, then we
> could stop caring about it in all drivers...
> 

then I said:

> But the platform devices core just call the method of each own.
> And don't care about the details like pdata, etc.
> 
> Meanwhile, I think the platform core need not care about these
> details.
> 
> and Greg, what do you think about this?
> 
this is the thread, Greg, understand now?

For short, it's all about the platform driver data. Since many drivers
set the platform driver data to NULL when it is removed, then Dmitry
think it should be done in the platform driver core instead.
So, I asked you for this.

It's clear now?

Thanks a lot


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 15:34       ` Wanlong Gao
@ 2011-07-25 18:19         ` Dmitry Torokhov
  2011-07-25 18:29           ` Mark Brown
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2011-07-25 18:19 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Greg KH, Wanlong Gao, linux-input

On Mon, Jul 25, 2011 at 11:34:29PM +0800, Wanlong Gao wrote:
> > > On 07/25/2011 04:30 PM, Dmitry Torokhov wrote:
> 
> > I'd rather have platform devices core clean up this pointer, then we
> > could stop caring about it in all drivers...
> > 
> 
> then I said:
> 
> > But the platform devices core just call the method of each own.
> > And don't care about the details like pdata, etc.
> > 
> > Meanwhile, I think the platform core need not care about these
> > details.
> > 
> > and Greg, what do you think about this?
> > 
> this is the thread, Greg, understand now?
> 
> For short, it's all about the platform driver data. Since many drivers
> set the platform driver data to NULL when it is removed, then Dmitry
> think it should be done in the platform driver core instead.

Right, like i2c bus we could just have platform core clean up platform
drvdata pointer after calling ->remove() and also if ->probe() errors
out.

Then individual drivers do not have to care about cleaning up this
pointer.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 15:21     ` Greg KH
  2011-07-25 15:34       ` Wanlong Gao
@ 2011-07-25 18:26       ` Mark Brown
  2011-07-25 23:25         ` Greg KH
  1 sibling, 1 reply; 19+ messages in thread
From: Mark Brown @ 2011-07-25 18:26 UTC (permalink / raw)
  To: Greg KH; +Cc: Wanlong Gao, Dmitry Torokhov, Wanlong Gao, linux-input

On Mon, Jul 25, 2011 at 08:21:06AM -0700, Greg KH wrote:
> On Mon, Jul 25, 2011 at 05:14:11PM +0800, Wanlong Gao wrote:
> > On 07/25/2011 04:30 PM, Dmitry Torokhov wrote:

> > >I'd rather have platform devices core clean up this pointer, then we
> > >could stop caring about it in all drivers...

> > But the platform devices core just call the method of each own.
> > And don't care about the details like pdata, etc.

> > Meanwhile, I think the platform core need not care about these details.

> > and Greg, what do you think about this?

> I don't understand what you are asking me.

They're asking if drivers should set driver_data to NULL while
unbinding, which always struck me as a waste of time given that
nothing except a currently bound driver should be using driver_data.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 18:19         ` Dmitry Torokhov
@ 2011-07-25 18:29           ` Mark Brown
  2011-07-25 18:37             ` Dmitry Torokhov
  0 siblings, 1 reply; 19+ messages in thread
From: Mark Brown @ 2011-07-25 18:29 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Wanlong Gao, Greg KH, Wanlong Gao, linux-input

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).

> Then individual drivers do not have to care about cleaning up this
> pointer.

They don't have to worry about it anyway, the only thing that is allowed
to use the pointer is a currently bound driver and it's only allowed to
rely on is that while it's bound it'll get back the same driver_data
that it put in.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 18:29           ` Mark Brown
@ 2011-07-25 18:37             ` Dmitry Torokhov
  2011-07-26  1:29               ` Wanlong Gao
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2011-07-25 18:37 UTC (permalink / raw)
  To: Mark Brown; +Cc: Wanlong Gao, Greg KH, Wanlong Gao, linux-input

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().

> > Then individual drivers do not have to care about cleaning up this
> > pointer.
> 
> They don't have to worry about it anyway, the only thing that is allowed
> to use the pointer is a currently bound driver and it's only allowed to
> rely on is that while it's bound it'll get back the same driver_data
> that it put in.

Right, except that some people trying to use this pointers to pass
platform data to the driver... Resetting the pointer to NULL on unbind
will hopefully show them their mistake.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 18:26       ` Mark Brown
@ 2011-07-25 23:25         ` Greg KH
  2011-07-26  8:54           ` Mark Brown
  0 siblings, 1 reply; 19+ messages in thread
From: Greg KH @ 2011-07-25 23:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Wanlong Gao, Dmitry Torokhov, Wanlong Gao, linux-input

On Mon, Jul 25, 2011 at 07:26:28PM +0100, Mark Brown wrote:
> On Mon, Jul 25, 2011 at 08:21:06AM -0700, Greg KH wrote:
> > On Mon, Jul 25, 2011 at 05:14:11PM +0800, Wanlong Gao wrote:
> > > On 07/25/2011 04:30 PM, Dmitry Torokhov wrote:
> 
> > > >I'd rather have platform devices core clean up this pointer, then we
> > > >could stop caring about it in all drivers...
> 
> > > But the platform devices core just call the method of each own.
> > > And don't care about the details like pdata, etc.
> 
> > > Meanwhile, I think the platform core need not care about these details.
> 
> > > and Greg, what do you think about this?
> 
> > I don't understand what you are asking me.
> 
> They're asking if drivers should set driver_data to NULL while
> unbinding, which always struck me as a waste of time given that
> nothing except a currently bound driver should be using driver_data.

Yeah, it's not needed, as nothing should rely on that.  However it's
also not hurting anything either.

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 18:37             ` Dmitry Torokhov
@ 2011-07-26  1:29               ` Wanlong Gao
  2011-07-26  4:39                 ` Greg KH
  0 siblings, 1 reply; 19+ messages in thread
From: Wanlong Gao @ 2011-07-26  1:29 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Mark Brown, Wanlong Gao, Greg KH, linux-input

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

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26  1:29               ` Wanlong Gao
@ 2011-07-26  4:39                 ` Greg KH
  2011-07-26  5:36                   ` Wanlong Gao
  0 siblings, 1 reply; 19+ messages in thread
From: Greg KH @ 2011-07-26  4:39 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Dmitry Torokhov, Mark Brown, Wanlong Gao, linux-input

On Tue, Jul 26, 2011 at 09:29:59AM +0800, Wanlong Gao wrote:
> 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.

No it isn't.

> 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;

When would dev ever be NULL?  Wouldn't that be an error?

> +
> +	if (!drv->probe)
> +		return -ENODEV;

That's not a valid error for this.  And when would probe ever be NULL?

> +
> +	dev_dbg(_dev, "probe\n");

Why add this noise?

> +
> +	status = drv->probe(dev);
> +	if (status)
> +		platform_set_drvdata(dev, NULL);

No, not ok.

> +
> +	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;

Again, when would that ever happen?

> +
> +	if (drv->remove) {
> +		dev_dbg(_dev, "remove\n");
> +		status = drv->remove(dev);
> +	} else {
> +		status = 0;
> +	}

Again, why would remove ever be NULL?

This whole thing isn't needed at all.

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26  4:39                 ` Greg KH
@ 2011-07-26  5:36                   ` Wanlong Gao
  2011-07-26  6:02                     ` Greg KH
  0 siblings, 1 reply; 19+ messages in thread
From: Wanlong Gao @ 2011-07-26  5:36 UTC (permalink / raw)
  To: Greg KH; +Cc: Dmitry Torokhov, Mark Brown, Wanlong Gao, linux-input

On 07/26/2011 12:39 PM, Greg KH wrote:

>> +
>> +	if (drv->remove) {
>> +		dev_dbg(_dev, "remove\n");
>> +		status = drv->remove(dev);
>> +	} else {
>> +		status = 0;
>> +	}
>
> Again, why would remove ever be NULL?
>
> This whole thing isn't needed at all.
>
> greg k-h
Yeah, I see.

But Greg, why does i2c-core do this?
like:drivers/i2c/i2c-core.c:
static int i2c_device_remove(struct device *dev)
{
	struct i2c_client	*client = i2c_verify_client(dev);
	struct i2c_driver	*driver;
	int			status;

	if (!client || !dev->driver)
		return 0;

	driver = to_i2c_driver(dev->driver);
	if (driver->remove) {
		dev_dbg(dev, "remove\n");
		status = driver->remove(client);
	} else {
		dev->driver = NULL;
		status = 0;
	}
	if (status == 0) {
		client->driver = NULL;
		i2c_set_clientdata(client, NULL);
	}
	return status;
}

And now, I'm in a fog, can you clear me/us ?

-- 
Thanks
Best Regards
Wanlong Gao

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26  5:36                   ` Wanlong Gao
@ 2011-07-26  6:02                     ` Greg KH
  2011-07-26  6:25                       ` Wanlong Gao
  0 siblings, 1 reply; 19+ messages in thread
From: Greg KH @ 2011-07-26  6:02 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Dmitry Torokhov, Mark Brown, Wanlong Gao, linux-input

On Tue, Jul 26, 2011 at 01:36:00PM +0800, Wanlong Gao wrote:
> On 07/26/2011 12:39 PM, Greg KH wrote:
> 
> >>+
> >>+	if (drv->remove) {
> >>+		dev_dbg(_dev, "remove\n");
> >>+		status = drv->remove(dev);
> >>+	} else {
> >>+		status = 0;
> >>+	}
> >
> >Again, why would remove ever be NULL?
> >
> >This whole thing isn't needed at all.
> >
> >greg k-h
> Yeah, I see.
> 
> But Greg, why does i2c-core do this?
> like:drivers/i2c/i2c-core.c:

The i2c core has different requirements than the driver core does,
right?  They are two totally different things, please don't assume that
the rules for one are the same for the other.

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26  6:02                     ` Greg KH
@ 2011-07-26  6:25                       ` Wanlong Gao
  2011-07-26  6:45                         ` Dmitry Torokhov
  0 siblings, 1 reply; 19+ messages in thread
From: Wanlong Gao @ 2011-07-26  6:25 UTC (permalink / raw)
  To: Greg KH; +Cc: Dmitry Torokhov, Mark Brown, Wanlong Gao, linux-input

On 07/26/2011 02:02 PM, Greg KH wrote:
> On Tue, Jul 26, 2011 at 01:36:00PM +0800, Wanlong Gao wrote:
>> On 07/26/2011 12:39 PM, Greg KH wrote:
>>
>>>> +
>>>> +	if (drv->remove) {
>>>> +		dev_dbg(_dev, "remove\n");
>>>> +		status = drv->remove(dev);
>>>> +	} else {
>>>> +		status = 0;
>>>> +	}
>>>
>>> Again, why would remove ever be NULL?
>>>
>>> This whole thing isn't needed at all.
>>>
>>> greg k-h
>> Yeah, I see.
>>
>> But Greg, why does i2c-core do this?
>> like:drivers/i2c/i2c-core.c:
>
> The i2c core has different requirements than the driver core does,
> right?  They are two totally different things, please don't assume that
> the rules for one are the same for the other.
>
> greg k-h
>
Hmm...They are totally different things, maybe I see..


-- 
Thanks
Best Regards
Wanlong Gao

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26  6:25                       ` Wanlong Gao
@ 2011-07-26  6:45                         ` Dmitry Torokhov
  2011-07-26 16:41                           ` Greg KH
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2011-07-26  6:45 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: Greg KH, Mark Brown, Wanlong Gao, linux-input

On Tue, Jul 26, 2011 at 02:25:48PM +0800, Wanlong Gao wrote:
> On 07/26/2011 02:02 PM, Greg KH wrote:
> >On Tue, Jul 26, 2011 at 01:36:00PM +0800, Wanlong Gao wrote:
> >>On 07/26/2011 12:39 PM, Greg KH wrote:
> >>
> >>>>+
> >>>>+	if (drv->remove) {
> >>>>+		dev_dbg(_dev, "remove\n");
> >>>>+		status = drv->remove(dev);
> >>>>+	} else {
> >>>>+		status = 0;
> >>>>+	}
> >>>
> >>>Again, why would remove ever be NULL?
> >>>
> >>>This whole thing isn't needed at all.
> >>>
> >>>greg k-h
> >>Yeah, I see.
> >>
> >>But Greg, why does i2c-core do this?
> >>like:drivers/i2c/i2c-core.c:
> >
> >The i2c core has different requirements than the driver core does,
> >right?  They are two totally different things, please don't assume that
> >the rules for one are the same for the other.
> >
> >greg k-h
> >
> Hmm...They are totally different things, maybe I see..

Still, it would make sense to clean up platform device's drvdata
pointer, so that every platform driver out there does not have to do it
on its own.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-25 23:25         ` Greg KH
@ 2011-07-26  8:54           ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2011-07-26  8:54 UTC (permalink / raw)
  To: Greg KH; +Cc: Wanlong Gao, Dmitry Torokhov, Wanlong Gao, linux-input

On Mon, Jul 25, 2011 at 04:25:33PM -0700, Greg KH wrote:
> On Mon, Jul 25, 2011 at 07:26:28PM +0100, Mark Brown wrote:

> > They're asking if drivers should set driver_data to NULL while
> > unbinding, which always struck me as a waste of time given that
> > nothing except a currently bound driver should be using driver_data.

> Yeah, it's not needed, as nothing should rely on that.  However it's
> also not hurting anything either.

Every time I see it it always sets off a red flag, partly because we
shouldn't need to bother at all and partly because to the extent it's
valuable it's not something we should be doing on a driver by driver or
even subsystem by subsystem basis.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26  6:45                         ` Dmitry Torokhov
@ 2011-07-26 16:41                           ` Greg KH
  2011-07-26 17:26                             ` Dmitry Torokhov
  0 siblings, 1 reply; 19+ messages in thread
From: Greg KH @ 2011-07-26 16:41 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Wanlong Gao, Mark Brown, Wanlong Gao, linux-input

On Mon, Jul 25, 2011 at 11:45:20PM -0700, Dmitry Torokhov wrote:
> On Tue, Jul 26, 2011 at 02:25:48PM +0800, Wanlong Gao wrote:
> > On 07/26/2011 02:02 PM, Greg KH wrote:
> > >On Tue, Jul 26, 2011 at 01:36:00PM +0800, Wanlong Gao wrote:
> > >>On 07/26/2011 12:39 PM, Greg KH wrote:
> > >>
> > >>>>+
> > >>>>+	if (drv->remove) {
> > >>>>+		dev_dbg(_dev, "remove\n");
> > >>>>+		status = drv->remove(dev);
> > >>>>+	} else {
> > >>>>+		status = 0;
> > >>>>+	}
> > >>>
> > >>>Again, why would remove ever be NULL?
> > >>>
> > >>>This whole thing isn't needed at all.
> > >>>
> > >>>greg k-h
> > >>Yeah, I see.
> > >>
> > >>But Greg, why does i2c-core do this?
> > >>like:drivers/i2c/i2c-core.c:
> > >
> > >The i2c core has different requirements than the driver core does,
> > >right?  They are two totally different things, please don't assume that
> > >the rules for one are the same for the other.
> > >
> > >greg k-h
> > >
> > Hmm...They are totally different things, maybe I see..
> 
> Still, it would make sense to clean up platform device's drvdata
> pointer, so that every platform driver out there does not have to do it
> on its own.

Again, it shouldn't need to be "cleaned" up, as no one relies on it
being there.

greg k-h

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] drivers:input:set driver data to NULL for pcap_keys
  2011-07-26 16:41                           ` Greg KH
@ 2011-07-26 17:26                             ` Dmitry Torokhov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Torokhov @ 2011-07-26 17:26 UTC (permalink / raw)
  To: Greg KH; +Cc: Wanlong Gao, Mark Brown, Wanlong Gao, linux-input

On Tue, Jul 26, 2011 at 09:41:06AM -0700, Greg KH wrote:
> On Mon, Jul 25, 2011 at 11:45:20PM -0700, Dmitry Torokhov wrote:
> > On Tue, Jul 26, 2011 at 02:25:48PM +0800, Wanlong Gao wrote:
> > > On 07/26/2011 02:02 PM, Greg KH wrote:
> > > >On Tue, Jul 26, 2011 at 01:36:00PM +0800, Wanlong Gao wrote:
> > > >>On 07/26/2011 12:39 PM, Greg KH wrote:
> > > >>
> > > >>>>+
> > > >>>>+	if (drv->remove) {
> > > >>>>+		dev_dbg(_dev, "remove\n");
> > > >>>>+		status = drv->remove(dev);
> > > >>>>+	} else {
> > > >>>>+		status = 0;
> > > >>>>+	}
> > > >>>
> > > >>>Again, why would remove ever be NULL?
> > > >>>
> > > >>>This whole thing isn't needed at all.
> > > >>>
> > > >>>greg k-h
> > > >>Yeah, I see.
> > > >>
> > > >>But Greg, why does i2c-core do this?
> > > >>like:drivers/i2c/i2c-core.c:
> > > >
> > > >The i2c core has different requirements than the driver core does,
> > > >right?  They are two totally different things, please don't assume that
> > > >the rules for one are the same for the other.
> > > >
> > > >greg k-h
> > > >
> > > Hmm...They are totally different things, maybe I see..
> > 
> > Still, it would make sense to clean up platform device's drvdata
> > pointer, so that every platform driver out there does not have to do it
> > on its own.
> 
> Again, it shouldn't need to be "cleaned" up, as no one relies on it
> being there.

No one should rely on it being there however I came across quite a few
MFD patches that tried passing parent's data in that pointer. Hopefully
they are all cleaned now but we getting new drivers all the time...

If we had it in the platform bus code such uses would break even before
we get such drivers and we won't have to deal with them.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-07-26 17:26 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).