Message ID | E1f830e-0001Lz-Vf@debutante |
---|---|
State | Not Applicable |
Headers | show |
Series | Applied "spi: Check presence the of ->transfer[_xxx]() before registering a controller" to the spi tree | expand |
Hi Mark, On Mon, 16 Apr 2018 13:13:24 +0100 Mark Brown <broonie@kernel.org> wrote: > The patch > > spi: Check presence the of ->transfer[_xxx]() before registering a controller > > has been applied to the spi tree at > > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git > I can't find this patch in any of your spi branches. Has it been intentionally dropped, and if it was, do you remember why? Regards, Boris
On Thu, Apr 26, 2018 at 02:14:01PM +0200, Boris Brezillon wrote: > I can't find this patch in any of your spi branches. Has it been > intentionally dropped, and if it was, do you remember why? No, not dropped intentionally.
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 7b213faa0a2b..24369e437c6b 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2063,6 +2063,19 @@ static int of_spi_register_master(struct spi_controller *ctlr) } #endif +static int spi_controller_check_ops(struct spi_controller *ctlr) +{ + /* + * The controller must at least implement one of the ->transfer() + * hooks. + */ + if (!ctlr->transfer && !ctlr->transfer_one && + !ctlr->transfer_one_message) + return -EINVAL; + + return 0; +} + /** * spi_register_controller - register SPI master or slave controller * @ctlr: initialized master, originally from spi_alloc_master() or @@ -2096,6 +2109,14 @@ int spi_register_controller(struct spi_controller *ctlr) if (!dev) return -ENODEV; + /* + * Make sure all necessary hooks are implemented before registering + * the SPI controller. + */ + status = spi_controller_check_ops(ctlr); + if (status) + return status; + if (!spi_controller_is_slave(ctlr)) { status = of_spi_register_master(ctlr); if (status)