Re: dev_printk output

From: Greg KH
Date: Fri May 19 2006 - 16:30:26 EST


On Fri, May 19, 2006 at 02:11:42PM -0600, Matthew Wilcox wrote:
> On Thu, May 18, 2006 at 01:09:57PM -0700, Patrick Mansfield wrote:
> > Funky how loading sd after sg changes the output ... and using the driver
> > name as a prefix sometimes messes this up for scsi.
> >
> > i.e. scan without sd_mod or sg loaded (and distro I'm using loads sg
> > before sd_mod via udev rules):
> >
> > 0:0:0:0: Attached scsi generic sg0 type 0
> > 0:0:0:1: Attached scsi generic sg1 type 0
> >
> > Then remove/add those devices, and sg lines become:
> >
> > sd 1:0:0:0: Attached scsi generic sg0 type 0
> > sd 1:0:0:1: Attached scsi generic sg1 type 0
>
> I find that a bit confusing too. Obviously, we should distinguish
> different kinds of bus_id from each other somehow -- but isn't the
> obvious thing to use the bus name? That must already be unique as sysfs
> relies on it. ie this patch:
>
> (seems that dev->bus isn't always set; I got a null ptr dereference when
> booting without that check).

Yes, not all devices are on a bus, so this will not work. And we want
to know the driver that controls the device too. So how about adding
the bus if it's not null?

Something like (untested):
printk(level "%s %s %s: " format , (dev)->bus ? (dev)->bus->name : "", (dev)->driver ? (dev)->driver->name : "", (dev)->bus_id , ## arg)

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/