Question: staging: comedi: printk to dev_* version changes
H Hartley Sweeten
hartleys at visionengravers.com
Thu May 3 22:59:43 UTC 2012
Greg,
There were a number of patches to the comedi drivers back in
Nov/Dec 2011 similar to this one:
commit 3dbeb83c245bbdc906eb54821d1cd77a25f56741
Staging: comedi: fix printk issue in serial2002.c
These patches converted the printk's to dev_* versions similar
to this:
- printk("comedi%d: serial2002: ", dev->minor);
+ dev_dbg(dev->hw_dev, "comedi%d: attached\n", dev->minor);
I don't think these will work like the author intended.
In comedidev.h the hw_dev variable in struct comedi_device is
defined as:
/* hw_dev is passed to dma_alloc_coherent when allocating async buffers
* for subdevices that have async_dma_dir set to something other than
* DMA_NONE */
struct device *hw_dev;
This pointer is only setup by a couple comedi pci drivers. For
most comedi drivers it's going to be NULL.
It appears the "correct" struct device * to use would be the
class_dev pointer in struct comedi_device. As a bonus, this
pointer is created in comedi_fops.c:comedi_alloc_board_minor()
like this:
info->device->minor = i;
csdev = device_create(comedi_class, hardware_device,
MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i);
if (!IS_ERR(csdev))
info->device->class_dev = csdev;
So, if I get this right, most of the printk's and current
dev_* variants of this form:
printk(KERN_INFO "comedi%d: 8255:", dev->minor);
could be changed to simply:
dev_info(dev->class_dev, "8255:");
And the "comedi" prefix is automatically added. Do I have this right?
I would like to verify this before submitting any patches.
Regards,
Hartley
More information about the devel
mailing list