From patchwork Wed Jun 14 20:30:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 105582 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp472082qgd; Wed, 14 Jun 2017 13:31:25 -0700 (PDT) X-Received: by 10.99.172.85 with SMTP id z21mr1715349pgn.246.1497472284987; Wed, 14 Jun 2017 13:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497472284; cv=none; d=google.com; s=arc-20160816; b=i2hoXOWaps16Z01qZysnCGS4zAW0NCnHp8rvp6IuuhwqXQK7ozFGa+spcOXLj6pSY3 eDGV8SB4WSUYbn1taNibhEiahXuILeZTNqzaOJHl3sxnfpoEtHFtm4ejsNEddaSrZlhU 2tOXkhXeTU4mxlkG+Dxj8xd5RXsl4Zs7cFvopzeN33u+qxTZB9YJP2ppi/Qcm/w7POhl SyvynFz1ORjlUSIuOwADBxfZVjD3+HO8X2vEuj75S/01tVVvLxVgQ2zpggnH8rI9NqWP JXhEa2ABi40Wqfe1pm4QZomSMXSuYi360g2ZLkfCgQLJE0ZNOHKqSSwgfyhmd38+Qn3+ IcKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=lJrb2DQHf3eeMUCnRMT9TXtOe5olxJY7wvyfn7Q3ozY=; b=L1+qY2UdCu3h8O2Gq+Ol8YvAbBegjIdQ1FOZNlxYRrQchpmEusw9yCTtI+RqIYdoeI yizHy43BGeJ8Wv+XDKpvLucOZEk6SjjJ6WR6BXUKOVC5OjOWXuiDBoRVXSrp6qIUjEWW 24bNSk0e2CmsesKuJ8s2usu+a7fxa8kWHrVFYwwHtCZn/gQna+oxaAX4t8zDd3I4taxc 3uK5olkJRgg1czrs5FhjCvvUwSNb/bpkLvsdFktPEF8VLUSqIJ2m54F2pdRv4cFi6VZe iVpYbkfpCoAyYenaVY6HVu5eUG2mGH53Al1jVkac28jnaY8xAnpcdS8ZPBAbZtQbmcrI foMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si722393plt.189.2017.06.14.13.31.24; Wed, 14 Jun 2017 13:31:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbdFNUbX (ORCPT + 7 others); Wed, 14 Jun 2017 16:31:23 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:36317 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751760AbdFNUaa (ORCPT ); Wed, 14 Jun 2017 16:30:30 -0400 Received: by mail-ot0-f193.google.com with SMTP id r67so1167847ota.3; Wed, 14 Jun 2017 13:30:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ks0JQpVLIaQW3+I3uLEfaYt/ZsrB/l4CnYvpalfhLnE=; b=TE2j+x2UzsF67sINo+oiXLk+TPNKnJRTf2QAK6JPXrzkWNlUgTLT70k6gs6dRMf06P HLr13Io8mGy6K1Zfy2QUv6wmNC2XIWjqE/jkdTEiy2QwEoh3LEg9UeqZQwnyUZHHJTHf C6sJNNyggnzTmqQ5bIYvp2HqBjAl5sUHaGCKTtraOoAM45LVBC+DER5e8PANu8ZmlxxZ XrHNguy6cn0sR4M+hGdqsGFKGtApr1Q+FGBfdYqGdYDP7aFM02+EmJntyT87SlpCdvP3 Vo8xEfsPFbVg8tpRxsBaAzSuT6HWJgmLfL8XK33sCMsnKC54N/sKtwVMEwie4jmVB/gS XMKQ== X-Gm-Message-State: AKS2vOx2vNT0iaFKHfdfW0AZedMJ0ggjRtfSB6Dxplqi9fuuLRZ2+PpJ zMlWKZVz/TOmUQ== X-Received: by 10.157.46.9 with SMTP id q9mr1270850otb.30.1497472229810; Wed, 14 Jun 2017 13:30:29 -0700 (PDT) Received: from localhost.localdomain (66-90-148-125.dyn.grandenetworks.net. [66.90.148.125]) by smtp.googlemail.com with ESMTPSA id w104sm586861ota.19.2017.06.14.13.30.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 13:30:29 -0700 (PDT) From: Rob Herring To: Frank Rowand , Mark Rutland Cc: Pantelis Antoniou , Joe Perches , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] of: use kbasename instead of open coding Date: Wed, 14 Jun 2017 15:30:22 -0500 Message-Id: <20170614203025.7581-2-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170614203025.7581-1-robh@kernel.org> References: <20170614203025.7581-1-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Several places in DT code open code the equivalent of kbasename. Replace them. The behavior for root nodes in node_name_cmp will be slightly different. Instead of comparing "/", "" will be compared. The comparison will be the same. Signed-off-by: Rob Herring --- drivers/of/base.c | 5 +---- drivers/of/platform.c | 2 +- drivers/of/resolver.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Andy Shevchenko diff --git a/drivers/of/base.c b/drivers/of/base.c index 28d5f53bc631..054159ccd5f8 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -773,10 +773,7 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, return NULL; __for_each_child_of_node(parent, child) { - const char *name = strrchr(child->full_name, '/'); - if (WARN(!name, "malformed device_node %s\n", child->full_name)) - continue; - name++; + const char *name = kbasename(child->full_name); if (strncmp(path, name, len) == 0 && (strlen(name) == len)) return child; } diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 71fecc2debfc..8f73413fa243 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -99,7 +99,7 @@ static void of_device_make_bus_id(struct device *dev) /* format arguments only used if dev_name() resolves to NULL */ dev_set_name(dev, dev_name(dev) ? "%s:%s" : "%s", - strrchr(node->full_name, '/') + 1, dev_name(dev)); + kbasename(node->full_name), dev_name(dev)); node = node->parent; } } diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 771f4844c781..63626d7d9adb 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -165,8 +165,8 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay, static int node_name_cmp(const struct device_node *dn1, const struct device_node *dn2) { - const char *n1 = strrchr(dn1->full_name, '/') ? : "/"; - const char *n2 = strrchr(dn2->full_name, '/') ? : "/"; + const char *n1 = kbasename(dn1->full_name); + const char *n2 = kbasename(dn2->full_name); return of_node_cmp(n1, n2); }