linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] drivers:iio:light:isl29125: added macros for sensing range
       [not found] <KL1PR04MB1205FC759593484E11F486A280210@KL1PR04MB1205.apcprd04.prod.outlook.com>
@ 2016-07-03  9:20 ` Jonathan Cameron
  0 siblings, 0 replies; only message in thread
From: Jonathan Cameron @ 2016-07-03  9:20 UTC (permalink / raw)
  To: Bijosh Thykkoottathil, knaack.h, lars, pmeerw, k.kozlowski
  Cc: linux-iio, linux-kernel

On 27/06/16 16:37, Bijosh Thykkoottathil wrote:
> Added macros for sensing range as the corresponding magic numbers
> were used at multiple places.
>    - ISL29125_SENSING_RANGE_0 for 375 lux full range
>    - ISL29125_SENSING_RANGE_1 for 10k lux full range
> 
> Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.com>
Applied to the togreg branch of iio.git. Initially pushed out
as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/light/isl29125.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
> index e2945a2..d0aa802 100644
> --- a/drivers/iio/light/isl29125.c
> +++ b/drivers/iio/light/isl29125.c
> @@ -44,6 +44,9 @@
>  #define ISL29125_MODE_B 0x3
>  #define ISL29125_MODE_RGB 0x5
>  
> +#define ISL29125_SENSING_RANGE_0 5722   /* 375 lux full range */
> +#define ISL29125_SENSING_RANGE_1 152590 /* 10k lux full range */
> +
>  #define ISL29125_MODE_RANGE BIT(3)
>  
>  #define ISL29125_STATUS_CONV BIT(1)
> @@ -140,9 +143,9 @@ static int isl29125_read_raw(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_SCALE:
>  		*val = 0;
>  		if (data->conf1 & ISL29125_MODE_RANGE)
> -			*val2 = 152590; /* 10k lux full range */
> +			*val2 = ISL29125_SENSING_RANGE_1; /*10k lux full range*/
>  		else
> -			*val2 = 5722; /* 375 lux full range */
> +			*val2 = ISL29125_SENSING_RANGE_0; /*375 lux full range*/
>  		return IIO_VAL_INT_PLUS_MICRO;
>  	}
>  	return -EINVAL;
> @@ -158,9 +161,9 @@ static int isl29125_write_raw(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_SCALE:
>  		if (val != 0)
>  			return -EINVAL;
> -		if (val2 == 152590)
> +		if (val2 == ISL29125_SENSING_RANGE_1)
>  			data->conf1 |= ISL29125_MODE_RANGE;
> -		else if (val2 == 5722)
> +		else if (val2 == ISL29125_SENSING_RANGE_0)
>  			data->conf1 &= ~ISL29125_MODE_RANGE;
>  		else
>  			return -EINVAL;
> 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-07-03  9:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <KL1PR04MB1205FC759593484E11F486A280210@KL1PR04MB1205.apcprd04.prod.outlook.com>
2016-07-03  9:20 ` [PATCH v2] drivers:iio:light:isl29125: added macros for sensing range 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).