lkml.org 
[lkml]   [2022]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 1/1] iio: humidity: hdc100x: add manufacturer and device ID cehck
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.

> 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;
> >> + }

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2022-07-27 13:57    [W:0.044 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site