cleanup in spi by use devm_clk_get_enabled
Subsystems (16)
v3 cover cleanup in spi by use devm_clk_get_enabled
I know that many old SPI drivers should not be modified for hardware stability and to reduce maintenance effort. But I can't help cleaning them up. To minimize the introduction of issues, I tried not to modify the timing of those hardware clock enables.
---
changes in v3: remove disable clk in remove function
changes in v2: fix error message but having a line break Missing error code argument to dev_err_probe()
---
Pei Xiao (17):
spi: axiado: Use helper function devm_clk_get_enabled()
spi: bcm63xx-hsspi: Use helper function devm_clk_get_enabled()
spi: bcmbca-hsspi: Use helper function devm_clk_get_enabled()
spi: img-spfi: Use helper function devm_clk_get_enabled()
spi: imx: Use helper function devm_clk_get_enabled()
spi: npcm-pspi: Use helper function devm_clk_get_enabled()
spi: orion: Use helper function devm_clk_get_enabled()
spi: rockchip-sfc: Use helper function devm_clk_get_enabled()
spi: sifive: Use helper function devm_clk_get_enabled()
spi: slave-mt27xx: Use helper function devm_clk_get_enabled()
spi: st: Use helper function devm_clk_get_enabled()
spi: stm32-qspi: Use helper function devm_clk_get_enabled()
spi: stm32: Use helper function devm_clk_get_enabled()
spi: sunplus-sp7021: Use helper function devm_clk_get_enabled()
spi: uniphier: Use helper function devm_clk_get_enabled()
spi: zynq-qspi: Use helper function devm_clk_get_enabled()
spi: zynqmp-gqspi: Use helper function devm_clk_get_enabled()
drivers/spi/spi-axiado.c | 31 +++++----------- drivers/spi/spi-bcm63xx-hsspi.c | 46 +++++++----------------- drivers/spi/spi-bcmbca-hsspi.c | 49 +++++++++---------------- drivers/spi/spi-img-spfi.c | 18 ++-------- drivers/spi/spi-imx.c | 15 ++------ drivers/spi/spi-npcm-pspi.c | 20 ++++------- drivers/spi/spi-orion.c | 11 ++---- drivers/spi/spi-rockchip-sfc.c | 22 ++---------- drivers/spi/spi-sifive.c | 21 ++++------- drivers/spi/spi-slave-mt27xx.c | 8 +---- drivers/spi/spi-st-ssc4.c | 16 +++------ drivers/spi/spi-stm32-qspi.c | 18 +++------- drivers/spi/spi-stm32.c | 61 ++++++++++---------------------- drivers/spi/spi-sunplus-sp7021.c | 15 +------- drivers/spi/spi-uniphier.c | 17 +++------ drivers/spi/spi-zynq-qspi.c | 31 ++++------------ drivers/spi/spi-zynqmp-gqspi.c | 19 ++-------- 17 files changed, 98 insertions(+), 320 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 3/17 spi: bcmbca-hsspi: Use helper function devm_clk_get_enabled()
devm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-bcmbca-hsspi.c | 49 +++++++++++----------------------- 1 file changed, 16 insertions(+), 33 deletions(-)
drivers/spi/spi-bcmbca-hsspi.c +16 -33
@@ -452,39 +452,30 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev)if (IS_ERR (spim_ctrl))return PTR_ERR (spim_ctrl); - clk =devm_clk_get (dev,"hsspi" ); + clk =devm_clk_get_enabled (dev,"hsspi" );if (IS_ERR (clk)) -return PTR_ERR (clk); - - ret =clk_prepare_enable (clk); -if (ret) -return ret; +return dev_err_probe (dev,PTR_ERR (clk), +"Failed to get hsspi clock\n" ); rate =clk_get_rate (clk);if (!rate) { - pll_clk =devm_clk_get (dev,"pll" ); + pll_clk =devm_clk_get_enabled (dev,"pll" );if (IS_ERR (pll_clk)) { - ret =PTR_ERR (pll_clk); - goto out_disable_clk; +return dev_err_probe (dev,PTR_ERR (pll_clk), +"Failed to get pll clock\n" ); } - ret =clk_prepare_enable (pll_clk); -if (ret) - goto out_disable_clk; - rate =clk_get_rate (pll_clk); -if (!rate) { - ret = -EINVAL ; - goto out_disable_pll_clk; - } +if (!rate) +return dev_err_probe (dev, -EINVAL , +"Failed to get pll clock rate\n" ); } host =devm_spi_alloc_host (&pdev->dev,sizeof (*bs)); -if (!host) { - ret = -ENOMEM ; - goto out_disable_pll_clk; - } +if (!host) +return dev_err_probe (dev, -ENOMEM , +"Failed alloc spi host\n" ); bs =spi_controller_get_devdata (host); bs->pdev = pdev;
@@ -535,18 +526,16 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) ret =devm_request_irq (dev, irq, bcmbca_hsspi_interrupt,IRQF_SHARED , pdev->name, bs);if (ret) - goto out_disable_pll_clk; +return dev_err_probe (dev, ret,"Failed request irq\n" ); } ret =devm_pm_runtime_enable (&pdev->dev);if (ret) - goto out_disable_pll_clk; +return dev_err_probe (dev, ret,"Failed pm runtime enable\n" ); ret =sysfs_create_group (&pdev->dev.kobj, &bcmbca_hsspi_group); -if (ret) { -dev_err (&pdev->dev,"couldn't register sysfs group\n" ); - goto out_disable_pll_clk; - } +if (ret) +return dev_err_probe (dev, ret,"couldn't register sysfs group\n" );/* register and we are done */ ret =devm_spi_register_controller (dev, host);
@@ -559,10 +548,6 @@ static int bcmbca_hsspi_probe(struct platform_device *pdev) out_sysgroup_disable:sysfs_remove_group (&pdev->dev.kobj, &bcmbca_hsspi_group); -out_disable_pll_clk: -clk_disable_unprepare (pll_clk); -out_disable_clk: -clk_disable_unprepare (clk);return ret; }
@@ -573,8 +558,6 @@ static void bcmbca_hsspi_remove(struct platform_device *pdev)/* reset the hardware and block queue progress */ __raw_writel (0 , bs->regs +HSSPI_INT_MASK_REG ); -clk_disable_unprepare (bs->pll_clk); -clk_disable_unprepare (bs->clk);sysfs_remove_group (&pdev->dev.kobj, &bcmbca_hsspi_group); }
Signature · 1 line
2.25.1
PATCH v3 4/17 spi: img-spfi: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-img-spfi.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/spi/spi-img-spfi.c +2 -16
@@ -557,24 +557,17 @@ static int img_spfi_probe(struct platform_device *pdev)if (ret) goto put_spi; - spfi->sys_clk =devm_clk_get (spfi->dev,"sys" ); + spfi->sys_clk =devm_clk_get_enabled (spfi->dev,"sys" );if (IS_ERR (spfi->sys_clk)) { ret =PTR_ERR (spfi->sys_clk); goto put_spi; } - spfi->spfi_clk =devm_clk_get (spfi->dev,"spfi" ); + spfi->spfi_clk =devm_clk_get_enabled (spfi->dev,"spfi" );if (IS_ERR (spfi->spfi_clk)) { ret =PTR_ERR (spfi->spfi_clk); goto put_spi; } - ret =clk_prepare_enable (spfi->sys_clk); -if (ret) - goto put_spi; - ret =clk_prepare_enable (spfi->spfi_clk); -if (ret) - goto disable_pclk; -spfi_reset (spfi);/* * Only enable the error (IACCESS) interrupt. In PIO mode we'll
@@ -655,9 +648,6 @@ static int img_spfi_probe(struct platform_device *pdev)dma_release_channel (spfi->rx_ch);if (spfi->tx_ch)dma_release_channel (spfi->tx_ch); -clk_disable_unprepare (spfi->spfi_clk); -disable_pclk: -clk_disable_unprepare (spfi->sys_clk); put_spi:spi_controller_put (host);
@@ -675,10 +665,6 @@ static void img_spfi_remove(struct platform_device *pdev)dma_release_channel (spfi->rx_ch);pm_runtime_disable (spfi->dev); -if (!pm_runtime_status_suspended (spfi->dev)) { -clk_disable_unprepare (spfi->spfi_clk); -clk_disable_unprepare (spfi->sys_clk); - } }#ifdef CONFIG_PM
Signature · 1 line
2.25.1
PATCH v3 1/17 spi: axiado: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-axiado.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-)
drivers/spi/spi-axiado.c +8 -23
@@ -768,25 +768,15 @@ static int ax_spi_probe(struct platform_device *pdev)if (IS_ERR (xspi->regs))return PTR_ERR (xspi->regs); - xspi->pclk =devm_clk_get (&pdev->dev,"pclk" ); + xspi->pclk =devm_clk_get_enabled (&pdev->dev,"pclk" );if (IS_ERR (xspi->pclk))return dev_err_probe (&pdev->dev,PTR_ERR (xspi->pclk), -"pclk clock not found.\n" ); +"Unable to enable APB clock.\n" ); - xspi->ref_clk =devm_clk_get (&pdev->dev,"ref" ); + xspi->ref_clk =devm_clk_get_enabled (&pdev->dev,"ref" );if (IS_ERR (xspi->ref_clk))return dev_err_probe (&pdev->dev,PTR_ERR (xspi->ref_clk), -"ref clock not found.\n" ); - - ret =clk_prepare_enable (xspi->pclk); -if (ret) -return dev_err_probe (&pdev->dev, ret,"Unable to enable APB clock.\n" ); - - ret =clk_prepare_enable (xspi->ref_clk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable device clock.\n" ); - goto clk_dis_apb; - } +"Unable to enable device clock.\n" );pm_runtime_use_autosuspend (&pdev->dev);pm_runtime_set_autosuspend_delay (&pdev->dev,SPI_AUTOSUSPEND_TIMEOUT );
@@ -815,7 +805,7 @@ static int ax_spi_probe(struct platform_device *pdev) irq =platform_get_irq (pdev,0 );if (irq <=0 ) { ret = -ENXIO ; - goto clk_dis_all; + goto err_disable_pm_runtime; } ret = devm_request_irq(&pdev->dev, irq, ax_spi_irq,
@@ -823,7 +813,7 @@ static int ax_spi_probe(struct platform_device *pdev)if (ret !=0 ) { ret = -ENXIO ;dev_err (&pdev->dev,"request_irq failed\n" ); - goto clk_dis_all; + goto err_disable_pm_runtime; } ctlr->use_gpio_descriptors = true;
@@ -849,17 +839,14 @@ static int ax_spi_probe(struct platform_device *pdev) ret =spi_register_controller (ctlr);if (ret) {dev_err (&pdev->dev,"spi_register_controller failed\n" ); - goto clk_dis_all; + goto err_disable_pm_runtime; }return ret; -clk_dis_all: +err_disable_pm_runtime:pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); -clk_disable_unprepare (xspi->ref_clk); -clk_dis_apb: -clk_disable_unprepare (xspi->pclk);return ret; }
@@ -882,8 +869,6 @@ static void ax_spi_remove(struct platform_device *pdev)pm_runtime_set_suspended (&pdev->dev);pm_runtime_disable (&pdev->dev); -clk_disable_unprepare (xspi->ref_clk); -clk_disable_unprepare (xspi->pclk); }/**
Signature · 1 line
2.25.1
PATCH v3 7/17 spi: orion: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-orion.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/spi/spi-orion.c +3 -8
@@ -695,13 +695,11 @@ static int orion_spi_probe(struct platform_device *pdev) }/* The following clock is only used by some SoCs */ - spi->axi_clk =devm_clk_get (&pdev->dev,"axi" ); + spi->axi_clk =devm_clk_get_enabled (&pdev->dev,"axi" );if (PTR_ERR (spi->axi_clk) == -EPROBE_DEFER ) { status = -EPROBE_DEFER ; goto out; } -if (!IS_ERR (spi->axi_clk)) -clk_prepare_enable (spi->axi_clk); tclk_hz =clk_get_rate (spi->clk);
@@ -726,7 +724,7 @@ static int orion_spi_probe(struct platform_device *pdev) spi->base =devm_platform_get_and_ioremap_resource (pdev,0 , &r);if (IS_ERR (spi->base)) { status =PTR_ERR (spi->base); - goto out_rel_axi_clk; + goto out; }for_each_available_child_of_node (pdev->dev.of_node, np) {
@@ -764,7 +762,7 @@ static int orion_spi_probe(struct platform_device *pdev)if (!dir_acc->vaddr) { status = -ENOMEM ;of_node_put (np); - goto out_rel_axi_clk; + goto out; } dir_acc->size =PAGE_SIZE ;
@@ -788,8 +786,6 @@ static int orion_spi_probe(struct platform_device *pdev) out_rel_pm:pm_runtime_disable (&pdev->dev); -out_rel_axi_clk: -clk_disable_unprepare (spi->axi_clk); out:spi_controller_put (host);return status;
@@ -802,7 +798,6 @@ static void orion_spi_remove(struct platform_device *pdev)struct orion_spi *spi =spi_controller_get_devdata (host);pm_runtime_get_sync (&pdev->dev); -clk_disable_unprepare (spi->axi_clk);spi_unregister_controller (host);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.25.1
PATCH v3 6/17 spi: npcm-pspi: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-npcm-pspi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/spi/spi-npcm-pspi.c +6 -14
@@ -361,27 +361,23 @@ static int npcm_pspi_probe(struct platform_device *pdev) goto out_host_put; } - priv->clk =devm_clk_get (&pdev->dev,NULL ); + priv->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (priv->clk)) { -dev_err (&pdev->dev,"failed to get clock\n" ); +dev_err (&pdev->dev,"failed to enable clock\n" ); ret =PTR_ERR (priv->clk); goto out_host_put; } - ret =clk_prepare_enable (priv->clk); -if (ret) - goto out_host_put; - irq =platform_get_irq (pdev,0 );if (irq <0 ) { ret = irq; - goto out_disable_clk; + goto out_host_put; } priv->reset =devm_reset_control_get (&pdev->dev,NULL );if (IS_ERR (priv->reset)) { ret =PTR_ERR (priv->reset); - goto out_disable_clk; + goto out_host_put; }/* reset SPI-HW block */
@@ -391,7 +387,7 @@ static int npcm_pspi_probe(struct platform_device *pdev) "npcm-pspi", priv);if (ret) {dev_err (&pdev->dev,"failed to request IRQ\n" ); - goto out_disable_clk; + goto out_host_put; }init_completion (&priv->xfer_done);
@@ -415,15 +411,12 @@ static int npcm_pspi_probe(struct platform_device *pdev) ret =devm_spi_register_controller (&pdev->dev, host);if (ret) - goto out_disable_clk; + goto out_host_put;pr_info ("NPCM Peripheral SPI %d probed\n" , host->bus_num);return 0 ; -out_disable_clk: -clk_disable_unprepare (priv->clk); - out_host_put:spi_controller_put (host);return ret;
@@ -435,7 +428,6 @@ static void npcm_pspi_remove(struct platform_device *pdev)struct npcm_pspi *priv =spi_controller_get_devdata (host);npcm_pspi_reset_hw (priv); -clk_disable_unprepare (priv->clk); }static const struct of_device_id npcm_pspi_match[] = {
Signature · 1 line
2.25.1
PATCH v3 2/17 spi: bcm63xx-hsspi: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-bcm63xx-hsspi.c | 46 +++++++++------------------------ 1 file changed, 12 insertions(+), 34 deletions(-)
drivers/spi/spi-bcm63xx-hsspi.c +12 -34
@@ -758,8 +758,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)if (IS_ERR (regs))return PTR_ERR (regs); - clk =devm_clk_get (dev,"hsspi" ); - + clk =devm_clk_get_enabled (dev,"hsspi" );if (IS_ERR (clk))return PTR_ERR (clk);
@@ -767,41 +766,26 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)if (IS_ERR (reset))return PTR_ERR (reset); - ret =clk_prepare_enable (clk); -if (ret) -return ret; - ret =reset_control_reset (reset); -if (ret) { -dev_err (dev,"unable to reset device: %d\n" , ret); - goto out_disable_clk; - } +if (ret) +return dev_err_probe (dev, ret,"unable to reset device: %d\n" , ret); rate =clk_get_rate (clk);if (!rate) { - pll_clk =devm_clk_get (dev,"pll" ); - -if (IS_ERR (pll_clk)) { - ret =PTR_ERR (pll_clk); - goto out_disable_clk; - } - - ret =clk_prepare_enable (pll_clk); -if (ret) - goto out_disable_clk; + pll_clk =devm_clk_get_enabled (dev,"pll" ); +if (IS_ERR (pll_clk)) +return dev_err_probe (dev,PTR_ERR (pll_clk), +"failed enable pll clk\n" ); rate =clk_get_rate (pll_clk); -if (!rate) { - ret = -EINVAL ; - goto out_disable_pll_clk; - } +if (!rate) +return dev_err_probe (dev, -EINVAL , +"failed get pll clk rate\n" ); } host =spi_alloc_host (&pdev->dev,sizeof (*bs)); -if (!host) { - ret = -ENOMEM ; - goto out_disable_pll_clk; - } +if (!host) +return dev_err_probe (dev, -ENOMEM ,"alloc host no mem\n" ); bs =spi_controller_get_devdata (host); bs->pdev = pdev;
@@ -887,10 +871,6 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); out_put_host:spi_controller_put (host); -out_disable_pll_clk: -clk_disable_unprepare (pll_clk); -out_disable_clk: -clk_disable_unprepare (clk);return ret; }
@@ -902,8 +882,6 @@ static void bcm63xx_hsspi_remove(struct platform_device *pdev)/* reset the hardware and block queue progress */ __raw_writel (0 , bs->regs +HSSPI_INT_MASK_REG ); -clk_disable_unprepare (bs->pll_clk); -clk_disable_unprepare (bs->clk);sysfs_remove_group (&pdev->dev.kobj, &bcm63xx_hsspi_group); }
Signature · 1 line
2.25.1
PATCH v3 8/17 spi: rockchip-sfc: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-rockchip-sfc.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-)
drivers/spi/spi-rockchip-sfc.c +2 -20
@@ -635,13 +635,13 @@ static int rockchip_sfc_probe(struct platform_device *pdev)return PTR_ERR (sfc->regbase);if (!has_acpi_companion (&pdev->dev)) - sfc->clk =devm_clk_get (&pdev->dev,"clk_sfc" ); + sfc->clk =devm_clk_get_enabled (&pdev->dev,"clk_sfc" );if (IS_ERR (sfc->clk))return dev_err_probe (&pdev->dev,PTR_ERR (sfc->clk),"Failed to get sfc interface clk\n" );if (!has_acpi_companion (&pdev->dev)) - sfc->hclk =devm_clk_get (&pdev->dev,"hclk_sfc" ); + sfc->hclk =devm_clk_get_enabled (&pdev->dev,"hclk_sfc" );if (IS_ERR (sfc->hclk))return dev_err_probe (&pdev->dev,PTR_ERR (sfc->hclk),"Failed to get sfc ahb clk\n" );
@@ -657,18 +657,6 @@ static int rockchip_sfc_probe(struct platform_device *pdev) sfc->use_dma = !of_property_read_bool (sfc->dev->of_node,"rockchip,sfc-no-dma" ); - ret =clk_prepare_enable (sfc->hclk); -if (ret) { -dev_err (&pdev->dev,"Failed to enable ahb clk\n" ); - goto err_hclk; - } - - ret =clk_prepare_enable (sfc->clk); -if (ret) { -dev_err (&pdev->dev,"Failed to enable interface clk\n" ); - goto err_clk; - } -/* Find the irq */ ret =platform_get_irq (pdev,0 );if (ret <0 )
@@ -730,10 +718,6 @@ static int rockchip_sfc_probe(struct platform_device *pdev)pm_runtime_set_suspended (dev);pm_runtime_dont_use_autosuspend (dev); err_irq: -clk_disable_unprepare (sfc->clk); -err_clk: -clk_disable_unprepare (sfc->hclk); -err_hclk:return ret; }
@@ -747,8 +731,6 @@ static void rockchip_sfc_remove(struct platform_device *pdev) DMA_BIDIRECTIONAL);free_pages ((unsigned long )sfc->buffer,get_order (sfc->max_iosize)); -clk_disable_unprepare (sfc->clk); -clk_disable_unprepare (sfc->hclk); }#ifdef CONFIG_PM
Signature · 1 line
2.25.1
PATCH v3 10/17 spi: slave-mt27xx: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-slave-mt27xx.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/spi/spi-slave-mt27xx.c +1 -7
@@ -438,19 +438,13 @@ static int mtk_spi_slave_probe(struct platform_device *pdev) goto err_put_ctlr; } - mdata->spi_clk =devm_clk_get (&pdev->dev,"spi" ); + mdata->spi_clk =devm_clk_get_enabled (&pdev->dev,"spi" );if (IS_ERR (mdata->spi_clk)) { ret =PTR_ERR (mdata->spi_clk);dev_err (&pdev->dev,"failed to get spi-clk: %d\n" , ret); goto err_put_ctlr; } - ret =clk_prepare_enable (mdata->spi_clk); -if (ret <0 ) { -dev_err (&pdev->dev,"failed to enable spi_clk (%d)\n" , ret); - goto err_put_ctlr; - } -pm_runtime_enable (&pdev->dev); ret =devm_spi_register_controller (&pdev->dev, ctlr);
Signature · 1 line
2.25.1
PATCH v3 11/17 spi: st: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-st-ssc4.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/spi/spi-st-ssc4.c +4 -12
@@ -293,24 +293,20 @@ static int spi_st_probe(struct platform_device *pdev) host->use_gpio_descriptors = true; spi_st =spi_controller_get_devdata (host); - spi_st->clk =devm_clk_get (&pdev->dev,"ssc" ); + spi_st->clk =devm_clk_get_enabled (&pdev->dev,"ssc" );if (IS_ERR (spi_st->clk)) {dev_err (&pdev->dev,"Unable to request clock\n" ); ret =PTR_ERR (spi_st->clk); goto put_host; } - ret =clk_prepare_enable (spi_st->clk); -if (ret) - goto put_host; -init_completion (&spi_st->done);/* Get resources */ spi_st->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (spi_st->base)) { ret =PTR_ERR (spi_st->base); - goto clk_disable; + goto put_host; }/* Disable I2C and Reset SSC */
@@ -333,14 +329,14 @@ static int spi_st_probe(struct platform_device *pdev)if (!irq) {dev_err (&pdev->dev,"IRQ missing or invalid\n" ); ret = -EINVAL ; - goto clk_disable; + goto put_host; } ret =devm_request_irq (&pdev->dev, irq, spi_st_irq,0 , pdev->name, spi_st);if (ret) {dev_err (&pdev->dev,"Failed to request irq %d\n" , irq); - goto clk_disable; + goto put_host; }/* by default the device is on */
@@ -359,8 +355,6 @@ static int spi_st_probe(struct platform_device *pdev) rpm_disable:pm_runtime_disable (&pdev->dev); -clk_disable: -clk_disable_unprepare (spi_st->clk); put_host:spi_controller_put (host);return ret;
@@ -373,8 +367,6 @@ static void spi_st_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); -clk_disable_unprepare (spi_st->clk); -pinctrl_pm_select_sleep_state (&pdev->dev); }
Signature · 1 line
2.25.1
PATCH v3 5/17 spi: imx: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-imx.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/spi/spi-imx.c +2 -13
@@ -2323,26 +2323,18 @@ static int spi_imx_probe(struct platform_device *pdev) goto out_controller_put; } - spi_imx->clk_ipg =devm_clk_get (&pdev->dev,"ipg" ); + spi_imx->clk_ipg =devm_clk_get_enabled (&pdev->dev,"ipg" );if (IS_ERR (spi_imx->clk_ipg)) { ret =PTR_ERR (spi_imx->clk_ipg); goto out_controller_put; } - spi_imx->clk_per =devm_clk_get (&pdev->dev,"per" ); + spi_imx->clk_per =devm_clk_get_enabled (&pdev->dev,"per" );if (IS_ERR (spi_imx->clk_per)) { ret =PTR_ERR (spi_imx->clk_per); goto out_controller_put; } - ret =clk_prepare_enable (spi_imx->clk_per); -if (ret) - goto out_controller_put; - - ret =clk_prepare_enable (spi_imx->clk_ipg); -if (ret) - goto out_put_per; -pm_runtime_set_autosuspend_delay (spi_imx->dev,MXC_RPM_TIMEOUT );pm_runtime_use_autosuspend (spi_imx->dev);pm_runtime_get_noresume (spi_imx->dev);
@@ -2386,9 +2378,6 @@ static int spi_imx_probe(struct platform_device *pdev)pm_runtime_disable (spi_imx->dev);pm_runtime_set_suspended (&pdev->dev); -clk_disable_unprepare (spi_imx->clk_ipg); -out_put_per: -clk_disable_unprepare (spi_imx->clk_per); out_controller_put:spi_controller_put (controller);
Signature · 1 line
2.25.1
PATCH v3 9/17 spi: sifive: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-sifive.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/spi/spi-sifive.c +6 -15
@@ -312,7 +312,8 @@ static int sifive_spi_probe(struct platform_device *pdev) goto put_host; } - spi->clk =devm_clk_get (&pdev->dev,NULL ); +/* Spin up the bus clock before hitting registers */ + spi->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (spi->clk)) {dev_err (&pdev->dev,"Unable to find bus clock\n" ); ret =PTR_ERR (spi->clk);
@@ -342,13 +343,6 @@ static int sifive_spi_probe(struct platform_device *pdev) goto put_host; } -/* Spin up the bus clock before hitting registers */ - ret =clk_prepare_enable (spi->clk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable bus clock\n" ); - goto put_host; - } -/* probe the number of CS lines */ spi->cs_inactive =sifive_spi_read (spi,SIFIVE_SPI_REG_CSDEF );sifive_spi_write (spi,SIFIVE_SPI_REG_CSDEF ,0xffffffffU );
@@ -357,14 +351,14 @@ static int sifive_spi_probe(struct platform_device *pdev)if (!cs_bits) {dev_err (&pdev->dev,"Could not auto probe CS lines\n" ); ret = -EINVAL ; - goto disable_clk; + goto put_host; } num_cs =ilog2 (cs_bits) +1 ;if (num_cs >SIFIVE_SPI_MAX_CS ) {dev_err (&pdev->dev,"Invalid number of spi targets\n" ); ret = -EINVAL ; - goto disable_clk; + goto put_host; }/* Define our host */
@@ -392,7 +386,7 @@ static int sifive_spi_probe(struct platform_device *pdev) dev_name(&pdev->dev), spi);if (ret) {dev_err (&pdev->dev,"Unable to bind to interrupt\n" ); - goto disable_clk; + goto put_host; } dev_info(&pdev->dev, "mapped; irq=%d, cs=%d\n",
@@ -401,13 +395,11 @@ static int sifive_spi_probe(struct platform_device *pdev) ret =devm_spi_register_controller (&pdev->dev, host);if (ret <0 ) {dev_err (&pdev->dev,"spi_register_host failed\n" ); - goto disable_clk; + goto put_host; }return 0 ; -disable_clk: -clk_disable_unprepare (spi->clk); put_host:spi_controller_put (host);
@@ -421,7 +413,6 @@ static void sifive_spi_remove(struct platform_device *pdev)/* Disable all the interrupts just in case */ sifive_spi_write (spi,SIFIVE_SPI_REG_IE ,0 ); -clk_disable_unprepare (spi->clk); }static int sifive_spi_suspend (struct device *dev)
Signature · 1 line
2.25.1
PATCH v3 13/17 spi: stm32: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-stm32.c | 61 ++++++++++++----------------------------- 1 file changed, 18 insertions(+), 43 deletions(-)
drivers/spi/spi-stm32.c +18 -43
@@ -2360,25 +2360,21 @@ static int stm32_spi_probe(struct platform_device *pdev)int ret; cfg =of_device_get_match_data (&pdev->dev); -if (!cfg) { -dev_err (&pdev->dev,"Failed to get match data for platform\n" ); -return -ENODEV ; - } +if (!cfg) +return dev_err_probe (&pdev->dev, -ENODEV , +"Failed to get match data for platform\n" ); device_mode =of_property_read_bool (np,"spi-slave" ); -if (!cfg->has_device_mode && device_mode) { -dev_err (&pdev->dev,"spi-slave not supported\n" ); -return -EPERM ; - } +if (!cfg->has_device_mode && device_mode) +return dev_err_probe (&pdev->dev, -EPERM ,"spi-slave not supported\n" );if (device_mode) ctrl =devm_spi_alloc_target (&pdev->dev,sizeof (struct stm32_spi ));else ctrl =devm_spi_alloc_host (&pdev->dev,sizeof (struct stm32_spi )); -if (!ctrl) { -dev_err (&pdev->dev,"spi controller allocation failed\n" ); -return -ENOMEM ; - } +if (!ctrl) +return dev_err_probe (&pdev->dev, -ENOMEM , +"spi controller allocation failed\n" );platform_set_drvdata (pdev, ctrl); spi =spi_controller_get_devdata (ctrl);
@@ -2409,32 +2405,19 @@ static int stm32_spi_probe(struct platform_device *pdev)return ret; } - spi->clk =devm_clk_get (&pdev->dev,NULL ); -if (IS_ERR (spi->clk)) { - ret =PTR_ERR (spi->clk); -dev_err (&pdev->dev,"clk get failed: %d\n" , ret); -return ret; - } + spi->clk =devm_clk_get_enabled (&pdev->dev,NULL ); +if (IS_ERR (spi->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (spi->clk),"clk enabled failed\n" ); - ret =clk_prepare_enable (spi->clk); -if (ret) { -dev_err (&pdev->dev,"clk enable failed: %d\n" , ret); -return ret; - } spi->clk_rate =clk_get_rate (spi->clk); -if (!spi->clk_rate) { -dev_err (&pdev->dev,"clk rate = 0\n" ); - ret = -EINVAL ; - goto err_clk_disable; - } +if (!spi->clk_rate) +return dev_err_probe (&pdev->dev, -EINVAL ,"clk rate = 0\n" ); rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (rst) { -if (IS_ERR (rst)) { +if (IS_ERR (rst)) ret =dev_err_probe (&pdev->dev,PTR_ERR (rst),"failed to get reset\n" ); - goto err_clk_disable; - }reset_control_assert (rst);udelay (2 );
@@ -2461,11 +2444,9 @@ static int stm32_spi_probe(struct platform_device *pdev)dev_dbg (spi->dev,"one message max size %d\n" , spi->t_size_max); ret = spi->cfg->config (spi); -if (ret) { -dev_err (&pdev->dev,"controller configuration failed: %d\n" , - ret); - goto err_clk_disable; - } +if (ret) +return dev_err_probe (&pdev->dev, ret, +"controller configuration failed: %d\n" , ret); ctrl->auto_runtime_pm = true; ctrl->bus_num = pdev->id;
@@ -2490,8 +2471,7 @@ static int stm32_spi_probe(struct platform_device *pdev)dev_info (&pdev->dev,"tx dma disabled\n" ); spi->dma_tx =NULL ; }else { -dev_err_probe (&pdev->dev, ret,"failed to request tx dma channel\n" ); - goto err_clk_disable; +return dev_err_probe (&pdev->dev, ret,"failed to request tx dma channel\n" ); } }else { ctrl->dma_tx = spi->dma_tx;
@@ -2579,8 +2559,6 @@ static int stm32_spi_probe(struct platform_device *pdev) err_dma_tx_release:if (spi->dma_tx)dma_release_channel (spi->dma_tx); -err_clk_disable: -clk_disable_unprepare (spi->clk);return ret; }
@@ -2610,9 +2588,6 @@ static void stm32_spi_remove(struct platform_device *pdev)gen_pool_free (spi->sram_pool, (unsigned long )spi->sram_rx_buf, spi->sram_rx_buf_size); -clk_disable_unprepare (spi->clk); - -pinctrl_pm_select_sleep_state (&pdev->dev); }
Signature · 1 line
2.25.1
PATCH v3 16/17 spi: zynq-qspi: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-zynq-qspi.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-)
drivers/spi/spi-zynq-qspi.c +6 -25
@@ -661,7 +661,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) goto remove_ctlr; } - xqspi->pclk =devm_clk_get (&pdev->dev,"pclk" ); + xqspi->pclk =devm_clk_get_enabled (&pdev->dev,"pclk" );if (IS_ERR (xqspi->pclk)) {dev_err (&pdev->dev,"pclk clock not found.\n" ); ret =PTR_ERR (xqspi->pclk);
@@ -670,36 +670,24 @@ static int zynq_qspi_probe(struct platform_device *pdev)init_completion (&xqspi->data_completion); - xqspi->refclk =devm_clk_get (&pdev->dev,"ref_clk" ); + xqspi->refclk =devm_clk_get_enabled (&pdev->dev,"ref_clk" );if (IS_ERR (xqspi->refclk)) {dev_err (&pdev->dev,"ref_clk clock not found.\n" ); ret =PTR_ERR (xqspi->refclk); goto remove_ctlr; } - ret =clk_prepare_enable (xqspi->pclk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable APB clock.\n" ); - goto remove_ctlr; - } - - ret =clk_prepare_enable (xqspi->refclk); -if (ret) { -dev_err (&pdev->dev,"Unable to enable device clock.\n" ); - goto clk_dis_pclk; - } - xqspi->irq =platform_get_irq (pdev,0 );if (xqspi->irq <0 ) { ret = xqspi->irq; - goto clk_dis_all; + goto remove_ctlr; } ret =devm_request_irq (&pdev->dev, xqspi->irq, zynq_qspi_irq,0 , pdev->name, xqspi);if (ret !=0 ) { ret = -ENXIO ;dev_err (&pdev->dev,"request_irq failed\n" ); - goto clk_dis_all; + goto remove_ctlr; } ret = of_property_read_u32(np, "num-cs",
@@ -709,7 +697,7 @@ static int zynq_qspi_probe(struct platform_device *pdev) }else if (num_cs >ZYNQ_QSPI_MAX_NUM_CS ) { ret = -EINVAL ;dev_err (&pdev->dev,"only 2 chip selects are available\n" ); - goto clk_dis_all; + goto remove_ctlr; }else { ctlr->num_chipselect = num_cs; }
@@ -728,15 +716,11 @@ static int zynq_qspi_probe(struct platform_device *pdev) ret =devm_spi_register_controller (&pdev->dev, ctlr);if (ret) {dev_err (&pdev->dev,"devm_spi_register_controller failed\n" ); - goto clk_dis_all; + goto remove_ctlr; }return ret; -clk_dis_all: -clk_disable_unprepare (xqspi->refclk); -clk_dis_pclk: -clk_disable_unprepare (xqspi->pclk); remove_ctlr:spi_controller_put (ctlr);
@@ -758,9 +742,6 @@ static void zynq_qspi_remove(struct platform_device *pdev)struct zynq_qspi *xqspi =platform_get_drvdata (pdev);zynq_qspi_write (xqspi,ZYNQ_QSPI_ENABLE_OFFSET ,0 ); - -clk_disable_unprepare (xqspi->refclk); -clk_disable_unprepare (xqspi->pclk); }static const struct of_device_id zynq_qspi_of_match[] = {
Signature · 1 line
2.25.1
PATCH v3 12/17 spi: stm32-qspi: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-stm32-qspi.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/spi/spi-stm32-qspi.c +5 -13
@@ -819,25 +819,19 @@ static int stm32_qspi_probe(struct platform_device *pdev)init_completion (&qspi->match_completion); - qspi->clk =devm_clk_get (dev,NULL ); + qspi->clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (qspi->clk)) -return PTR_ERR (qspi->clk); - +return dev_err_probe (dev,PTR_ERR (qspi->clk), +"can not enable the clock\n" ); qspi->clk_rate =clk_get_rate (qspi->clk);if (!qspi->clk_rate)return -EINVAL ; - ret =clk_prepare_enable (qspi->clk); -if (ret) { -dev_err (dev,"can not enable the clock\n" ); -return ret; - } - rstc =devm_reset_control_get_exclusive (dev,NULL );if (IS_ERR (rstc)) { ret =PTR_ERR (rstc);if (ret == -EPROBE_DEFER ) - goto err_clk_disable; + goto err_defer; }else {reset_control_assert (rstc);udelay (2 );
@@ -886,8 +880,7 @@ static int stm32_qspi_probe(struct platform_device *pdev)pm_runtime_dont_use_autosuspend (qspi->dev); err_dma_free:stm32_qspi_dma_free (qspi); -err_clk_disable: -clk_disable_unprepare (qspi->clk); +err_defer:return ret; }
@@ -906,7 +899,6 @@ static void stm32_qspi_remove(struct platform_device *pdev)pm_runtime_disable (qspi->dev);pm_runtime_set_suspended (qspi->dev);pm_runtime_dont_use_autosuspend (qspi->dev); -clk_disable_unprepare (qspi->clk); }static int stm32_qspi_runtime_suspend (struct device *dev)
Signature · 1 line
2.25.1
PATCH v3 15/17 spi: uniphier: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-uniphier.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/spi/spi-uniphier.c +4 -13
@@ -666,28 +666,24 @@ static int uniphier_spi_probe(struct platform_device *pdev) } priv->base_dma_addr = res->start; - priv->clk =devm_clk_get (&pdev->dev,NULL ); + priv->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (priv->clk)) {dev_err (&pdev->dev,"failed to get clock\n" ); ret =PTR_ERR (priv->clk); goto out_host_put; } - ret =clk_prepare_enable (priv->clk); -if (ret) - goto out_host_put; - irq =platform_get_irq (pdev,0 );if (irq <0 ) { ret = irq; - goto out_disable_clk; + goto out_host_put; } ret =devm_request_irq (&pdev->dev, irq, uniphier_spi_handler,0 ,"uniphier-spi" , priv);if (ret) {dev_err (&pdev->dev,"failed to request IRQ\n" ); - goto out_disable_clk; + goto out_host_put; }init_completion (&priv->xfer_done);
@@ -716,7 +712,7 @@ static int uniphier_spi_probe(struct platform_device *pdev)if (IS_ERR_OR_NULL (host->dma_tx)) {if (PTR_ERR (host->dma_tx) == -EPROBE_DEFER ) { ret = -EPROBE_DEFER ; - goto out_disable_clk; + goto out_host_put; } host->dma_tx =NULL ; dma_tx_burst =INT_MAX ;
@@ -766,9 +762,6 @@ static int uniphier_spi_probe(struct platform_device *pdev) host->dma_tx =NULL ; } -out_disable_clk: -clk_disable_unprepare (priv->clk); - out_host_put:spi_controller_put (host);return ret;
@@ -783,8 +776,6 @@ static void uniphier_spi_remove(struct platform_device *pdev)dma_release_channel (host->dma_tx);if (host->dma_rx)dma_release_channel (host->dma_rx); - -clk_disable_unprepare (priv->clk); }static const struct of_device_id uniphier_spi_match[] = {
Signature · 1 line
2.25.1
PATCH v3 17/17 spi: zynqmp-gqspi: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-zynqmp-gqspi.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/spi/spi-zynqmp-gqspi.c +2 -17
@@ -1244,26 +1244,16 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)if (IS_ERR (xqspi->regs))return PTR_ERR (xqspi->regs); - xqspi->pclk =devm_clk_get (&pdev->dev,"pclk" ); + xqspi->pclk =devm_clk_get_enabled (&pdev->dev,"pclk" );if (IS_ERR (xqspi->pclk))return dev_err_probe (dev,PTR_ERR (xqspi->pclk),"pclk clock not found.\n" ); - xqspi->refclk =devm_clk_get (&pdev->dev,"ref_clk" ); + xqspi->refclk =devm_clk_get_enabled (&pdev->dev,"ref_clk" );if (IS_ERR (xqspi->refclk))return dev_err_probe (dev,PTR_ERR (xqspi->refclk),"ref_clk clock not found.\n" ); - ret =clk_prepare_enable (xqspi->pclk); -if (ret) -return dev_err_probe (dev, ret,"Unable to enable APB clock.\n" ); - - ret =clk_prepare_enable (xqspi->refclk); -if (ret) { -dev_err (dev,"Unable to enable device clock.\n" ); - goto clk_dis_pclk; - } -init_completion (&xqspi->data_completion);mutex_init (&xqspi->op_lock);
@@ -1339,9 +1329,6 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);pm_runtime_set_suspended (&pdev->dev); -clk_disable_unprepare (xqspi->refclk); -clk_dis_pclk: -clk_disable_unprepare (xqspi->pclk);return ret; }
@@ -1368,8 +1355,6 @@ static void zynqmp_qspi_remove(struct platform_device *pdev)pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_put_noidle (&pdev->dev);pm_runtime_set_suspended (&pdev->dev); -clk_disable_unprepare (xqspi->refclk); -clk_disable_unprepare (xqspi->pclk); }MODULE_DEVICE_TABLE (of, zynqmp_qspi_of_match);
Signature · 1 line
2.25.1
PATCH v3 14/17 spi: sunplus-sp7021: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaodevm_clk_get() and clk_prepare_enable() can now be replaced by devm_clk_get_enabled() when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
--- drivers/spi/spi-sunplus-sp7021.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/spi/spi-sunplus-sp7021.c +1 -14
@@ -389,11 +389,6 @@ static int sp7021_spi_target_transfer_one(struct spi_controller *ctlr, struct spreturn ret; } -static void sp7021_spi_disable_unprepare (void *data) -{ -clk_disable_unprepare (data); -} -static void sp7021_spi_reset_control_assert (void *data) {reset_control_assert (data);
@@ -460,7 +455,7 @@ static int sp7021_spi_controller_probe(struct platform_device *pdev)if (pspim->s_irq <0 )return pspim->s_irq; - pspim->spi_clk =devm_clk_get (dev,NULL ); + pspim->spi_clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (pspim->spi_clk))return dev_err_probe (dev,PTR_ERR (pspim->spi_clk),"clk get fail\n" );
@@ -468,14 +463,6 @@ static int sp7021_spi_controller_probe(struct platform_device *pdev)if (IS_ERR (pspim->rstc))return dev_err_probe (dev,PTR_ERR (pspim->rstc),"rst get fail\n" ); - ret =clk_prepare_enable (pspim->spi_clk); -if (ret) -return dev_err_probe (dev, ret,"failed to enable clk\n" ); - - ret =devm_add_action_or_reset (dev, sp7021_spi_disable_unprepare, pspim->spi_clk); -if (ret) -return ret; - ret =reset_control_deassert (pspim->rstc);if (ret)return dev_err_probe (dev, ret,"failed to deassert reset\n" );
Signature · 1 line
2.25.1
Mark Brown
maintainerRe: [PATCH v3 01/17] spi: axiado: Use helper function devm_clk_get_enabled()
In reply to Pei XiaoQuoted 4 lines · Pei Xiao
devm_clk_get()andclk_prepare_enable()can now be replaced bydevm_clk_get_enabled()when driver enables the clocks. Moreover, it is no longer necessary to unprepare and disable the clocks explicitly. Simplify code.
This doens't apply against current code, please check and resend.
kernel test robot
build botRe: [PATCH v3 01/17] spi: axiado: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaokernel test robot noticed the following build warnings:
Hi Pei,
kernel test robot noticed the following build warnings:
[auto build test WARNING on broonie-spi/for-next]
[also build test WARNING on next-20260317]
[cannot apply to atorgue-stm32/stm32-next rockchip/for-next xilinx-xlnx/master clk/clk-next shawnguo/for-next soc/for-next linus/master v7.0-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Pei-Xiao/spi-axiado-Use-helper-function-devm_clk_get_enabled/20260318-110300 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next patch link: https://lore.kernel.org/r/a78f25f1b15b90121e9723ecb5bd606bbb1868d4.1773733017.git.xiaopei01%40kylinos.cn patch subject: [PATCH v3 01/17] spi: axiado: Use helper function devm_clk_get_enabled() config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20260318/[email protected]/config) compiler: nios2-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260318/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/spi/spi-axiado.c: In function 'ax_spi_remove':
>> drivers/spi/spi-axiado.c:865:24: warning: unused variable 'xspi' [-Wunused-variable]
865 | struct ax_spi *xspi = spi_controller_get_devdata(ctlr);
| ^~~~vim +/xspi +865 drivers/spi/spi-axiado.c
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 853
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 854 /**
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 855 * ax_spi_remove - Remove method for the SPI driver
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 856 * @pdev: Pointer to the platform_device structure
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 857 *
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 858 * This function is called if a device is physically removed from the system or
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 859 * if the driver module is being unloaded. It frees all resources allocated to
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 860 * the device.
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 861 */
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 862 static void ax_spi_remove(struct platform_device *pdev)
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 863 {
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 864 struct spi_controller *ctlr = platform_get_drvdata(pdev);
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 @865 struct ax_spi *xspi = spi_controller_get_devdata(ctlr);
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 866
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 867 spi_unregister_controller(ctlr);
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 868
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 869 pm_runtime_set_suspended(&pdev->dev);
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 870 pm_runtime_disable(&pdev->dev);
e75a6b00ad7962a Vladimir Moravcevic 2026-01-07 871 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 07/17] spi: orion: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaokernel test robot noticed the following build warnings:
Hi Pei,
kernel test robot noticed the following build warnings:
[auto build test WARNING on broonie-spi/for-next]
[also build test WARNING on next-20260317]
[cannot apply to atorgue-stm32/stm32-next rockchip/for-next xilinx-xlnx/master clk/clk-next shawnguo/for-next soc/for-next linus/master v7.0-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Pei-Xiao/spi-axiado-Use-helper-function-devm_clk_get_enabled/20260318-110300 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next patch link: https://lore.kernel.org/r/5727aa84748872059e2a39eb67f1f08c0de6206b.1773733017.git.xiaopei01%40kylinos.cn patch subject: [PATCH v3 07/17] spi: orion: Use helper function devm_clk_get_enabled() config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20260319/[email protected]/config) compiler: nios2-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260319/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/spi/spi-orion.c: In function 'orion_spi_remove':
>> drivers/spi/spi-orion.c:798:27: warning: unused variable 'spi' [-Wunused-variable]
798 | struct orion_spi *spi = spi_controller_get_devdata(host);
| ^~~vim +/spi +798 drivers/spi/spi-orion.c
60cadec9da7b6c drivers/spi/orion_spi.c Shadi Ammouri 2008-08-05 793
60cadec9da7b6c drivers/spi/orion_spi.c Shadi Ammouri 2008-08-05 794
2e0de1efb233ab drivers/spi/spi-orion.c Uwe Kleine-König 2023-03-03 795 static void orion_spi_remove(struct platform_device *pdev)
60cadec9da7b6c drivers/spi/orion_spi.c Shadi Ammouri 2008-08-05 796 {
08e6c5038fee47 drivers/spi/spi-orion.c Yang Yingliang 2023-08-18 797 struct spi_controller *host = platform_get_drvdata(pdev);
08e6c5038fee47 drivers/spi/spi-orion.c Yang Yingliang 2023-08-18 @798 struct orion_spi *spi = spi_controller_get_devdata(host);
60cadec9da7b6c drivers/spi/orion_spi.c Shadi Ammouri 2008-08-05 799
5c6786945b4e04 drivers/spi/spi-orion.c Russell King 2014-06-21 800 pm_runtime_get_sync(&pdev->dev);
4574b886698dfa drivers/spi/spi-orion.c Andrew Lunn 2012-04-06 801
08e6c5038fee47 drivers/spi/spi-orion.c Yang Yingliang 2023-08-18 802 spi_unregister_controller(host);
5c6786945b4e04 drivers/spi/spi-orion.c Russell King 2014-06-21 803 pm_runtime_disable(&pdev->dev);
60cadec9da7b6c drivers/spi/orion_spi.c Shadi Ammouri 2008-08-05 804 }
60cadec9da7b6c drivers/spi/orion_spi.c Shadi Ammouri 2008-08-05 805 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 11/17] spi: st: Use helper function devm_clk_get_enabled()
In reply to Pei Xiaokernel test robot noticed the following build warnings:
Hi Pei,
kernel test robot noticed the following build warnings:
[auto build test WARNING on broonie-spi/for-next]
[also build test WARNING on next-20260318]
[cannot apply to atorgue-stm32/stm32-next rockchip/for-next xilinx-xlnx/master clk/clk-next shawnguo/for-next soc/for-next linus/master v7.0-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Pei-Xiao/spi-axiado-Use-helper-function-devm_clk_get_enabled/20260318-110300 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next patch link: https://lore.kernel.org/r/96c8fbf6840c71f29ebcf37d7ffc68f297601c8a.1773733017.git.xiaopei01%40kylinos.cn patch subject: [PATCH v3 11/17] spi: st: Use helper function devm_clk_get_enabled() config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20260319/[email protected]/config) compiler: nios2-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260319/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/spi/spi-st-ssc4.c: In function 'spi_st_remove':
>> drivers/spi/spi-st-ssc4.c:366:24: warning: unused variable 'spi_st' [-Wunused-variable]
366 | struct spi_st *spi_st = spi_controller_get_devdata(host);
| ^~~~~~vim +/spi_st +366 drivers/spi/spi-st-ssc4.c
9e862375c5420a Lee Jones 2014-12-09 3622dd42da0b479ff Uwe Kleine-König 2023-03-03 363 static void spi_st_remove(struct platform_device *pdev)
9e862375c5420a Lee Jones 2014-12-09 364 {
e6b7e64cb11966 Yang Yingliang 2023-11-28 365 struct spi_controller *host = platform_get_drvdata(pdev);
e6b7e64cb11966 Yang Yingliang 2023-11-28 @366 struct spi_st *spi_st = spi_controller_get_devdata(host);
9e862375c5420a Lee Jones 2014-12-09 367
cd050abeba2a95 Chuhong Yuan 2019-11-18 368 pm_runtime_disable(&pdev->dev);
cd050abeba2a95 Chuhong Yuan 2019-11-18 369
9e862375c5420a Lee Jones 2014-12-09 370 pinctrl_pm_select_sleep_state(&pdev->dev);
9e862375c5420a Lee Jones 2014-12-09 371 }
9e862375c5420a Lee Jones 2014-12-09 372 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki