* Logging communication with devices
@ 2015-10-04 11:18 Peter Senna Tschudin
2015-10-04 11:26 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Peter Senna Tschudin @ 2015-10-04 11:18 UTC (permalink / raw)
To: kernelnewbies
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);
--
Peter
^ permalink raw reply [flat|nested] 2+ messages in thread* Logging communication with devices
2015-10-04 11:18 Logging communication with devices Peter Senna Tschudin
@ 2015-10-04 11:26 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2015-10-04 11:26 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-10-04 11:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-04 11:18 Logging communication with devices Peter Senna Tschudin
2015-10-04 11:26 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).