From: Jonathan Cameron <jic23-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
To: samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org
Cc: "linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org"
<alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
Subject: Re: [PATCHv2 1/5] misc: Driver for bh1770glc / sfh7770 ALS and proximity sensor
Date: Mon, 11 Oct 2010 14:35:17 +0100 [thread overview]
Message-ID: <4CB31295.9020907@cam.ac.uk> (raw)
In-Reply-To: <1286777763.28027.3.camel@4fid08082>
On 10/11/10 07:16, Onkalo Samu wrote:
>
> I have a question about one of your comment
>
> On Fri, 2010-10-08 at 16:35 +0200, ext Jonathan Cameron wrote:
>> On 10/08/10 14:42, Samu Onkalo wrote:
>>> This is a driver for ROHM BH1770GLC and OSRAM SFH7770 combined
>>> ALS and proximity sensor.
>>>
>>> Interface is sysfs based. The driver uses interrupts to provide new data.
>>> The driver supports pm_runtime and regulator frameworks.
>>>
>>> See Documentation/misc-devices/bhsfh.txt for details
>>
>> Couple of nitpicks / formatting suggestions inline.
>>
>>>
>>> +/* chip->mutex is kept when this is called */
>>> +static int bhsfh_lux_update_thresholds(struct bhsfh_chip *chip,
>>> + u16 threshold_hi, u16 threshold_lo)
>>> +{
>>> + u8 data[4];
>>
>> u8 data[4] = { threshold_hi,
>> threshold_hi >> 8,
>> threshold_lo,
>> threshold_low >> 8};
>> and loose the below will give same result.
>
> What do you mean by that? Threshold_lo / threshold_hi parameters can be
> modified before they are stored to HW.
>
>>> + int ret;
>>> +
>>> + /* sysfs may call this when the chip is powered off */
>>> + if (pm_runtime_suspended(&chip->client->dev))
>>> + return 0;
>>> +
>>> + /*
>>> + * Compensate threshold values with the correction factors if not
>>> + * set to minimum or maximum.
>>> + * Min & max values disables interrupts.
>>> + */
>>> + if (threshold_hi != BHSFH_LUX_RANGE && threshold_hi != 0)
>>> + threshold_hi = bhsfh_lux_adjusted_to_raw(chip, threshold_hi);
>>> +
>>> + if (threshold_lo != BHSFH_LUX_RANGE && threshold_lo != 0)
>>> + threshold_lo = bhsfh_lux_adjusted_to_raw(chip, threshold_lo);
>
> Code above can modify values.
ah. Sorry, I was clearly half asleep when I reviewed this!
>
>>> +
>>> + if (chip->lux_thres_hi_onchip == threshold_hi &&
>>> + chip->lux_thres_lo_onchip == threshold_lo)
>>> + return 0;
>>> +
>>> + chip->lux_thres_hi_onchip = threshold_hi;
>>> + chip->lux_thres_lo_onchip = threshold_lo;
>>> +
>>> + data[0] = threshold_hi;
>>> + data[1] = threshold_hi >> 8;
>>> + data[2] = threshold_lo;
>>> + data[3] = threshold_lo >> 8;
>>> +
>>> + ret = i2c_smbus_write_i2c_block_data(chip->client,
>>> + BHSFH_ALS_TH_UP_0,
>>> + ARRAY_SIZE(data),
>>> + data);
>>> + return ret;
>>> +}
>>> +
>
>
>
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@cam.ac.uk>
To: samu.p.onkalo@nokia.com
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"alan@lxorguk.ukuu.org.uk" <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCHv2 1/5] misc: Driver for bh1770glc / sfh7770 ALS and proximity sensor
Date: Mon, 11 Oct 2010 14:35:17 +0100 [thread overview]
Message-ID: <4CB31295.9020907@cam.ac.uk> (raw)
In-Reply-To: <1286777763.28027.3.camel@4fid08082>
On 10/11/10 07:16, Onkalo Samu wrote:
>
> I have a question about one of your comment
>
> On Fri, 2010-10-08 at 16:35 +0200, ext Jonathan Cameron wrote:
>> On 10/08/10 14:42, Samu Onkalo wrote:
>>> This is a driver for ROHM BH1770GLC and OSRAM SFH7770 combined
>>> ALS and proximity sensor.
>>>
>>> Interface is sysfs based. The driver uses interrupts to provide new data.
>>> The driver supports pm_runtime and regulator frameworks.
>>>
>>> See Documentation/misc-devices/bhsfh.txt for details
>>
>> Couple of nitpicks / formatting suggestions inline.
>>
>>>
>>> +/* chip->mutex is kept when this is called */
>>> +static int bhsfh_lux_update_thresholds(struct bhsfh_chip *chip,
>>> + u16 threshold_hi, u16 threshold_lo)
>>> +{
>>> + u8 data[4];
>>
>> u8 data[4] = { threshold_hi,
>> threshold_hi >> 8,
>> threshold_lo,
>> threshold_low >> 8};
>> and loose the below will give same result.
>
> What do you mean by that? Threshold_lo / threshold_hi parameters can be
> modified before they are stored to HW.
>
>>> + int ret;
>>> +
>>> + /* sysfs may call this when the chip is powered off */
>>> + if (pm_runtime_suspended(&chip->client->dev))
>>> + return 0;
>>> +
>>> + /*
>>> + * Compensate threshold values with the correction factors if not
>>> + * set to minimum or maximum.
>>> + * Min & max values disables interrupts.
>>> + */
>>> + if (threshold_hi != BHSFH_LUX_RANGE && threshold_hi != 0)
>>> + threshold_hi = bhsfh_lux_adjusted_to_raw(chip, threshold_hi);
>>> +
>>> + if (threshold_lo != BHSFH_LUX_RANGE && threshold_lo != 0)
>>> + threshold_lo = bhsfh_lux_adjusted_to_raw(chip, threshold_lo);
>
> Code above can modify values.
ah. Sorry, I was clearly half asleep when I reviewed this!
>
>>> +
>>> + if (chip->lux_thres_hi_onchip == threshold_hi &&
>>> + chip->lux_thres_lo_onchip == threshold_lo)
>>> + return 0;
>>> +
>>> + chip->lux_thres_hi_onchip = threshold_hi;
>>> + chip->lux_thres_lo_onchip = threshold_lo;
>>> +
>>> + data[0] = threshold_hi;
>>> + data[1] = threshold_hi >> 8;
>>> + data[2] = threshold_lo;
>>> + data[3] = threshold_lo >> 8;
>>> +
>>> + ret = i2c_smbus_write_i2c_block_data(chip->client,
>>> + BHSFH_ALS_TH_UP_0,
>>> + ARRAY_SIZE(data),
>>> + data);
>>> + return ret;
>>> +}
>>> +
>
>
>
>
next prev parent reply other threads:[~2010-10-11 13:35 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-08 13:41 [PATCHv2 0/5] BH1770GLC, SFH7770 and APDS990x als / proximity sensor drivers Samu Onkalo
2010-10-08 13:41 ` Samu Onkalo
2010-10-08 13:42 ` [PATCHv2 1/5] misc: Driver for bh1770glc / sfh7770 ALS and proximity sensor Samu Onkalo
[not found] ` <1286545324-18506-2-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-08 14:35 ` Jonathan Cameron
2010-10-08 14:35 ` Jonathan Cameron
2010-10-11 6:16 ` Onkalo Samu
2010-10-11 13:35 ` Jonathan Cameron [this message]
2010-10-11 13:35 ` Jonathan Cameron
2010-10-08 13:42 ` [PATCHv2 2/5] misc: update bhsfh driver to Kconfig and Makefile Samu Onkalo
[not found] ` <1286545324-18506-3-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-08 14:25 ` Jonathan Cameron
2010-10-08 14:25 ` Jonathan Cameron
[not found] ` <4CAF29F4.9010709-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2010-10-11 6:17 ` Onkalo Samu
2010-10-11 6:17 ` Onkalo Samu
2010-10-11 13:36 ` Jonathan Cameron
2010-10-11 13:36 ` Jonathan Cameron
2010-10-09 23:43 ` Randy Dunlap
2010-10-09 23:43 ` Randy Dunlap
[not found] ` <1286545324-18506-1-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-08 13:42 ` [PATCHv2 3/5] misc: Driver for APDS990X ALS and proximity sensors Samu Onkalo
2010-10-08 13:42 ` Samu Onkalo
[not found] ` <1286545324-18506-4-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-08 14:46 ` Jonathan Cameron
2010-10-08 14:46 ` Jonathan Cameron
2010-10-08 13:42 ` [PATCHv2 4/5] misc: update apds990x driver to Kconfig and Makefile Samu Onkalo
2010-10-08 13:42 ` Samu Onkalo
[not found] ` <1286545324-18506-5-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-09 23:43 ` Randy Dunlap
2010-10-09 23:43 ` Randy Dunlap
2010-10-08 13:42 ` [PATCHv2 5/5] Documentation: Short descriptions for bhsfh and apds990x drivers Samu Onkalo
2010-10-08 13:42 ` Samu Onkalo
[not found] ` <1286545324-18506-6-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-08 14:07 ` Jonathan Cameron
2010-10-08 14:07 ` Jonathan Cameron
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=4CB31295.9020907@cam.ac.uk \
--to=jic23-kwpb1pkirijaa/9udqfwiw@public.gmane.org \
--cc=alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.