lkml.org 
[lkml]   [2016]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH/RFC v2 3/7] spi: core: Add support for registering SPI slave controllers
On Mon, Sep 12, 2016 at 10:50 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -1477,15 +1477,6 @@ static int of_spi_parse_dt(struct spi_master *master, struct spi_device *spi,

> @@ -1799,7 +1908,6 @@ struct spi_master *spi_alloc_master(struct device *dev, unsigned size)
> device_initialize(&master->dev);
> master->bus_num = -1;
> master->num_chipselect = 1;
> - master->dev.class = &spi_master_class;
> master->dev.parent = dev;
> pm_suspend_ignore_children(&master->dev, true);
> spi_master_set_devdata(master, &master[1]);
> @@ -1882,9 +1990,18 @@ int spi_register_master(struct spi_master *master)
> if (!dev)
> return -ENODEV;
>
> - status = of_spi_register_master(master);
> - if (status)
> - return status;
> + if (master->flags & SPI_CONTROLLER_IS_SLAVE) {
> + if (!IS_ENABLED(CONFIG_SPI_SLAVE))
> + return -ENOSYS;
> +
> + master->dev.class = &spi_slave_class;
> + } else {
> + master->dev.class = &spi_master_class;
> +
> + status = of_spi_register_master(master);
> + if (status)
> + return status;
> + }
>
> /* even if it's just one always-selected device, there must
> * be at least one chipselect

0day reported a warning during boot:

WARNING: CPU: 0 PID: 1 at drivers/base/core.c:251 device_release+0x7d/0x8a
Device '(null)' does not have a release() function, it is broken
and must be fixed.

This is caused by moving the setup of master->dev.class.
To fix this, I can
1) Introduce a separate spi_alloc_slave() function, which sets up
spi_slave_class instead of spi_master class,
OR
2) Keep the setup of spi_master_class in spi_alloc_master(), and override it
later. Both classes use the same dev_release method anyway.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2016-09-18 11:05    [W:0.200 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site