Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1520325 > unrolled thread

[PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool

Started byBrian Masney <masneyb@onstation.org>
First post2016-11-12 19:30 +0100
Last post2016-11-13 13:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool Brian Masney <masneyb@onstation.org> - 2016-11-12 19:30 +0100
    Re: [PATCH v4 04/26] staging: iio: tsl2583: change current chip state  from a tristate to a bool Jonathan Cameron <jic23@kernel.org> - 2016-11-13 13:00 +0100

#1520325 — [PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool

FromBrian Masney <masneyb@onstation.org>
Date2016-11-12 19:30 +0100
Subject[PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool
Message-ID<sCLdT-5L4-13@gated-at.bofh.it>
The current chip state is represented as a tristate (working, suspended,
and unknown). The unknown state was not used. This patch changes the
chip state so that it is now represented as a single boolean value
(suspended).

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

diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 40aa78e..5a32102 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -67,12 +67,6 @@
 #define TSL2583_CHIP_ID			0x90
 #define TSL2583_CHIP_ID_MASK		0xf0
 
-enum {
-	TSL258X_CHIP_UNKNOWN = 0,
-	TSL258X_CHIP_WORKING = 1,
-	TSL258X_CHIP_SUSPENDED = 2
-};
-
 /* Per-device data */
 struct taos_als_info {
 	u16 als_ch0;
@@ -94,7 +88,7 @@ struct tsl2583_chip {
 	struct taos_settings taos_settings;
 	int als_time_scale;
 	int als_saturation;
-	int taos_chip_status;
+	bool suspended;
 };
 
 struct taos_lux {
@@ -441,7 +435,7 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev)
 	if (ret < 0)
 		return ret;
 
-	chip->taos_chip_status = TSL258X_CHIP_WORKING;
+	chip->suspended = false;
 
 	return ret;
 }
@@ -494,7 +488,7 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
 
 	mutex_lock(&chip->als_mutex);
 
-	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+	if (chip->suspended) {
 		ret = -EBUSY;
 		goto done;
 	}
@@ -627,7 +621,7 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
 
 	mutex_lock(&chip->als_mutex);
 
-	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+	if (chip->suspended) {
 		ret = -EBUSY;
 		goto read_done;
 	}
@@ -704,7 +698,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
 
 	mutex_lock(&chip->als_mutex);
 
-	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
+	if (chip->suspended) {
 		ret = -EBUSY;
 		goto write_done;
 	}
@@ -778,7 +772,7 @@ static int taos_probe(struct i2c_client *clientp,
 	i2c_set_clientdata(clientp, indio_dev);
 
 	mutex_init(&chip->als_mutex);
-	chip->taos_chip_status = TSL258X_CHIP_UNKNOWN;
+	chip->suspended = true;
 
 	ret = i2c_smbus_read_byte_data(clientp,
 				       TSL258X_CMD_REG | TSL258X_CHIPID);
@@ -835,7 +829,7 @@ static int __maybe_unused taos_suspend(struct device *dev)
 	mutex_lock(&chip->als_mutex);
 
 	ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
-	chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
+	chip->suspended = true;
 
 	mutex_unlock(&chip->als_mutex);
 	return ret;
-- 
2.7.4

[toc] | [next] | [standalone]


#1520591 — Re: [PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool

FromJonathan Cameron <jic23@kernel.org>
Date2016-11-13 13:00 +0100
SubjectRe: [PATCH v4 04/26] staging: iio: tsl2583: change current chip state from a tristate to a bool
Message-ID<sD1C1-89M-7@gated-at.bofh.it>
In reply to#1520325
On 12/11/16 18:19, Brian Masney wrote:
> The current chip state is represented as a tristate (working, suspended,
> and unknown). The unknown state was not used. This patch changes the
> chip state so that it is now represented as a single boolean value
> (suspended).
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Applied.

> ---
>  drivers/staging/iio/light/tsl2583.c | 20 +++++++-------------
>  1 file changed, 7 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 40aa78e..5a32102 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -67,12 +67,6 @@
>  #define TSL2583_CHIP_ID			0x90
>  #define TSL2583_CHIP_ID_MASK		0xf0
>  
> -enum {
> -	TSL258X_CHIP_UNKNOWN = 0,
> -	TSL258X_CHIP_WORKING = 1,
> -	TSL258X_CHIP_SUSPENDED = 2
> -};
> -
>  /* Per-device data */
>  struct taos_als_info {
>  	u16 als_ch0;
> @@ -94,7 +88,7 @@ struct tsl2583_chip {
>  	struct taos_settings taos_settings;
>  	int als_time_scale;
>  	int als_saturation;
> -	int taos_chip_status;
> +	bool suspended;
>  };
>  
>  struct taos_lux {
> @@ -441,7 +435,7 @@ static int tsl2583_chip_init_and_power_on(struct iio_dev *indio_dev)
>  	if (ret < 0)
>  		return ret;
>  
> -	chip->taos_chip_status = TSL258X_CHIP_WORKING;
> +	chip->suspended = false;
>  
>  	return ret;
>  }
> @@ -494,7 +488,7 @@ static ssize_t in_illuminance_calibrate_store(struct device *dev,
>  
>  	mutex_lock(&chip->als_mutex);
>  
> -	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
> +	if (chip->suspended) {
>  		ret = -EBUSY;
>  		goto done;
>  	}
> @@ -627,7 +621,7 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev,
>  
>  	mutex_lock(&chip->als_mutex);
>  
> -	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
> +	if (chip->suspended) {
>  		ret = -EBUSY;
>  		goto read_done;
>  	}
> @@ -704,7 +698,7 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev,
>  
>  	mutex_lock(&chip->als_mutex);
>  
> -	if (chip->taos_chip_status != TSL258X_CHIP_WORKING) {
> +	if (chip->suspended) {
>  		ret = -EBUSY;
>  		goto write_done;
>  	}
> @@ -778,7 +772,7 @@ static int taos_probe(struct i2c_client *clientp,
>  	i2c_set_clientdata(clientp, indio_dev);
>  
>  	mutex_init(&chip->als_mutex);
> -	chip->taos_chip_status = TSL258X_CHIP_UNKNOWN;
> +	chip->suspended = true;
>  
>  	ret = i2c_smbus_read_byte_data(clientp,
>  				       TSL258X_CMD_REG | TSL258X_CHIPID);
> @@ -835,7 +829,7 @@ static int __maybe_unused taos_suspend(struct device *dev)
>  	mutex_lock(&chip->als_mutex);
>  
>  	ret = tsl2583_set_power_state(chip, TSL258X_CNTL_PWR_OFF);
> -	chip->taos_chip_status = TSL258X_CHIP_SUSPENDED;
> +	chip->suspended = true;
>  
>  	mutex_unlock(&chip->als_mutex);
>  	return ret;
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web