From: Ryan Mallon <rmallon@gmail.com>
To: Ravishankar <ravishankarkm32@gmail.com>
Cc: gregkh@suse.de, wfp5p@virginia.edu, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org,
Ravishankar <ravi.shankar@greenturtles.in>
Subject: Re: [PATCH 1/2 v3] Staging: comedi: fix printk() issue in adv_pci1710.c
Date: Tue, 19 Jul 2011 16:07:27 +1000 [thread overview]
Message-ID: <4E251F1F.2080406@gmail.com> (raw)
In-Reply-To: <1311054656-14207-1-git-send-email-ravishanakarkm32@gmail.com>
On 19/07/11 15:50, Ravishankar wrote:
> From: Ravishankar<ravi.shankar@greenturtles.in>
>
> This is a patch to the adv_pci1710.c file that fixes up a printk() warning found by the checkpatch.pl tool
>
> Signed-off-by: Ravishankar<ravishankarkm32@gmail.com>
> ---
> KERN_CONT issue is fixed
>
> drivers/staging/comedi/drivers/adv_pci1710.c | 20 ++++++++++----------
> 1 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c
> index fd71cc6..093b9e6 100644
> --- a/drivers/staging/comedi/drivers/adv_pci1710.c
> +++ b/drivers/staging/comedi/drivers/adv_pci1710.c
> @@ -1396,14 +1396,14 @@ static int pci1710_attach(struct comedi_device *dev,
> int i;
> int board_index;
>
> - printk("comedi%d: adv_pci1710: ", dev->minor);
> + printk(KERN_INFO "comedi%d: adv_pci1710: ", dev->minor);
>
> opt_bus = it->options[0];
> opt_slot = it->options[1];
>
> ret = alloc_private(dev, sizeof(struct pci1710_private));
> if (ret< 0) {
> - printk(" - Allocation failed!\n");
> + printk(KERN_CONT "\n");
> + printk(KERN_ERR "Comedi%d: adv_pci1710: Allocation failed\n",
> + dev->minor);
This still isn't correct. The initial printk (KERN_INFO above) has no
trailing newline. Here you are almost doing it correctly, except that
you are adding an extra newline. This error message will look like this:
comedi0: adv_pci1710:
comedi0: adv_pci1710: Allocation failed
Which is just silly. The printk's below are broken in that you are using
KERN_ERR where you should be using KERN_CONT.
As it stands the code is a little tricky to follow since the trailing
newline gets added at the end unless there is an error when it gets
added in place. It might be better just to print the full message,
including the "comedi%d: adv_pci1710:" bit, at each printk call site and
get rid of the whole KERN_CONT nonsense altogether. Alternatively you
could create a comedi_printk function (or use pr_fmt) which wraps this up.
Also, do we really need to print out things like allocation failures? We
have the errno value already and allocation failures for devices drivers
aren't so common that we error messages for them?
~Ryan
> return -ENOMEM;
> }
>
> @@ -1451,10 +1451,10 @@ static int pci1710_attach(struct comedi_device *dev,
>
> if (!pcidev) {
> if (opt_bus || opt_slot) {
> - printk(" - Card at b:s %d:%d %s\n",
> + printk(KERN_ERR " - Card at b:s %d:%d %s\n",
> opt_bus, opt_slot, errstr);
> } else {
> - printk(" - Card %s\n", errstr);
> + printk(KERN_ERR " - Card %s\n", errstr);
> }
> return -EIO;
> }
> @@ -1465,7 +1465,7 @@ static int pci1710_attach(struct comedi_device *dev,
> irq = pcidev->irq;
> iobase = pci_resource_start(pcidev, 2);
>
> - printk(", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot, pci_func,
> + printk(KERN_INFO ", b:s:f=%d:%d:%d, io=0x%4lx", pci_bus, pci_slot,
> + pci_func, iobase);
>
> dev->iobase = iobase;
> @@ -1487,7 +1487,7 @@ static int pci1710_attach(struct comedi_device *dev,
>
> ret = alloc_subdevices(dev, n_subdevices);
> if (ret< 0) {
> - printk(" - Allocation failed!\n");
> + printk(KERN_CONT " - Allocation failed!\n");
> return ret;
> }
>
> @@ -1499,14 +1499,14 @@ static int pci1710_attach(struct comedi_device *dev,
> IRQF_SHARED, "Advantech PCI-1710",
> dev)) {
> printk
> - (", unable to allocate IRQ %d, DISABLING IT",
> + (KERN_INFO ", unable to allocate IRQ %d, DISABLING IT",
> irq);
> irq = 0; /* Can't use IRQ */
> } else {
> - printk(", irq=%u", irq);
> + printk(KERN_CONT ", irq=%u", irq);
> }
> } else {
> - printk(", IRQ disabled");
> + printk(KERN_CONT ", IRQ disabled");
> }
> } else {
> irq = 0;
> @@ -1514,7 +1514,7 @@ static int pci1710_attach(struct comedi_device *dev,
>
> dev->irq = irq;
>
> - printk(".\n");
> + printk(KERN_CONT ".\n");
>
> subdev = 0;
>
next prev parent reply other threads:[~2011-07-19 6:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <[PATCH]Staging: comedi: fix printk() issue in adv_pci1710.c>
2011-07-19 3:52 ` [PATCH 1/2 v2] Staging: comedi: fix printk() issue in adv_pci1710.c Ravishankar
2011-07-19 3:55 ` Joe Perches
2011-07-19 4:55 ` [PATCH 1/2 v3] " Ravishankar
2011-07-19 4:52 ` Joe Perches
2011-07-19 5:50 ` Ravishankar
2011-07-19 6:07 ` Ryan Mallon [this message]
2011-07-19 6:12 ` Dan Carpenter
2011-07-19 6:15 ` Ryan Mallon
2011-07-19 6:25 ` Dan Carpenter
2011-07-19 23:44 ` Ryan Mallon
[not found] <[PATCH]Staging: Comedi: fix printk issue in adv_pci1710.c>
2011-07-22 11:24 ` [PATCH 1/2 v3] Staging: comedi: fix printk " Ravishankar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E251F1F.2080406@gmail.com \
--to=rmallon@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=ravi.shankar@greenturtles.in \
--cc=ravishankarkm32@gmail.com \
--cc=wfp5p@virginia.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox