lkml.org 
[lkml]   [2020]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v5 2/2] iio: proximity: Add driver support for vcnl3020 proximity sensor
From
Date
On Tue, 2020-03-31 at 14:00 +0300, Andy Shevchenko wrote:
> > > Why not to use standard pattern, i.e.
> > >
> > > if (rc)
> > > return rc;
> > > ...
> > > rc = regmap_write(...);
> > >
> > > ?
> >
> > Optional parameter. There exists a lot of ways to do it:
>
> I'm simple reading the code. And I believe the above I suggested is
> cleaner equivalent.
> Is it?
>
> > rc = device_property_read_u32(dev, "milliamp", &led_current);
> > rc = regmap_write(regmap, VCNL_LED_CURRENT, (!rc) : led_current ? 0);
>
> This seems not equal to above.

Yes, it is not equal. Error will be returned in case of non existent parameter
in vcnl3020_init but parameter is optional. rc shouldn't be checked or should
return 0 with your suggestion.

rc = device_property_read_u32(...);
if (rc)
return 0;
rc = regmap_write(...);
if (rc)
dev_err(...);
return rc;

\
 
 \ /
  Last update: 2020-03-31 18:56    [W:0.064 / U:4.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site