From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83EC7C43331 for ; Thu, 26 Mar 2020 10:50:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59D0320748 for ; Thu, 26 Mar 2020 10:50:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbgCZKuM (ORCPT ); Thu, 26 Mar 2020 06:50:12 -0400 Received: from mga09.intel.com ([134.134.136.24]:14806 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbgCZKuM (ORCPT ); Thu, 26 Mar 2020 06:50:12 -0400 IronPort-SDR: xwDxZvg70KlseplL8CyBfr4AudMWSWOrSRrh3IpCV7anY7ngXf2pvdJiA3vuGE3dzTTbJCayfp Lsc0SQ3JdfGg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2020 03:50:11 -0700 IronPort-SDR: M0amHD3MPVMlEJU+XQjOzgUglcdYP6/EcfcXDNEslyuwHukvN2/Lpdnxv/AwYWsJao5ttKea7c 7NP8429VXeNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,308,1580803200"; d="scan'208";a="265832861" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002.jf.intel.com with ESMTP; 26 Mar 2020 03:50:10 -0700 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1jHQ5U-00D5oD-Gv; Thu, 26 Mar 2020 12:50:12 +0200 Date: Thu, 26 Mar 2020 12:50:12 +0200 From: Andy Shevchenko To: Geert Uytterhoeven Cc: Wolfram Sang , Linux I2C , Linux-Renesas Subject: Re: [RFC PATCH] i2c: refactor parsing of timings 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 Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@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