spi: omap2-mcspi: switch to managed controller allocation
v2 cover spi: omap2-mcspi: switch to managed controller allocation
This series supersedes the omap2-mcspi patch in the managed controller allocation series. [1]
Included are also two related cleanups.
Johan
[1] https://lore.kernel.org/lkml/[email protected]/
Changes in v2:
- release DMA resources also if DMA setup fails
- clean up error labels
- clean up return value
Johan Hovold (3):
spi: omap2-mcspi: switch to managed controller allocation
spi: omap2-mcspi: clean up error labels
spi: omap2-mcspi: clean up probe return value
drivers/spi/spi-omap2-mcspi.c | 42 +++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/3 spi: omap2-mcspi: switch to managed controller allocation
Switch to device managed controller allocation to simplify error handling and to avoid having to take another reference during deregistration.
--- drivers/spi/spi-omap2-mcspi.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/spi/spi-omap2-mcspi.c +8 -15
@@ -1484,9 +1484,9 @@ static int omap2_mcspi_probe(struct platform_device *pdev)const struct of_device_id *match;if (of_property_read_bool (node,"spi-slave" )) - ctlr =spi_alloc_target (&pdev->dev,sizeof (*mcspi)); + ctlr =devm_spi_alloc_target (&pdev->dev,sizeof (*mcspi));else - ctlr =spi_alloc_host (&pdev->dev,sizeof (*mcspi)); + ctlr =devm_spi_alloc_host (&pdev->dev,sizeof (*mcspi));if (!ctlr)return -ENOMEM ;
@@ -1530,10 +1530,9 @@ static int omap2_mcspi_probe(struct platform_device *pdev) } mcspi->base =devm_platform_get_and_ioremap_resource (pdev,0 , &r); -if (IS_ERR (mcspi->base)) { - status =PTR_ERR (mcspi->base); - goto free_ctlr; - } +if (IS_ERR (mcspi->base)) +return PTR_ERR (mcspi->base); + mcspi->phys = r->start + regs_offset; mcspi->base += regs_offset;
@@ -1544,10 +1543,8 @@ static int omap2_mcspi_probe(struct platform_device *pdev) mcspi->dma_channels =devm_kcalloc (&pdev->dev, ctlr->num_chipselect,sizeof (struct omap2_mcspi_dma ),GFP_KERNEL ); -if (mcspi->dma_channels ==NULL ) { - status = -ENOMEM ; - goto free_ctlr; - } +if (mcspi->dma_channels ==NULL ) +return -ENOMEM ;for (i =0 ; i < ctlr->num_chipselect; i++) {sprintf (mcspi->dma_channels[i].dma_rx_ch_name,"rx%d" , i);
@@ -1604,7 +1601,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); free_ctlr:omap2_mcspi_release_dma (ctlr); -spi_controller_put (ctlr); +return status; }
@@ -1613,8 +1610,6 @@ static void omap2_mcspi_remove(struct platform_device *pdev)struct spi_controller *ctlr =platform_get_drvdata (pdev);struct omap2_mcspi *mcspi =spi_controller_get_devdata (ctlr); -spi_controller_get (ctlr); -spi_unregister_controller (ctlr);omap2_mcspi_release_dma (ctlr);
@@ -1622,8 +1617,6 @@ static void omap2_mcspi_remove(struct platform_device *pdev)pm_runtime_dont_use_autosuspend (mcspi->dev);pm_runtime_put_sync (mcspi->dev);pm_runtime_disable (&pdev->dev); - -spi_controller_put (ctlr); }/* work with hotplug and coldplug */
Signature · 1 line
2.53.0
PATCH v2 2/3 spi: omap2-mcspi: clean up error labels
In reply to Johan HovoldClean up the error labels by adding a common prefix and naming them after what they do.
--- drivers/spi/spi-omap2-mcspi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/spi/spi-omap2-mcspi.c +9 -8
@@ -1553,26 +1553,27 @@ static int omap2_mcspi_probe(struct platform_device *pdev) status =omap2_mcspi_request_dma (mcspi, &mcspi->dma_channels[i]);if (status == -EPROBE_DEFER ) - goto free_ctlr; + goto err_release_dma; } status =platform_get_irq (pdev,0 );if (status <0 ) - goto free_ctlr; + goto err_release_dma; +init_completion (&mcspi->txdone); status =devm_request_irq (&pdev->dev, status, omap2_mcspi_irq_handler,0 , pdev->name, mcspi);if (status) {dev_err (&pdev->dev,"Cannot request IRQ" ); - goto free_ctlr; + goto err_release_dma; } mcspi->ref_clk =devm_clk_get_optional_enabled (&pdev->dev,NULL );if (IS_ERR (mcspi->ref_clk)) { status =PTR_ERR (mcspi->ref_clk);dev_err_probe (&pdev->dev, status,"Failed to get ref_clk" ); - goto free_ctlr; + goto err_release_dma; }if (mcspi->ref_clk) mcspi->ref_clk_hz =clk_get_rate (mcspi->ref_clk);
@@ -1587,19 +1588,19 @@ static int omap2_mcspi_probe(struct platform_device *pdev) status =omap2_mcspi_controller_setup (mcspi);if (status <0 ) - goto disable_pm; + goto err_disable_rpm; status =spi_register_controller (ctlr);if (status <0 ) - goto disable_pm; + goto err_disable_rpm;return status; -disable_pm: +err_disable_rpm:pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_put_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); -free_ctlr: +err_release_dma:omap2_mcspi_release_dma (ctlr);return status;
Signature · 1 line
2.53.0
PATCH v2 3/3 spi: omap2-mcspi: clean up probe return value
In reply to Johan HovoldReturn explicit zero on successful probe to clearly separate the success and error paths and make the code more readable.
--- drivers/spi/spi-omap2-mcspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-omap2-mcspi.c +1 -1
@@ -1594,7 +1594,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)if (status <0 ) goto err_disable_rpm; -return status; +return 0 ; err_disable_rpm:pm_runtime_dont_use_autosuspend (&pdev->dev);
Signature · 1 line
2.53.0
Mark Brown
maintainerQuoted 8 lines · Johan Hovold
spi: omap2-mcspi: switch to managed controller allocation
This series supersedes the omap2-mcspi patch in the managed controller allocation series. [1]
Included are also two related cleanups.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2
Thanks!
[1/3] spi: omap2-mcspi: switch to managed controller allocation
https://git.kernel.org/broonie/spi/c/caf2fd997bf3 [2/3] spi: omap2-mcspi: clean up error labels https://git.kernel.org/broonie/spi/c/186fda6ee1ac [3/3] spi: omap2-mcspi: clean up probe return value https://git.kernel.org/broonie/spi/c/46bd1fafc494
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark