From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
Petr Mladek <pmladek@suse.com>,
linux-kernel@vger.kernel.org, rafael@kernel.org,
linux-acpi@vger.kernel.org, devicetree@vger.kernel.org,
Rob Herring <robh@kernel.org>
Subject: Re: [PATCH v2 6/6] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names
Date: Tue, 26 Mar 2019 15:24:50 +0200 [thread overview]
Message-ID: <20190326132450.GB9224@smile.fi.intel.com> (raw)
In-Reply-To: <8c6accab-9e0c-c2d4-ce93-ea3ede60f34e@rasmusvillemoes.dk>
On Tue, Mar 26, 2019 at 02:11:35PM +0100, Rasmus Villemoes wrote:
> On 26/03/2019 13.41, Sakari Ailus wrote:
> > Add support for %pfw conversion specifier (with "f" and "P" modifiers) to
> > support printing full path of the node, including its name ("f") and only
> > the node's name ("P") in the printk family of functions. The two flags
> > have equivalent functionality to existing %pOF with the same two modifiers
> > ("f" and "P") on OF based systems. The ability to do the same on ACPI
> > based systems is added by this patch.
> > + for (pass = false; strspn(fmt, modifiers); fmt++, pass = true) {
> > + if (pass) {
> > + if (buf < end)
> > + *buf = ':';
> > + buf++;
> > + }
> > +
> > + switch (*fmt) {
> > + case 'f': /* full_name */
> > + buf = fwnode_gen_full_name(fwnode, buf, end);
> > + break;
> > + case 'P': /* name */
> > + buf = string(buf, end, fwnode_get_name(fwnode),
> > + str_spec);
> > + break;
> > + default:
> > + break;
> > + }
> > + }
>
> This seems awfully complicated. Why would anyone ever pass more than one
> of 'f' and 'P'? Why not just
>
> switch(*fmt) {
> case 'P':
> ...
> case 'f':
> default:
> ...
> }
>
> which avoids the loop and the strcspn. Or, drop the default: case and
> don't have logic at all for falling back to 'f' if neither is present.
>
> > + return widen_string(buf, buf - buf_start, end, spec);
> > +}
My point as well (as per sent comments against previous version).
Sakari, can you add test cases at the same time?
> > return device_node_string(buf, end, ptr, spec, fmt + 1);
> > + return fwnode_string(buf, end, ptr, spec, fmt + 1);
>
> Why not pass fmt+2; we know that fmt+1 points at a 'w'. Just to avoid
> doing the fmt++ inside fwnode_string().
I guess in order to be consistent with existing %pOF case. But wouldn't be
better to fix %pOF for that sooner or later?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2019-03-26 13:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-26 12:41 [PATCH v2 0/6] Device property improvements, add %pfw format specifier Sakari Ailus
2019-03-26 12:41 ` [PATCH v2 1/6] device property: Add functions for accessing node's parents Sakari Ailus
2019-03-27 12:26 ` Petr Mladek
2019-03-27 14:20 ` Sakari Ailus
2019-03-28 9:38 ` Rafael J. Wysocki
2019-03-28 11:13 ` Sakari Ailus
2019-03-28 14:52 ` Rafael J. Wysocki
2019-03-29 13:15 ` Sakari Ailus
2019-03-29 14:15 ` Andy Shevchenko
2019-03-29 14:46 ` Sakari Ailus
2019-03-29 23:00 ` Rafael J. Wysocki
2019-03-28 14:10 ` Petr Mladek
2019-03-29 13:04 ` Sakari Ailus
2019-03-29 14:14 ` Andy Shevchenko
2019-03-29 15:31 ` Sakari Ailus
2019-03-26 12:41 ` [PATCH v2 2/6] device property: Add fwnode_get_name for returning the name of a node Sakari Ailus
2019-03-28 9:45 ` Rafael J. Wysocki
2019-03-28 11:31 ` Sakari Ailus
2019-03-31 6:42 ` Rob Herring
2019-03-26 12:41 ` [PATCH v2 3/6] device property: Add a function to obtain a node's prefix Sakari Ailus
2019-03-26 13:16 ` Andy Shevchenko
2019-03-26 13:32 ` Sakari Ailus
2019-03-27 12:36 ` Petr Mladek
2019-03-28 11:43 ` Sakari Ailus
2019-03-31 6:42 ` Rob Herring
2019-03-26 12:41 ` [PATCH v2 4/6] lib/vsprintf: Remove support for %pF and %pf in favour of %pS and %ps Sakari Ailus
2019-03-26 12:41 ` [PATCH v2 5/6] lib/vsprintf: Make use of fwnode API to obtain node names and separators Sakari Ailus
2019-03-26 12:41 ` [PATCH v2 6/6] lib/vsprintf: Add %pfw conversion specifier for printing fwnode names Sakari Ailus
2019-03-26 13:11 ` Rasmus Villemoes
2019-03-26 13:24 ` Andy Shevchenko [this message]
2019-03-26 13:31 ` Sakari Ailus
2019-03-28 14:29 ` Petr Mladek
2019-03-29 13:10 ` Sakari Ailus
2019-03-26 20:18 ` Joe Perches
[not found] ` <20190328114845.giusyarjibvg5ru7@kekkonen.localdomain>
2019-03-28 11:51 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190326132450.GB9224@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox