Subject: [PATCH] spi/spi-fsl-spi: reference correct pdata in fsl_spi_cs_control

From: Herton Ronaldo Krzesinski <[email protected]>

Commit 178db7d3, "spi: Fix device unregistration when unregistering
the bus master", changed spi device initialization of dev.parent pointer
to be the master's device pointer instead of his parent.

This introduced a bug in spi-fsl-spi, since its usage of spi device
pointer was not updated accordingly. This was later fixed by commit
5039a86, "spi/mpc83xx: fix NULL pdata dereference bug", but it missed
another spot on fsl_spi_cs_control function where we also need to update
usage of spi device pointer. This change address that.

Cc: [email protected]
Signed-off-by: Herton Ronaldo Krzesinski <[email protected]>
---
drivers/spi/spi-fsl-spi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
index 5f748c0..6a62934 100644
--- a/drivers/spi/spi-fsl-spi.c
+++ b/drivers/spi/spi-fsl-spi.c
@@ -933,7 +933,7 @@ err:

static void fsl_spi_cs_control(struct spi_device *spi, bool on)
{
- struct device *dev = spi->dev.parent;
+ struct device *dev = spi->dev.parent->parent;
struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
u16 cs = spi->chip_select;
int gpio = pinfo->gpios[cs];
--
1.7.9.5


2012-05-13 09:22:30

by Joakim Tjernlund

[permalink] [raw]
Subject: Re: [PATCH] spi/spi-fsl-spi: reference correct pdata in fsl_spi_cs_control

"Herton R. Krzesinski" <[email protected]> wrote on 2012/05/12 00:29:50:
>
> From: Herton Ronaldo Krzesinski <[email protected]>
>
> Commit 178db7d3, "spi: Fix device unregistration when unregistering
> the bus master", changed spi device initialization of dev.parent pointer
> to be the master's device pointer instead of his parent.
>
> This introduced a bug in spi-fsl-spi, since its usage of spi device
> pointer was not updated accordingly. This was later fixed by commit
> 5039a86, "spi/mpc83xx: fix NULL pdata dereference bug", but it missed
> another spot on fsl_spi_cs_control function where we also need to update
> usage of spi device pointer. This change address that.
>
> Cc: [email protected]
> Signed-off-by: Herton Ronaldo Krzesinski <[email protected]>
> ---
> drivers/spi/spi-fsl-spi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
> index 5f748c0..6a62934 100644
> --- a/drivers/spi/spi-fsl-spi.c
> +++ b/drivers/spi/spi-fsl-spi.c
> @@ -933,7 +933,7 @@ err:
>
> static void fsl_spi_cs_control(struct spi_device *spi, bool on)
> {
> - struct device *dev = spi->dev.parent;
> + struct device *dev = spi->dev.parent->parent;
> struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
> u16 cs = spi->chip_select;
> int gpio = pinfo->gpios[cs];

So it seems
Acked-by: Joakim Tjernlund <[email protected]>

2012-05-20 05:12:34

by Grant Likely

[permalink] [raw]
Subject: Re: [PATCH] spi/spi-fsl-spi: reference correct pdata in fsl_spi_cs_control

On Sun, 13 May 2012 11:22:25 +0200, Joakim Tjernlund <[email protected]> wrote:
> "Herton R. Krzesinski" <[email protected]> wrote on 2012/05/12 00:29:50:
> >
> > From: Herton Ronaldo Krzesinski <[email protected]>
> >
> > Commit 178db7d3, "spi: Fix device unregistration when unregistering
> > the bus master", changed spi device initialization of dev.parent pointer
> > to be the master's device pointer instead of his parent.
> >
> > This introduced a bug in spi-fsl-spi, since its usage of spi device
> > pointer was not updated accordingly. This was later fixed by commit
> > 5039a86, "spi/mpc83xx: fix NULL pdata dereference bug", but it missed
> > another spot on fsl_spi_cs_control function where we also need to update
> > usage of spi device pointer. This change address that.
> >
> > Cc: [email protected]
> > Signed-off-by: Herton Ronaldo Krzesinski <[email protected]>
> > ---
> > drivers/spi/spi-fsl-spi.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
> > index 5f748c0..6a62934 100644
> > --- a/drivers/spi/spi-fsl-spi.c
> > +++ b/drivers/spi/spi-fsl-spi.c
> > @@ -933,7 +933,7 @@ err:
> >
> > static void fsl_spi_cs_control(struct spi_device *spi, bool on)
> > {
> > - struct device *dev = spi->dev.parent;
> > + struct device *dev = spi->dev.parent->parent;
> > struct mpc8xxx_spi_probe_info *pinfo = to_of_pinfo(dev->platform_data);
> > u16 cs = spi->chip_select;
> > int gpio = pinfo->gpios[cs];
>
> So it seems
> Acked-by: Joakim Tjernlund <[email protected]>
>

Applied, thanks.

g.


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