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=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham 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 055D6C43381 for ; Tue, 26 Mar 2019 12:41:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D2DCB2075D for ; Tue, 26 Mar 2019 12:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731582AbfCZMlS (ORCPT ); Tue, 26 Mar 2019 08:41:18 -0400 Received: from retiisi.org.uk ([95.216.213.190]:42382 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731508AbfCZMlM (ORCPT ); Tue, 26 Mar 2019 08:41:12 -0400 Received: from lanttu.localdomain (unknown [IPv6:2a01:4f9:c010:4572::e1:1001]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 4307B634C84; Tue, 26 Mar 2019 14:41:05 +0200 (EET) From: Sakari Ailus To: Petr Mladek , linux-kernel@vger.kernel.org, rafael@kernel.org Cc: Andy Shevchenko , linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring Subject: [PATCH v2 5/6] lib/vsprintf: Make use of fwnode API to obtain node names and separators Date: Tue, 26 Mar 2019 14:41:05 +0200 Message-Id: <20190326124106.27694-6-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190326124106.27694-1-sakari.ailus@linux.intel.com> References: <20190326124106.27694-1-sakari.ailus@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- lib/vsprintf.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 5f60b8d41277..91f2a3e4892e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef CONFIG_BLOCK #include #endif @@ -1720,32 +1721,23 @@ char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt) 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_gen_full_name(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(buf, end, "/", default_str_spec); + for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) { + struct fwnode_handle *__fwnode = + fwnode_get_nth_parent(fwnode, depth); - for (depth = 0; parent->parent; depth++) - parent = parent->parent; - - for ( ; depth >= 0; depth--) { - buf = string(buf, end, "/", default_str_spec); - buf = string(buf, end, device_node_name_for_depth(np, depth), + buf = string(buf, end, fwnode_get_name_prefix(__fwnode), + default_str_spec); + buf = string(buf, end, fwnode_get_name(__fwnode), default_str_spec); + + fwnode_handle_put(__fwnode); } + return buf; } @@ -1790,10 +1782,11 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, switch (*fmt) { case 'f': /* full_name */ - buf = device_node_gen_full_name(dn, buf, end); + buf = fwnode_gen_full_name(of_fwnode_handle(dn), buf, + end); break; case 'n': /* name */ - p = kbasename(of_node_full_name(dn)); + p = fwnode_get_name(of_fwnode_handle(dn)); precision = str_spec.precision; str_spec.precision = strchrnul(p, '@') - p; buf = string(buf, end, p, str_spec); @@ -1803,7 +1796,7 @@ char *device_node_string(char *buf, char *end, struct device_node *dn, buf = number(buf, end, (unsigned int)dn->phandle, num_spec); break; case 'P': /* path-spec */ - p = kbasename(of_node_full_name(dn)); + p = fwnode_get_name(of_fwnode_handle(dn)); if (!p[1]) p = "/"; buf = string(buf, end, p, str_spec); -- 2.11.0