[PATCH v5 06/10] i2c: Introduce OF component probe function

Andy Shevchenko andriy.shevchenko at linux.intel.com
Fri Aug 23 06:52:54 PDT 2024


On Fri, Aug 23, 2024 at 04:40:36PM +0800, Chen-Yu Tsai wrote:
> On Thu, Aug 22, 2024 at 10:02 PM Andy Shevchenko
> <andriy.shevchenko at linux.intel.com> wrote:
> > On Thu, Aug 22, 2024 at 05:19:59PM +0800, Chen-Yu Tsai wrote:

...

> > > +     ret = of_changeset_apply(ocs);
> > > +     if (!ret) {
> >
> > Why not positive conditional?
> 
> No real reason. I suppose having the error condition come first is more
> common.

Yes, when you have something like

	if (err) {
		...
		return err;
	} else {
		...
	}


But you don't. That's why I commented on this.

> Not sure if it makes any difference in this case though?

! is hard to read by a human being, easy to make a mistake in the brain of
reader and with inverted logic the code reading becomes harder. So, it's pure
about cognitive function.

> > > +             /*
> > > +              * ocs is intentionally kept around as it needs to
> > > +              * exist as long as the change is applied.
> > > +              */
> > > +             void *ptr __always_unused = no_free_ptr(ocs);
> > > +     } else {
> > > +             /* ocs needs to be explicitly cleaned up before being freed. */
> > > +             of_changeset_destroy(ocs);
> > > +     }

-- 
With Best Regards,
Andy Shevchenko





More information about the Linux-mediatek mailing list