From: Alan Cox <alan-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
To: Samu Onkalo <samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/5] misc: Driver for APDS990X ALS and proximity sensors
Date: Tue, 5 Oct 2010 12:23:23 +0100 [thread overview]
Message-ID: <20101005122323.2d2870ee@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <1286271779-19819-4-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> +static int apds990x_refresh_athres(struct apds990x_chip *chip)
> +{
> + int ret;
> + /* If the chip is not in use, don't try to access it */
> + if (pm_runtime_suspended(&chip->client->dev))
> + return 0;
> +
> + ret = apds990x_write_word(chip, APDS990X_AILTL,
> + apds990x_lux_to_threshold(chip, chip->lux_thres_lo));
> + ret |= apds990x_write_word(chip, APDS990X_AIHTL,
> + apds990x_lux_to_threshold(chip, chip->lux_thres_hi));
> +
What is the locking theory in the driver for things like these multi word
writes. It's not clear from a first read how you guaranteed the refreshes
don't get tangled up or how you know there won't be an interrupt half way
through one of these pairs of accesses
> +static void apds990x_force_a_refresh(struct apds990x_chip *chip)
> +{
> + /* This will force ALS interrupt after the next measurement. */
> + apds990x_write_word(chip, APDS990X_AILTL, APDS_LUX_DEF_THRES_LO);
> + apds990x_write_word(chip, APDS990X_AIHTL, APDS_LUX_DEF_THRES_HI);
> +}
> +
> +static void apds990x_force_p_refresh(struct apds990x_chip *chip)
> +{
> + /* This will force proximity interrupt after the next measurement. */
> + apds990x_write_word(chip, APDS990X_PILTL, APDS_PROX_DEF_THRES - 1);
> + apds990x_write_word(chip, APDS990X_PIHTL, APDS_PROX_DEF_THRES);
> +}
> +
> +
> + if (ret < 0)
> + apds990x_force_a_refresh(chip); /* Bad result -> re-measure */
What stops this getting stuck forever - I admit it would probably need a
drastic case of strobe lighting but people do take phones to raves ..
> +static DEVICE_ATTR(lux0_input, S_IRUGO, apds990x_lux_show, NULL);
Are well all agreed on lux0_input ? I'm just putting some of the other
bits together to submit and using the same spec
> +static DEVICE_ATTR(lux0_input10x, S_IRUGO, apds990x_lux10x_show, NULL);
This seems daft. No doubt we'll want lux0_input100x next year
What's wrong with outputting %d.%d format to lux0_input - existing apps
will read the integer bit fine and we've not defined the interface yet
anyway.
> + if ((value > APDS_RANGE) || (value == 0) ||
> + (value < APDS_PROX_HYSTERESIS))
> + return -EINVAL;
Excess brackets
> + chip->regs[0].supply = reg_vcc;
> + chip->regs[1].supply = reg_vled;
Shouldn't these come from the provided platform data ? and again if there
isn't a platform one supplied just skip the regulators. There are going
to be cases of boxes with regulator API stuff in use but who don't have
regulators for that device.
On the sysfs side
- not clear how power_state and runtime pm interact - do we in fact need
power state ?
- lux0_input range being fixed seems inconvenient, the sensors I've got
queued here use lux0_input as you do but also provide a read (and
optionally writable) range limit in lux
static DEVICE_ATTR(lux0_sensor_range, S_IRUGO | S_IWUSR,
als_sensing_range_show, als_sensing_range_store);
and in your case you could just return 65535
The sampling rate stuff is a bit different to what I have - in my case
writing to the sensing range alters the sampling rate requirements. I can
easily make either one adjust the other however so that fits nicely
next prev parent reply other threads:[~2010-10-05 11:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 9:42 [PATCH 0/5] BH1770GLC, SFH7770 and APDS990x als / proximity sensor drivers Samu Onkalo
2010-10-05 9:42 ` [PATCH 1/5] misc: Driver for bh1770glc / sfh7770 ALS and proximity sensor Samu Onkalo
[not found] ` <1286271779-19819-2-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-05 11:21 ` Alan Cox
[not found] ` <20101005122157.149f14d0-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-10-05 11:29 ` Onkalo Samu
2010-10-05 12:01 ` Alan Cox
[not found] ` <20101005130102.7690c484-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-10-05 12:37 ` Onkalo Samu
[not found] ` <1286271779-19819-1-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-05 9:42 ` [PATCH 2/5] misc: update bhsfh driver to Kconfig and Makefile Samu Onkalo
2010-10-05 9:42 ` [PATCH 4/5] misc: update apds990x " Samu Onkalo
2010-10-05 9:42 ` [PATCH 3/5] misc: Driver for APDS990X ALS and proximity sensors Samu Onkalo
[not found] ` <1286271779-19819-4-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-05 11:23 ` Alan Cox [this message]
2010-10-05 11:48 ` Onkalo Samu
2010-10-05 13:00 ` Alan Cox
[not found] ` <20101005140049.1f25bb24-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-10-05 12:39 ` Onkalo Samu
[not found] ` <20101005122323.2d2870ee-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2010-10-05 21:42 ` Mark Brown
2010-10-05 9:42 ` [PATCH 5/5] Documentation: Short descriptions for bhsfh and apds990x drivers Samu Onkalo
[not found] ` <1286271779-19819-6-git-send-email-samu.p.onkalo-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-10-05 11:53 ` Jonathan Cameron
[not found] ` <4CAB11C7.8040408-KWPb1pKIrIJaa/9Udqfwiw@public.gmane.org>
2010-10-05 12:22 ` Onkalo Samu
2010-10-05 14:13 ` 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=20101005122323.2d2870ee@lxorguk.ukuu.org.uk \
--to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox