From: Andrew Morton <akpm@linux-foundation.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Jonathan Corbet <corbet@lwn.net>,
Mike Turquette <mturquette@linaro.org>,
Stephen Boyd <sboyd@codeaurora.org>,
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: Re: [PATCH 3/3] lib/vsprintf: Add %pC{,n,r} format specifiers for clocks
Date: Fri, 27 Feb 2015 14:18:37 -0800 [thread overview]
Message-ID: <20150227141837.0bca29d9a33c5b107a786a7a@linux-foundation.org> (raw)
In-Reply-To: <1424949183-31425-4-git-send-email-geert@linux-m68k.org>
On Thu, 26 Feb 2015 12:13:03 +0100 Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> From: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Add format specifiers for printing struct clk:
> - '%pC' or '%pCn': name (Common Clock Framework) or address (legacy
> clock framework) of the clock,
> - '%pCr': rate of the clock.
>
> ...
>
> +static noinline_for_stack
> +char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
> + const char *fmt)
> +{
> + if (!clk)
> + return string(buf, end, NULL, spec);
> +
> + switch (fmt[1]) {
> + case 'r':
> + return number(buf, end, clk_get_rate(clk), spec);
> +
> + case 'n':
> + default:
> +#ifdef CONFIG_COMMON_CLK
> + return string(buf, end, __clk_get_name(clk), spec);
> +#else
> + spec.base = 16;
> + spec.field_width = sizeof(unsigned long) * 2 + 2;
> + spec.flags |= SPECIAL | SMALL | ZEROPAD;
> + return number(buf, end, (unsigned long)clk, spec);
> +#endif
> + }
> +}
Seems a bit cruel to teeny systems which don't implement clock. How does
this look? Saves 160 bytes in each powerpc build!
static noinline_for_stack
char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
const char *fmt)
{
#ifdef CONFIG_HAVE_CLK
if (clk) {
switch (fmt[1]) {
case 'r':
return number(buf, end, clk_get_rate(clk), spec);
case 'n':
default:
#ifdef CONFIG_COMMON_CLK
return string(buf, end, __clk_get_name(clk), spec);
#else
spec.base = 16;
spec.field_width = sizeof(unsigned long) * 2 + 2;
spec.flags |= SPECIAL | SMALL | ZEROPAD;
return number(buf, end, (unsigned long)clk, spec);
#endif
}
}
#endif /* CONFIG_HAVE_CLK */
return string(buf, end, NULL, spec);
}
diff -puN lib/vsprintf.c~lib-vsprintf-add-%pcnr-format-specifiers-for-clocks-fix lib/vsprintf.c
--- a/lib/vsprintf.c~lib-vsprintf-add-%pcnr-format-specifiers-for-clocks-fix
+++ a/lib/vsprintf.c
@@ -1320,24 +1320,27 @@ static noinline_for_stack
char *clock(char *buf, char *end, struct clk *clk, struct printf_spec spec,
const char *fmt)
{
- if (!clk)
- return string(buf, end, NULL, spec);
+#ifdef CONFIG_HAVE_CLK
+ if (clk) {
+ switch (fmt[1]) {
+ case 'r':
+ return number(buf, end, clk_get_rate(clk), spec);
- switch (fmt[1]) {
- case 'r':
- return number(buf, end, clk_get_rate(clk), spec);
-
- case 'n':
- default:
-#ifdef CONFIG_COMMON_CLK
- return string(buf, end, __clk_get_name(clk), spec);
-#else
- spec.base = 16;
- spec.field_width = sizeof(unsigned long) * 2 + 2;
- spec.flags |= SPECIAL | SMALL | ZEROPAD;
- return number(buf, end, (unsigned long)clk, spec);
-#endif
+ case 'n':
+ default:
+#ifdef CONFIG_COMMON_CLK
+ return string(buf, end, __clk_get_name(clk), spec);
+#else
+ spec.base = 16;
+ spec.field_width = sizeof(unsigned long) * 2 + 2;
+ spec.flags |= SPECIAL | SMALL | ZEROPAD;
+ return number(buf, end, (unsigned long)clk, spec);
+#endif
+ }
}
+#endif /* CONFIG_HAVE_CLK */
+
+ return string(buf, end, NULL, spec);
}
int kptr_restrict __read_mostly;
_
next prev parent reply other threads:[~2015-02-27 22:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-26 11:13 [PATCH 0/3] lib/vsprintf: Doc improvements and clock support Geert Uytterhoeven
2015-02-26 11:13 ` [PATCH 1/3] lib/vsprintf: Document %p parameters passed by reference Geert Uytterhoeven
2015-02-26 11:13 ` [PATCH 2/3] lib/vsprintf: Move integer format types to the top Geert Uytterhoeven
2015-02-26 11:13 ` [PATCH 3/3] lib/vsprintf: Add %pC{,n,r} format specifiers for clocks Geert Uytterhoeven
2015-02-27 22:18 ` Andrew Morton [this message]
2015-02-27 22:55 ` Joe Perches
2015-02-28 8:53 ` Geert Uytterhoeven
2015-02-28 14:56 ` Geert Uytterhoeven
2015-02-27 0:02 ` [PATCH 0/3] lib/vsprintf: Doc improvements and clock support Stephen Boyd
2015-02-27 7:52 ` Geert Uytterhoeven
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=20150227141837.0bca29d9a33c5b107a786a7a@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=geert+renesas@glider.be \
--cc=geert@linux-m68k.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=sboyd@codeaurora.org \
/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
all inboxes | Powered by JetHome®