Linux IIO development
 help / color / mirror / Atom feed
From: Shreeya Patel <shreeya.patel@collabora.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Rob Herring <robh+dt@kernel.org>,
	Zhigang.Shi@liteon.com, krisman@collabora.com,
	linux-iio <linux-iio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Collabora Kernel ML <kernel@collabora.com>,
	alvaro.soliverez@collabora.com, dmitry.osipenko@collabora.com
Subject: Re: [PATCH v7 2/2] iio: light: Add support for ltrf216a sensor
Date: Mon, 11 Jul 2022 19:09:15 +0530	[thread overview]
Message-ID: <c90e7334-5921-886b-2f9c-869fb55216ca@collabora.com> (raw)
In-Reply-To: <CAHp75Vf3NDsep5_819=e8yrna_AGh5cew=fs+hHe1q8LCa-PyA@mail.gmail.com>


On 11/07/22 18:36, Andy Shevchenko wrote:
> On Mon, Jul 11, 2022 at 1:30 PM Shreeya Patel
> <shreeya.patel@collabora.com> wrote:
>> From: Zhigang Shi <Zhigang.Shi@liteon.com>
>>
>> Add initial support for ltrf216a ambient light sensor.
>>
>> Datasheet: https://gitlab.steamos.cloud/shreeya/iio/-/blob/main/LTRF216A.pdf
>> Co-developed-by: Shreeya Patel <shreeya.patel@collabora.com>
>> Signed-off-by: Shreeya Patel <shreeya.patel@collabora.com>
>> Signed-off-by: Zhigang Shi <Zhigang.Shi@liteon.com>
> Submitter's SoB always has to be last among SoBs in the proposed change.
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#sign-your-work-the-developer-s-certificate-of-origin
> https://www.kernel.org/doc/html/latest/process/submitting-patches.html#when-to-use-acked-by-cc-and-co-developed-by
>
> ...
>
>> +static int ltrf216a_set_power_state(struct ltrf216a_data *data, bool on)
>> +{
>> +       struct device *dev = &data->client->dev;
>> +       int ret;
>> +
>> +       if (on) {
>> +               ret = pm_runtime_resume_and_get(dev);
>> +               if (ret < 0) {
>> +                       dev_err(dev, "Failed to resume runtime PM: %d\n", ret);
>> +                       return ret;
>> +               }
>> +
> Unneeded blank line.
>
>> +       } else {
>> +               pm_runtime_mark_last_busy(dev);
>> +               ret = pm_runtime_put_autosuspend(dev);
>> +       }
>> +
>> +       return ret;
>> +}
> ...
>
>> +       ret = regmap_read_poll_timeout(data->regmap, LTRF216A_MAIN_STATUS,
>> +                                      val, val & LTRF216A_ALS_DATA_STATUS,
>> +                                      LTRF216A_ALS_READ_DATA_DELAY_US,
>> +                                      LTRF216A_ALS_READ_DATA_DELAY_US * 50);
>> +       if (ret) {
>> +               dev_err(dev, "Timed out waiting for valid data from LTRF216A_MAIN_STATUS reg: %d\n",
>> +                       ret);
> THe message is a bit misleading. The loop might be broken by the I/O error.
>
>> +               return ret;
>> +       }
>> +
>> +       ret = regmap_bulk_read(data->regmap, addr, buf, sizeof(buf));
>> +       if (ret < 0) {
>> +               dev_err(dev, "Error reading measurement data: %d\n", ret);
>> +               return ret;
>> +       }
> ...
>
>> +static const struct regmap_config ltrf216a_regmap_config = {
>> +       .name = LTRF216A_DRV_NAME,
>> +       .reg_bits = 8,
>> +       .val_bits = 8,
>> +       .max_register = LTRF216A_MAX_REG,
> Why do you use regmap locking? What for?
>
Hi Andy,

Why do we want to skip the internal locking if it doesn't bring any 
benefits?


>> +};
> ...
>
>> +       data->regmap = devm_regmap_init_i2c(client, &ltrf216a_regmap_config);
>> +       if (IS_ERR(data->regmap)) {
>> +               dev_err(&client->dev, "Regmap initialization failed.\n");
>> +               return PTR_ERR(data->regmap);
> return dev_err_probe(...);
>
>> +       }
> ...
>
>> +       ret = devm_pm_runtime_enable(&client->dev);
>> +       if (ret < 0) {
>> +               dev_err_probe(&client->dev, ret, "Failed to enable runtime PM\n");
>> +               return ret;
> Ditto.
>
>> +       }
> ...
>
>> +               ret = ltrf216a_init(indio_dev);
>> +               if (ret) {
>> +                       dev_err_probe(&client->dev, ret, "Failed to enable the sensor\n");
>> +                       return ret;
> Ditto.
>
>> +               }
> ...
>
>> +       if (ret < 0)
> For all these  ' < 0', please explain what positive return value means
> there, if any, and why it's being ignored.
>
> ...
>
>> +static const struct i2c_device_id ltrf216a_id[] = {
>> +       { LTRF216A_DRV_NAME, 0 },
> Please, use the string literal directly since it's kinda an ABI,
> defining above for potential changes is not a good idea. Also you may
> drop the ', 0' part.
>
>> +       {}
>> +};
> ...
>
>> +static struct i2c_driver ltrf216a_driver = {
>> +       .driver = {
>> +               .name = LTRF216A_DRV_NAME,
> Ditto.
>
>> +               .pm = pm_ptr(&ltrf216a_pm_ops),
>> +               .of_match_table = ltrf216a_of_match,
>> +       },
>> +       .probe_new      = ltrf216a_probe,
>> +       .id_table       = ltrf216a_id,
>> +};

  reply	other threads:[~2022-07-11 13:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 11:28 [PATCH v7 0/2] Add LTRF216A Driver Shreeya Patel
2022-07-11 11:28 ` [PATCH v7 1/2] dt-bindings: Document ltrf216a light sensor bindings Shreeya Patel
2022-07-11 11:29 ` [PATCH v7 2/2] iio: light: Add support for ltrf216a sensor Shreeya Patel
2022-07-11 13:06   ` Andy Shevchenko
2022-07-11 13:39     ` Shreeya Patel [this message]
2022-07-11 13:41       ` Andy Shevchenko
2022-07-11 14:04         ` Dmitry Osipenko
2022-07-11 14:22           ` Andy Shevchenko
2022-07-11 14:50             ` Dmitry Osipenko

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=c90e7334-5921-886b-2f9c-869fb55216ca@collabora.com \
    --to=shreeya.patel@collabora.com \
    --cc=Zhigang.Shi@liteon.com \
    --cc=alvaro.soliverez@collabora.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=jic23@kernel.org \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@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