diff mbox

[05/12] staging: iio: tsl2x7x: convert mutex_trylock() to mutex_lock()

Message ID 20180304014942.18727-6-masneyb@onstation.org (mailing list archive)
State New, archived
Headers show

Commit Message

Brian Masney March 4, 2018, 1:49 a.m. UTC
The driver uses mutex_lock() and mutex_trylock() in several places.
Convert the mutex_trylock() to mutex_lock() for consistency with other
IIO light drivers in mainline.

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

Comments

Jonathan Cameron March 10, 2018, 2:39 p.m. UTC | #1
On Sat,  3 Mar 2018 20:49:35 -0500
Brian Masney <masneyb@onstation.org> wrote:

> The driver uses mutex_lock() and mutex_trylock() in several places.
> Convert the mutex_trylock() to mutex_lock() for consistency with other
> IIO light drivers in mainline.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
This was a little odd given we don't lock the device for long and all this
will do is slow down userspace access if it tries several at the same time
(a fairy uncommon usecase).

Applied

Thanks,

Jonathan
> ---
>  drivers/staging/iio/light/tsl2x7x.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
> index cf16dd206c0b..5c611250127f 100644
> --- a/drivers/staging/iio/light/tsl2x7x.c
> +++ b/drivers/staging/iio/light/tsl2x7x.c
> @@ -350,8 +350,7 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
>  	u32 ch0lux = 0;
>  	u32 ch1lux = 0;
>  
> -	if (mutex_trylock(&chip->als_mutex) == 0)
> -		return chip->als_cur_info.lux; /* busy, so return LAST VALUE */
> +	mutex_lock(&chip->als_mutex);
>  
>  	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
>  		/* device is not enabled */
> @@ -478,11 +477,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
>  	u8 chdata[2];
>  	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
>  
> -	if (mutex_trylock(&chip->prox_mutex) == 0) {
> -		dev_err(&chip->client->dev,
> -			"%s: Can't get prox mutex\n", __func__);
> -		return -EBUSY;
> -	}
> +	mutex_lock(&chip->prox_mutex);
>  
>  	ret = tsl2x7x_read_status(chip);
>  	if (ret < 0)

--
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
diff mbox

Patch

diff --git a/drivers/staging/iio/light/tsl2x7x.c b/drivers/staging/iio/light/tsl2x7x.c
index cf16dd206c0b..5c611250127f 100644
--- a/drivers/staging/iio/light/tsl2x7x.c
+++ b/drivers/staging/iio/light/tsl2x7x.c
@@ -350,8 +350,7 @@  static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	u32 ch0lux = 0;
 	u32 ch1lux = 0;
 
-	if (mutex_trylock(&chip->als_mutex) == 0)
-		return chip->als_cur_info.lux; /* busy, so return LAST VALUE */
+	mutex_lock(&chip->als_mutex);
 
 	if (chip->tsl2x7x_chip_status != TSL2X7X_CHIP_WORKING) {
 		/* device is not enabled */
@@ -478,11 +477,7 @@  static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 	u8 chdata[2];
 	struct tsl2X7X_chip *chip = iio_priv(indio_dev);
 
-	if (mutex_trylock(&chip->prox_mutex) == 0) {
-		dev_err(&chip->client->dev,
-			"%s: Can't get prox mutex\n", __func__);
-		return -EBUSY;
-	}
+	mutex_lock(&chip->prox_mutex);
 
 	ret = tsl2x7x_read_status(chip);
 	if (ret < 0)