devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Subhajit Ghosh <subhajit.ghosh@tweaklogic.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Paul Gazzillo <paul@pgazz.com>,
	Conor Dooley <conor+dt@kernel.org>,
	Stefan Windfeldt-Prytz <stefan.windfeldt-prytz@axis.com>
Subject: Re: [PATCH 2/2] iio: light: Add support for APDS9306 Light Sensor
Date: Tue, 10 Oct 2023 22:47:14 +1030	[thread overview]
Message-ID: <09a07473-2558-2b05-c9d5-8d439749bfa7@tweaklogic.com> (raw)
In-Reply-To: <ae210957-4a72-24b3-2f11-8d5824041e85@gmail.com>

On 10/10/23 20:15, Matti Vaittinen wrote:

> 
> To my eyes this driver looks nice. Just spotted two minor things.
> 

Thanks Matti. Nice is one nice thing I heard after some time!

>> +    gain_new_closest = iio_find_closest_gain_low(&data->gts, gain_new, &ok);
>> +    if (gain_new_closest < 0) {
>> +        gain_new_closest = iio_gts_get_min_gain(&data->gts);
>> +        if (gain_new_closest < 0)
>> +            return gain_new_closest < 0;
> 
> Returning the truth value on purpose? :)

Nope, it's a bug. I'll fix it.

>> +static int get_device_id_lux_per_count(struct apds9306_data *data)
>> +{
>> +    int ret, part_id;
>> +
>> +    ret = regmap_read(data->regmap, APDS9306_PART_ID, &part_id);
>> +    if (ret)
>> +        return ret;
>> +
>> +    if (part_id == apds9306_part_id_nlux_per_count[0].part_id)
>> +        data->nlux_per_count =
>> +            apds9306_part_id_nlux_per_count[0].nlux_per_count;
>> +    else if (part_id == apds9306_part_id_nlux_per_count[1].part_id)
>> +        data->nlux_per_count =
>> +            apds9306_part_id_nlux_per_count[1].nlux_per_count;
>> +    else
>> +        return -ENXIO;
> 
> I think we should be able to differentiate between the IC variants by DT compatible. (Commented that on bindings patch). Not sure if we need to support cases where the sensor is instantiated without device-tree. I am not super happy when code requires the part-id to be known if we have separate compatibles for variants. Can we in dt-case just print a warning if the part-ID is not what we expect - and proceed assuming the nlux_per_count based on the DT information? (Sometimes we see new variants with same part-IDs - or many part-IDs with no SW changes needed. Hence maintaining the part-ID lists may be tedious). This is just some pondering though, no strong requirements from my side

Yes, I agree with you. The purpose of DT is to provide proper hardware descriptions.
I will throw a warning as well as implement a compatibility match.

Regards,
Subhajit Ghosh


  reply	other threads:[~2023-10-10 12:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-08 15:48 [PATCH 0/2] Support for Avago APDS9306 Ambient Light Sensor Subhajit Ghosh
2023-10-08 15:48 ` [PATCH 1/2] dt-bindings: iio: light: Avago APDS9306 Subhajit Ghosh
2023-10-09  8:36   ` Krzysztof Kozlowski
2023-10-09 11:25     ` Subhajit Ghosh
2023-10-10  8:52   ` Matti Vaittinen
2023-10-10 12:18     ` Subhajit Ghosh
2023-10-10 14:49       ` Jonathan Cameron
2023-10-10 16:19     ` Rob Herring
2023-10-11 13:04       ` Subhajit Ghosh
2023-10-10 13:51   ` Jonathan Cameron
2023-10-11 13:10     ` Subhajit Ghosh
2023-10-08 15:48 ` [PATCH 2/2] iio: light: Add support for APDS9306 Light Sensor Subhajit Ghosh
2023-10-10  9:45   ` Matti Vaittinen
2023-10-10 12:17     ` Subhajit Ghosh [this message]
2023-10-10 14:38   ` Jonathan Cameron
2023-10-11 14:37     ` Subhajit Ghosh
2023-10-12  7:54       ` Jonathan Cameron
2023-10-12 12:37         ` Subhajit Ghosh

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=09a07473-2558-2b05-c9d5-8d439749bfa7@tweaklogic.com \
    --to=subhajit.ghosh@tweaklogic.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=paul@pgazz.com \
    --cc=robh+dt@kernel.org \
    --cc=stefan.windfeldt-prytz@axis.com \
    /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;
as well as URLs for NNTP newsgroup(s).