Re: Question: staging: comedi: printk to dev_* version changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 03, 2012 at 03:59:43PM -0700, H Hartley Sweeten wrote:
> 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.

Based on my previous interactions with that author, I wouldn't doubt it :(

> 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?

Yes.  You can drop the 8255: as well if you want, but, you probably
don't want to, see the thread on linux-kernel today from me and Kay and
Dmitry with the subject: "proper struct device selection for
dev_printk()" for more details.

Thanks for finding this, and fixing it up.

greg k-h
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux