Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: adc: vf610: Avoid division by zero
@ 2015-11-03 16:18 Fabio Estevam
  2015-11-04  6:41 ` Duan Andy
  2015-11-15 12:37 ` Jonathan Cameron
  0 siblings, 2 replies; 4+ messages in thread
From: Fabio Estevam @ 2015-11-03 16:18 UTC (permalink / raw)
  To: jic23; +Cc: b38611, linux-iio, festevam, Fabio Estevam

When the 'adck-max-frequency' property is not passed in device tree,
the following division by zero is seen:

[    2.196814] Hardware name: Freescale i.MX6 SoloX (Device Tree)
[    2.202652] Backtrace: 
[    2.205156] [<c0013600>] (dump_backtrace) from [<c001379c>] (show_stack+0x18/0x1c)
[    2.212730]  r6:ef138410 r5:00000000 r4:00000000 r3:00000000
[    2.218494] [<c0013784>] (show_stack) from [<c02d8220>] (dump_stack+0x88/0xa4)
[    2.225756] [<c02d8198>] (dump_stack) from [<c001346c>] (__div0+0x18/0x20)
[    2.232636]  r5:00000001 r4:eeb0a800
[    2.236286] [<c0013454>] (__div0) from [<c02d6be4>] (Ldiv0+0x8/0x10)
[    2.242657] [<c0574574>] (vf610_adc_probe) from [<c03c9274>] (platform_drv_probe+0x58/0xb4)

Provide a sane adck_rate default value that can be used in normal,
high-speed and low-power modes in the case of 'adck-max-frequency' property
being absent.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/iio/adc/vf610_adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
index 599cde3..424fd69 100644
--- a/drivers/iio/adc/vf610_adc.c
+++ b/drivers/iio/adc/vf610_adc.c
@@ -105,6 +105,7 @@
 #define VF610_ADC_TIMEOUT		msecs_to_jiffies(100)
 
 #define DEFAULT_SAMPLE_TIME		1000
+#define ADCK_RATE_MAX_DEFAULT		20000000
 
 enum clk_sel {
 	VF610_ADCIOC_BUSCLK_SET,
@@ -195,6 +196,7 @@ static inline void vf610_adc_calculate_rates(struct vf610_adc *info)
 	} else {
 		/* fall-back value using a safe divisor */
 		adc_feature->clk_div = 8;
+		adck_rate = ADCK_RATE_MAX_DEFAULT;
 	}
 
 	/*
-- 
1.9.1

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

* RE: [PATCH] iio: adc: vf610: Avoid division by zero
  2015-11-03 16:18 [PATCH] iio: adc: vf610: Avoid division by zero Fabio Estevam
@ 2015-11-04  6:41 ` Duan Andy
  2015-11-08 15:42   ` Jonathan Cameron
  2015-11-15 12:37 ` Jonathan Cameron
  1 sibling, 1 reply; 4+ messages in thread
From: Duan Andy @ 2015-11-04  6:41 UTC (permalink / raw)
  To: Fabio Estevam, jic23@kernel.org
  Cc: linux-iio@vger.kernel.org, festevam@gmail.com, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com> Sent: Wednesday, November 04, 2015 12:19 AM
> To: jic23@kernel.org
> Cc: Duan Fugang-B38611; linux-iio@vger.kernel.org; festevam@gmail.com;
> Estevam Fabio-R49496
> Subject: [PATCH] iio: adc: vf610: Avoid division by zero
> 
> When the 'adck-max-frequency' property is not passed in device tree, the
> following division by zero is seen:
> 
> [    2.196814] Hardware name: Freescale i.MX6 SoloX (Device Tree)
> [    2.202652] Backtrace:
> [    2.205156] [<c0013600>] (dump_backtrace) from [<c001379c>]
> (show_stack+0x18/0x1c)
> [    2.212730]  r6:ef138410 r5:00000000 r4:00000000 r3:00000000
> [    2.218494] [<c0013784>] (show_stack) from [<c02d8220>]
> (dump_stack+0x88/0xa4)
> [    2.225756] [<c02d8198>] (dump_stack) from [<c001346c>]
> (__div0+0x18/0x20)
> [    2.232636]  r5:00000001 r4:eeb0a800
> [    2.236286] [<c0013454>] (__div0) from [<c02d6be4>] (Ldiv0+0x8/0x10)
> [    2.242657] [<c0574574>] (vf610_adc_probe) from [<c03c9274>]
> (platform_drv_probe+0x58/0xb4)
> 
> Provide a sane adck_rate default value that can be used in normal, high-
> speed and low-power modes in the case of 'adck-max-frequency' property
> being absent.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  drivers/iio/adc/vf610_adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
> index 599cde3..424fd69 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -105,6 +105,7 @@
>  #define VF610_ADC_TIMEOUT		msecs_to_jiffies(100)
> 
>  #define DEFAULT_SAMPLE_TIME		1000
> +#define ADCK_RATE_MAX_DEFAULT		20000000
> 
>  enum clk_sel {
>  	VF610_ADCIOC_BUSCLK_SET,
> @@ -195,6 +196,7 @@ static inline void vf610_adc_calculate_rates(struct
> vf610_adc *info)
>  	} else {
>  		/* fall-back value using a safe divisor */
>  		adc_feature->clk_div = 8;
> +		adck_rate = ADCK_RATE_MAX_DEFAULT;
>  	}
> 
>  	/*
> --
> 1.9.1

Acked-by: Fugang Duan <B38611@freescale.com>

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

* Re: [PATCH] iio: adc: vf610: Avoid division by zero
  2015-11-04  6:41 ` Duan Andy
@ 2015-11-08 15:42   ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2015-11-08 15:42 UTC (permalink / raw)
  To: Duan Andy, Fabio Estevam; +Cc: linux-iio@vger.kernel.org, festevam@gmail.com

On 04/11/15 06:41, Duan Andy wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com> Sent: Wednesday, November 04, 2015 12:19 AM
>> To: jic23@kernel.org
>> Cc: Duan Fugang-B38611; linux-iio@vger.kernel.org; festevam@gmail.com;
>> Estevam Fabio-R49496
>> Subject: [PATCH] iio: adc: vf610: Avoid division by zero
>>
>> When the 'adck-max-frequency' property is not passed in device tree, the
>> following division by zero is seen:
>>
>> [    2.196814] Hardware name: Freescale i.MX6 SoloX (Device Tree)
>> [    2.202652] Backtrace:
>> [    2.205156] [<c0013600>] (dump_backtrace) from [<c001379c>]
>> (show_stack+0x18/0x1c)
>> [    2.212730]  r6:ef138410 r5:00000000 r4:00000000 r3:00000000
>> [    2.218494] [<c0013784>] (show_stack) from [<c02d8220>]
>> (dump_stack+0x88/0xa4)
>> [    2.225756] [<c02d8198>] (dump_stack) from [<c001346c>]
>> (__div0+0x18/0x20)
>> [    2.232636]  r5:00000001 r4:eeb0a800
>> [    2.236286] [<c0013454>] (__div0) from [<c02d6be4>] (Ldiv0+0x8/0x10)
>> [    2.242657] [<c0574574>] (vf610_adc_probe) from [<c03c9274>]
>> (platform_drv_probe+0x58/0xb4)
>>
>> Provide a sane adck_rate default value that can be used in normal, high-
>> speed and low-power modes in the case of 'adck-max-frequency' property
>> being absent.
>>
>> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
>> ---
>>  drivers/iio/adc/vf610_adc.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
>> index 599cde3..424fd69 100644
>> --- a/drivers/iio/adc/vf610_adc.c
>> +++ b/drivers/iio/adc/vf610_adc.c
>> @@ -105,6 +105,7 @@
>>  #define VF610_ADC_TIMEOUT		msecs_to_jiffies(100)
>>
>>  #define DEFAULT_SAMPLE_TIME		1000
>> +#define ADCK_RATE_MAX_DEFAULT		20000000
>>
>>  enum clk_sel {
>>  	VF610_ADCIOC_BUSCLK_SET,
>> @@ -195,6 +196,7 @@ static inline void vf610_adc_calculate_rates(struct
>> vf610_adc *info)
>>  	} else {
>>  		/* fall-back value using a safe divisor */
>>  		adc_feature->clk_div = 8;
>> +		adck_rate = ADCK_RATE_MAX_DEFAULT;
>>  	}
>>
>>  	/*
>> --
>> 1.9.1
> 
> Acked-by: Fugang Duan <B38611@freescale.com>
Applied to the fixes-togreg branch of iio.git - marked for stable.

Thanks,

Jonathan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [PATCH] iio: adc: vf610: Avoid division by zero
  2015-11-03 16:18 [PATCH] iio: adc: vf610: Avoid division by zero Fabio Estevam
  2015-11-04  6:41 ` Duan Andy
@ 2015-11-15 12:37 ` Jonathan Cameron
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2015-11-15 12:37 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: b38611, linux-iio, festevam

On 03/11/15 16:18, Fabio Estevam wrote:
> When the 'adck-max-frequency' property is not passed in device tree,
> the following division by zero is seen:
> 
> [    2.196814] Hardware name: Freescale i.MX6 SoloX (Device Tree)
> [    2.202652] Backtrace: 
> [    2.205156] [<c0013600>] (dump_backtrace) from [<c001379c>] (show_stack+0x18/0x1c)
> [    2.212730]  r6:ef138410 r5:00000000 r4:00000000 r3:00000000
> [    2.218494] [<c0013784>] (show_stack) from [<c02d8220>] (dump_stack+0x88/0xa4)
> [    2.225756] [<c02d8198>] (dump_stack) from [<c001346c>] (__div0+0x18/0x20)
> [    2.232636]  r5:00000001 r4:eeb0a800
> [    2.236286] [<c0013454>] (__div0) from [<c02d6be4>] (Ldiv0+0x8/0x10)
> [    2.242657] [<c0574574>] (vf610_adc_probe) from [<c03c9274>] (platform_drv_probe+0x58/0xb4)
> 
> Provide a sane adck_rate default value that can be used in normal,
> high-speed and low-power modes in the case of 'adck-max-frequency' property
> being absent.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Hi Fabio

Actually ended up with two different fixes for the same issue merged
so as this was the later one I've dropped it.

The other fix changed the code ordering to set the adck_rate using the default
divisor.
> ---
>  drivers/iio/adc/vf610_adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
> index 599cde3..424fd69 100644
> --- a/drivers/iio/adc/vf610_adc.c
> +++ b/drivers/iio/adc/vf610_adc.c
> @@ -105,6 +105,7 @@
>  #define VF610_ADC_TIMEOUT		msecs_to_jiffies(100)
>  
>  #define DEFAULT_SAMPLE_TIME		1000
> +#define ADCK_RATE_MAX_DEFAULT		20000000
>  
>  enum clk_sel {
>  	VF610_ADCIOC_BUSCLK_SET,
> @@ -195,6 +196,7 @@ static inline void vf610_adc_calculate_rates(struct vf610_adc *info)
>  	} else {
>  		/* fall-back value using a safe divisor */
>  		adc_feature->clk_div = 8;
> +		adck_rate = ADCK_RATE_MAX_DEFAULT;
>  	}
>  
>  	/*
> 


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

end of thread, other threads:[~2015-11-15 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-03 16:18 [PATCH] iio: adc: vf610: Avoid division by zero Fabio Estevam
2015-11-04  6:41 ` Duan Andy
2015-11-08 15:42   ` Jonathan Cameron
2015-11-15 12:37 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox