iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare
PATCH 1/1 iio: adc: stm32-adc: Remove redundant null check before clk_prepare_enable/clk_disable_unprepare
Because clk_prepare_enable() and clk_disable_unprepare() already checked NULL clock parameter, so the additional checks are unnecessary, just remove them.
Signed-off-by Xu Wang <[email protected]>
--- drivers/iio/adc/stm32-adc-core.c | 29 +++++++++++------------------ drivers/iio/adc/stm32-adc.c | 14 +++++--------- 2 files changed, 16 insertions(+), 27 deletions(-)
drivers/iio/adc/stm32-adc-core.c +11 -18
@@ -535,20 +535,16 @@ static int stm32_adc_core_hw_start(struct device *dev) goto err_switches_dis; } -if (priv->bclk) { - ret =clk_prepare_enable (priv->bclk); -if (ret <0 ) { -dev_err (dev,"bus clk enable failed\n" ); - goto err_regulator_disable; - } + ret =clk_prepare_enable (priv->bclk); +if (ret <0 ) { +dev_err (dev,"bus clk enable failed\n" ); + goto err_regulator_disable; } -if (priv->aclk) { - ret =clk_prepare_enable (priv->aclk); -if (ret <0 ) { -dev_err (dev,"adc clk enable failed\n" ); - goto err_bclk_disable; - } + ret =clk_prepare_enable (priv->aclk); +if (ret <0 ) { +dev_err (dev,"adc clk enable failed\n" ); + goto err_bclk_disable; }writel_relaxed (priv->ccr_bak, priv->common.base + priv->cfg->regs->ccr);
@@ -556,8 +552,7 @@ static int stm32_adc_core_hw_start(struct device *dev)return 0 ; err_bclk_disable: -if (priv->bclk) -clk_disable_unprepare (priv->bclk); +clk_disable_unprepare (priv->bclk); err_regulator_disable:regulator_disable (priv->vref); err_switches_dis:
@@ -575,10 +570,8 @@ static void stm32_adc_core_hw_stop(struct device *dev)/* Backup CCR that may be lost (depends on power state to achieve) */ priv->ccr_bak =readl_relaxed (priv->common.base + priv->cfg->regs->ccr); -if (priv->aclk) -clk_disable_unprepare (priv->aclk); -if (priv->bclk) -clk_disable_unprepare (priv->bclk); +clk_disable_unprepare (priv->aclk); +clk_disable_unprepare (priv->bclk);regulator_disable (priv->vref);stm32_adc_core_switches_supply_dis (priv);regulator_disable (priv->vdda);
drivers/iio/adc/stm32-adc.c +5 -9
@@ -546,8 +546,7 @@ static int stm32_adc_hw_stop(struct device *dev)if (adc->cfg->unprepare) adc->cfg->unprepare (indio_dev); -if (adc->clk) -clk_disable_unprepare (adc->clk); +clk_disable_unprepare (adc->clk);return 0 ; }
@@ -558,11 +557,9 @@ static int stm32_adc_hw_start(struct device *dev)struct stm32_adc *adc =iio_priv (indio_dev);int ret; -if (adc->clk) { - ret =clk_prepare_enable (adc->clk); -if (ret) -return ret; - } + ret =clk_prepare_enable (adc->clk); +if (ret) +return ret;stm32_adc_set_res (adc);
@@ -575,8 +572,7 @@ static int stm32_adc_hw_start(struct device *dev)return 0 ; err_clk_dis: -if (adc->clk) -clk_disable_unprepare (adc->clk); +clk_disable_unprepare (adc->clk);return ret; }
Signature · 1 line
2.17.1
Quoted 9 lines · Xu Wang
Because
clk_prepare_enable()andclk_disable_unprepare()already checked NULL clock parameter, so the additional checks are unnecessary, just remove them.Signed-off-by Xu Wang <[email protected]>--- drivers/iio/adc/stm32-adc-core.c | 29 +++++++++++------------------ drivers/iio/adc/stm32-adc.c | 14 +++++--------- 2 files changed, 16 insertions(+), 27 deletions(-)
Hi Xu,
Acked-by Fabrice Gasnier <[email protected]>
Thanks for your patch,
Best Regards,
Fabrice
Quoted 97 lines
drivers/iio/adc/stm32-adc-core.c +11
-18@@ -535,20 +535,16 @@ static int stm32_adc_core_hw_start(struct device *dev) goto err_switches_dis; } -if (priv->bclk) { - ret =clk_prepare_enable (priv->bclk); -if (ret <0 ) { -dev_err (dev,"bus clk enable failed\n" ); - goto err_regulator_disable; - } + ret =clk_prepare_enable (priv->bclk); +if (ret <0 ) { +dev_err (dev,"bus clk enable failed\n" ); + goto err_regulator_disable; } -if (priv->aclk) { - ret =clk_prepare_enable (priv->aclk); -if (ret <0 ) { -dev_err (dev,"adc clk enable failed\n" ); - goto err_bclk_disable; - } + ret =clk_prepare_enable (priv->aclk); +if (ret <0 ) { +dev_err (dev,"adc clk enable failed\n" ); + goto err_bclk_disable; }writel_relaxed (priv->ccr_bak, priv->common.base + priv->cfg->regs->ccr);@@ -556,8 +552,7 @@ static int stm32_adc_core_hw_start(struct device *dev)return 0 ; err_bclk_disable: -if (priv->bclk) -clk_disable_unprepare (priv->bclk); +clk_disable_unprepare (priv->bclk); err_regulator_disable:regulator_disable (priv->vref); err_switches_dis:@@ -575,10 +570,8 @@ static void stm32_adc_core_hw_stop(struct device *dev)/* Backup CCR that may be lost (depends on power state to achieve) */ priv->ccr_bak =readl_relaxed (priv->common.base + priv->cfg->regs->ccr); -if (priv->aclk) -clk_disable_unprepare (priv->aclk); -if (priv->bclk) -clk_disable_unprepare (priv->bclk); +clk_disable_unprepare (priv->aclk); +clk_disable_unprepare (priv->bclk);regulator_disable (priv->vref);stm32_adc_core_switches_supply_dis (priv);regulator_disable (priv->vdda);drivers/iio/adc/stm32-adc.c +5
-9@@ -546,8 +546,7 @@ static int stm32_adc_hw_stop(struct device *dev)if (adc->cfg->unprepare) adc->cfg->unprepare (indio_dev); -if (adc->clk) -clk_disable_unprepare (adc->clk); +clk_disable_unprepare (adc->clk);return 0 ; }@@ -558,11 +557,9 @@ static int stm32_adc_hw_start(struct device *dev)struct stm32_adc *adc =iio_priv (indio_dev);int ret; -if (adc->clk) { - ret =clk_prepare_enable (adc->clk); -if (ret) -return ret; - } + ret =clk_prepare_enable (adc->clk); +if (ret) +return ret;stm32_adc_set_res (adc);@@ -575,8 +572,7 @@ static int stm32_adc_hw_start(struct device *dev)return 0 ; err_clk_dis: -if (adc->clk) -clk_disable_unprepare (adc->clk); +clk_disable_unprepare (adc->clk);return ret; }
Quoted 11 lines · On Fri, 18 Dec 2020 15:32:32 +0100 Fabrice Gasnier…
Quoted 9 lines · Xu Wang
Because
clk_prepare_enable()andclk_disable_unprepare()already checked NULL clock parameter, so the additional checks are unnecessary, just remove them.Signed-off-by Xu Wang <[email protected]>--- drivers/iio/adc/stm32-adc-core.c | 29 +++++++++++------------------ drivers/iio/adc/stm32-adc.c | 14 +++++--------- 2 files changed, 16 insertions(+), 27 deletions(-)
Quoted 3 lines
Hi Xu,
Acked-by Fabrice Gasnier <[email protected]>
Applied,
thanks,
Jonathan
Quoted 102 lines
Thanks for your patch,
Best Regards,
FabriceQuoted 97 lines
drivers/iio/adc/stm32-adc-core.c +11
-18@@ -535,20 +535,16 @@ static int stm32_adc_core_hw_start(struct device *dev) goto err_switches_dis; } -if (priv->bclk) { - ret =clk_prepare_enable (priv->bclk); -if (ret <0 ) { -dev_err (dev,"bus clk enable failed\n" ); - goto err_regulator_disable; - } + ret =clk_prepare_enable (priv->bclk); +if (ret <0 ) { +dev_err (dev,"bus clk enable failed\n" ); + goto err_regulator_disable; } -if (priv->aclk) { - ret =clk_prepare_enable (priv->aclk); -if (ret <0 ) { -dev_err (dev,"adc clk enable failed\n" ); - goto err_bclk_disable; - } + ret =clk_prepare_enable (priv->aclk); +if (ret <0 ) { +dev_err (dev,"adc clk enable failed\n" ); + goto err_bclk_disable; }writel_relaxed (priv->ccr_bak, priv->common.base + priv->cfg->regs->ccr);@@ -556,8 +552,7 @@ static int stm32_adc_core_hw_start(struct device *dev)return 0 ; err_bclk_disable: -if (priv->bclk) -clk_disable_unprepare (priv->bclk); +clk_disable_unprepare (priv->bclk); err_regulator_disable:regulator_disable (priv->vref); err_switches_dis:@@ -575,10 +570,8 @@ static void stm32_adc_core_hw_stop(struct device *dev)/* Backup CCR that may be lost (depends on power state to achieve) */ priv->ccr_bak =readl_relaxed (priv->common.base + priv->cfg->regs->ccr); -if (priv->aclk) -clk_disable_unprepare (priv->aclk); -if (priv->bclk) -clk_disable_unprepare (priv->bclk); +clk_disable_unprepare (priv->aclk); +clk_disable_unprepare (priv->bclk);regulator_disable (priv->vref);stm32_adc_core_switches_supply_dis (priv);regulator_disable (priv->vdda);drivers/iio/adc/stm32-adc.c +5
-9@@ -546,8 +546,7 @@ static int stm32_adc_hw_stop(struct device *dev)if (adc->cfg->unprepare) adc->cfg->unprepare (indio_dev); -if (adc->clk) -clk_disable_unprepare (adc->clk); +clk_disable_unprepare (adc->clk);return 0 ; }@@ -558,11 +557,9 @@ static int stm32_adc_hw_start(struct device *dev)struct stm32_adc *adc =iio_priv (indio_dev);int ret; -if (adc->clk) { - ret =clk_prepare_enable (adc->clk); -if (ret) -return ret; - } + ret =clk_prepare_enable (adc->clk); +if (ret) +return ret;stm32_adc_set_res (adc);@@ -575,8 +572,7 @@ static int stm32_adc_hw_start(struct device *dev)return 0 ; err_clk_dis: -if (adc->clk) -clk_disable_unprepare (adc->clk); +clk_disable_unprepare (adc->clk);return ret; }