linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove
@ 2013-02-15 18:41 Doug Anderson
  2013-02-15 19:37 ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Anderson @ 2013-02-15 18:41 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Stephen Warren, Doug Anderson, Peter Korsgaard,
	Ben Dooks (embedded platforms),
	linux-i2c, linux-kernel

Stephen Warren pointed out as part of a code review of another mux
driver that there should be no need to have
"platform_set_drvdata(pdev, NULL)" in the remove function.  Get rid of
it in the i2c-mux-gpio driver.

See Stephen's comment at:
  http://www.gossamer-threads.com/lists/linux/kernel/1678627?do=post_view_threaded#1678627

Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/i2c/muxes/i2c-mux-gpio.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 9f50ef0..abc2e55a 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -250,7 +250,6 @@ static int i2c_mux_gpio_remove(struct platform_device *pdev)
 	for (i = 0; i < mux->data.n_gpios; i++)
 		gpio_free(mux->gpio_base + mux->data.gpios[i]);
 
-	platform_set_drvdata(pdev, NULL);
 	i2c_put_adapter(mux->parent);
 
 	return 0;
-- 
1.8.1


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

* Re: [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove
  2013-02-15 18:41 [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove Doug Anderson
@ 2013-02-15 19:37 ` Wolfram Sang
  2013-02-15 19:43   ` Doug Anderson
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2013-02-15 19:37 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Stephen Warren, Peter Korsgaard, Ben Dooks (embedded platforms),
	linux-i2c, linux-kernel

On Fri, Feb 15, 2013 at 10:41:22AM -0800, Doug Anderson wrote:
> Stephen Warren pointed out as part of a code review of another mux
> driver that there should be no need to have
> "platform_set_drvdata(pdev, NULL)" in the remove function.  Get rid of
> it in the i2c-mux-gpio driver.
> 
> See Stephen's comment at:
>   http://www.gossamer-threads.com/lists/linux/kernel/1678627?do=post_view_threaded#1678627
> 
> Signed-off-by: Doug Anderson <dianders@chromium.org>

I think we should do this at least I2C subsystem wide (51 occasions of
setting some *_drvdata to NULL), even better kernel-wide. Patching
individual drivers won't cut the confusion around this issue, I am
afraid.

Thanks,

   Wolfram


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

* Re: [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove
  2013-02-15 19:37 ` Wolfram Sang
@ 2013-02-15 19:43   ` Doug Anderson
  2013-02-15 19:53     ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Anderson @ 2013-02-15 19:43 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Stephen Warren, Peter Korsgaard, Ben Dooks (embedded platforms),
	linux-i2c, linux-kernel

Wolfram,

On Fri, Feb 15, 2013 at 11:37 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> I think we should do this at least I2C subsystem wide (51 occasions of
> setting some *_drvdata to NULL), even better kernel-wide. Patching
> individual drivers won't cut the confusion around this issue, I am
> afraid.

I did it "mux" directory wide and this was the only instance.  ;)
I'll re-send with I2C subsystem wide.  I probably won't attempt the
whole kernel wide at this point, but would be very happy if someone
else wanted to!  :)

Thanks for the review!

-Doug

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

* Re: [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove
  2013-02-15 19:43   ` Doug Anderson
@ 2013-02-15 19:53     ` Wolfram Sang
  2013-02-15 23:17       ` Doug Anderson
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2013-02-15 19:53 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Stephen Warren, Peter Korsgaard, Ben Dooks (embedded platforms),
	linux-i2c, linux-kernel


> I'll re-send with I2C subsystem wide.  I probably won't attempt the
> whole kernel wide at this point, but would be very happy if someone
> else wanted to!  :)

Thanks. Please double check that setting NULL is really unneeded for the
non-platform-bus variants, too, or skip those if you are unsure. Please
also update the commit message to reference a stronger indication than
Stephen's "should not be necessary" ;) I do agree but for the commit
history, a better reference would be nice to educate readers.

Thanks,

   Wolfram


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

* Re: [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove
  2013-02-15 19:53     ` Wolfram Sang
@ 2013-02-15 23:17       ` Doug Anderson
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Anderson @ 2013-02-15 23:17 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Stephen Warren, Peter Korsgaard, Ben Dooks (embedded platforms),
	linux-i2c, linux-kernel

Wolfram,

On Fri, Feb 15, 2013 at 11:53 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
>
>> I'll re-send with I2C subsystem wide.  I probably won't attempt the
>> whole kernel wide at this point, but would be very happy if someone
>> else wanted to!  :)
>
> Thanks. Please double check that setting NULL is really unneeded for the
> non-platform-bus variants, too, or skip those if you are unsure. Please
> also update the commit message to reference a stronger indication than
> Stephen's "should not be necessary" ;) I do agree but for the commit
> history, a better reference would be nice to educate readers.

Sounds good.

I've it looks like non-platform-bus instances in drivers/i2c break down to:
* dev_set_drvdata() directly (even though we're a platform device)
* pci_set_drvdata()
* amba_set_drvdata()
* serio_set_drvdata()

I'll go ahead and include those in my patch.  I've looked through the
code a bit.  While I can't 100% guarantee that there's not some
strange code path that I'm missing, it all looks pretty
straightforward.  A few points to be made:

* It would be a bit hard to believe that some higher-level code could
make any particular assumptions about the value in the pointer (it
might point to static data, kmalloced data, etc).  ...so if the
higher-level code is directly looking at this value it'd really could
only be looking to validate that the driver put NULL here.  I don't
see that anywhere.

* I've checked all of the calls to xxx_get_drvdata() in the drivers
touched.  The majority are in remove, suspend, or resume, so we're
good there.  In other cases I just validated that they aren't checking
for and relying on a NULL result of xxx_get_drvdata().

* It would be possible that some subsystem tries to be helpful and
call xxx_get_drvdata() for you and then pass drvdata into a callback
(so I wouldn't see xxx_get_drvdata()).  I don't see that (it would be
a strange design anyway IMHO).  Most of the time I2C devices seem to
get their private data from adap->algo_data anyway (or from the
pointer passed to IRQ registration) and xxx_set_drvdata() doesn't
touch those.

* The __device_release_driver() function actually calls the
"dev_set_drvdata(dev, NULL)" for you anyway.  ...and I that's what's
running the remove code anyway.  ...so we'd only need to worry about
code that could show up before that...


-Doug

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

end of thread, other threads:[~2013-02-15 23:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 18:41 [PATCH] i2c: mux: Remove unneeded platform_set_drvdata to NULL in remove Doug Anderson
2013-02-15 19:37 ` Wolfram Sang
2013-02-15 19:43   ` Doug Anderson
2013-02-15 19:53     ` Wolfram Sang
2013-02-15 23:17       ` Doug Anderson

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