aboutsummaryrefslogtreecommitdiff
path: root/drivers/spi/spi-microchip-core.c
AgeCommit message (Collapse)AuthorFilesLines
2023-03-11spi: Replace all spi->chip_select and spi->cs_gpiod references with function ↵Amit Kumar Mahapatra via Alsa-devel1-3/+3
call Supporting multi-cs in spi drivers would require the chip_select & cs_gpiod members of struct spi_device to be an array. But changing the type of these members to array would break the spi driver functionality. To make the transition smoother introduced four new APIs to get/set the spi->chip_select & spi->cs_gpiod and replaced all spi->chip_select and spi->cs_gpiod references with get or set API calls. While adding multi-cs support in further patches the chip_select & cs_gpiod members of the spi_device structure would be converted to arrays & the "idx" parameter of the APIs would be used as array index i.e., spi->chip_select[idx] & spi->cs_gpiod[idx] respectively. Signed-off-by: Amit Kumar Mahapatra <[email protected]> Acked-by: Heiko Stuebner <[email protected]> # Rockchip drivers Reviewed-by: Michal Simek <[email protected]> Reviewed-by: Cédric Le Goater <[email protected]> # Aspeed driver Reviewed-by: Dhruva Gole <[email protected]> # SPI Cadence QSPI Reviewed-by: Patrice Chotard <[email protected]> # spi-stm32-qspi Acked-by: William Zhang <[email protected]> # bcm63xx-hsspi driver Reviewed-by: Serge Semin <[email protected]> # DW SSI part Link: https://lore.kernel.org/r/167847070432.26.15076794204368669839@mailman-core.alsa-project.org Signed-off-by: Mark Brown <[email protected]>
2023-03-06spi: microchip-core: Convert to platform remove callback returning voidUwe Kleine-König1-4/+2
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 <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-10-17spi: microchip-core: Remove the unused function mchp_corespi_enable()Jiapeng Chong1-9/+0
The function mchp_corespi_enable() is defined in the spi-microchip-core.c file, but not called elsewhere, so delete this unused function. drivers/spi/spi-microchip-core.c:122:20: warning: unused function 'mchp_corespi_enable'. Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2418 Reported-by: Abaci Robot <[email protected]> Signed-off-by: Jiapeng Chong <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-08-15spi: microchip-core: Simplify some error messageChristophe JAILLET1-2/+2
dev_err_probe() already prints the error code in a human readable way, so there is no need to duplicate it as a numerical value at the end of the message. Moreover, in the case of devm_clk_get() it would only display '0' because 'ret' is know to be 0 at this point. Fixes: cdeaf3a99a02 ("spi: microchip-core: switch to use dev_err_probe()") Signed-off-by: Christophe JAILLET <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/fb894ecec68e03fb7fc9353027c8b1a2610833d7.1659735153.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown <[email protected]>
2022-07-13spi: microchip-core: switch to use dev_err_probe()Yang Yingliang1-25/+17
Switch to use dev_err_probe() to simpify error path. Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-07-13spi: microchip-core: switch to use devm_spi_alloc_master()Yang Yingliang1-13/+7
Switch to use devm_spi_alloc_master() to simpify error path. Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-07-13spi: microchip-core: fix UAF in mchp_corespi_remove()Yang Yingliang1-2/+0
When using devm_spi_register_master(), the unregister function will be called in devres_release_all() which is called after ->remove(), so remove spi_unregister_master() andspi_master_put(). Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers") Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-06-16spi: microchip-core: fix passing zero to PTR_ERR warningConor Dooley1-1/+3
It is possible that the error case for devm_clk_get() returns NULL, in which case zero will be passed to PTR_ERR() as shown by the Smatch static checker warning: drivers/spi/spi-microchip-core.c:557 mchp_corespi_probe() warn: passing zero to 'PTR_ERR' Remove the NULL check and carry on with a dummy clock in case of an error. To avoid a potential div zero, abort calculating clkgen if clk_get_rate(spi->clk) is zero. Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers") Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/linux-spi/20220615091633.GI2168@kadam/ Signed-off-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-06-14spi: microchip-core: fix potentially incorrect return from probeConor Dooley1-1/+1
If platform_get_irqi() returns 0, the error case will be triggered but probe() will return 0 rather than an error. Ape the other drivers using this pattern and return -ENXIO. Reported-by: Yang Li <[email protected]> Link: https://lore.kernel.org/linux-spi/[email protected]/ Signed-off-by: Conor Dooley <[email protected]> Fixes: 9ac8d17694b6 ("spi: add support for microchip fpga spi controllers") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-06-13spi: micro: fix unreasonable clk_prepare_enable() on error in ↵Peng Wu1-1/+1
mchp_corespi_probe() Fix the unreasonable clk_prepare_enable() with clk_disable_unprepare() before return from mchp_corespi_probe() in the error handling case. Signed-off-by: Peng Wu <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-06-09spi: fix platform_no_drv_owner.cocci warningYang Li1-1/+0
Remove .owner field if calls are used which set it automatically. Eliminate the following coccicheck warning: ./drivers/spi/spi-microchip-core.c:624:3-8: No need to set .owner here. The core will do it. Reported-by: Abaci Robot <[email protected]> Signed-off-by: Yang Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
2022-06-07spi: add support for microchip fpga spi controllersConor Dooley1-0/+632
Add a driver for Microchip FPGA SPI controllers, specifically supporting the "hard" controllers on PolarFire SoC. Co-developed-by: Daire McNamara <[email protected]> Signed-off-by: Daire McNamara <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>