From: Potin Lai <potin.lai.pt@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Patrick Williams <patrick@stwcx.xyz>,
Potin Lai <potin.lai@quantatw.com>,
linux-iio <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/1] iio: humidity: hdc100x: add manufacturer and device ID cehck
Date: Wed, 27 Jul 2022 23:44:42 +0800 [thread overview]
Message-ID: <47516b38-58e1-e3c9-1ac2-7b8d8586566e@gmail.com> (raw)
In-Reply-To: <CAHp75VdjvJRwzPLLdMji+_m2tQY4JLBcNwt-QFkDJTyGFUOdKg@mail.gmail.com>
Andy Shevchenko 於 7/27/2022 7:56 PM 寫道:
> On Wed, Jul 27, 2022 at 12:42 PM Potin Lai <potin.lai.pt@gmail.com> wrote:
>> On 7/27/22 18:00, Andy Shevchenko wrote:
>>> On Wed, Jul 27, 2022 at 8:46 AM Potin Lai <potin.lai.pt@gmail.com> wrote:
> ...
>
>>>> + data = device_get_match_data(&client->dev);
>>>> + if (data) {
>>> This check is redundant. Too much protective programming. Just oblige
>>> that matched ID has to always have an associated data.
>> Is it guaranteed that device_get_match_data will not return NULL? I find some examples in other drivers, all of them have a check on returned data.
> No, but as I said you may guarantee that by obliging developers not to
> shoot in their feet.
Thanks for the explanation, I will remove the checking part.
Potin
>> Will it be more appropriate if I move device_get_match_data to probe function, and return EINVAL when we get a NULL pointer from device_get_match_data?
> Why is this check needed? We do not like dead code.
>
>>>> + if (!data->support_mfr_check)
>>>> + return true;
>>>> + }
prev parent reply other threads:[~2022-07-27 15:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-27 6:44 [PATCH v2 1/1] iio: humidity: hdc100x: add manufacturer and device ID cehck Potin Lai
2022-07-27 10:00 ` Andy Shevchenko
2022-07-27 10:40 ` Potin Lai
2022-07-27 11:56 ` Andy Shevchenko
2022-07-27 15:44 ` Potin Lai [this message]
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=47516b38-58e1-e3c9-1ac2-7b8d8586566e@gmail.com \
--to=potin.lai.pt@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patrick@stwcx.xyz \
--cc=potin.lai@quantatw.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