Staging: Comedi: dyna_pci10xx: Replace printk with dev_info
PATCH 1/2 Staging: Comedi: dyna_pci10xx: Replace printk with dev_info
Replace printk(KERN_XXX with dev_info, dev_warn, dev_dbg as appropiate in dyna_pci10xx
--- drivers/staging/comedi/drivers/dyna_pci10xx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/staging/comedi/drivers/dyna_pci10xx.c +6 -8
@@ -140,8 +140,7 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, goto conv_finish; } data[n] =0 ; -printk (KERN_DEBUG "comedi: dyna_pci10xx: " -"timeout reading analog input\n" ); +dev_dbg (dev->class_dev,"timeout reading analog input\n" );continue ; conv_finish:/* mask the first 4 bits - EOC bits */
@@ -262,8 +261,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,int ret;if (alloc_private (dev,sizeof (struct dyna_pci10xx_private )) <0 ) { -printk (KERN_ERR "comedi: dyna_pci10xx: " -"failed to allocate memory!\n" ); +dev_err (dev->class_dev,"failed to allocate memory!\n" );return -ENOMEM ; }
@@ -276,14 +274,14 @@ static int dyna_pci10xx_attach(struct comedi_device *dev, dev->irq =0 ;if (comedi_pci_enable (pcidev,DRV_NAME )) { -printk (KERN_ERR "comedi: dyna_pci10xx: " -"failed to enable PCI device and request regions!" ); +dev_err (dev->class_dev, +"failed to enable PCI device and request regions!\n" );return -EIO ; }mutex_init (&devpriv->mutex); -printk (KERN_INFO "comedi: dyna_pci10xx: device found!\n" ); +pr_info ("comedi: dyna_pci10xx: device found!\n" ); dev->iobase =pci_resource_start (pcidev,2 ); devpriv->BADR3 =pci_resource_start (pcidev,3 );
@@ -333,7 +331,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev, s->state =0 ; s->insn_bits = dyna_pci10xx_do_insn_bits; -printk (KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n" , +dev_info (dev->class_dev,"%s - device setup completed!\n" , thisboard->name);return 1 ;
Signature · 1 line
1.7.9.5
Quoted 12 lines · Bruce Humphrey
Replace printk(KERN_XXX with
dev_info,dev_warn,dev_dbgas appropiate indyna_pci10xxSigned-off-by Bruce Humphrey Ventura <[email protected]>--- drivers/staging/comedi/drivers/dyna_pci10xx.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/staging/comedi/drivers/dyna_pci10xx.c +0
-0
drivers/staging/comedi/drivers/dyna_pci10xx.c static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, · line 143
Quoted 6 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +1
-2@@ -140,8 +140,7 @@ static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, goto conv_finish; } data[n] =0 ; -printk (KERN_DEBUG "comedi: dyna_pci10xx: " -"timeout reading analog input\n" ); +dev_dbg (dev->class_dev,"timeout reading analog input\n" );
The trick with removing the "comedi: dyna_pci10xx: " prefix is that you need to put this at the top of the file before the includes.
#define pr_fmt(fmt) "comedi: dyna_pci10xx: " fmt
You would need to remove the prefix from the other pr_info printk as well so it's not included twice.
drivers/staging/comedi/drivers/dyna_pci10xx.c static int dyna_pci10xx_attach(struct comedi_device *dev, · line 264
Quoted 10 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +1
-2continue ; conv_finish:/* mask the first 4 bits - EOC bits */ @@ -262,8 +261,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev,int ret;if (alloc_private (dev,sizeof (struct dyna_pci10xx_private )) <0 ) { -printk (KERN_ERR "comedi: dyna_pci10xx: " -"failed to allocate memory!\n" ); +dev_err (dev->class_dev,"failed to allocate memory!\n" );
No need. Kmalloc has it's own printk().
Quoted 8 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +0
-1return -ENOMEM ; }@@ -276,14 +274,14 @@ static int dyna_pci10xx_attach(struct comedi_device *dev, dev->irq =0 ;if (comedi_pci_enable (pcidev,DRV_NAME )) { - printk(KERN_ERR "comedi: dyna_pci10xx: "
drivers/staging/comedi/drivers/dyna_pci10xx.c static int dyna_pci10xx_attach(struct comedi_device *dev, · line 284
Quoted 10 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +3
-2- "failed to enable PCI device and request regions!"); +dev_err (dev->class_dev, +"failed to enable PCI device and request regions!\n" );return -EIO ; }mutex_init (&devpriv->mutex); -printk (KERN_INFO "comedi: dyna_pci10xx: device found!\n" ); +pr_info ("comedi: dyna_pci10xx: device found!\n" );
No need.
drivers/staging/comedi/drivers/dyna_pci10xx.c static int dyna_pci10xx_attach(struct comedi_device *dev, · line 335
Quoted 10 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +1
-1dev->iobase =pci_resource_start (pcidev,2 ); devpriv->BADR3 =pci_resource_start (pcidev,3 );@@ -333,7 +331,7 @@ static int dyna_pci10xx_attach(struct comedi_device *dev, s->state =0 ; s->insn_bits = dyna_pci10xx_do_insn_bits; -printk (KERN_INFO "comedi: dyna_pci10xx: %s - device setup completed!\n" , +dev_info (dev->class_dev,"%s - device setup completed!\n" , thisboard->name);
No need for this either.
regards,
dan carpenter
Quoted 9 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +0
-0return 1 ;Signature · 6 lines
1.7.9.5 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
A message that is not in the archive (sent off-list or not yet received): CAGzQFLgLkqOdfQjbz3LFArEZGxwiEA4nnpLLtCHaX3w=-=RbKw@mail.gmail.com
Quoted 15 lines · Bruce Humphrey
Thanks for all the comments!
My own answers are from the complete linux kernel newbie point of view! That's why I'm writing them even if they seem obvious, to make sure.
Quoted 10 lines
data[n] = 0;drivers/staging/comedi/drivers/dyna_pci10xx.c static int dyna_pci10xx_insn_read_ai(struct comedi_device *dev, · line 143
Quoted 3 lines
drivers/staging/comedi/drivers/dyna_pci10xx.c +1
-2-printk (KERN_DEBUG "comedi: dyna_pci10xx: " -"timeout reading analog input\n" ); +dev_dbg (dev->class_dev,"timeout reading analog input\n" );The trick with removing the "comedi:
dyna_pci10xx: " prefix is that you need to put this at the top of the file before the includes.#define
pr_fmt(fmt)"comedi:dyna_pci10xx: " fmt
Quoted 8 lines
Quoted 3 lines
You would need to remove the prefix from the other
pr_infoprintk as well so it's not included twice.Thanks for the very useful info!
This would usepr_info, and notdev_info, which I think is prefered. But of course,pr_infois much better than printk, coding style wise.
Sorry, for some reason I thought there was an existing pr_info() in the file which would have needed to be updated. I'm not sure what I was looking at...
Anyway, this file has changed recently in linux-next so there is only one printk() left now.
regards,
dan carpenter