Skip to contentSkip to conversation

iio: imx7d_adc: Remove unneeded error message

PATCH Applied Fabio Estevam 2 participants 8 messages Jun 3, 2019 – Jun 8, 2019

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 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
index 4fe97c2a0f43..23c7b0ee945f 100644
@@ -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
author reviewer
#1 lore raw

PATCH 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
index 23c7b0ee945f..bffc172e7635 100644
@@ -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		24000000
 
 enum 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
author reviewer
#3 lore raw

PATCH 3/4 iio: imx7d_adc: Fit into a single line

In reply to Fabio Estevam

All 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
index bffc172e7635..46e88899ad74 100644
@@ -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
author reviewer
#5 lore raw

PATCH 4/4 iio: imx7d_adc: Remove unneeded 'average_en' member

In reply to Fabio Estevam

average_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
index 46e88899ad74..26a7bbe4d534 100644
@@ -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
maintainer
#7 lore raw
In reply to Fabio Estevam
Quoted 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.

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
index 4fe97c2a0f43..23c7b0ee945f 100644
@@ -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) {
maintainer
#2 lore raw

Re: [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock

In reply to Fabio Estevam
Quoted 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.

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
index 23c7b0ee945f..bffc172e7635 100644
@@ -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		24000000
 
 enum 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;
maintainer Applied
#4 lore raw

Re: [PATCH 3/4] iio: imx7d_adc: Fit into a single line

In reply to Fabio Estevam
Quoted 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.

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
index bffc172e7635..46e88899ad74 100644
@@ -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;
maintainer Applied
#6 lore raw

Re: [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member

In reply to Fabio Estevam
Quoted 4 lines · On Mon, 3 Jun 2019 16:34:33 -0300 Fabio Estevam <[email protected]> wrote:

average_en is always true, so there is not really need for this structure member.

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
index 46e88899ad74..26a7bbe4d534 100644
@@ -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