All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message
@ 2019-06-03 19:34 Fabio Estevam
  2019-06-03 19:34 ` [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock Fabio Estevam
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Fabio Estevam @ 2019-06-03 19:34 UTC (permalink / raw)
  To: jic23; +Cc: andrew.smirnov, linux-iio, Fabio Estevam

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 <festevam@gmail.com>
---
 drivers/iio/adc/imx7d_adc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 4fe97c2a0f43..23c7b0ee945f 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -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) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock
  2019-06-03 19:34 [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Fabio Estevam
@ 2019-06-03 19:34 ` Fabio Estevam
  2019-06-08 12:59   ` Jonathan Cameron
  2019-06-03 19:34 ` [PATCH 3/4] iio: imx7d_adc: Fit into a single line Fabio Estevam
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Fabio Estevam @ 2019-06-03 19:34 UTC (permalink / raw)
  To: jic23; +Cc: andrew.smirnov, linux-iio, Fabio Estevam

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 <festevam@gmail.com>
---
 drivers/iio/adc/imx7d_adc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 23c7b0ee945f..bffc172e7635 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] iio: imx7d_adc: Fit into a single line
  2019-06-03 19:34 [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Fabio Estevam
  2019-06-03 19:34 ` [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock Fabio Estevam
@ 2019-06-03 19:34 ` Fabio Estevam
  2019-06-08 13:00   ` Jonathan Cameron
  2019-06-03 19:34 ` [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member Fabio Estevam
  2019-06-08 12:58 ` [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Jonathan Cameron
  3 siblings, 1 reply; 8+ messages in thread
From: Fabio Estevam @ 2019-06-03 19:34 UTC (permalink / raw)
  To: jic23; +Cc: andrew.smirnov, linux-iio, 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.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/iio/adc/imx7d_adc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index bffc172e7635..46e88899ad74 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member
  2019-06-03 19:34 [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Fabio Estevam
  2019-06-03 19:34 ` [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock Fabio Estevam
  2019-06-03 19:34 ` [PATCH 3/4] iio: imx7d_adc: Fit into a single line Fabio Estevam
@ 2019-06-03 19:34 ` Fabio Estevam
  2019-06-08 13:01   ` Jonathan Cameron
  2019-06-08 12:58 ` [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Jonathan Cameron
  3 siblings, 1 reply; 8+ messages in thread
From: Fabio Estevam @ 2019-06-03 19:34 UTC (permalink / raw)
  To: jic23; +Cc: andrew.smirnov, linux-iio, Fabio Estevam

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

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/iio/adc/imx7d_adc.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 46e88899ad74..26a7bbe4d534 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -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
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message
  2019-06-03 19:34 [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Fabio Estevam
                   ` (2 preceding siblings ...)
  2019-06-03 19:34 ` [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member Fabio Estevam
@ 2019-06-08 12:58 ` Jonathan Cameron
  3 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2019-06-08 12:58 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: andrew.smirnov, linux-iio

On Mon,  3 Jun 2019 16:34:30 -0300
Fabio Estevam <festevam@gmail.com> 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 <festevam@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/imx7d_adc.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index 4fe97c2a0f43..23c7b0ee945f 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -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) {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock
  2019-06-03 19:34 ` [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock Fabio Estevam
@ 2019-06-08 12:59   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2019-06-08 12:59 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: andrew.smirnov, linux-iio

On Mon,  3 Jun 2019 16:34:31 -0300
Fabio Estevam <festevam@gmail.com> 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 <festevam@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

thanks,

Jonathan

> ---
>  drivers/iio/adc/imx7d_adc.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index 23c7b0ee945f..bffc172e7635 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -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;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] iio: imx7d_adc: Fit into a single line
  2019-06-03 19:34 ` [PATCH 3/4] iio: imx7d_adc: Fit into a single line Fabio Estevam
@ 2019-06-08 13:00   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2019-06-08 13:00 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: andrew.smirnov, linux-iio

On Mon,  3 Jun 2019 16:34:32 -0300
Fabio Estevam <festevam@gmail.com> 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 <festevam@gmail.com>
Applied.

Thanks,
> ---
>  drivers/iio/adc/imx7d_adc.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index bffc172e7635..46e88899ad74 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -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;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member
  2019-06-03 19:34 ` [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member Fabio Estevam
@ 2019-06-08 13:01   ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2019-06-08 13:01 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: andrew.smirnov, linux-iio

On Mon,  3 Jun 2019 16:34:33 -0300
Fabio Estevam <festevam@gmail.com> wrote:

> average_en is always true, so there is not really need for
> this structure member.
> 
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
Applied.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/imx7d_adc.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index 46e88899ad74..26a7bbe4d534 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-06-08 13:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-03 19:34 [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Fabio Estevam
2019-06-03 19:34 ` [PATCH 2/4] iio: imx7d_adc: Introduce a definition for the input clock Fabio Estevam
2019-06-08 12:59   ` Jonathan Cameron
2019-06-03 19:34 ` [PATCH 3/4] iio: imx7d_adc: Fit into a single line Fabio Estevam
2019-06-08 13:00   ` Jonathan Cameron
2019-06-03 19:34 ` [PATCH 4/4] iio: imx7d_adc: Remove unneeded 'average_en' member Fabio Estevam
2019-06-08 13:01   ` Jonathan Cameron
2019-06-08 12:58 ` [PATCH 1/4] iio: imx7d_adc: Remove unneeded error message Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.