linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SPI: Fix unregistering of the SPI master and SPI devices
@ 2011-01-17 16:00 Guennadi Liakhovetski
       [not found] ` <Pine.LNX.4.64.1101171659550.16051-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2011-01-17 16:00 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

The actual SPI master device instance and SPI devices on the bus are all
children of the same parent, typically, the SPI host platform device. Not
taking this into consideration leads to SPI devices never being unregistered.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
---
 drivers/spi/spi.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 34bb17f..0fa6c6c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -636,9 +636,13 @@ done:
 EXPORT_SYMBOL_GPL(spi_register_master);
 
 
-static int __unregister(struct device *dev, void *null)
+static int __unregister(struct device *dev, void *data)
 {
-	spi_unregister_device(to_spi_device(dev));
+	struct spi_master *master = data;
+
+	if (&master->dev != dev)
+		spi_unregister_device(to_spi_device(dev));
+
 	return 0;
 }
 
@@ -660,7 +664,7 @@ void spi_unregister_master(struct spi_master *master)
 	list_del(&master->list);
 	mutex_unlock(&board_lock);
 
-	dummy = device_for_each_child(&master->dev, NULL, __unregister);
+	dummy = device_for_each_child(master->dev.parent, master, __unregister);
 	device_unregister(&master->dev);
 }
 EXPORT_SYMBOL_GPL(spi_unregister_master);
-- 
1.7.2.3


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl

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

* Re: [PATCH] SPI: Fix unregistering of the SPI master and SPI devices
       [not found] ` <Pine.LNX.4.64.1101171659550.16051-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
@ 2011-01-17 17:12   ` Grant Likely
       [not found]     ` <AANLkTinufhbNoAkozt2-xf7Nnd4GAs77mYy9X2NxO8uV-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Grant Likely @ 2011-01-17 17:12 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, David Brownell

On Mon, Jan 17, 2011 at 9:00 AM, Guennadi Liakhovetski
<g.liakhovetski-Mmb7MZpHnFY@public.gmane.org> wrote:
> The actual SPI master device instance and SPI devices on the bus are all
> children of the same parent, typically, the SPI host platform device. Not
> taking this into consideration leads to SPI devices never being unregistered.

Conceptually, the fact that spi puts the master and the slaves at the
same level doesn't make very much sense to me.  I've been toying with
the idea of changing it so that the slaves become children of the
master.  It is conceivable that a single device would contain two or
more spi master instances, so it would be wise to separate the slave
instances from each other.

David, what's the reasoning for making slaves and the master peers?

g.

>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
> ---
>  drivers/spi/spi.c |   10 +++++++---
>  1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 34bb17f..0fa6c6c 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -636,9 +636,13 @@ done:
>  EXPORT_SYMBOL_GPL(spi_register_master);
>
>
> -static int __unregister(struct device *dev, void *null)
> +static int __unregister(struct device *dev, void *data)
>  {
> -       spi_unregister_device(to_spi_device(dev));
> +       struct spi_master *master = data;
> +
> +       if (&master->dev != dev)
> +               spi_unregister_device(to_spi_device(dev));
> +
>        return 0;
>  }
>
> @@ -660,7 +664,7 @@ void spi_unregister_master(struct spi_master *master)
>        list_del(&master->list);
>        mutex_unlock(&board_lock);
>
> -       dummy = device_for_each_child(&master->dev, NULL, __unregister);
> +       dummy = device_for_each_child(master->dev.parent, master, __unregister);
>        device_unregister(&master->dev);
>  }
>  EXPORT_SYMBOL_GPL(spi_unregister_master);
> --
> 1.7.2.3
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl

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

* Re: [PATCH] SPI: Fix unregistering of the SPI master and SPI devices
       [not found]     ` <AANLkTinufhbNoAkozt2-xf7Nnd4GAs77mYy9X2NxO8uV-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-09-02 13:37       ` Guennadi Liakhovetski
  0 siblings, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2011-09-02 13:37 UTC (permalink / raw)
  To: Grant Likely
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, David Brownell

Hi all

On Mon, 17 Jan 2011, Grant Likely wrote:

> On Mon, Jan 17, 2011 at 9:00 AM, Guennadi Liakhovetski
> <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org> wrote:
> > The actual SPI master device instance and SPI devices on the bus are all
> > children of the same parent, typically, the SPI host platform device. Not
> > taking this into consideration leads to SPI devices never being unregistered.
> 
> Conceptually, the fact that spi puts the master and the slaves at the
> same level doesn't make very much sense to me.  I've been toying with
> the idea of changing it so that the slaves become children of the
> master.  It is conceivable that a single device would contain two or
> more spi master instances, so it would be wise to separate the slave
> instances from each other.
> 
> David, what's the reasoning for making slaves and the master peers?

The bug is still there, can we kill it, please?

Thanks
Guennadi

> 
> g.
> 
> >
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
> > ---
> >  drivers/spi/spi.c |   10 +++++++---
> >  1 files changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> > index 34bb17f..0fa6c6c 100644
> > --- a/drivers/spi/spi.c
> > +++ b/drivers/spi/spi.c
> > @@ -636,9 +636,13 @@ done:
> >  EXPORT_SYMBOL_GPL(spi_register_master);
> >
> >
> > -static int __unregister(struct device *dev, void *null)
> > +static int __unregister(struct device *dev, void *data)
> >  {
> > -       spi_unregister_device(to_spi_device(dev));
> > +       struct spi_master *master = data;
> > +
> > +       if (&master->dev != dev)
> > +               spi_unregister_device(to_spi_device(dev));
> > +
> >        return 0;
> >  }
> >
> > @@ -660,7 +664,7 @@ void spi_unregister_master(struct spi_master *master)
> >        list_del(&master->list);
> >        mutex_unlock(&board_lock);
> >
> > -       dummy = device_for_each_child(&master->dev, NULL, __unregister);
> > +       dummy = device_for_each_child(master->dev.parent, master, __unregister);
> >        device_unregister(&master->dev);
> >  }
> >  EXPORT_SYMBOL_GPL(spi_unregister_master);
> > --
> > 1.7.2.3
> >
> >
> > ------------------------------------------------------------------------------
> > Protect Your Site and Customers from Malware Attacks
> > Learn about various malware tactics and how to avoid them. Understand
> > malware threats, the impact they can have on your business, and how you
> > can protect your company and customers by using code signing.
> > http://p.sf.net/sfu/oracle-sfdevnl
> > _______________________________________________
> > spi-devel-general mailing list
> > spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> > https://lists.sourceforge.net/lists/listinfo/spi-devel-general
> >
> 
> 
> 
> -- 
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev

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

end of thread, other threads:[~2011-09-02 13:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 16:00 [PATCH] SPI: Fix unregistering of the SPI master and SPI devices Guennadi Liakhovetski
     [not found] ` <Pine.LNX.4.64.1101171659550.16051-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2011-01-17 17:12   ` Grant Likely
     [not found]     ` <AANLkTinufhbNoAkozt2-xf7Nnd4GAs77mYy9X2NxO8uV-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-09-02 13:37       ` Guennadi Liakhovetski

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