lkml.org 
[lkml]   [2021]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5] printk: Userspace format enumeration support
Hey Petr, Rasmus,

Apologies for the delay, I've been out ill for a while so I'm just coming back
to look at this.

Petr Mladek writes:
>> Anyway, on to the other thing I mentioned on dev_err and friends: I
>> think it would improve readability and make it a lot easier to (probably
>> in a later patch) add support for all those dev_* and net_* and whatever
>> other subsystems have their own wrappers
>
>This is great point! There are many other subsystem specific wrappers,
>e,g, ata_dev_printk(), netdev_printk(), snd_printk(), dprintk().
>We should make it easy to index them as well.

These would be nice to have, but we should agree about how we store things
internally.

For example, in printk we typically store the level inline as part of the
format string at compile time. However, for `dev_printk`, it's passed entirely
separately from the format string after preprocessing is already concluded (or
at least, not in a way we can easily parse it the same way we do for
printk()):

void dev_printk(const char *level, const struct device *dev, const char *fmt, ...)

One (ugly) way to handle this would be to have a new "level" field in the
printk index entry, with semantics that if it's some sentinel value, look at
the format itself for the format, otherwise if it's some other value, the level
field itself is the level.

This will work, but it's pretty ugly. Any better suggestions? :-)

Thanks,

Chris

\
 
 \ /
  Last update: 2021-04-16 15:59    [W:0.122 / U:1.620 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site