Em Fri, 03 Apr 2020 09:56:42 -0700 Joe Perches joe@perches.com escreveu:
On Fri, 2020-04-03 at 14:10 +0200, Rasmus Villemoes wrote:
On 03/04/2020 11.11, Sakari Ailus wrote:
Add a printk modifier %ppf (for pixel format) for printing V4L2 and DRM pixel formats denoted by 4ccs. The 4cc encoding is the same for both so the same implementation can be used.
This seems quite niche to me, I'm not sure that belongs in vsprintf.c. What's wrong with having a
char *fourcc_string(char *buf, u32 x)
that formats x into buf and returns buf, so it can be used in a
char buf[8]; pr_debug("bla: %s\n", fourcc_string(buf, x))
Nothing really, it's a number of uses question.
For networking code, print_mac was used before %pM.
After Linus floated the idea of %p<foo>, %pM was introduced and all the DECLARE_MAC_BUF/print_mac calls were converted.
%pM did reduce overall object size a fair amount.
How many instances of %p4cc could there be?
That's hard to know... there are several places printing it with different ways:
$ git grep -i -E "(dev|pr)_(warn|dbg|info)" drivers/media|grep pixf|wc -l 6 $ git grep -i -E "print" drivers/media|grep pixf|wc -l 1 $ git grep print_fourcc|wc -l 7 $ git grep -i -E "(dev|pr)_(warn|dbg|info)" drivers/media|grep pixelf|wc -l 10 $ git grep -i -E "(dev|pr|v4l)_(warn|dbg|info)" drivers/media|grep format|wc -l 60
I bet there are other places besides the above ones, but the thing is, as we currently lack a standard way, drivers still have their own ideas about how to handle it. Each one does it differently.
Thanks, Mauro