From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Subject: Re: [RFC PATCH] i2c: refactor parsing of timings Date: Thu, 26 Mar 2020 12:50:12 +0200 Message-ID: <20200326105012.GN1922688@smile.fi.intel.com> References: <20200326101647.1756-1-wsa+renesas@sang-engineering.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-renesas-soc-owner@vger.kernel.org To: Geert Uytterhoeven Cc: Wolfram Sang , Linux I2C , Linux-Renesas List-Id: linux-i2c@vger.kernel.org On Thu, Mar 26, 2020 at 11:36:44AM +0100, Geert Uytterhoeven wrote: > On Thu, Mar 26, 2020 at 11:17 AM Wolfram Sang > wrote: > > When I wanted to print the chosen values to debug output, I concluded > > that a helper function to parse one timing would be helpful. ... > > +static void i2c_parse_timing(struct device *dev, char *prop_name, u32 *cur_val_p, > > + u32 def_val, bool use_def) > > +{ > > + int ret; > > + > > + ret = device_property_read_u32(dev, prop_name, cur_val_p); > > + if (ret && use_def) > > + *cur_val_p = def_val; > > Alternatively, you could just preinitialize the value with the default value > before calling this function, and ignoring ret. > That would remove the need for both the def_val and use_def parameters. Some drivers are using false to use_defaults. How they will survive this change? (See rcar case, for instance) > > + dev_dbg(dev, "%s: %u\n", prop_name, *cur_val_p); > > +} -- With Best Regards, Andy Shevchenko