From patchwork Wed Jun 14 20:30:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 105579 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp471809qgd; Wed, 14 Jun 2017 13:30:41 -0700 (PDT) X-Received: by 10.99.121.13 with SMTP id u13mr1730006pgc.147.1497472240899; Wed, 14 Jun 2017 13:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497472240; cv=none; d=google.com; s=arc-20160816; b=ZHA+puX7mfV087IAalVpZm7uzxW/6uWgaW2SH1FqWPTc5/txs06qRHNriMWQ05gzCp qHL0XhhehNNfRPepClwNd53apNjHOd38yK7W1JQIY7rKQuBO6WgBP5xuyq/bgtX6Rr04 Z9Q84o8MyKnHsBbq1uImtLCdPTMCRFLMU0Sdr1W3xQXRX6YTdoHb9Mzp4mwxsT7yY0Z3 lfiR/Y7/pWqVu5EjXjBX+47LTeQDXFTavw+dCHyzFtFNIjzov04jKdvIAHBAiD7VKZ1q w85hlOf9uzWJesVMbogTCOzrC9Oq8zqenAZdGJ0iUgrQTz8APx77opKywjx0+VP6oKrb BPnA== 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=TQiXFrEtI2VsVLFvB9pEct/S2y/XE4c6xAV3sHwE+iU=; b=iFRYelAHKEGs/cDftDz/8UX1EProcRkFyJJ1AAcbBZccNMfcGCEKjLr01xmIugsDRd kgzFOAb4Vf2jCkP+y750EgFus2x0Q9GGdWhfE/LF0jxVaxAn7a2skR7ulGw7di8YqFxO c1J6qeRtuBELC2UELLlXiuDKuGjAYS0bwyDCbXOqwkI7GYa3Z5FfIb1tD8wrhcYyndLM G1ro3Lvziqxy5kvjorysMS3bp7ZulCnnHMx1NC7FC1W0NVbcj4fnfyz8gdKsdleiQnJy PgmcaOa+397o04/6bRv3T0G2ejSgMyVtqOYtcV0LzT3G2O16vKDtsIN6PuCxgSXGu++p K+PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 z2si678968pgn.171.2017.06.14.13.30.40; Wed, 14 Jun 2017 13:30:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752429AbdFNUae (ORCPT + 25 others); Wed, 14 Jun 2017 16:30:34 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35564 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752359AbdFNUab (ORCPT ); Wed, 14 Jun 2017 16:30:31 -0400 Received: by mail-oi0-f65.google.com with SMTP id v74so944300oie.2; Wed, 14 Jun 2017 13:30:31 -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=TQiXFrEtI2VsVLFvB9pEct/S2y/XE4c6xAV3sHwE+iU=; b=kFv3H3Px9f6uTrya0R91qL7Tqh5aU57G+acwJbs9QYh8X2MdyLKD4de2J79iP5OfG5 TQYHO4sLaTdEwLfPH3DLdQZ2AvnJw+zhkXiovvMjMWUZB8iyFkGmU5fq4aeL2afLvmn3 jlHT80zNVguaHbPw+iy38TxRpKp4hIxCy/LxA8WWHVJXaeSBI+dpIKrfJLpX8cLuPwAS tRcmrh/yHhSL578IXkvkAlp6QtjFm03QWnCNYaQETnZjefEvhVZp2NwIPvsJ0UGRdDNH 9ODktLS+Nf/8Ljca1qgYKpeINQWqrkLkyoo2ZHkM1zrUistganhcGTC9qyw290p6f1R7 55Lw== X-Gm-Message-State: AKS2vOxUwNV2BtcK+njHZd0aqLJUt34MjwAt0KTj33fNigCLPX6D8zCw dfHjXu3TH5bWxQ== X-Received: by 10.202.88.214 with SMTP id m205mr1298087oib.173.1497472230868; Wed, 14 Jun 2017 13:30:30 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 13:30:30 -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 2/4] of: find_node_by_full_name rewrite to compare each level Date: Wed, 14 Jun 2017 15:30:23 -0500 Message-Id: <20170614203025.7581-3-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org find_node_by_full_name() does the same thing as of_find_node_by_path(), but takes no locks and doesn't work on aliases. Refactor of_find_node_opts_by_path() into __of_find_node_by_full_path() and replace find_node_by_full_name() with it. Signed-off-by: Rob Herring --- drivers/of/base.c | 29 +++++++++++++++++++---------- drivers/of/of_private.h | 3 +++ drivers/of/resolver.c | 30 +++--------------------------- 3 files changed, 25 insertions(+), 37 deletions(-) -- 2.11.0 diff --git a/drivers/of/base.c b/drivers/of/base.c index 054159ccd5f8..02be991a29c5 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -780,6 +780,24 @@ static struct device_node *__of_find_node_by_path(struct device_node *parent, return NULL; } +struct device_node *__of_find_node_by_full_path(struct device_node *node, + const char *path) +{ + const char *separator = strchr(path, ':'); + + while (node && *path == '/') { + struct device_node *tmp = node; + + path++; /* Increment past '/' delimiter */ + node = __of_find_node_by_path(node, path); + of_node_put(tmp); + path = strchrnul(path, '/'); + if (separator && separator < path) + break; + } + return node; +} + /** * of_find_node_opts_by_path - Find a node matching a full OF path * @path: Either the full path to match, or if the path does not @@ -839,16 +857,7 @@ struct device_node *of_find_node_opts_by_path(const char *path, const char **opt raw_spin_lock_irqsave(&devtree_lock, flags); if (!np) np = of_node_get(of_root); - while (np && *path == '/') { - struct device_node *tmp = np; - - path++; /* Increment past '/' delimiter */ - np = __of_find_node_by_path(np, path); - of_node_put(tmp); - path = strchrnul(path, '/'); - if (separator && separator < path) - break; - } + np =__of_find_node_by_full_path(np, path); raw_spin_unlock_irqrestore(&devtree_lock, flags); return np; } diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h index 4ebb0149d118..e7bbfa3e9632 100644 --- a/drivers/of/of_private.h +++ b/drivers/of/of_private.h @@ -77,6 +77,9 @@ extern void *__unflatten_device_tree(const void *blob, struct property *__of_prop_dup(const struct property *prop, gfp_t allocflags); __printf(2, 3) struct device_node *__of_node_dup(const struct device_node *np, const char *fmt, ...); +struct device_node *__of_find_node_by_full_path(struct device_node *node, + const char *path); + extern const void *__of_get_property(const struct device_node *np, const char *name, int *lenp); extern int __of_add_property(struct device_node *np, struct property *prop); diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c index 63626d7d9adb..b3f987c1301b 100644 --- a/drivers/of/resolver.c +++ b/drivers/of/resolver.c @@ -20,35 +20,11 @@ #include #include +#include "of_private.h" + /* illegal phandle value (set when unresolved) */ #define OF_PHANDLE_ILLEGAL 0xdeadbeef -/** - * Find a node with the give full name by recursively following any of - * the child node links. - */ -static struct device_node *find_node_by_full_name(struct device_node *node, - const char *full_name) -{ - struct device_node *child, *found; - - if (!node) - return NULL; - - if (!of_node_cmp(node->full_name, full_name)) - return of_node_get(node); - - for_each_child_of_node(node, child) { - found = find_node_by_full_name(child, full_name); - if (found != NULL) { - of_node_put(child); - return found; - } - } - - return NULL; -} - static phandle live_tree_max_phandle(void) { struct device_node *node; @@ -138,7 +114,7 @@ static int update_usages_of_a_phandle_reference(struct device_node *overlay, if (err) goto err_fail; - refnode = find_node_by_full_name(overlay, node_path); + refnode = __of_find_node_by_full_path(overlay, node_path); if (!refnode) continue; From patchwork Wed Jun 14 20:30:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 105581 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp472023qgd; Wed, 14 Jun 2017 13:31:18 -0700 (PDT) X-Received: by 10.98.33.84 with SMTP id h81mr1650974pfh.81.1497472278426; Wed, 14 Jun 2017 13:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497472278; cv=none; d=google.com; s=arc-20160816; b=hGkrKWHNf3rQ45ZRp8JxIy7sU9Nza8i/VxsKh858qfPBBK81oYOPM0e/vIjd9/Gmav OGWAfweLUk2QNc71Aip/75bMI3ls9u1rBFq2m7E7UzTLBYXR9RDeAEbHkbnTcpjEtsN4 5MvN7Ko4fjyxWoKYCRzzxdIhjEQMfkGJ+qb+RKsNyZ5f/BDmhYPBtLap1cunA3X97+RT nlXuuYzDJcCA7uh+fEUJuAUg14x5nHz1w8UoMHRJ/r4qnoxfJlWvtCG5P0sjXRuE39jb pWB1uRjzyEO7rLMay9EQkta/Pf4AZhyi6EF//SDuVLuAlvtnTAOL5Xzq9LLEeL06nKbG znaQ== 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=pyA04n8JWChY2NqljOUX/axVpIwhoHQZxEWWaxIrQRk=; b=Yx3qO9sqBZ+jnFikY6KsN7wtfVSoNGZz3pM67JSxErAGGOV6qGsz70URodBK8zxw5A botzZTZh6tZpRl/1UtjDBJnMTgcImCf2iyg4Fr0Rn6pTHg4slUM4AM1YBg5FpvlXYafP 9v5JDziABLxB6S6Be1Zwp76GTjpkul3tqwUhm6GiXWg9wTUireJNwCUNNMjef7NxuME9 WCJstioaIar5US8d/eXJ9HKtJXQtwoG/rzHCG/P7HVCLhXn+fp+U3E4kuZGuCcUkcTiX W4nnOaG/Gb/5I0qMJrXZ4Q+1S8Re0uhTFaHgQj3YWnNd5KOYzVKAo9SlODjxXWxYBUA6 R7Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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.18; Wed, 14 Jun 2017 13:31:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752551AbdFNUbA (ORCPT + 25 others); Wed, 14 Jun 2017 16:31:00 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34432 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbdFNUac (ORCPT ); Wed, 14 Jun 2017 16:30:32 -0400 Received: by mail-oi0-f67.google.com with SMTP id d99so951360oic.1; Wed, 14 Jun 2017 13:30:32 -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=pyA04n8JWChY2NqljOUX/axVpIwhoHQZxEWWaxIrQRk=; b=jbjiD/d6/pEatNyKo2eIV4p11q93fQjO1pZhi4gEcPuWOF3oEWb94bTTZIPQYEMiDk 1U/KYjbbREyngJ5FoqghQ1pD5+ajuJuyIkN8VRsfXrkryT8nDO2uXXu04LNgMMVOZQIo YcJDhj760XOZ80ZeZWbzoVFiM5YDy8P4FhqzsevWgoUsJRT4fXDJy9xPi9VCYa1Unv8Q FaW/CIbHB/73k2dC7Dq3MQUdteor87WILD0GjTlX6UBNh6gUBoMPF/sImfYCcZ+j+BB4 wbLtTeaNseXEH4nH0G/xg/RAmRzly9ymOf0LNx//SeK5E749dVa2F3qrvIfydnSsyXsZ Tuww== X-Gm-Message-State: AKS2vOwpcpKzqonQ24uRhtKyS73q5XDY+DFl5PeYM8jwcGNoMVLbe0KR 23pE5MkF+rQNtA== X-Received: by 10.202.71.21 with SMTP id u21mr1372788oia.136.1497472231828; Wed, 14 Jun 2017 13:30:31 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 13:30:31 -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 3/4] of: Custom printk format specifier for device node Date: Wed, 14 Jun 2017 15:30:24 -0500 Message-Id: <20170614203025.7581-4-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pantelis Antoniou 90% of the usage of device node's full_name is printing it out in a kernel message. Preparing for the eventual delayed allocation introduce a custom printk format specifier that is both more compact and more pleasant to the eye. For instance typical use is: pr_info("Frobbing node %s\n", node->full_name); Which can be written now as: pr_info("Frobbing node %pOF\n", node); More fine-grained control of formatting includes printing the name, flag, path-spec name, reference count and others, explained in the documentation entry. Originally written by Pantelis, but pretty much rewrote the core function using existing string/number functions. The 2 passes were unnecessary and have been removed. Also, updated the checkpatch.pl check. Signed-off-by: Pantelis Antoniou Signed-off-by: Rob Herring --- Documentation/printk-formats.txt | 31 +++++++++ lib/vsprintf.c | 135 ++++++++++++++++++++++++++++++++++++++- scripts/checkpatch.pl | 2 +- 3 files changed, 166 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index 5962949944fd..07bc088ba5f5 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt @@ -275,6 +275,37 @@ struct va_format: Passed by reference. +Device tree nodes: + + %pOF[fnpPcCFr] + + For printing device tree nodes. The optional arguments are: + f device node full_name + n device node name + p device node phandle + P device node path spec (name + @unit) + F device node flags + c major compatible string + C full compatible string + r node reference count + Without any arguments prints full_name (same as %pOf) + The separator when using multiple arguments is '|' + + Examples: + + %pOF /foo/bar@0 - Node full name + %pOFf /foo/bar@0 - Same as above + %pOFfp /foo/bar@0|10 - Node full name + phandle + %pOFfcF /foo/bar@0|foo,device|--P- - Node full name + + major compatible string + + node flags + D - dynamic + d - detached + P - Populated + B - Populated bus + + Passed by reference. + struct clk: %pC pll1 diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 2d41de3f98a1..80b3e237f8d1 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #ifdef CONFIG_BLOCK #include @@ -650,7 +651,7 @@ char *bdev_name(char *buf, char *end, struct block_device *bdev, struct printf_spec spec, const char *fmt) { struct gendisk *hd = bdev->bd_disk; - + buf = string(buf, end, hd->disk_name, spec); if (bdev->bd_part->partno) { if (isdigit(hd->disk_name[strlen(hd->disk_name)-1])) { @@ -1470,6 +1471,123 @@ char *flags_string(char *buf, char *end, void *flags_ptr, const char *fmt) return format_flags(buf, end, flags, names); } +static noinline_for_stack +char *device_node_gen_full_name(const struct device_node *np, char *buf, char *end) +{ + int len, ret; + + if (!np || !np->parent) + return buf; + + buf = device_node_gen_full_name(np->parent, buf, end); + + if (buf < end) + len = end - buf; + else + len = 0; + ret = snprintf(buf, len, "/%s", kbasename(np->full_name)); + if (ret <= 0) + return buf; + else if (len == 0 || ret < len) + return buf + ret; + return buf + len; +} + +static noinline_for_stack +char *device_node_string(char *buf, char *end, struct device_node *dn, + struct printf_spec spec, const char *fmt) +{ + char tbuf[sizeof("xxxxxxxxxx") + 1]; + const char *fmtp, *p; + int ret; + char *buf_start = buf; + struct property *prop; + bool has_mult, pass; + const struct printf_spec num_spec = { + .flags = SMALL, + .field_width = -1, + .precision = -1, + .base = 10, + }; + + struct printf_spec str_spec = spec; + str_spec.field_width = -1; + + if (!IS_ENABLED(CONFIG_OF)) + return string(buf, end, "(!OF)", spec); + + if ((unsigned long)dn < PAGE_SIZE) + return string(buf, end, "(null)", spec); + + /* simple case without anything any more format specifiers */ + if (fmt[1] == '\0' || strcspn(fmt + 1,"fnpPFcCr") > 0) + fmt = "Ff"; + + for (fmtp = fmt + 1, pass = false; strspn(fmtp,"fnpPFcCr"); fmtp++, pass = true) { + if (pass && (*fmtp != 'f')) { + if (buf < end) + *buf = '|'; + buf++; + } + + switch (*fmtp) { + case 'f': /* full_name */ + if (pass) { + if (buf < end) + *buf = ':'; + buf++; + } + buf = device_node_gen_full_name(dn, buf, end); + break; + case 'n': /* name */ + buf = string(buf, end, dn->name, str_spec); + break; + case 'p': /* phandle */ + buf = number(buf, end, (unsigned int)dn->phandle, num_spec); + break; + case 'P': /* path-spec */ + buf = string(buf, end, kbasename(of_node_full_name(dn)), str_spec); + break; + case 'F': /* flags */ + snprintf(tbuf, sizeof(tbuf), "%c%c%c%c", + of_node_check_flag(dn, OF_DYNAMIC) ? + 'D' : '-', + of_node_check_flag(dn, OF_DETACHED) ? + 'd' : '-', + of_node_check_flag(dn, OF_POPULATED) ? + 'P' : '-', + of_node_check_flag(dn, + OF_POPULATED_BUS) ? 'B' : '-'); + buf = string(buf, end, tbuf, str_spec); + break; + case 'c': /* major compatible string */ + ret = of_property_read_string(dn, "compatible", &p); + if (!ret) + buf = string(buf, end, p, str_spec); + break; + case 'C': /* full compatible string */ + has_mult = false; + of_property_for_each_string(dn, "compatible", prop, p) { + if (has_mult) + buf = string(buf, end, ",", str_spec); + buf = string(buf, end, "\"", str_spec); + buf = string(buf, end, p, str_spec); + buf = string(buf, end, "\"", str_spec); + + has_mult = true; + } + break; + case 'r': /* node reference count */ + buf = number(buf, end, refcount_read(&dn->kobj.kref.refcount), num_spec); + break; + default: + break; + } + } + + return widen_string(buf, buf - buf_start, end, spec); +} + int kptr_restrict __read_mostly; /* @@ -1566,6 +1684,16 @@ int kptr_restrict __read_mostly; * p page flags (see struct page) given as pointer to unsigned long * g gfp flags (GFP_* and __GFP_*) given as pointer to gfp_t * v vma flags (VM_*) given as pointer to unsigned long + * - 'OF[fnpPcCFr]' For an DT device node + * Without any optional arguments prints the full_name + * f device node full_name + * n device node name + * p device node phandle + * P device node path spec (name + @unit) + * F device node flags + * c major compatible string + * C full compatible string + * r node reference count * * ** Please update also Documentation/printk-formats.txt when making changes ** * @@ -1721,6 +1849,11 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, case 'G': return flags_string(buf, end, ptr, fmt); + case 'O': + switch (fmt[1]) { + case 'F': + return device_node_string(buf, end, ptr, spec, fmt + 1); + } } spec.flags |= SMALL; if (spec.field_width == -1) { diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4b9569fa931b..411f2098fa6b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5709,7 +5709,7 @@ sub process { for (my $count = $linenr; $count <= $lc; $count++) { my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0)); $fmt =~ s/%%//g; - if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGN]).)/) { + if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNO]).)/) { $bad_extension = $1; last; } From patchwork Wed Jun 14 20:30:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 105580 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp471810qgd; Wed, 14 Jun 2017 13:30:41 -0700 (PDT) X-Received: by 10.99.111.205 with SMTP id k196mr1761047pgc.104.1497472241339; Wed, 14 Jun 2017 13:30:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497472241; cv=none; d=google.com; s=arc-20160816; b=aeMkck4dNoczVG30X81oOBctdF2mBlPm9JgueNEAgM071sAFH1mEF/OScZbqUL5dZO 3+jNNvxVrY5G+WwdoMgxTolA0ofFMYP9KzUtNYMEFHpweZpC3I3iZytRq67uh2zI+6P1 wDjG/7LCa9SH6xzEMLGJBUx5Iz5iZFic5j4/bO9XlEt0eHaek/cEgjJtYZ4pJA/3tBme 8DvXTfE3hT/l+f45Mc4MNuHNYS7reCf4D8/zmKRLeJtDPY7VFnXW5/f8rOkFz5jqkQ2b gdcz8XDUFccXvf+AHoXh+vVH9ToEC+XBNs7+rSgOlMjZUy81fkg5RHNovilzleFiF01H JMPQ== 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=/z6W8xv5hGo7PjXs0SsBsPPBgcHgL01O5EiPPeQUqsQ=; b=P4fKlRB7KAlhBFD816/Zaj1+GzVXwt7msrJl/NB2pOfJI2DcdmH+WRw+RL0YwJ1JOr YslWsCZT3v8FysfQpS8/nQcah32gGZeQOckDfEqjdoNgPu5fFWlek0GIEv+Yc4MlLufz n8ImF/VlOGzlti9tuMNUefiNzXQPiHSQ48Xn/m80tki8F+ToBgvIJC3U8NwCoEcfKJhB yqhj69IWCOkEeSbxJlUdqqws8l03sYKwqIwJ1ty0FrWRnoTS1zCaSFJB1Cyby/3GszRS UuFoVXUBaAmGX44wP6i5E62t2J/3vx8nED39lH0W4EKL/X81dEmQPM+t/Ow0wRGC0D/a s89A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 z2si678968pgn.171.2017.06.14.13.30.41; Wed, 14 Jun 2017 13:30:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752479AbdFNUag (ORCPT + 25 others); Wed, 14 Jun 2017 16:30:36 -0400 Received: from mail-ot0-f194.google.com ([74.125.82.194]:34223 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752419AbdFNUae (ORCPT ); Wed, 14 Jun 2017 16:30:34 -0400 Received: by mail-ot0-f194.google.com with SMTP id p48so389487otc.1; Wed, 14 Jun 2017 13:30:33 -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=/z6W8xv5hGo7PjXs0SsBsPPBgcHgL01O5EiPPeQUqsQ=; b=sAYQhKPJu5t0rT58rphNDW6HmuClthejpFufl/H0RJHtO0mz6K+oO+MUvQpQ47vmLX U2Ca3TTJhzoUn8TJrqUwiZWPrmIsTbTnByRSmjwz7SgJJ1MP1u0wMeG8E9/uQZ3nll8i yC6VoDlb9flHIQd5hOOvxW4nb8zlqRqJ3o90RqyWCj0Q1yVe2S3r7dw2qg12L4Bxv3mj QcA9NLujZZkjHg8TFHPN9ykBXl43AKDgaC7adoxFRk7Juq0PowN351QZLu//mplgTy8P A/TlbmFFZiOJytpi8WgEERAUDxMKyvMc16Ftm05RDu57POTJ6akFconhkmp0q1tFqGIZ KbUA== X-Gm-Message-State: AKS2vOy8fD9UmEonc22lVzqKjElu5jgZt7OtPIL0M5+mW07tfsT0YwUa dvfYTfMg0hP53A== X-Received: by 10.157.45.133 with SMTP id g5mr1216032otb.68.1497472233019; Wed, 14 Jun 2017 13:30:33 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 13:30:32 -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 4/4] of: Convert to using %pOF instead of full_name Date: Wed, 14 Jun 2017 15:30:25 -0500 Message-Id: <20170614203025.7581-5-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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have a custom printf format specifier, convert users of full_name to use %pOF instead. This is preparation to remove storing of the full path string for each node. Signed-off-by: Rob Herring --- drivers/of/address.c | 21 ++++++++-------- drivers/of/base.c | 42 ++++++++++++++++---------------- drivers/of/device.c | 2 +- drivers/of/dynamic.c | 33 +++++++++++++------------- drivers/of/irq.c | 10 ++++---- drivers/of/of_mdio.c | 10 ++++---- drivers/of/of_pci.c | 29 +++++++++++----------- drivers/of/overlay.c | 21 ++++++++-------- drivers/of/platform.c | 32 ++++++++++++------------- drivers/of/unittest.c | 66 +++++++++++++++++++++++++++++---------------------- 10 files changed, 136 insertions(+), 130 deletions(-) -- 2.11.0 diff --git a/drivers/of/address.c b/drivers/of/address.c index 72914cdfce2a..6cce3c750a8f 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -559,7 +559,7 @@ static u64 __of_translate_address(struct device_node *dev, int na, ns, pna, pns; u64 result = OF_BAD_ADDR; - pr_debug("** translation for device %s **\n", of_node_full_name(dev)); + pr_debug("** translation for device %pOF **\n", dev); /* Increase refcount at current level */ of_node_get(dev); @@ -573,13 +573,13 @@ static u64 __of_translate_address(struct device_node *dev, /* Count address cells & copy address locally */ bus->count_cells(dev, &na, &ns); if (!OF_CHECK_COUNTS(na, ns)) { - pr_debug("Bad cell count for %s\n", of_node_full_name(dev)); + pr_debug("Bad cell count for %pOF\n", dev); goto bail; } memcpy(addr, in_addr, na * 4); - pr_debug("bus is %s (na=%d, ns=%d) on %s\n", - bus->name, na, ns, of_node_full_name(parent)); + pr_debug("bus is %s (na=%d, ns=%d) on %pOF\n", + bus->name, na, ns, parent); of_dump_addr("translating address:", addr, na); /* Translate */ @@ -600,13 +600,12 @@ static u64 __of_translate_address(struct device_node *dev, pbus = of_match_bus(parent); pbus->count_cells(dev, &pna, &pns); if (!OF_CHECK_COUNTS(pna, pns)) { - pr_err("Bad cell count for %s\n", - of_node_full_name(dev)); + pr_err("Bad cell count for %pOF\n", dev); break; } - pr_debug("parent bus is %s (na=%d, ns=%d) on %s\n", - pbus->name, pna, pns, of_node_full_name(parent)); + pr_debug("parent bus is %s (na=%d, ns=%d) on %pOF\n", + pbus->name, pna, pns, parent); /* Apply bus translation */ if (of_translate_one(dev, bus, pbus, addr, na, ns, pna, rprop)) @@ -855,7 +854,7 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz } if (!ranges) { - pr_debug("no dma-ranges found for node(%s)\n", np->full_name); + pr_debug("no dma-ranges found for node(%pOF)\n", np); ret = -ENODEV; goto out; } @@ -872,8 +871,8 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz dmaaddr = of_read_number(ranges, naddr); *paddr = of_translate_dma_address(np, ranges); if (*paddr == OF_BAD_ADDR) { - pr_err("translation of DMA address(%pad) to CPU address failed node(%s)\n", - dma_addr, np->full_name); + pr_err("translation of DMA address(%pad) to CPU address failed node(%pOF)\n", + dma_addr, np); ret = -EINVAL; goto out; } diff --git a/drivers/of/base.c b/drivers/of/base.c index 02be991a29c5..bbbaf1d080c2 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -160,7 +160,7 @@ int __of_add_property_sysfs(struct device_node *np, struct property *pp) pp->attr.read = of_node_property_read; rc = sysfs_create_bin_file(&np->kobj, &pp->attr); - WARN(rc, "error adding attribute %s to node %s\n", pp->name, np->full_name); + WARN(rc, "error adding attribute %s to node %pOF\n", pp->name, np); return rc; } @@ -1142,8 +1142,8 @@ int of_property_count_elems_of_size(const struct device_node *np, return -ENODATA; if (prop->length % elem_size != 0) { - pr_err("size of %s in node %s is not a multiple of %d\n", - propname, np->full_name, elem_size); + pr_err("size of %s in node %pOF is not a multiple of %d\n", + propname, np, elem_size); return -EINVAL; } @@ -1574,7 +1574,7 @@ EXPORT_SYMBOL_GPL(of_property_read_string_helper); void of_print_phandle_args(const char *msg, const struct of_phandle_args *args) { int i; - printk("%s %s", msg, of_node_full_name(args->np)); + printk("%s %pOF", msg, args->np); for (i = 0; i < args->args_count; i++) { const char delim = i ? ',' : ':'; @@ -1635,17 +1635,17 @@ int of_phandle_iterator_next(struct of_phandle_iterator *it) if (it->cells_name) { if (!it->node) { - pr_err("%s: could not find phandle\n", - it->parent->full_name); + pr_err("%pOF: could not find phandle\n", + it->parent); goto err; } if (of_property_read_u32(it->node, it->cells_name, &count)) { - pr_err("%s: could not get %s for %s\n", - it->parent->full_name, + pr_err("%pOF: could not get %s for %pOF\n", + it->parent, it->cells_name, - it->node->full_name); + it->node); goto err; } } else { @@ -1657,8 +1657,8 @@ int of_phandle_iterator_next(struct of_phandle_iterator *it) * property data length */ if (it->cur + count > it->list_end) { - pr_err("%s: arguments longer than property\n", - it->parent->full_name); + pr_err("%pOF: arguments longer than property\n", + it->parent); goto err; } } @@ -2089,8 +2089,8 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np, strncpy(ap->stem, stem, stem_len); ap->stem[stem_len] = 0; list_add_tail(&ap->link, &aliases_lookup); - pr_debug("adding DT alias:%s: stem=%s id=%i node=%s\n", - ap->alias, ap->stem, ap->id, of_node_full_name(np)); + pr_debug("adding DT alias:%s: stem=%s id=%i node=%pOF\n", + ap->alias, ap->stem, ap->id, np); } /** @@ -2344,8 +2344,8 @@ int of_graph_parse_endpoint(const struct device_node *node, { struct device_node *port_node = of_get_parent(node); - WARN_ONCE(!port_node, "%s(): endpoint %s has no parent node\n", - __func__, node->full_name); + WARN_ONCE(!port_node, "%s(): endpoint %pOF has no parent node\n", + __func__, node); memset(endpoint, 0, sizeof(*endpoint)); @@ -2428,14 +2428,14 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, of_node_put(node); if (!port) { - pr_err("graph: no port node found in %s\n", - parent->full_name); + pr_err("graph: no port node found in %pOF\n", + parent); return NULL; } } else { port = of_get_parent(prev); - if (WARN_ONCE(!port, "%s(): endpoint %s has no parent node\n", - __func__, prev->full_name)) + if (WARN_ONCE(!port, "%s(): endpoint %pOF has no parent node\n", + __func__, prev)) return NULL; } @@ -2551,8 +2551,8 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, endpoint_node = of_graph_get_endpoint_by_regs(node, port, endpoint); if (!endpoint_node) { - pr_debug("no valid endpoint (%d, %d) for node %s\n", - port, endpoint, node->full_name); + pr_debug("no valid endpoint (%d, %d) for node %pOF\n", + port, endpoint, node); return NULL; } diff --git a/drivers/of/device.c b/drivers/of/device.c index 9416d052cb89..cce2f48c92be 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -294,7 +294,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env) return; add_uevent_var(env, "OF_NAME=%s", dev->of_node->name); - add_uevent_var(env, "OF_FULLNAME=%s", dev->of_node->full_name); + add_uevent_var(env, "OF_FULLNAME=%pOF", dev->of_node); if (dev->of_node->type && strcmp("", dev->of_node->type) != 0) add_uevent_var(env, "OF_TYPE=%s", dev->of_node->type); diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c index 888fdbc09992..4ee1bd9bd79c 100644 --- a/drivers/of/dynamic.c +++ b/drivers/of/dynamic.c @@ -98,14 +98,14 @@ int of_reconfig_notify(unsigned long action, struct of_reconfig_data *p) switch (action) { case OF_RECONFIG_ATTACH_NODE: case OF_RECONFIG_DETACH_NODE: - pr_debug("notify %-15s %s\n", action_names[action], - pr->dn->full_name); + pr_debug("notify %-15s %pOF\n", action_names[action], + pr->dn); break; case OF_RECONFIG_ADD_PROPERTY: case OF_RECONFIG_REMOVE_PROPERTY: case OF_RECONFIG_UPDATE_PROPERTY: - pr_debug("notify %-15s %s:%s\n", action_names[action], - pr->dn->full_name, pr->prop->name); + pr_debug("notify %-15s %pOF:%s\n", action_names[action], + pr->dn, pr->prop->name); break; } @@ -328,11 +328,10 @@ void of_node_release(struct kobject *kobj) /* We should never be releasing nodes that haven't been detached. */ if (!of_node_check_flag(node, OF_DETACHED)) { - pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name); + pr_err("ERROR: Bad of_node_put() on %pOF\n", node); dump_stack(); return; } - if (!of_node_check_flag(node, OF_DYNAMIC)) return; @@ -462,13 +461,13 @@ static void __of_changeset_entry_dump(struct of_changeset_entry *ce) case OF_RECONFIG_ADD_PROPERTY: case OF_RECONFIG_REMOVE_PROPERTY: case OF_RECONFIG_UPDATE_PROPERTY: - pr_debug("cset<%p> %-15s %s/%s\n", ce, action_names[ce->action], - ce->np->full_name, ce->prop->name); + pr_debug("cset<%p> %-15s %pOF/%s\n", ce, action_names[ce->action], + ce->np, ce->prop->name); break; case OF_RECONFIG_ATTACH_NODE: case OF_RECONFIG_DETACH_NODE: - pr_debug("cset<%p> %-15s %s\n", ce, action_names[ce->action], - ce->np->full_name); + pr_debug("cset<%p> %-15s %pOF\n", ce, action_names[ce->action], + ce->np); break; } } @@ -539,7 +538,7 @@ static void __of_changeset_entry_notify(struct of_changeset_entry *ce, bool reve } if (ret) - pr_err("changeset notifier error @%s\n", ce->np->full_name); + pr_err("changeset notifier error @%pOF\n", ce->np); } static int __of_changeset_entry_apply(struct of_changeset_entry *ce) @@ -570,8 +569,8 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce) ret = __of_add_property(ce->np, ce->prop); if (ret) { - pr_err("changeset: add_property failed @%s/%s\n", - ce->np->full_name, + pr_err("changeset: add_property failed @%pOF/%s\n", + ce->np, ce->prop->name); break; } @@ -579,8 +578,8 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce) case OF_RECONFIG_REMOVE_PROPERTY: ret = __of_remove_property(ce->np, ce->prop); if (ret) { - pr_err("changeset: remove_property failed @%s/%s\n", - ce->np->full_name, + pr_err("changeset: remove_property failed @%pOF/%s\n", + ce->np, ce->prop->name); break; } @@ -598,8 +597,8 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce) ret = __of_update_property(ce->np, ce->prop, &old_prop); if (ret) { - pr_err("changeset: update_property failed @%s/%s\n", - ce->np->full_name, + pr_err("changeset: update_property failed @%pOF/%s\n", + ce->np, ce->prop->name); break; } diff --git a/drivers/of/irq.c b/drivers/of/irq.c index 6ce72aa65425..9c4b32522bc2 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -131,7 +131,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) goto fail; } - pr_debug("of_irq_parse_raw: ipar=%s, size=%d\n", of_node_full_name(ipar), intsize); + pr_debug("of_irq_parse_raw: ipar=%pOF, size=%d\n", ipar, intsize); if (out_irq->args_count != intsize) goto fail; @@ -269,7 +269,7 @@ int of_irq_parse_raw(const __be32 *addr, struct of_phandle_args *out_irq) skiplevel: /* Iterate again with new parent */ out_irq->np = newpar; - pr_debug(" -> new parent: %s\n", of_node_full_name(newpar)); + pr_debug(" -> new parent: %pOF\n", newpar); of_node_put(ipar); ipar = newpar; newpar = NULL; @@ -301,7 +301,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar u32 intsize, intlen; int i, res; - pr_debug("of_irq_parse_one: dev=%s, index=%d\n", of_node_full_name(device), index); + pr_debug("of_irq_parse_one: dev=%pOF, index=%d\n", device, index); /* OldWorld mac stuff is "special", handle out of line */ if (of_irq_workarounds & OF_IMAP_OLDWORLD_MAC) @@ -555,8 +555,8 @@ void __init of_irq_init(const struct of_device_id *matches) of_node_set_flag(desc->dev, OF_POPULATED); - pr_debug("of_irq_init: init %s (%p), parent %p\n", - desc->dev->full_name, + pr_debug("of_irq_init: init %pOF (%p), parent %p\n", + desc->dev, desc->dev, desc->interrupt_parent); ret = desc->irq_init_cb(desc->dev, desc->interrupt_parent); diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index 7e4c80f9b6cd..f0a32be9cc61 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c @@ -126,14 +126,14 @@ int of_mdio_parse_addr(struct device *dev, const struct device_node *np) ret = of_property_read_u32(np, "reg", &addr); if (ret < 0) { - dev_err(dev, "%s has invalid PHY address\n", np->full_name); + dev_err(dev, "%pOF has invalid PHY address\n", np); return ret; } /* A PHY must have a reg property in the range [0-31] */ if (addr >= PHY_MAX_ADDR) { - dev_err(dev, "%s PHY address %i is too large\n", - np->full_name, addr); + dev_err(dev, "%pOF PHY address %i is too large\n", + np, addr); return -EINVAL; } @@ -188,8 +188,8 @@ static bool of_mdiobus_child_is_phy(struct device_node *child) if (of_match_node(whitelist_phys, child)) { pr_warn(FW_WARN - "%s: Whitelisted compatible string. Please remove\n", - child->full_name); + "%pOF: Whitelisted compatible string. Please remove\n", + child); return true; } diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index c9d4d3a7b0fe..3d4cb7090878 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c @@ -204,15 +204,15 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, if (!bus_range) return -ENOMEM; - pr_info("host bridge %s ranges:\n", dev->full_name); + pr_info("host bridge %pOF ranges:\n", dev); err = of_pci_parse_bus_range(dev, bus_range); if (err) { bus_range->start = busno; bus_range->end = bus_max; bus_range->flags = IORESOURCE_BUS; - pr_info(" No bus range found for %s, using %pR\n", - dev->full_name, bus_range); + pr_info(" No bus range found for %pOF, using %pR\n", + dev, bus_range); } else { if (bus_range->end > bus_range->start + bus_max) bus_range->end = bus_range->start + bus_max; @@ -258,14 +258,14 @@ int of_pci_get_host_bridge_resources(struct device_node *dev, if (resource_type(res) == IORESOURCE_IO) { if (!io_base) { - pr_err("I/O range found for %s. Please provide an io_base pointer to save CPU base address\n", - dev->full_name); + pr_err("I/O range found for %pOF. Please provide an io_base pointer to save CPU base address\n", + dev); err = -EINVAL; goto conversion_failed; } if (*io_base != (resource_size_t)OF_BAD_ADDR) - pr_warn("More than one I/O resource converted for %s. CPU base address for old range lost!\n", - dev->full_name); + pr_warn("More than one I/O resource converted for %pOF. CPU base address for old range lost!\n", + dev); *io_base = range.cpu_addr; } @@ -325,7 +325,7 @@ int of_pci_map_rid(struct device_node *np, u32 rid, } if (!map_len || map_len % (4 * sizeof(*map))) { - pr_err("%s: Error: Bad %s length: %d\n", np->full_name, + pr_err("%pOF: Error: Bad %s length: %d\n", np, map_name, map_len); return -EINVAL; } @@ -349,8 +349,8 @@ int of_pci_map_rid(struct device_node *np, u32 rid, u32 rid_len = be32_to_cpup(map + 3); if (rid_base & ~map_mask) { - pr_err("%s: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", - np->full_name, map_name, map_name, + pr_err("%pOF: Invalid %s translation - %s-mask (0x%x) ignores rid-base (0x%x)\n", + np, map_name, map_name, map_mask, rid_base); return -EFAULT; } @@ -375,14 +375,13 @@ int of_pci_map_rid(struct device_node *np, u32 rid, if (id_out) *id_out = masked_rid - rid_base + out_base; - pr_debug("%s: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", - np->full_name, map_name, map_mask, rid_base, out_base, + pr_debug("%pOF: %s, using mask %08x, rid-base: %08x, out-base: %08x, length: %08x, rid: %08x -> %08x\n", + np, map_name, map_mask, rid_base, out_base, rid_len, rid, *id_out); return 0; } - pr_err("%s: Invalid %s translation - no match for rid 0x%x on %s\n", - np->full_name, map_name, rid, - target && *target ? (*target)->full_name : "any target"); + pr_err("%pOF: Invalid %s translation - no match for rid 0x%x on %pOF\n", + np, map_name, rid, target && *target ? *target : NULL); return -EFAULT; } diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c index 7827786718d8..5948eac07f34 100644 --- a/drivers/of/overlay.c +++ b/drivers/of/overlay.c @@ -137,7 +137,7 @@ static int of_overlay_apply_single_device_node(struct of_overlay *ov, of_node_put(tchild); } else { /* create empty tree as a target */ - tchild = __of_node_dup(child, "%s/%s", target->full_name, cname); + tchild = __of_node_dup(child, "%pOF/%s", target, cname); if (!tchild) return -ENOMEM; @@ -173,8 +173,8 @@ static int of_overlay_apply_one(struct of_overlay *ov, for_each_property_of_node(overlay, prop) { ret = of_overlay_apply_single_property(ov, target, prop); if (ret) { - pr_err("Failed to apply prop @%s/%s\n", - target->full_name, prop->name); + pr_err("Failed to apply prop @%pOF/%s\n", + target, prop->name); return ret; } } @@ -182,8 +182,8 @@ static int of_overlay_apply_one(struct of_overlay *ov, for_each_child_of_node(overlay, child) { ret = of_overlay_apply_single_device_node(ov, target, child); if (ret != 0) { - pr_err("Failed to apply single node @%s/%s\n", - target->full_name, child->name); + pr_err("Failed to apply single node @%pOF/%s\n", + target, child->name); of_node_put(child); return ret; } @@ -211,7 +211,7 @@ static int of_overlay_apply(struct of_overlay *ov) err = of_overlay_apply_one(ov, ovinfo->target, ovinfo->overlay); if (err != 0) { - pr_err("apply failed '%s'\n", ovinfo->target->full_name); + pr_err("apply failed '%pOF'\n", ovinfo->target); return err; } } @@ -396,8 +396,8 @@ int of_overlay_create(struct device_node *tree) /* build the overlay info structures */ err = of_build_overlay_info(ov, tree); if (err) { - pr_err("of_build_overlay_info() failed for tree@%s\n", - tree->full_name); + pr_err("of_build_overlay_info() failed for tree@%pOF\n", + tree); goto err_free_idr; } @@ -476,9 +476,8 @@ static int overlay_is_topmost(struct of_overlay *ov, struct device_node *dn) /* check against each subtree affected by this overlay */ list_for_each_entry(ce, &ovt->cset.entries, node) { if (overlay_subtree_check(ce->np, dn)) { - pr_err("%s: #%d clashes #%d @%s\n", - __func__, ov->id, ovt->id, - dn->full_name); + pr_err("%s: #%d clashes #%d @%pOF\n", + __func__, ov->id, ovt->id, dn); return 0; } } diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 8f73413fa243..09045265b1b9 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -228,7 +228,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node, const void *prop; int i, ret; - pr_debug("Creating amba device %s\n", node->full_name); + pr_debug("Creating amba device %pOF\n", node); if (!of_device_is_available(node) || of_node_test_and_set_flag(node, OF_POPULATED)) @@ -259,15 +259,15 @@ static struct amba_device *of_amba_device_create(struct device_node *node, ret = of_address_to_resource(node, 0, &dev->res); if (ret) { - pr_err("amba: of_address_to_resource() failed (%d) for %s\n", - ret, node->full_name); + pr_err("amba: of_address_to_resource() failed (%d) for %pOF\n", + ret, node); goto err_free; } ret = amba_device_add(dev, &iomem_resource); if (ret) { - pr_err("amba_device_add() failed (%d) for %s\n", - ret, node->full_name); + pr_err("amba_device_add() failed (%d) for %pOF\n", + ret, node); goto err_free; } @@ -310,7 +310,7 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l if (!of_address_to_resource(np, 0, &res)) if (res.start != auxdata->phys_addr) continue; - pr_debug("%s: devname=%s\n", np->full_name, auxdata->name); + pr_debug("%pOF: devname=%s\n", np, auxdata->name); return auxdata; } @@ -323,7 +323,7 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l if (!of_device_is_compatible(np, auxdata->compatible)) continue; if (!auxdata->phys_addr && !auxdata->name) { - pr_debug("%s: compatible match\n", np->full_name); + pr_debug("%pOF: compatible match\n", np); return auxdata; } } @@ -356,14 +356,14 @@ static int of_platform_bus_create(struct device_node *bus, /* Make sure it has a compatible property */ if (strict && (!of_get_property(bus, "compatible", NULL))) { - pr_debug("%s() - skipping %s, no compatible prop\n", - __func__, bus->full_name); + pr_debug("%s() - skipping %pOF, no compatible prop\n", + __func__, bus); return 0; } if (of_node_check_flag(bus, OF_POPULATED_BUS)) { - pr_debug("%s() - skipping %s, already populated\n", - __func__, bus->full_name); + pr_debug("%s() - skipping %pOF, already populated\n", + __func__, bus); return 0; } @@ -387,7 +387,7 @@ static int of_platform_bus_create(struct device_node *bus, return 0; for_each_child_of_node(bus, child) { - pr_debug(" create child: %s\n", child->full_name); + pr_debug(" create child: %pOF\n", child); rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict); if (rc) { of_node_put(child); @@ -419,7 +419,7 @@ int of_platform_bus_probe(struct device_node *root, return -EINVAL; pr_debug("%s()\n", __func__); - pr_debug(" starting at: %s\n", root->full_name); + pr_debug(" starting at: %pOF\n", root); /* Do a self check of bus type, if there's a match, create children */ if (of_match_node(matches, root)) { @@ -471,7 +471,7 @@ int of_platform_populate(struct device_node *root, return -EINVAL; pr_debug("%s()\n", __func__); - pr_debug(" starting at: %s\n", root->full_name); + pr_debug(" starting at: %pOF\n", root); for_each_child_of_node(root, child) { rc = of_platform_bus_create(child, matches, lookup, parent, true); @@ -659,8 +659,8 @@ static int of_platform_notify(struct notifier_block *nb, of_dev_put(pdev_parent); if (pdev == NULL) { - pr_err("%s: failed to create for '%s'\n", - __func__, rd->dn->full_name); + pr_err("%s: failed to create for '%pOF'\n", + __func__, rd->dn); /* of_platform_device_create tosses the error code */ return notifier_from_errno(-EINVAL); } diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 987a1530282a..038fec3e3463 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -46,46 +46,54 @@ static struct unittest_results { static void __init of_unittest_find_node_by_name(void) { struct device_node *np; - const char *options; + const char *options, *name; np = of_find_node_by_path("/testcase-data"); - unittest(np && !strcmp("/testcase-data", np->full_name), + name = kasprintf(GFP_KERNEL, "%pOF", np); + unittest(np && !strcmp("/testcase-data", name), "find /testcase-data failed\n"); of_node_put(np); + kfree(name); /* Test if trailing '/' works */ np = of_find_node_by_path("/testcase-data/"); unittest(!np, "trailing '/' on /testcase-data/ should fail\n"); np = of_find_node_by_path("/testcase-data/phandle-tests/consumer-a"); - unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), + name = kasprintf(GFP_KERNEL, "%pOF", np); + unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", name), "find /testcase-data/phandle-tests/consumer-a failed\n"); of_node_put(np); + kfree(name); np = of_find_node_by_path("testcase-alias"); - unittest(np && !strcmp("/testcase-data", np->full_name), + name = kasprintf(GFP_KERNEL, "%pOF", np); + unittest(np && !strcmp("/testcase-data", name), "find testcase-alias failed\n"); of_node_put(np); + kfree(name); /* Test if trailing '/' works on aliases */ np = of_find_node_by_path("testcase-alias/"); unittest(!np, "trailing '/' on testcase-alias/ should fail\n"); np = of_find_node_by_path("testcase-alias/phandle-tests/consumer-a"); - unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", np->full_name), + name = kasprintf(GFP_KERNEL, "%pOF", np); + unittest(np && !strcmp("/testcase-data/phandle-tests/consumer-a", name), "find testcase-alias/phandle-tests/consumer-a failed\n"); of_node_put(np); + kfree(name); np = of_find_node_by_path("/testcase-data/missing-path"); - unittest(!np, "non-existent path returned node %s\n", np->full_name); + unittest(!np, "non-existent path returned node %pOF\n", np); of_node_put(np); np = of_find_node_by_path("missing-alias"); - unittest(!np, "non-existent alias returned node %s\n", np->full_name); + unittest(!np, "non-existent alias returned node %pOF\n", np); of_node_put(np); np = of_find_node_by_path("testcase-alias/missing-path"); - unittest(!np, "non-existent alias with relative path returned node %s\n", np->full_name); + unittest(!np, "non-existent alias with relative path returned node %pOF\n", np); of_node_put(np); np = of_find_node_opts_by_path("/testcase-data:testoption", &options); @@ -258,8 +266,8 @@ static void __init of_unittest_check_phandles(void) hash_for_each_possible(phandle_ht, nh, node, np->phandle) { if (nh->np->phandle == np->phandle) { - pr_info("Duplicate phandle! %i used by %s and %s\n", - np->phandle, nh->np->full_name, np->full_name); + pr_info("Duplicate phandle! %i used by %pOF and %pOF\n", + np->phandle, nh->np, np); dup_count++; break; } @@ -349,8 +357,8 @@ static void __init of_unittest_parse_phandle_with_args(void) passed = false; } - unittest(passed, "index %i - data error on node %s rc=%i\n", - i, args.np->full_name, rc); + unittest(passed, "index %i - data error on node %pOF rc=%i\n", + i, args.np, rc); } /* Check for missing list property */ @@ -533,7 +541,7 @@ static void __init of_unittest_changeset(void) /* Make sure node names are constructed correctly */ unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), - "'%s' not added\n", n21->full_name); + "'%pOF' not added\n", n21); of_node_put(np); unittest(!of_changeset_revert(&chgset), "revert failed\n"); @@ -564,8 +572,8 @@ static void __init of_unittest_parse_interrupts(void) passed &= (args.args_count == 1); passed &= (args.args[0] == (i + 1)); - unittest(passed, "index %i - data error on node %s rc=%i\n", - i, args.np->full_name, rc); + unittest(passed, "index %i - data error on node %pOF rc=%i\n", + i, args.np, rc); } of_node_put(np); @@ -610,8 +618,8 @@ static void __init of_unittest_parse_interrupts(void) default: passed = false; } - unittest(passed, "index %i - data error on node %s rc=%i\n", - i, args.np->full_name, rc); + unittest(passed, "index %i - data error on node %pOF rc=%i\n", + i, args.np, rc); } of_node_put(np); } @@ -680,8 +688,8 @@ static void __init of_unittest_parse_interrupts_extended(void) passed = false; } - unittest(passed, "index %i - data error on node %s rc=%i\n", - i, args.np->full_name, rc); + unittest(passed, "index %i - data error on node %pOF rc=%i\n", + i, args.np, rc); } of_node_put(np); } @@ -861,7 +869,9 @@ static int attach_node_and_children(struct device_node *np) struct device_node *next, *dup, *child; unsigned long flags; - dup = of_find_node_by_path(np->full_name); + full_name = kasprintf(GFP_KERNEL, "%pOF", np); + dup = of_find_node_by_path(full_name); + kfree(full_name); if (dup) { update_node_properties(np, dup); return 0; @@ -966,7 +976,7 @@ static int unittest_probe(struct platform_device *pdev) } - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); of_platform_populate(np, NULL, NULL, &pdev->dev); @@ -978,7 +988,7 @@ static int unittest_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); return 0; } @@ -1592,7 +1602,7 @@ static int unittest_i2c_bus_probe(struct platform_device *pdev) } - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); std = devm_kzalloc(dev, sizeof(*std), GFP_KERNEL); if (!std) { @@ -1630,7 +1640,7 @@ static int unittest_i2c_bus_remove(struct platform_device *pdev) struct device_node *np = dev->of_node; struct unittest_i2c_bus_data *std = platform_get_drvdata(pdev); - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); i2c_del_adapter(&std->adap); return 0; @@ -1661,7 +1671,7 @@ static int unittest_i2c_dev_probe(struct i2c_client *client, return -EINVAL; } - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); return 0; }; @@ -1671,7 +1681,7 @@ static int unittest_i2c_dev_remove(struct i2c_client *client) struct device *dev = &client->dev; struct device_node *np = client->dev.of_node; - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); return 0; } @@ -1706,7 +1716,7 @@ static int unittest_i2c_mux_probe(struct i2c_client *client, struct i2c_mux_core *muxc; u32 reg, max_reg; - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); if (!np) { dev_err(dev, "No OF node\n"); @@ -1751,7 +1761,7 @@ static int unittest_i2c_mux_remove(struct i2c_client *client) struct device_node *np = client->dev.of_node; struct i2c_mux_core *muxc = i2c_get_clientdata(client); - dev_dbg(dev, "%s for node @%s\n", __func__, np->full_name); + dev_dbg(dev, "%s for node @%pOF\n", __func__, np); i2c_mux_del_adapters(muxc); return 0; }