iio: imx7d_adc: Remove unneeded error message
Fabio Estevam
reviewerPATCH 1/4 iio: imx7d_adc: Remove unneeded error message
In case of ioremap failure, the core code will take care of printing the error message, so there is no need for having a local error message in the driver.
--- drivers/iio/adc/imx7d_adc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/adc/imx7d_adc.c +2 -5
@@ -493,11 +493,8 @@ static int imx7d_adc_probe(struct platform_device *pdev) info->dev = dev; info->regs =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (info->regs)) { - ret =PTR_ERR (info->regs); -dev_err (dev,"Failed to remap adc memory, err = %d\n" , ret); -return ret; - } +if (IS_ERR (info->regs)) +return PTR_ERR (info->regs); irq =platform_get_irq (pdev,0 );if (irq <0 ) {
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 2/4 iio: imx7d_adc: Introduce a definition for the input clock
Since the input clock is always 24MHz, there is no need for storing this value into a variable.
Use a definition instead, which is more appropriate in this case.
--- drivers/iio/adc/imx7d_adc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/adc/imx7d_adc.c +2 -3
@@ -78,6 +78,7 @@#define IMX7D_REG_ADC_INT_STATUS_CHANNEL_CONV_TIME_OUT 0xf0000#define IMX7D_ADC_TIMEOUT msecs_to_jiffies(100) +#define IMX7D_ADC_INPUT_CLK 24000000enum imx7d_adc_clk_pre_div {IMX7D_ADC_ANALOG_CLK_PRE_DIV_4 ,
@@ -272,13 +273,11 @@ static void imx7d_adc_channel_set(struct imx7d_adc *info)static u32 imx7d_adc_get_sample_rate (struct imx7d_adc *info) { -/* input clock is always 24MHz */ -u32 input_clk =24000000 ;u32 analogue_core_clk;u32 core_time_unit = info->adc_feature.core_time_unit;u32 tmp; - analogue_core_clk = input_clk / info->pre_div_num; + analogue_core_clk =IMX7D_ADC_INPUT_CLK / info->pre_div_num; tmp = (core_time_unit +1 ) *6 ;return analogue_core_clk / tmp;
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 3/4 iio: imx7d_adc: Fit into a single line
In reply to Fabio EstevamAll the parameters of devm_request_irq() can fit into a single line, so place them all in a single line for better readability.
--- drivers/iio/adc/imx7d_adc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/iio/adc/imx7d_adc.c +1 -3
@@ -527,9 +527,7 @@ static int imx7d_adc_probe(struct platform_device *pdev) indio_dev->channels = imx7d_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (imx7d_adc_iio_channels); - ret =devm_request_irq (dev, irq, - imx7d_adc_isr,0 , -dev_name (dev), info); + ret =devm_request_irq (dev, irq, imx7d_adc_isr,0 ,dev_name (dev), info);if (ret <0 ) {dev_err (dev,"Failed requesting irq, irq = %d\n" , irq);return ret;
Signature · 1 line
2.17.1
Fabio Estevam
reviewerPATCH 4/4 iio: imx7d_adc: Remove unneeded 'average_en' member
In reply to Fabio Estevamaverage_en is always true, so there is not really need for this structure member.
--- drivers/iio/adc/imx7d_adc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/iio/adc/imx7d_adc.c +2 -6
@@ -101,8 +101,6 @@ struct imx7d_adc_feature {enum imx7d_adc_average_num avg_num;u32 core_time_unit;/* impact the sample rate */ - -bool average_en; };struct imx7d_adc {
@@ -180,7 +178,6 @@ static void imx7d_adc_feature_config(struct imx7d_adc *info) info->adc_feature.clk_pre_div =IMX7D_ADC_ANALOG_CLK_PRE_DIV_4 ; info->adc_feature.avg_num =IMX7D_ADC_AVERAGE_NUM_32 ; info->adc_feature.core_time_unit =1 ; - info->adc_feature.average_en = true; }static void imx7d_adc_sample_rate_set (struct imx7d_adc *info)
@@ -241,9 +238,8 @@ static void imx7d_adc_channel_set(struct imx7d_adc *info)/* the channel choose single conversion, and enable average mode */ cfg1 |= (IMX7D_REG_ADC_CH_CFG1_CHANNEL_EN | -IMX7D_REG_ADC_CH_CFG1_CHANNEL_SINGLE ); -if (info->adc_feature.average_en) - cfg1 |=IMX7D_REG_ADC_CH_CFG1_CHANNEL_AVG_EN ; +IMX7D_REG_ADC_CH_CFG1_CHANNEL_SINGLE | +IMX7D_REG_ADC_CH_CFG1_CHANNEL_AVG_EN );/* * physical channel 0 chose logical channel A
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerQuoted 5 lines · On Mon, 3 Jun 2019 16:34:30 -0300 Fabio Estevam <[email protected]> wrote:
In case of ioremap failure, the core code will take care of printing the error message, so there is no need for having a local error message in the driver.
Signed-off-by Fabio Estevam <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 22 lines
--- drivers/iio/adc/imx7d_adc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/iio/adc/imx7d_adc.c +2
-5@@ -493,11 +493,8 @@ static int imx7d_adc_probe(struct platform_device *pdev) info->dev = dev; info->regs =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (info->regs)) { - ret =PTR_ERR (info->regs); -dev_err (dev,"Failed to remap adc memory, err = %d\n" , ret); -return ret; - } +if (IS_ERR (info->regs)) +return PTR_ERR (info->regs); irq =platform_get_irq (pdev,0 );if (irq <0 ) {
Jonathan Cameron
maintainerRe: [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock
In reply to Fabio EstevamQuoted 6 lines · On Mon, 3 Jun 2019 16:34:31 -0300 Fabio Estevam <[email protected]> wrote:
Since the input clock is always 24MHz, there is no need for storing this value into a variable.
Use a definition instead, which is more appropriate in this case.
Signed-off-by Fabio Estevam <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
thanks,
Jonathan
Quoted 31 lines
--- drivers/iio/adc/imx7d_adc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/adc/imx7d_adc.c +2
-3@@ -78,6 +78,7 @@#define IMX7D_REG_ADC_INT_STATUS_CHANNEL_CONV_TIME_OUT 0xf0000#define IMX7D_ADC_TIMEOUT msecs_to_jiffies(100) +#define IMX7D_ADC_INPUT_CLK 24000000enum imx7d_adc_clk_pre_div {IMX7D_ADC_ANALOG_CLK_PRE_DIV_4 ,@@ -272,13 +273,11 @@ static void imx7d_adc_channel_set(struct imx7d_adc *info)static u32 imx7d_adc_get_sample_rate (struct imx7d_adc *info) { -/* input clock is always 24MHz */ -u32 input_clk =24000000 ;u32 analogue_core_clk;u32 core_time_unit = info->adc_feature.core_time_unit;u32 tmp; - analogue_core_clk = input_clk / info->pre_div_num; + analogue_core_clk =IMX7D_ADC_INPUT_CLK / info->pre_div_num; tmp = (core_time_unit +1 ) *6 ;return analogue_core_clk / tmp;
Re: [PATCH 3/4] iio: imx7d_adc: Fit into a single line
In reply to Fabio EstevamQuoted 5 lines · On Mon, 3 Jun 2019 16:34:32 -0300 Fabio Estevam <[email protected]> wrote:
All the parameters of
devm_request_irq()can fit into a single line, so place them all in a single line for better readability.Signed-off-by Fabio Estevam <[email protected]>
Applied.
Thanks,
Quoted 19 lines
--- drivers/iio/adc/imx7d_adc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/iio/adc/imx7d_adc.c +1
-3@@ -527,9 +527,7 @@ static int imx7d_adc_probe(struct platform_device *pdev) indio_dev->channels = imx7d_adc_iio_channels; indio_dev->num_channels =ARRAY_SIZE (imx7d_adc_iio_channels); - ret =devm_request_irq (dev, irq, - imx7d_adc_isr,0 , -dev_name (dev), info); + ret =devm_request_irq (dev, irq, imx7d_adc_isr,0 ,dev_name (dev), info);if (ret <0 ) {dev_err (dev,"Failed requesting irq, irq = %d\n" , irq);return ret;
Re: [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member
In reply to Fabio EstevamQuoted 4 lines · On Mon, 3 Jun 2019 16:34:33 -0300 Fabio Estevam <[email protected]> wrote:
average_enis always true, so there is not really need for this structure member.Signed-off-by Fabio Estevam <[email protected]>
Applied.
Thanks,
Jonathan
Quoted 37 lines
--- drivers/iio/adc/imx7d_adc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/iio/adc/imx7d_adc.c +2
-6@@ -101,8 +101,6 @@ struct imx7d_adc_feature {enum imx7d_adc_average_num avg_num;u32 core_time_unit;/* impact the sample rate */ - -bool average_en; };struct imx7d_adc {@@ -180,7 +178,6 @@ static void imx7d_adc_feature_config(struct imx7d_adc *info) info->adc_feature.clk_pre_div =IMX7D_ADC_ANALOG_CLK_PRE_DIV_4 ; info->adc_feature.avg_num =IMX7D_ADC_AVERAGE_NUM_32 ; info->adc_feature.core_time_unit =1 ; - info->adc_feature.average_en = true; }static void imx7d_adc_sample_rate_set (struct imx7d_adc *info)@@ -241,9 +238,8 @@ static void imx7d_adc_channel_set(struct imx7d_adc *info)/* the channel choose single conversion, and enable average mode */ cfg1 |= (IMX7D_REG_ADC_CH_CFG1_CHANNEL_EN | -IMX7D_REG_ADC_CH_CFG1_CHANNEL_SINGLE ); -if (info->adc_feature.average_en) - cfg1 |=IMX7D_REG_ADC_CH_CFG1_CHANNEL_AVG_EN ; +IMX7D_REG_ADC_CH_CFG1_CHANNEL_SINGLE | +IMX7D_REG_ADC_CH_CFG1_CHANNEL_AVG_EN );/* * physical channel 0 chose logical channel A