lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 18 Jul 2018 09:21:22 +0000
From:   Phil Edworthy <phil.edworthy@...esas.com>
To:     Simon Horman <horms@...ge.net.au>
CC:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-renesas-soc@...r.kernel.org" 
        <linux-renesas-soc@...r.kernel.org>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>
Subject: RE: [PATCH 2/2] i2c: designware: Add support for a bus clock

Hi Simon,

On 18 July 2018 10:15 Simon Horman wrote:
> On Tue, Jul 17, 2018 at 02:57:27PM +0000, Phil Edworthy wrote:
> > On 17 July 2018 15:47, Andy Shevchenko wrote:
> > > On Tue, 2018-07-17 at 14:40 +0000, Phil Edworthy wrote:
> > > > On 17 July 2018 15:19, Andy Shevchenko wrote:
> > > > > On Tue, 2018-07-17 at 12:42 +0000, Phil Edworthy wrote:
> > > > >
> > > > > > > While your point sounds valid (don't remember how clk_get()
> > > > > > > is implemented), NULL is also OK to have.
> > > > > >
> > > > > > Ok as in there is no bus clock, right?
> > > > > > So it should be:
> > > > > >  if (!IS_ERR_OR_NULL (dev->busclk))
> > > > >
> > > > > Nope, NULL is no error case for optional clock.
> > > >
> > > > I must be missing something here...
> > >
> > > See how clk_prepare_enable() is implemented.
> > Ok, if busclk is NULL the code can safely call clk_prepare_enable()
> >
> > > > I agree that NULL for an optional clock is not an error. However,
> > > > the code above is now:
> > > > +	if (prepare) {
> > > > +		/* Optional bus clock */
> > >
> > > > +		if (!IS_ERR_OR_NULL(dev->busclk)) {
> > >
> > > Check for NULL is redundant.
> > >
> > > > +			ret = clk_prepare_enable(dev->busclk);
> > > > +			if (ret)
> > > > +				return ret;
> > > > +		}
> > > > +
> > > >  		return clk_prepare_enable(dev->clk);
> > > > +	}
> > > >
> > > > So, if you have a valid busclk, it gets enabled, otherwise it is
> > > > left alone.
> > >
> > So the code as sent in the original email is correct (aside from
> > Geert's comments about EPROBE_DEFER handling).
> >
> > Maybe I need some coffee :\
> > Thanks
> > Phil
> 
> My point is that errors should be treated as errors.
> 
> In i2c_dw_prepare_clk() the following appears:
> 
>         if (IS_ERR(dev->clk))
>                 return PTR_ERR(dev->clk);
> 
> So dev->clk being an error value is treated as an error that is passed up to the
> caller.
> 
> But in your patch (and the snippet below) dev->busclk is treated as the
> optional clock not being present. Even if the error stored nothing to do with
> the clock not being present - f.e.  ENOMEM or as Geert mentioned
> elsewhere, EPROBE_DEFER.
> 
> Assuming the absense of the optional clock is indicated by ENOENT, in my
> view correct code would include something like:
> 
> 	...
> 
> 	if (IS_ERR(dev->clk))
> 		return PTR_ERR(dev->clk);
> 
> 	if (IS_ERR(dev->buslck) && PTR_ERR(dev->busclk) != -ENOENT)
> 		return PTR_ERR(dev->busclk);
> 
> 	...

Yes, I completely agree!

Thanks
Phil

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ