On 9/25/07, Joe Perches <joe@perches.com> wrote:Yes, this is a very good point, they're already used. If they hadn't been, everything would have been perfect. Actually, I'd have preferred info/warn/err over kprint_<level> if it wasn't for the fact that they're used (and in slightly different ways too). As I wrote initially, one of the absolute requirements of a new API is to retain full backwards compatibility with printk(). Which means that using simply err()/info()/warn() is out of the question *for now*. That is not to say we can't change this at a later time. I think it would be good to have a base layer containing the functions kprint_<level>(), just to have something that 1) has a meaningful name, and 2) doesn't disturb anybody else's names. err/info/warn or kp_err/info/warn() (in order to have shorter names) can then be implemented in terms of this. I suppose that another goal of a new API would be to unify the somewhat-a-mess of API that is now, i.e. many alternatives that do the same thing is also not good. But this can be changed with patches (to convert to new API) later. If you look closer at the current definitions of erro/warn/info, it turns out that most of them also do this to automatically prefix all messages with the driver name. This makes me realize that there really is a need for a way to automatically prefix messages or store a per-message "subsystem" field. I propose the following solution: The kprint.h header file looks like this: /* This is a back-up string to be used if the source file doesn't define this as a macro. */ const char *SUBSYSTEM = ""; /* Call this macro whatever you want, it's just an example anyway. */ #define info(msg, ...) printf("%s: " msg, SUBSYSTEM, ## __VA_ARGS__) Then you can have a C file that overrides SUBSYSTEM by defining it as a macro: #include <linux/kprint.h> #define SUBSYSTEM "usb" info("test"); --> results in printf("%s: " "test", "usb"); Or, a C file that doesn't: #include <linux/kprint.h> info("test"); --> results in printf("%s: " "test", SYBSYSTEM); --> output is ": test" Though, instead of actually incorporating this SUBSYSTEM name into the string, I suggest passing it off as an argument into the real kprint() machinery, to be stored along (but seperately) with timestamp, etc. Hm, that's a digression. But thanks for the idea :) Vegard -
| monstr | [PATCH 11/60] microblaze_v4: cache support |
| Andrew Morton | Re: x86: 4kstacks default |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Alan Cox | Re: Dual-Licensing Linux Kernel with GPL V2 and GPL V3 |
git: | |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Ben Hutchings | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 03/37] dccp: List management for new feature negotiation |
| Jiri Olsa | [PATCHv5 0/2] net: fix race in the receive/select |
