linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines
@ 2016-09-25 11:41 Brian Masney
  2016-09-25 11:41 ` [PATCH 2/3] staging: iio: isl29018: made error handling consistent Brian Masney
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Brian Masney @ 2016-09-25 11:41 UTC (permalink / raw)
  To: gregkh; +Cc: linux-iio, devel

Removes unused variable and associated #defines that was found using
make W=1.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29018.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 76d9f74..ad282f1 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -66,16 +66,6 @@
 #define ISL29035_BOUT_SHIFT		0x07
 #define ISL29035_BOUT_MASK		(0x01 << ISL29035_BOUT_SHIFT)
 
-#define ISL29018_INT_TIME_AVAIL		"0.090000 0.005630 0.000351 0.000021"
-#define ISL29023_INT_TIME_AVAIL		"0.090000 0.005600 0.000352 0.000022"
-#define ISL29035_INT_TIME_AVAIL		"0.105000 0.006500 0.000410 0.000025"
-
-static const char * const int_time_avail[] = {
-	ISL29018_INT_TIME_AVAIL,
-	ISL29023_INT_TIME_AVAIL,
-	ISL29035_INT_TIME_AVAIL,
-};
-
 enum isl29018_int_time {
 	ISL29018_INT_TIME_16,
 	ISL29018_INT_TIME_12,
-- 
2.7.4


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

* [PATCH 2/3] staging: iio: isl29018: made error handling consistent
  2016-09-25 11:41 [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines Brian Masney
@ 2016-09-25 11:41 ` Brian Masney
  2016-09-25 14:28   ` Jonathan Cameron
  2016-09-25 11:41 ` [PATCH 3/3] staging: iio: isl29018: fix comparison between signed and unsigned integers Brian Masney
  2016-09-25 14:26 ` [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Brian Masney @ 2016-09-25 11:41 UTC (permalink / raw)
  To: gregkh; +Cc: linux-iio, devel

Changed the processing of IIO_CHAN_INFO_INT_TIME in isl29018_write_raw()
to unlock the mutex and return at the end of the function if invalid
input is passed in. This makes the error handling code consistent with
the processing of IIO_CHAN_INFO_CALIBSCALE and IIO_CHAN_INFO_SCALE
within the same function.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29018.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index ad282f1..0a35588 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -364,13 +364,8 @@ static int isl29018_write_raw(struct iio_dev *indio_dev,
 		}
 		break;
 	case IIO_CHAN_INFO_INT_TIME:
-		if (chan->type == IIO_LIGHT) {
-			if (val) {
-				mutex_unlock(&chip->lock);
-				return -EINVAL;
-			}
+		if (chan->type == IIO_LIGHT && !val)
 			ret = isl29018_set_integration_time(chip, val2);
-		}
 		break;
 	case IIO_CHAN_INFO_SCALE:
 		if (chan->type == IIO_LIGHT)
-- 
2.7.4


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

* [PATCH 3/3] staging: iio: isl29018: fix comparison between signed and unsigned integers
  2016-09-25 11:41 [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines Brian Masney
  2016-09-25 11:41 ` [PATCH 2/3] staging: iio: isl29018: made error handling consistent Brian Masney
@ 2016-09-25 11:41 ` Brian Masney
  2016-09-25 14:32   ` Jonathan Cameron
  2016-09-25 14:26 ` [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Brian Masney @ 2016-09-25 11:41 UTC (permalink / raw)
  To: gregkh; +Cc: linux-iio, devel

Fixes warning found by make W=2:
warning: comparison between signed and unsigned integer expressions

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/isl29018.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index 0a35588..4e2ce74 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -104,7 +104,8 @@ struct isl29018_chip {
 static int isl29018_set_integration_time(struct isl29018_chip *chip,
 					 unsigned int utime)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 	unsigned int int_time, new_int_time;
 
 	for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i) {
@@ -139,7 +140,8 @@ static int isl29018_set_integration_time(struct isl29018_chip *chip,
 
 static int isl29018_set_scale(struct isl29018_chip *chip, int scale, int uscale)
 {
-	int i, ret;
+	unsigned int i;
+	int ret;
 	struct isl29018_scale new_scale;
 
 	for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i) {
@@ -275,7 +277,8 @@ static ssize_t show_scale_available(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct isl29018_chip *chip = iio_priv(indio_dev);
-	int i, len = 0;
+	unsigned int i;
+	int len = 0;
 
 	for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i)
 		len += sprintf(buf + len, "%d.%06d ",
@@ -292,7 +295,8 @@ static ssize_t show_int_time_available(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct isl29018_chip *chip = iio_priv(indio_dev);
-	int i, len = 0;
+	unsigned int i;
+	int len = 0;
 
 	for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i)
 		len += sprintf(buf + len, "0.%06d ",
-- 
2.7.4


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

* Re: [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines
  2016-09-25 11:41 [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines Brian Masney
  2016-09-25 11:41 ` [PATCH 2/3] staging: iio: isl29018: made error handling consistent Brian Masney
  2016-09-25 11:41 ` [PATCH 3/3] staging: iio: isl29018: fix comparison between signed and unsigned integers Brian Masney
@ 2016-09-25 14:26 ` Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2016-09-25 14:26 UTC (permalink / raw)
  To: Brian Masney, gregkh; +Cc: linux-iio, devel

On 25/09/16 12:41, Brian Masney wrote:
> Removes unused variable and associated #defines that was found using
> make W=1.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Hmm. Must have gotten left over from some refactoring that generates
these strings on the fly.

Applied to the togreg branch of iio.git - initially pushed out as
testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29018.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
> index 76d9f74..ad282f1 100644
> --- a/drivers/staging/iio/light/isl29018.c
> +++ b/drivers/staging/iio/light/isl29018.c
> @@ -66,16 +66,6 @@
>  #define ISL29035_BOUT_SHIFT		0x07
>  #define ISL29035_BOUT_MASK		(0x01 << ISL29035_BOUT_SHIFT)
>  
> -#define ISL29018_INT_TIME_AVAIL		"0.090000 0.005630 0.000351 0.000021"
> -#define ISL29023_INT_TIME_AVAIL		"0.090000 0.005600 0.000352 0.000022"
> -#define ISL29035_INT_TIME_AVAIL		"0.105000 0.006500 0.000410 0.000025"
> -
> -static const char * const int_time_avail[] = {
> -	ISL29018_INT_TIME_AVAIL,
> -	ISL29023_INT_TIME_AVAIL,
> -	ISL29035_INT_TIME_AVAIL,
> -};
> -
>  enum isl29018_int_time {
>  	ISL29018_INT_TIME_16,
>  	ISL29018_INT_TIME_12,
> 


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

* Re: [PATCH 2/3] staging: iio: isl29018: made error handling consistent
  2016-09-25 11:41 ` [PATCH 2/3] staging: iio: isl29018: made error handling consistent Brian Masney
@ 2016-09-25 14:28   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2016-09-25 14:28 UTC (permalink / raw)
  To: Brian Masney, gregkh; +Cc: linux-iio, devel

On 25/09/16 12:41, Brian Masney wrote:
> Changed the processing of IIO_CHAN_INFO_INT_TIME in isl29018_write_raw()
> to unlock the mutex and return at the end of the function if invalid
> input is passed in. This makes the error handling code consistent with
> the processing of IIO_CHAN_INFO_CALIBSCALE and IIO_CHAN_INFO_SCALE
> within the same function.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Nice little cleanup.

Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/isl29018.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
> index ad282f1..0a35588 100644
> --- a/drivers/staging/iio/light/isl29018.c
> +++ b/drivers/staging/iio/light/isl29018.c
> @@ -364,13 +364,8 @@ static int isl29018_write_raw(struct iio_dev *indio_dev,
>  		}
>  		break;
>  	case IIO_CHAN_INFO_INT_TIME:
> -		if (chan->type == IIO_LIGHT) {
> -			if (val) {
> -				mutex_unlock(&chip->lock);
> -				return -EINVAL;
> -			}
> +		if (chan->type == IIO_LIGHT && !val)
>  			ret = isl29018_set_integration_time(chip, val2);
> -		}
>  		break;
>  	case IIO_CHAN_INFO_SCALE:
>  		if (chan->type == IIO_LIGHT)
> 


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

* Re: [PATCH 3/3] staging: iio: isl29018: fix comparison between signed and unsigned integers
  2016-09-25 11:41 ` [PATCH 3/3] staging: iio: isl29018: fix comparison between signed and unsigned integers Brian Masney
@ 2016-09-25 14:32   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2016-09-25 14:32 UTC (permalink / raw)
  To: Brian Masney, gregkh; +Cc: linux-iio, devel

On 25/09/16 12:41, Brian Masney wrote:
> Fixes warning found by make W=2:
> warning: comparison between signed and unsigned integer expressions
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
This one is pretty marginal on whether it is worth while given
it is easy to verify that it doesn't matter in any of these cases.

Anyhow, I suppose it does no harm and maybe is a really small
improvement in the code.

Applied to the togreg branch of iio.git etc.

Jonathan
> ---
>  drivers/staging/iio/light/isl29018.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
> index 0a35588..4e2ce74 100644
> --- a/drivers/staging/iio/light/isl29018.c
> +++ b/drivers/staging/iio/light/isl29018.c
> @@ -104,7 +104,8 @@ struct isl29018_chip {
>  static int isl29018_set_integration_time(struct isl29018_chip *chip,
>  					 unsigned int utime)
>  {
> -	int i, ret;
> +	unsigned int i;
> +	int ret;
>  	unsigned int int_time, new_int_time;
>  
>  	for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i) {
> @@ -139,7 +140,8 @@ static int isl29018_set_integration_time(struct isl29018_chip *chip,
>  
>  static int isl29018_set_scale(struct isl29018_chip *chip, int scale, int uscale)
>  {
> -	int i, ret;
> +	unsigned int i;
> +	int ret;
>  	struct isl29018_scale new_scale;
>  
>  	for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i) {
> @@ -275,7 +277,8 @@ static ssize_t show_scale_available(struct device *dev,
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct isl29018_chip *chip = iio_priv(indio_dev);
> -	int i, len = 0;
> +	unsigned int i;
> +	int len = 0;
>  
>  	for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i)
>  		len += sprintf(buf + len, "%d.%06d ",
> @@ -292,7 +295,8 @@ static ssize_t show_int_time_available(struct device *dev,
>  {
>  	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct isl29018_chip *chip = iio_priv(indio_dev);
> -	int i, len = 0;
> +	unsigned int i;
> +	int len = 0;
>  
>  	for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i)
>  		len += sprintf(buf + len, "0.%06d ",
> 


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

end of thread, other threads:[~2016-09-25 14:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-25 11:41 [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines Brian Masney
2016-09-25 11:41 ` [PATCH 2/3] staging: iio: isl29018: made error handling consistent Brian Masney
2016-09-25 14:28   ` Jonathan Cameron
2016-09-25 11:41 ` [PATCH 3/3] staging: iio: isl29018: fix comparison between signed and unsigned integers Brian Masney
2016-09-25 14:32   ` Jonathan Cameron
2016-09-25 14:26 ` [PATCH 1/3] staging: iio: isl29018: remove unused variable and defines 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).