From: Sakari Ailus Subject: Re: [PATCH v4 08/11] lib/vsprintf: Make use of fwnode API to obtain node names and separators Date: Mon, 2 Sep 2019 18:41:49 +0300 Message-ID: <20190902154149.GO5475@paasikivi.fi.intel.com> References: <20190902083240.20367-1-sakari.ailus@linux.intel.com> <20190902083240.20367-9-sakari.ailus@linux.intel.com> <20190902151803.wgt2x5rtpziggtgx@pathway.suse.cz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190902151803.wgt2x5rtpziggtgx@pathway.suse.cz> Sender: linux-kernel-owner@vger.kernel.org To: Petr Mladek Cc: rafael@kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Andy Shevchenko , Heikki Krogerus , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org List-Id: devicetree@vger.kernel.org Hi Petr, Thanks for the review. On Mon, Sep 02, 2019 at 05:18:03PM +0200, Petr Mladek wrote: > On Mon 2019-09-02 11:32:37, Sakari Ailus wrote: > > Instead of implementing our own means of discovering parent nodes, node > > names or counting how many parents a node has, use the newly added > > functions in the fwnode API to obtain that information. > > > > Signed-off-by: Sakari Ailus > > Reviewed-by: Andy Shevchenko > > --- > > lib/vsprintf.c | 38 ++++++++++++++++---------------------- > > 1 file changed, 16 insertions(+), 22 deletions(-) > > > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > > index b00b57f9f911f..a04a2167101ef 100644 > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -1863,32 +1864,24 @@ char *flags_string(char *buf, char *end, void *flags_ptr, > > return format_flags(buf, end, flags, names); > > } > > > > -static const char *device_node_name_for_depth(const struct device_node *np, int depth) > > -{ > > - for ( ; np && depth; depth--) > > - np = np->parent; > > - > > - return kbasename(np->full_name); > > -} > > - > > static noinline_for_stack > > -char *device_node_gen_full_name(const struct device_node *np, char *buf, char *end) > > +char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf, > > + char *end) > > { > > int depth; > > - const struct device_node *parent = np->parent; > > > > - /* special case for root node */ > > - if (!parent) > > - return string_nocheck(buf, end, "/", default_str_spec); > > + for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) { > > It looked suspicious that it iterated "depth + 1" times. It might be > obvious for people traversing paths every day but not for me ;-) > Please, add a comment, for example: > > /* Iterate over parents and current node. */ > > With the above comment: > > Reviewed-by: Petr Mladek Thanks. How about: /* Loop starting from the root node to the current node. */ -- Sakari Ailus sakari.ailus@linux.intel.com