On Sun, Oct 04, 2015 at 01:18:29PM +0200, Peter Senna Tschudin wrote: > Does Linux provide an elegant and/or standard way of logging > communication with devices that manage buffers and that can help me > improve code like: > > $ cat drivers/usb/host/fotg210-hcd.c > ... > temp = snprintf(next, size, > "\n\t%p%c%s len=%d %08x urb %p", > td, mark, ({ char *tmp; > switch ((scratch>>8)&0x03) { > case 0: > tmp = "out"; > break; > case 1: > tmp = "in"; > break; > case 2: > tmp = "setup"; > break; > default: > tmp = "?"; > break; > } tmp; }), > (scratch >> 16) & 0x7fff, > scratch, > td->urb); > What is this mess? /me digs in the driver... Hm, it's actually not that bad. Well, besides the horrid logic here, this is all debugfs file information to help people see what is going on in the internals of the driver as its running. It seems to be using the correct debugfs apis to handle the buffer management properly, which is a nice surprise. So while you could work on cleaning up that crazy snprintf call to be "nicer", I'd just leave it alone. It obviously must work as the developer used it when creating the code, so let's just trust that it is correct and walk away slowly... thanks, greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies