iio: adc: lpc18xx_adc: Reorder clk_get_rate function call
Subsystems (2)
PATCH 1/1 iio: adc: lpc18xx_adc: Reorder clk_get_rate function call
clk_get_rate is not garanteed to work if called before clk_prepare_enable.
Reorder clk_get_rate, so it's called after clk_prepare_enable and after devm_add_action_or_reset of lpc18xx_clk_disable.
--- drivers/iio/adc/lpc18xx_adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/adc/lpc18xx_adc.c +3 -3
@@ -157,9 +157,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (adc->clk),"error getting clock\n" ); - rate =clk_get_rate (adc->clk); - clkdiv =DIV_ROUND_UP (rate,LPC18XX_ADC_CLK_TARGET ); - adc->vref =devm_regulator_get (&pdev->dev,"vref" );if (IS_ERR (adc->vref)) return dev_err_probe(&pdev->dev, PTR_ERR(adc->vref),
@@ -192,6 +189,9 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)if (ret)return ret; + rate =clk_get_rate (adc->clk); + clkdiv =DIV_ROUND_UP (rate,LPC18XX_ADC_CLK_TARGET ); + adc->cr_reg = (clkdiv <<LPC18XX_ADC_CR_CLKDIV_SHIFT ) |LPC18XX_ADC_CR_PDN ;writel (adc->cr_reg, adc->base +LPC18XX_ADC_CR );
Signature · 1 line
2.33.0
Hi André,
Quoted 1 line · André Gustavo Nakagomi Lopez
clk_get_rateis not garanteed to work if called beforeclk_prepare_enable.
typo, s/garanteed/guaranteed/
Quoted 25 lines
Reorder
clk_get_rate, so it's called afterclk_prepare_enableand afterdevm_add_action_or_resetoflpc18xx_clk_disable.Signed-off-by André Gustavo Nakagomi Lopez <[email protected]>--- drivers/iio/adc/lpc18xx_adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/adc/lpc18xx_adc.c +0
-3@@ -157,9 +157,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (adc->clk),"error getting clock\n" ); - rate =clk_get_rate (adc->clk); - clkdiv =DIV_ROUND_UP (rate,LPC18XX_ADC_CLK_TARGET ); - adc->vref =devm_regulator_get (&pdev->dev,"vref" );if (IS_ERR (adc->vref)) return dev_err_probe(&pdev->dev, PTR_ERR(adc->vref),
drivers/iio/adc/lpc18xx_adc.c static int lpc18xx_adc_probe(struct platform_device *pdev) · line 197
Quoted 9 lines
drivers/iio/adc/lpc18xx_adc.c +3
-0@@ -192,6 +189,9 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)if (ret)return ret; + rate =clk_get_rate (adc->clk); + clkdiv =DIV_ROUND_UP (rate,LPC18XX_ADC_CLK_TARGET ); + adc->cr_reg = (clkdiv <<LPC18XX_ADC_CR_CLKDIV_SHIFT ) |LPC18XX_ADC_CR_PDN ;writel (adc->cr_reg, adc->base +LPC18XX_ADC_CR );
Thank you for the change, per se this particular change is not needed on LPC18xx/43xx platform, however I don't object to it.
--
Best wishes,
Vladimir
Quoted 43 lines · Vladimir Zapolskiy
Hi André,
Quoted 1 line · André Gustavo Nakagomi Lopez
clk_get_rateis not garanteed to work if called beforeclk_prepare_enable.typo, s/garanteed/guaranteed/
Quoted 23 lines
Reorder
clk_get_rate, so it's called afterclk_prepare_enableand afterdevm_add_action_or_resetoflpc18xx_clk_disable.Signed-off-by André Gustavo Nakagomi Lopez <[email protected]>--- drivers/iio/adc/lpc18xx_adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/adc/lpc18xx_adc.c +0
-3@@ -157,9 +157,6 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (adc->clk),"error getting clock\n" ); - rate =clk_get_rate (adc->clk); - clkdiv =DIV_ROUND_UP (rate,LPC18XX_ADC_CLK_TARGET ); - adc->vref =devm_regulator_get (&pdev->dev,"vref" );if (IS_ERR (adc->vref)) return dev_err_probe(&pdev->dev, PTR_ERR(adc->vref),drivers/iio/adc/lpc18xx_adc.c static int lpc18xx_adc_probe(struct platform_device *pdev) · line 197
Quoted 9 lines
drivers/iio/adc/lpc18xx_adc.c +3
-0@@ -192,6 +189,9 @@ static int lpc18xx_adc_probe(struct platform_device *pdev)if (ret)return ret; + rate =clk_get_rate (adc->clk); + clkdiv =DIV_ROUND_UP (rate,LPC18XX_ADC_CLK_TARGET ); + adc->cr_reg = (clkdiv <<LPC18XX_ADC_CR_CLKDIV_SHIFT ) |LPC18XX_ADC_CR_PDN ;writel (adc->cr_reg, adc->base +LPC18XX_ADC_CR );Thank you for the change, per se this particular change is not needed on LPC18xx/43xx platform, however I don't object to it.
Quoted 6 lines
Suggested-by Jonathan Cameron <[email protected]>--
Best wishes,
Vladimir
Ok, thank you for the review. I will fix the typo and add the appropriate tags.