[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220215062743.GA12431@wunner.de>
Date: Tue, 15 Feb 2022 07:27:43 +0100
From: Lukas Wunner <lukas@...ner.de>
To: Cédric Le Goater <clg@...d.org>
Cc: linux-spi@...r.kernel.org, linux-mtd@...ts.infradead.org,
Mark Brown <broonie@...nel.org>,
Tudor Ambarus <tudor.ambarus@...rochip.com>,
Pratyush Yadav <p.yadav@...com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
linux-aspeed@...ts.ozlabs.org, Joel Stanley <joel@....id.au>,
Andrew Jeffery <andrew@...id.au>,
Chin-Ting Kuo <chin-ting_kuo@...eedtech.com>,
devicetree@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 03/10] spi: spi-mem: Add driver for Aspeed SMC controllers
On Mon, Feb 14, 2022 at 10:42:24AM +0100, Cédric Le Goater wrote:
> +static int aspeed_spi_probe(struct platform_device *pdev)
> +{
[...]
> + ctlr = spi_alloc_master(dev, sizeof(*aspi));
> + if (!ctlr)
> + return -ENOMEM;
Use devm_spi_alloc_master() and remove the "put_controller" error path
for simplicity.
> + ret = devm_spi_register_controller(dev, ctlr);
[...]
> +static int aspeed_spi_remove(struct platform_device *pdev)
> +{
> + struct spi_controller *ctlr = platform_get_drvdata(pdev);
> + struct aspeed_spi *aspi = spi_controller_get_devdata(ctlr);
> +
> + aspeed_spi_enable(aspi, false);
> + spi_unregister_controller(ctlr);
> + clk_disable_unprepare(aspi->clk);
> + return 0;
> +}
You need to move the call to spi_unregister_controller() *before*
the call to aspeed_spi_enable(). The controller must be fully
operational until spi_unregister_controller() returns.
You also need to replace the call to devm_spi_register_controller()
in aspeed_spi_probe() with spi_register_controller().
Otherwise you'll unregister the controller twice because you're
calling spi_unregister_controller() in aspeed_spi_remove().
Thanks,
Lukas
Powered by blists - more mailing lists