linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] staging:iio: Don't compare boolean values with true/false
@ 2012-10-18 14:43 Lars-Peter Clausen
  2012-10-18 14:43 ` [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it Lars-Peter Clausen
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Lars-Peter Clausen @ 2012-10-18 14:43 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Fixes the following coccicheck warnings:
	drivers/staging/iio/accel/lis3l02dq_ring.c:240:5-10: WARNING: Comparison to bool
	drivers/staging/iio/iio_dummy_evgen.c:111:6-25: WARNING: Comparison to bool

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/staging/iio/accel/lis3l02dq_ring.c |    2 +-
 drivers/staging/iio/iio_dummy_evgen.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
index fa4190d..ee887e9 100644
--- a/drivers/staging/iio/accel/lis3l02dq_ring.c
+++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
@@ -237,7 +237,7 @@ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
 	u8 t;
 
 	__lis3l02dq_write_data_ready_config(indio_dev, state);
-	if (state == false) {
+	if (!state) {
 		/*
 		 * A possible quirk with the handler is currently worked around
 		 * by ensuring outstanding read events are cleared.
diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
index 74e24e8..132d278 100644
--- a/drivers/staging/iio/iio_dummy_evgen.c
+++ b/drivers/staging/iio/iio_dummy_evgen.c
@@ -108,7 +108,7 @@ int iio_dummy_evgen_get_irq(void)
 
 	mutex_lock(&iio_evgen->lock);
 	for (i = 0; i < IIO_EVENTGEN_NO; i++)
-		if (iio_evgen->inuse[i] == false) {
+		if (!iio_evgen->inuse[i]) {
 			ret = iio_evgen->base + i;
 			iio_evgen->inuse[i] = true;
 			break;
-- 
1.7.10.4


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

* [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it
  2012-10-18 14:43 [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Lars-Peter Clausen
@ 2012-10-18 14:43 ` Lars-Peter Clausen
  2012-10-18 16:16   ` Roland Stigge
  2012-10-18 14:43 ` [PATCH 3/4] iio: Don't compare boolean values to true/false Lars-Peter Clausen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: Lars-Peter Clausen @ 2012-10-18 14:43 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Roland Stigge

Fixes the following error from coccicheck:
	drivers/staging/iio/adc/lpc32xx_adc.c:153:43-46: ERROR: Missing resource_size with res

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Roland Stigge <stigge@antcom.de>
---
 drivers/staging/iio/adc/lpc32xx_adc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c
index 7e9bd00..10c5962 100644
--- a/drivers/staging/iio/adc/lpc32xx_adc.c
+++ b/drivers/staging/iio/adc/lpc32xx_adc.c
@@ -150,7 +150,7 @@ static int __devinit lpc32xx_adc_probe(struct platform_device *pdev)
 
 	info = iio_priv(iodev);
 
-	info->adc_base = ioremap(res->start, res->end - res->start + 1);
+	info->adc_base = ioremap(res->start, resource_size(res));
 	if (!info->adc_base) {
 		dev_err(&pdev->dev, "failed mapping memory\n");
 		retval = -EBUSY;
-- 
1.7.10.4


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

* [PATCH 3/4] iio: Don't compare boolean values to true/false
  2012-10-18 14:43 [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Lars-Peter Clausen
  2012-10-18 14:43 ` [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it Lars-Peter Clausen
@ 2012-10-18 14:43 ` Lars-Peter Clausen
  2012-10-19 15:27   ` Jonathan Cameron
  2012-10-18 14:43 ` [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays Lars-Peter Clausen
  2012-10-19 15:24 ` [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Jonathan Cameron
  3 siblings, 1 reply; 12+ messages in thread
From: Lars-Peter Clausen @ 2012-10-18 14:43 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Fixes the following warnings from coccicheck:
	drivers/iio/inkern.c:81:6-14: WARNING: Comparison to bool
	drivers/iio/dac/ad5686.c:191:5-11: WARNING: Comparison to bool

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/dac/ad5686.c |    2 +-
 drivers/iio/inkern.c     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 6948d75..bc92ff9 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -188,7 +188,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
 	if (ret)
 		return ret;
 
-	if (readin == true)
+	if (readin)
 		st->pwr_down_mask |= (0x3 << (chan->channel * 2));
 	else
 		st->pwr_down_mask &= ~(0x3 << (chan->channel * 2));
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index f2b78d4..5230a33 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -78,7 +78,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev,
 				found_it = true;
 				break;
 			}
-		if (found_it == false) {
+		if (!found_it) {
 			ret = -ENODEV;
 			goto error_ret;
 		}
-- 
1.7.10.4


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

* [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays
  2012-10-18 14:43 [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Lars-Peter Clausen
  2012-10-18 14:43 ` [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it Lars-Peter Clausen
  2012-10-18 14:43 ` [PATCH 3/4] iio: Don't compare boolean values to true/false Lars-Peter Clausen
@ 2012-10-18 14:43 ` Lars-Peter Clausen
  2012-10-19  8:54   ` Maxime Ripard
  2012-10-19 15:32   ` Jonathan Cameron
  2012-10-19 15:24 ` [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Jonathan Cameron
  3 siblings, 2 replies; 12+ messages in thread
From: Lars-Peter Clausen @ 2012-10-18 14:43 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen, Maxime Ripard

Use dev_kcalloc instead of devm_kzalloc to allocate arrays since it is
semantically more appropriate.

While we are at it the patch also fixes the following coccinelle warning:
	drivers/iio/adc/at91_adc.c:277:25-31: ERROR: application of sizeof to pointer

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 drivers/iio/adc/at91_adc.c |   16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 3ed94bf..b81f93b 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -126,10 +126,8 @@ static int at91_adc_channel_init(struct iio_dev *idev)
 	idev->num_channels = bitmap_weight(&st->channels_mask,
 					   st->num_channels) + 1;
 
-	chan_array = devm_kzalloc(&idev->dev,
-				  ((idev->num_channels + 1) *
-					sizeof(struct iio_chan_spec)),
-				  GFP_KERNEL);
+	chan_array = devm_kcalloc(&idev->dev, idev->num_channels + 1,
+					sizeof(*chan_array), GFP_KERNEL);
 
 	if (!chan_array)
 		return -ENOMEM;
@@ -273,9 +271,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
 	struct at91_adc_state *st = iio_priv(idev);
 	int i, ret;
 
-	st->trig = devm_kzalloc(&idev->dev,
-				st->trigger_number * sizeof(st->trig),
-				GFP_KERNEL);
+	st->trig = devm_kcalloc(&idev->dev, st->trigger_number,
+				sizeof(*st->trig), GFP_KERNEL);
 
 	if (st->trig == NULL) {
 		ret = -ENOMEM;
@@ -457,9 +454,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
 	st->registers->trigger_register = prop;
 
 	st->trigger_number = of_get_child_count(node);
-	st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
-					sizeof(struct at91_adc_trigger),
-					GFP_KERNEL);
+	st->trigger_list = devm_kcalloc(&idev->dev, st->trigger_number,
+					sizeof(*st->trigger_list), GFP_KERNEL);
 	if (!st->trigger_list) {
 		dev_err(&idev->dev, "Could not allocate trigger list memory.\n");
 		ret = -ENOMEM;
-- 
1.7.10.4


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

* Re: [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it
  2012-10-18 14:43 ` [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it Lars-Peter Clausen
@ 2012-10-18 16:16   ` Roland Stigge
  2012-10-19 15:26     ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Roland Stigge @ 2012-10-18 16:16 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio

On 10/18/2012 04:43 PM, Lars-Peter Clausen wrote:
> Fixes the following error from coccicheck:
> 	drivers/staging/iio/adc/lpc32xx_adc.c:153:43-46: ERROR: Missing resource_size with res
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Acked-by: Roland Stigge <stigge@antcom.de>

> Cc: Roland Stigge <stigge@antcom.de>
> ---
>  drivers/staging/iio/adc/lpc32xx_adc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c
> index 7e9bd00..10c5962 100644
> --- a/drivers/staging/iio/adc/lpc32xx_adc.c
> +++ b/drivers/staging/iio/adc/lpc32xx_adc.c
> @@ -150,7 +150,7 @@ static int __devinit lpc32xx_adc_probe(struct platform_device *pdev)
>  
>  	info = iio_priv(iodev);
>  
> -	info->adc_base = ioremap(res->start, res->end - res->start + 1);
> +	info->adc_base = ioremap(res->start, resource_size(res));
>  	if (!info->adc_base) {
>  		dev_err(&pdev->dev, "failed mapping memory\n");
>  		retval = -EBUSY;


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

* Re: [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays
  2012-10-18 14:43 ` [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays Lars-Peter Clausen
@ 2012-10-19  8:54   ` Maxime Ripard
  2012-10-19 15:32   ` Jonathan Cameron
  1 sibling, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2012-10-19  8:54 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio

Le 18/10/2012 16:43, Lars-Peter Clausen a écrit :
> Use dev_kcalloc instead of devm_kzalloc to allocate arrays since it is
> semantically more appropriate.
> 
> While we are at it the patch also fixes the following coccinelle warning:
> 	drivers/iio/adc/at91_adc.c:277:25-31: ERROR: application of sizeof to pointer
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Acked-By: Maxime Ripard <maxime.ripard@free-electrons.com>


-- 
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

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

* Re: [PATCH 1/4] staging:iio: Don't compare boolean values with true/false
  2012-10-18 14:43 [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Lars-Peter Clausen
                   ` (2 preceding siblings ...)
  2012-10-18 14:43 ` [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays Lars-Peter Clausen
@ 2012-10-19 15:24 ` Jonathan Cameron
  2012-10-19 17:55   ` Lars-Peter Clausen
  3 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cameron @ 2012-10-19 15:24 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio

On 10/18/2012 03:43 PM, Lars-Peter Clausen wrote:
> Fixes the following coccicheck warnings:
> 	drivers/staging/iio/accel/lis3l02dq_ring.c:240:5-10: WARNING: Comparison to bool
> 	drivers/staging/iio/iio_dummy_evgen.c:111:6-25: WARNING: Comparison to bool
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Can't say I can summon much enthusiasm for this patch..

Added to togreg branch.
> ---
>  drivers/staging/iio/accel/lis3l02dq_ring.c |    2 +-
>  drivers/staging/iio/iio_dummy_evgen.c      |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
> index fa4190d..ee887e9 100644
> --- a/drivers/staging/iio/accel/lis3l02dq_ring.c
> +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
> @@ -237,7 +237,7 @@ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
>  	u8 t;
>  
>  	__lis3l02dq_write_data_ready_config(indio_dev, state);
> -	if (state == false) {
> +	if (!state) {
>  		/*
>  		 * A possible quirk with the handler is currently worked around
>  		 * by ensuring outstanding read events are cleared.
> diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
> index 74e24e8..132d278 100644
> --- a/drivers/staging/iio/iio_dummy_evgen.c
> +++ b/drivers/staging/iio/iio_dummy_evgen.c
> @@ -108,7 +108,7 @@ int iio_dummy_evgen_get_irq(void)
>  
>  	mutex_lock(&iio_evgen->lock);
>  	for (i = 0; i < IIO_EVENTGEN_NO; i++)
> -		if (iio_evgen->inuse[i] == false) {
> +		if (!iio_evgen->inuse[i]) {
>  			ret = iio_evgen->base + i;
>  			iio_evgen->inuse[i] = true;
>  			break;
> 

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

* Re: [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it
  2012-10-18 16:16   ` Roland Stigge
@ 2012-10-19 15:26     ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2012-10-19 15:26 UTC (permalink / raw)
  To: Roland Stigge; +Cc: Lars-Peter Clausen, Jonathan Cameron, linux-iio

On 10/18/2012 05:16 PM, Roland Stigge wrote:
> On 10/18/2012 04:43 PM, Lars-Peter Clausen wrote:
>> Fixes the following error from coccicheck:
>> 	drivers/staging/iio/adc/lpc32xx_adc.c:153:43-46: ERROR: Missing resource_size with res
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> 
> Acked-by: Roland Stigge <stigge@antcom.de>
Applied to togreg branch of iio.git
> 
>> Cc: Roland Stigge <stigge@antcom.de>
>> ---
>>  drivers/staging/iio/adc/lpc32xx_adc.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c
>> index 7e9bd00..10c5962 100644
>> --- a/drivers/staging/iio/adc/lpc32xx_adc.c
>> +++ b/drivers/staging/iio/adc/lpc32xx_adc.c
>> @@ -150,7 +150,7 @@ static int __devinit lpc32xx_adc_probe(struct platform_device *pdev)
>>  
>>  	info = iio_priv(iodev);
>>  
>> -	info->adc_base = ioremap(res->start, res->end - res->start + 1);
>> +	info->adc_base = ioremap(res->start, resource_size(res));
>>  	if (!info->adc_base) {
>>  		dev_err(&pdev->dev, "failed mapping memory\n");
>>  		retval = -EBUSY;
> 
> --
> 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] 12+ messages in thread

* Re: [PATCH 3/4] iio: Don't compare boolean values to true/false
  2012-10-18 14:43 ` [PATCH 3/4] iio: Don't compare boolean values to true/false Lars-Peter Clausen
@ 2012-10-19 15:27   ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2012-10-19 15:27 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: linux-iio

On 10/18/2012 03:43 PM, Lars-Peter Clausen wrote:
> Fixes the following warnings from coccicheck:
> 	drivers/iio/inkern.c:81:6-14: WARNING: Comparison to bool
> 	drivers/iio/dac/ad5686.c:191:5-11: WARNING: Comparison to bool
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Another 'exciting patch'.  I guess it fills the time whilst on a train
under the sea though... hohum.  Land soon and back to mindless websurfing...
> ---
>  drivers/iio/dac/ad5686.c |    2 +-
>  drivers/iio/inkern.c     |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index 6948d75..bc92ff9 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -188,7 +188,7 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev,
>  	if (ret)
>  		return ret;
>  
> -	if (readin == true)
> +	if (readin)
>  		st->pwr_down_mask |= (0x3 << (chan->channel * 2));
>  	else
>  		st->pwr_down_mask &= ~(0x3 << (chan->channel * 2));
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index f2b78d4..5230a33 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -78,7 +78,7 @@ int iio_map_array_unregister(struct iio_dev *indio_dev,
>  				found_it = true;
>  				break;
>  			}
> -		if (found_it == false) {
> +		if (!found_it) {
>  			ret = -ENODEV;
>  			goto error_ret;
>  		}
> 

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

* Re: [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays
  2012-10-18 14:43 ` [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays Lars-Peter Clausen
  2012-10-19  8:54   ` Maxime Ripard
@ 2012-10-19 15:32   ` Jonathan Cameron
  1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2012-10-19 15:32 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, Maxime Ripard

On 10/18/2012 03:43 PM, Lars-Peter Clausen wrote:
> Use dev_kcalloc instead of devm_kzalloc to allocate arrays since it is
> semantically more appropriate.
> 
> While we are at it the patch also fixes the following coccinelle warning:
> 	drivers/iio/adc/at91_adc.c:277:25-31: ERROR: application of sizeof to pointer
'interesting description'. Surely it means in assigment of memory to the same pointer.
Not the clearest description and here doesn't cause an actual bug, just a semantic
mess.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Applied to togreg branch of iio.git.  Hmm.. should have stayed under the sea.
It wasn't raining there.
> ---
>  drivers/iio/adc/at91_adc.c |   16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 3ed94bf..b81f93b 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -126,10 +126,8 @@ static int at91_adc_channel_init(struct iio_dev *idev)
>  	idev->num_channels = bitmap_weight(&st->channels_mask,
>  					   st->num_channels) + 1;
>  
> -	chan_array = devm_kzalloc(&idev->dev,
> -				  ((idev->num_channels + 1) *
> -					sizeof(struct iio_chan_spec)),
> -				  GFP_KERNEL);
> +	chan_array = devm_kcalloc(&idev->dev, idev->num_channels + 1,
> +					sizeof(*chan_array), GFP_KERNEL);
>  
>  	if (!chan_array)
>  		return -ENOMEM;
> @@ -273,9 +271,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
>  	struct at91_adc_state *st = iio_priv(idev);
>  	int i, ret;
>  
> -	st->trig = devm_kzalloc(&idev->dev,
> -				st->trigger_number * sizeof(st->trig),
> -				GFP_KERNEL);
> +	st->trig = devm_kcalloc(&idev->dev, st->trigger_number,
> +				sizeof(*st->trig), GFP_KERNEL);
>  
>  	if (st->trig == NULL) {
>  		ret = -ENOMEM;
> @@ -457,9 +454,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
>  	st->registers->trigger_register = prop;
>  
>  	st->trigger_number = of_get_child_count(node);
> -	st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
> -					sizeof(struct at91_adc_trigger),
> -					GFP_KERNEL);
> +	st->trigger_list = devm_kcalloc(&idev->dev, st->trigger_number,
> +					sizeof(*st->trigger_list), GFP_KERNEL);
>  	if (!st->trigger_list) {
>  		dev_err(&idev->dev, "Could not allocate trigger list memory.\n");
>  		ret = -ENOMEM;
> 

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

* Re: [PATCH 1/4] staging:iio: Don't compare boolean values with true/false
  2012-10-19 15:24 ` [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Jonathan Cameron
@ 2012-10-19 17:55   ` Lars-Peter Clausen
  2012-10-19 17:59     ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Lars-Peter Clausen @ 2012-10-19 17:55 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Jonathan Cameron, linux-iio

On 10/19/2012 05:24 PM, Jonathan Cameron wrote:
> On 10/18/2012 03:43 PM, Lars-Peter Clausen wrote:
>> Fixes the following coccicheck warnings:
>> 	drivers/staging/iio/accel/lis3l02dq_ring.c:240:5-10: WARNING: Comparison to bool
>> 	drivers/staging/iio/iio_dummy_evgen.c:111:6-25: WARNING: Comparison to bool
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Can't say I can summon much enthusiasm for this patch..

Me neither, that's why I did not fix this up for the DAC drivers when I moved
them out of staging. But it turns out that existing coccicheck errors can cause
false positives in Fengguang Wu automated commit test scripts. We've seen a few
of these in the past. So I've to decided to just fix all coccicheck
warnings/error for IIO to avoid further false positives.

> Added to togreg branch.

Thanks.

>> ---
>>  drivers/staging/iio/accel/lis3l02dq_ring.c |    2 +-
>>  drivers/staging/iio/iio_dummy_evgen.c      |    2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
>> index fa4190d..ee887e9 100644
>> --- a/drivers/staging/iio/accel/lis3l02dq_ring.c
>> +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
>> @@ -237,7 +237,7 @@ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
>>  	u8 t;
>>  
>>  	__lis3l02dq_write_data_ready_config(indio_dev, state);
>> -	if (state == false) {
>> +	if (!state) {
>>  		/*
>>  		 * A possible quirk with the handler is currently worked around
>>  		 * by ensuring outstanding read events are cleared.
>> diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
>> index 74e24e8..132d278 100644
>> --- a/drivers/staging/iio/iio_dummy_evgen.c
>> +++ b/drivers/staging/iio/iio_dummy_evgen.c
>> @@ -108,7 +108,7 @@ int iio_dummy_evgen_get_irq(void)
>>  
>>  	mutex_lock(&iio_evgen->lock);
>>  	for (i = 0; i < IIO_EVENTGEN_NO; i++)
>> -		if (iio_evgen->inuse[i] == false) {
>> +		if (!iio_evgen->inuse[i]) {
>>  			ret = iio_evgen->base + i;
>>  			iio_evgen->inuse[i] = true;
>>  			break;
>>
> --
> 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] 12+ messages in thread

* Re: [PATCH 1/4] staging:iio: Don't compare boolean values with true/false
  2012-10-19 17:55   ` Lars-Peter Clausen
@ 2012-10-19 17:59     ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2012-10-19 17:59 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio

On 10/19/2012 06:55 PM, Lars-Peter Clausen wrote:
> On 10/19/2012 05:24 PM, Jonathan Cameron wrote:
>> On 10/18/2012 03:43 PM, Lars-Peter Clausen wrote:
>>> Fixes the following coccicheck warnings:
>>> 	drivers/staging/iio/accel/lis3l02dq_ring.c:240:5-10: WARNING: Comparison to bool
>>> 	drivers/staging/iio/iio_dummy_evgen.c:111:6-25: WARNING: Comparison to bool
>>>
>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> Can't say I can summon much enthusiasm for this patch..
> 
> Me neither, that's why I did not fix this up for the DAC drivers when I moved
> them out of staging. But it turns out that existing coccicheck errors can cause
> false positives in Fengguang Wu automated commit test scripts. We've seen a few
> of these in the past. So I've to decided to just fix all coccicheck
> warnings/error for IIO to avoid further false positives.
Fair enough and aiming for a clean coccicheck, smatch, sparse set makes it easier
to spot anything real that occurs locally. Also this is the correct time to do
this sort of stuff - nothing particularly big in the way of abi changes queued up
for these to cause fuzz in (for once ;)
> 
>> Added to togreg branch.
> 
> Thanks.
> 
>>> ---
>>>  drivers/staging/iio/accel/lis3l02dq_ring.c |    2 +-
>>>  drivers/staging/iio/iio_dummy_evgen.c      |    2 +-
>>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/staging/iio/accel/lis3l02dq_ring.c b/drivers/staging/iio/accel/lis3l02dq_ring.c
>>> index fa4190d..ee887e9 100644
>>> --- a/drivers/staging/iio/accel/lis3l02dq_ring.c
>>> +++ b/drivers/staging/iio/accel/lis3l02dq_ring.c
>>> @@ -237,7 +237,7 @@ static int lis3l02dq_data_rdy_trigger_set_state(struct iio_trigger *trig,
>>>  	u8 t;
>>>  
>>>  	__lis3l02dq_write_data_ready_config(indio_dev, state);
>>> -	if (state == false) {
>>> +	if (!state) {
>>>  		/*
>>>  		 * A possible quirk with the handler is currently worked around
>>>  		 * by ensuring outstanding read events are cleared.
>>> diff --git a/drivers/staging/iio/iio_dummy_evgen.c b/drivers/staging/iio/iio_dummy_evgen.c
>>> index 74e24e8..132d278 100644
>>> --- a/drivers/staging/iio/iio_dummy_evgen.c
>>> +++ b/drivers/staging/iio/iio_dummy_evgen.c
>>> @@ -108,7 +108,7 @@ int iio_dummy_evgen_get_irq(void)
>>>  
>>>  	mutex_lock(&iio_evgen->lock);
>>>  	for (i = 0; i < IIO_EVENTGEN_NO; i++)
>>> -		if (iio_evgen->inuse[i] == false) {
>>> +		if (!iio_evgen->inuse[i]) {
>>>  			ret = iio_evgen->base + i;
>>>  			iio_evgen->inuse[i] = true;
>>>  			break;
>>>
>> --
>> 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] 12+ messages in thread

end of thread, other threads:[~2012-10-19 17:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-18 14:43 [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Lars-Peter Clausen
2012-10-18 14:43 ` [PATCH 2/4] staging:iio:lpc32xx_adc: Use resource_size instead of opencoding it Lars-Peter Clausen
2012-10-18 16:16   ` Roland Stigge
2012-10-19 15:26     ` Jonathan Cameron
2012-10-18 14:43 ` [PATCH 3/4] iio: Don't compare boolean values to true/false Lars-Peter Clausen
2012-10-19 15:27   ` Jonathan Cameron
2012-10-18 14:43 ` [PATCH 4/4] iio: at91_adc: Use devm_kcalloc to allocate arrays Lars-Peter Clausen
2012-10-19  8:54   ` Maxime Ripard
2012-10-19 15:32   ` Jonathan Cameron
2012-10-19 15:24 ` [PATCH 1/4] staging:iio: Don't compare boolean values with true/false Jonathan Cameron
2012-10-19 17:55   ` Lars-Peter Clausen
2012-10-19 17:59     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).