[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <51ECE6E0.1030509@digi.com>
Date: Mon, 22 Jul 2013 10:01:36 +0200
From: Hector Palacios <hector.palacios@...i.com>
To: Jonathan Cameron <jic23@...nel.org>
CC: Marek Vasut <marex@...x.de>,
"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"devicetree-discuss@...ts.ozlabs.org"
<devicetree-discuss@...ts.ozlabs.org>,
"alexandre.belloni@...e-electrons.com"
<alexandre.belloni@...e-electrons.com>,
"lars@...afoo.de" <lars@...afoo.de>,
"fabio.estevam@...escale.com" <fabio.estevam@...escale.com>
Subject: Re: [PATCH v2 5/5] iio: mxs-lradc: add write_raw function to modify
scale
Hi Jonathan,
On 07/19/2013 10:32 PM, Jonathan Cameron wrote:
>>>> @@ -323,6 +326,54 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
>>>> return ret;
>>>> }
>>>>
>>>> +static int mxs_lradc_write_raw(struct iio_dev *iio_dev,
>>>> + const struct iio_chan_spec *chan,
>>>> + int val, int val2, long m)
>>>> +{
>>>> + struct mxs_lradc *lradc = iio_priv(iio_dev);
>>>> + int ret;
>>>> +
>>>> + ret = mutex_trylock(&lradc->lock);
>>>> + if (!ret)
>>>> + return -EBUSY;
>>>> +
>>>> + switch (m) {
>>>> + case IIO_CHAN_INFO_SCALE:
>>>> + ret = -EINVAL;
>>>> + if (val == lradc->scale_avail[chan->channel][0][0] &&
>>>> + val2 == lradc->scale_avail[chan->channel][0][1]) {
>>>> + /* [0] -> divider by two disabled */
>>>
>>> This comment is confusing, you use [0] in different dimensions of the array. So
>>> is the stuff below.
>>>
>>> Still, how does this even work, can you show me and example how to set the
>>> divider from userland ? Sorry, I'm a bit confused with this 3D-business here,
>>> even if the comment in previous patch made it a bit clearer. Actually you can
>>> use some #define to specify if you're accessing div/2 or div/1 portion of the
>>> array to make it more readable.
>>>
>>> Like ... scale_avail[chan->channel][LRADC_DIV_BY_2][LRADC_DECIMAL_PART] ...
>>> would by nice.
>>
>> Agreed.
> Could even make the int + nano part a structure then you could have
> scale_avail[chan->channel][LRADC_DIV_BY_2].integer / .nano
>
> might not be worth the hassel though for the slight gain in readability.
>
> I'm happy either way.
I prefer the struct approach, it removes one dimension to the array and I find it cleaner.
Best regards,
--
Hector Palacios
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists