* [PATCH] spi: erase pointer to drvdata on removal
@ 2012-11-01 18:05 Vivien Didelot
[not found] ` <1351793136-14126-1-git-send-email-vivien.didelot-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Vivien Didelot @ 2012-11-01 18:05 UTC (permalink / raw)
To: spi-devel-general; +Cc: Vivien Didelot, Grant Likely, linux-kernel
As for i2c-core, let the SPI core handle the removal of the device's
drvdata, after a remove() or a probe() failure.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
drivers/spi/spi.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 84c2861..fe636fe 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -233,15 +233,25 @@ EXPORT_SYMBOL_GPL(spi_bus_type);
static int spi_drv_probe(struct device *dev)
{
const struct spi_driver *sdrv = to_spi_driver(dev->driver);
+ struct spi_device *sdev = to_spi_device(dev);
+ int status;
- return sdrv->probe(to_spi_device(dev));
+ status = sdrv->probe(sdev);
+ if (status)
+ spi_set_drvdata(sdev, NULL);
+ return status;
}
static int spi_drv_remove(struct device *dev)
{
const struct spi_driver *sdrv = to_spi_driver(dev->driver);
+ struct spi_device *sdev = to_spi_device(dev);
+ int status;
- return sdrv->remove(to_spi_device(dev));
+ status = sdrv->remove(sdev);
+ if (status == 0)
+ spi_set_drvdata(sdev, NULL);
+ return status;
}
static void spi_drv_shutdown(struct device *dev)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: erase pointer to drvdata on removal
[not found] ` <1351793136-14126-1-git-send-email-vivien.didelot-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
@ 2013-01-14 2:51 ` Mark Brown
2013-01-14 20:11 ` Grant Likely
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2013-01-14 2:51 UTC (permalink / raw)
To: Vivien Didelot
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
On Thu, Nov 01, 2012 at 02:05:36PM -0400, Vivien Didelot wrote:
> As for i2c-core, let the SPI core handle the removal of the device's
> drvdata, after a remove() or a probe() failure.
Any driver that notices this change is buggy, the driver shouldn't
use a drvdata value that it didn't set. I had thought this stuff had
all been removed from I2C and either dropped or factored out into the
driver core...
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: erase pointer to drvdata on removal
2013-01-14 2:51 ` Mark Brown
@ 2013-01-14 20:11 ` Grant Likely
2013-01-14 21:24 ` Vivien Didelot
0 siblings, 1 reply; 4+ messages in thread
From: Grant Likely @ 2013-01-14 20:11 UTC (permalink / raw)
To: Mark Brown, Vivien Didelot; +Cc: spi-devel-general, linux-kernel
On Mon, 14 Jan 2013 02:51:45 +0000, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Thu, Nov 01, 2012 at 02:05:36PM -0400, Vivien Didelot wrote:
> > As for i2c-core, let the SPI core handle the removal of the device's
> > drvdata, after a remove() or a probe() failure.
>
> Any driver that notices this change is buggy, the driver shouldn't
> use a drvdata value that it didn't set. I had thought this stuff had
> all been removed from I2C and either dropped or factored out into the
> driver core...
Looks to me like __device_release_driver() in drivers/base/dd.c already
does this.
g.
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] spi: erase pointer to drvdata on removal
2013-01-14 20:11 ` Grant Likely
@ 2013-01-14 21:24 ` Vivien Didelot
0 siblings, 0 replies; 4+ messages in thread
From: Vivien Didelot @ 2013-01-14 21:24 UTC (permalink / raw)
To: Grant Likely; +Cc: spi-devel-general, linux-kernel, Mark Brown
Hi Mark, Grant,
> On Mon, 14 Jan 2013 02:51:45 +0000, Mark Brown
> <broonie@opensource.wolfsonmicro.com> wrote:
> > On Thu, Nov 01, 2012 at 02:05:36PM -0400, Vivien Didelot wrote:
> > > As for i2c-core, let the SPI core handle the removal of the
> > > device's
> > > drvdata, after a remove() or a probe() failure.
> >
> > Any driver that notices this change is buggy, the driver shouldn't
> > use a drvdata value that it didn't set. I had thought this stuff
> > had
> > all been removed from I2C and either dropped or factored out into
> > the
> > driver core...
>
> Looks to me like __device_release_driver() in drivers/base/dd.c
> already
> does this.
>
> g.
You are right, I figured this out after the resend of this patch, see my reply here:
https://lkml.org/lkml/2012/12/4/224
-Vivien
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-01-14 21:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-01 18:05 [PATCH] spi: erase pointer to drvdata on removal Vivien Didelot
[not found] ` <1351793136-14126-1-git-send-email-vivien.didelot-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2013-01-14 2:51 ` Mark Brown
2013-01-14 20:11 ` Grant Likely
2013-01-14 21:24 ` Vivien Didelot
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).