From 3e11e4f336f603d3cddcc89f94e518391b6a08a5 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Fri, 3 Mar 2023 18:20:27 +0100 Subject: spi: stm32: Convert to platform remove callback returning void MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20230303172041.2103336-74-u.kleine-koenig@pengutronix.de Signed-off-by: Mark Brown --- drivers/spi/spi-stm32.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/spi/spi-stm32.c') diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index def09cf0dc147..9ccb52296e579 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -1922,7 +1922,7 @@ err_clk_disable: return ret; } -static int stm32_spi_remove(struct platform_device *pdev) +static void stm32_spi_remove(struct platform_device *pdev) { struct spi_master *master = platform_get_drvdata(pdev); struct stm32_spi *spi = spi_master_get_devdata(master); @@ -1946,8 +1946,6 @@ static int stm32_spi_remove(struct platform_device *pdev) pinctrl_pm_select_sleep_state(&pdev->dev); - - return 0; } static int __maybe_unused stm32_spi_runtime_suspend(struct device *dev) @@ -2023,7 +2021,7 @@ static const struct dev_pm_ops stm32_spi_pm_ops = { static struct platform_driver stm32_spi_driver = { .probe = stm32_spi_probe, - .remove = stm32_spi_remove, + .remove_new = stm32_spi_remove, .driver = { .name = DRIVER_NAME, .pm = &stm32_spi_pm_ops, -- cgit v1.2.3 From 1e4929112507f145951f4c356161ab80ad9c1f0e Mon Sep 17 00:00:00 2001 From: Leonard Göhrs Date: Fri, 10 Mar 2023 10:20:53 +0100 Subject: spi: stm32: split large transfers based on word size instead of bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TSIZE register in CR2, to which the number of words to transfer is written, is only 16 Bit. This limits transfers to 65535 SPI _words_ at a time. The existing code uses spi_split_transfers_maxsize to limit transfers to 65535 _bytes_ at a time. This breaks large transfers with bits_per_word > 8, as they are split inside of a word boundary by the odd size limit. Split transfers based on the number of words instead. This has the added benefit of not artificially limiting the maximum length of bpw > 8 transfers to half or a quarter of the actual limit. The combination of very large transfers and bits_per_word = 16 is triggered e.g. by MIPI DBI displays when updating large parts of the screen. Signed-off-by: Leonard Göhrs Acked-by: Alain Volmat Link: https://lore.kernel.org/r/20230310092053.1006459-2-l.goehrs@pengutronix.de Signed-off-by: Mark Brown --- drivers/spi/spi-stm32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/spi/spi-stm32.c') diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 9ccb52296e579..8e6532d8babc6 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -984,9 +984,9 @@ static int stm32_spi_prepare_msg(struct spi_master *master, if (spi->cfg->set_number_of_data) { int ret; - ret = spi_split_transfers_maxsize(master, msg, - STM32H7_SPI_TSIZE_MAX, - GFP_KERNEL | GFP_DMA); + ret = spi_split_transfers_maxwords(master, msg, + STM32H7_SPI_TSIZE_MAX, + GFP_KERNEL | GFP_DMA); if (ret) return ret; } -- cgit v1.2.3 From 75c1b5fc493c21ebe524e9e5bb8501bb351ad94a Mon Sep 17 00:00:00 2001 From: Yang Li Date: Tue, 28 Mar 2023 14:18:39 +0800 Subject: spi: stm32: Use devm_platform_get_and_ioremap_resource() According to commit 890cc39a8799 ("drivers: provide devm_platform_get_and_ioremap_resource()"), convert platform_get_resource(), devm_ioremap_resource() to a single call to devm_platform_get_and_ioremap_resource(), as this is exactly what this function does. Signed-off-by: Yang Li Link: https://lore.kernel.org/r/20230328061839.82185-1-yang.lee@linux.alibaba.com Signed-off-by: Mark Brown --- drivers/spi/spi-stm32.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/spi/spi-stm32.c') diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 8e6532d8babc6..d6598e4116bd2 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -1780,8 +1780,7 @@ static int stm32_spi_probe(struct platform_device *pdev) of_match_device(pdev->dev.driver->of_match_table, &pdev->dev)->data; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - spi->base = devm_ioremap_resource(&pdev->dev, res); + spi->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(spi->base)) return PTR_ERR(spi->base); -- cgit v1.2.3