mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
To: Bijosh Thykkoottathil <bijosh.t@hotmail.com>,
	Jonathan Cameron <jic23@kernel.org>
Cc: "knaack.h@gmx.de" <knaack.h@gmx.de>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"k.kozlowski@samsung.com" <k.kozlowski@samsung.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] drivers:iio:light:isl29125: added macros for sensing range
Date: Mon, 27 Jun 2016 15:56:48 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.02.1606271554240.2632@pmeerw.net> (raw)
In-Reply-To: <cd4fd8f2-a44a-abd5-5d6b-9d8618d435ac@kernel.org>


> On 24/06/16 12:16, Bijosh Thykkoottathil wrote:
> > Added macros for sensing range as the corresponding magic numbers
> > were used at multiple places.
> >    - SENSING_RANGE_0 for 375 lux full range
> >    - SENSING_RANGE_1 for 10k lux full range

> Macros are great for making cases of 'magic numbers' more readable.
> However here we are wrapping up 'real' numbers in macros that actually
> obscure what they are...
> 
> Now the fact they are used twice does make it a little more worthwhile.
> Peter, what do you think?  Your driver so up to you ;)

I'm fine with the proposed change, but a proper prefix is required, hence
ISL29125_SENSING_RANGE_0 and _1

regards, p.

> > ---
> >  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..83a5a7a 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 SENSING_RANGE_0 5722   /* 375 lux full range */
> > +#define 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 = SENSING_RANGE_1; /* 10k lux full range */
> >  		else
> > -			*val2 = 5722; /* 375 lux full range */
> > +			*val2 = 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 == SENSING_RANGE_1)
> >  			data->conf1 |= ISL29125_MODE_RANGE;
> > -		else if (val2 == 5722)
> > +		else if (val2 == SENSING_RANGE_0)
> >  			data->conf1 &= ~ISL29125_MODE_RANGE;
> >  		else
> >  			return -EINVAL;
> > 
> 

-- 

Peter Meerwald-Stadler
+43-664-2444418 (mobile)

      reply	other threads:[~2016-06-27 13:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <KL1PR04MB12053135303C2DFF58F70CB2802E0@KL1PR04MB1205.apcprd04.prod.outlook.com>
2016-06-26 13:56 ` Jonathan Cameron
2016-06-27 13:56   ` Peter Meerwald-Stadler [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.02.1606271554240.2632@pmeerw.net \
    --to=pmeerw@pmeerw.net \
    --cc=bijosh.t@hotmail.com \
    --cc=jic23@kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®