[PATCH 1/1] spi: initialize of_node in spi_alloc_master

Grant Likely grant.likely at secretlab.ca
Fri Oct 15 01:08:50 EST 2010


On Thu, Oct 14, 2010 at 2:37 AM, Jonas Bonn <jonas at southpole.se> wrote:
> spi_alloc_master should do the work of setting the of_node on the device if
> it is set on the incoming parent.
>
> Signed-off-by: Jonas Bonn <jonas at southpole.se>

Hi Jonas.

Thanks for the patch, but I have to nack it.  The way it is done right
now is by design.  Each spi bus driver is responsible to ensure that
the correct device tree node is used for the spi bus, which is not
necessarily the same node as the bus controller node (depending on the
binding).  The bus driver always needs the ability to use a different
node, or to omit OF registrations entirely.

Cheers,
g.

> ---
>  drivers/spi/mpc512x_psc_spi.c |    1 -
>  drivers/spi/mpc52xx_psc_spi.c |    1 -
>  drivers/spi/mpc52xx_spi.c     |    1 -
>  drivers/spi/spi.c             |    3 +++
>  drivers/spi/spi_mpc8xxx.c     |    1 -
>  drivers/spi/spi_ppc4xx.c      |    1 -
>  drivers/spi/xilinx_spi.c      |    3 ---
>  7 files changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/spi/mpc512x_psc_spi.c b/drivers/spi/mpc512x_psc_spi.c
> index 77d9e7e..1ab1807 100644
> --- a/drivers/spi/mpc512x_psc_spi.c
> +++ b/drivers/spi/mpc512x_psc_spi.c
> @@ -441,7 +441,6 @@ static int __devinit mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
>        master->setup = mpc512x_psc_spi_setup;
>        master->transfer = mpc512x_psc_spi_transfer;
>        master->cleanup = mpc512x_psc_spi_cleanup;
> -       master->dev.of_node = dev->of_node;
>
>        tempp = ioremap(regaddr, size);
>        if (!tempp) {
> diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
> index 983fbbf..44077f8 100644
> --- a/drivers/spi/mpc52xx_psc_spi.c
> +++ b/drivers/spi/mpc52xx_psc_spi.c
> @@ -398,7 +398,6 @@ static int __init mpc52xx_psc_spi_do_probe(struct device *dev, u32 regaddr,
>        master->setup = mpc52xx_psc_spi_setup;
>        master->transfer = mpc52xx_psc_spi_transfer;
>        master->cleanup = mpc52xx_psc_spi_cleanup;
> -       master->dev.of_node = dev->of_node;
>
>        mps->psc = ioremap(regaddr, size);
>        if (!mps->psc) {
> diff --git a/drivers/spi/mpc52xx_spi.c b/drivers/spi/mpc52xx_spi.c
> index ec9f0b1..b46dbd0 100644
> --- a/drivers/spi/mpc52xx_spi.c
> +++ b/drivers/spi/mpc52xx_spi.c
> @@ -438,7 +438,6 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op,
>        master->setup = mpc52xx_spi_setup;
>        master->transfer = mpc52xx_spi_transfer;
>        master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST;
> -       master->dev.of_node = op->dev.of_node;
>
>        dev_set_drvdata(&op->dev, master);
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index b5a78a1..28f9d1a 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -482,6 +482,9 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
>        device_initialize(&master->dev);
>        master->dev.class = &spi_master_class;
>        master->dev.parent = get_device(dev);
> +#ifdef CONFIG_OF
> +       master->dev.of_node = dev->of_node;
> +#endif
>        spi_master_set_devdata(master, &master[1]);
>
>        return master;
> diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
> index 1dd86b8..5a35741 100644
> --- a/drivers/spi/spi_mpc8xxx.c
> +++ b/drivers/spi/spi_mpc8xxx.c
> @@ -1014,7 +1014,6 @@ mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq)
>        master->setup = mpc8xxx_spi_setup;
>        master->transfer = mpc8xxx_spi_transfer;
>        master->cleanup = mpc8xxx_spi_cleanup;
> -       master->dev.of_node = dev->of_node;
>
>        mpc8xxx_spi = spi_master_get_devdata(master);
>        mpc8xxx_spi->dev = dev;
> diff --git a/drivers/spi/spi_ppc4xx.c b/drivers/spi/spi_ppc4xx.c
> index 80e172d..ca18432 100644
> --- a/drivers/spi/spi_ppc4xx.c
> +++ b/drivers/spi/spi_ppc4xx.c
> @@ -407,7 +407,6 @@ static int __init spi_ppc4xx_of_probe(struct platform_device *op,
>        master = spi_alloc_master(dev, sizeof *hw);
>        if (master == NULL)
>                return -ENOMEM;
> -       master->dev.of_node = np;
>        dev_set_drvdata(dev, master);
>        hw = spi_master_get_devdata(master);
>        hw->master = spi_master_get(master);
> diff --git a/drivers/spi/xilinx_spi.c b/drivers/spi/xilinx_spi.c
> index 80f2db5..1b47363 100644
> --- a/drivers/spi/xilinx_spi.c
> +++ b/drivers/spi/xilinx_spi.c
> @@ -390,9 +390,6 @@ struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
>
>        master->bus_num = bus_num;
>        master->num_chipselect = pdata->num_chipselect;
> -#ifdef CONFIG_OF
> -       master->dev.of_node = dev->of_node;
> -#endif
>
>        xspi->mem = *mem;
>        xspi->irq = irq;
> --
> 1.7.1
>
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss
>



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


More information about the devicetree-discuss mailing list