From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Date: Wed, 09 Dec 2015 12:12:36 +0000 Subject: Re: [PATCH v2 2/9] i2c: add generic routine to parse DT for timing information Message-Id: <1449663156.30729.63.camel@linux.intel.com> List-Id: References: <1449567473-2084-1-git-send-email-wsa@the-dreams.de> <1449567473-2084-3-git-send-email-wsa@the-dreams.de> <1449572085.30729.28.camel@linux.intel.com> <20151208130323.GB3359@katana> <20151208215103.GA1601@katana> In-Reply-To: <20151208215103.GA1601@katana> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: Wolfram Sang Cc: linux-sh-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Yoshihiro Shimoda , Magnus Damm , linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Simon Horman , Geert Uytterhoeven , linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jarkko Nikula , Mika Westerberg , Laurent Pinchart On Tue, 2015-12-08 at 22:51 +0100, Wolfram Sang wrote: > On Tue, Dec 08, 2015 at 02:03:23PM +0100, Wolfram Sang wrote: > > > > > Too many && use_defaults. What about > > > > > > memset(t, 0, sizeof(*t)); > > > > > > device_property_read_u32(dev, "i2c-scl-internal-delay-ns", &t- > > > > scl_int_delay_ns); > > > > > > if (!use_defaults) > > >  return; > > > > I like this! Thanks for the input. > > Oops, too enthusiastic. This skips parsing all the other > properties... > The defaults should only be applied if reading the properties fails. Looks like property stuff is not destructive in case of error, so, what about paramX = use_defaults ? defaultX : 0; device_property_read…(…, ¶mX); Or maybe just be a bit verbose like the original variant int ret; ret = device_property_read…(…); if (ret && use_defaults) { … } Among all variants I like the latter one here. What do you think? -- Andy Shevchenko Intel Finland Oy