Re: Code Style issue

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

 



The short answer:
use pr_debug instead of printk.

The long answer:
(This is  the answer I got from stackoverflow question that I had
asked for similar question I was having:)


Each kernel subsystem usually has its own printk format. So when you
are using network subsystem, you have to use netdev_dbg; when you are
using V4L you have to use v4l_dbg. It standardizes the output format
within the subsystem.
...
You have got the warning because you are using prink() which is the
raw way to print something.
Depending on what you are coding you should use a different print style:
printk(): never
pr_debug(): always good
dev_dbg(): prefered when you have a struct device object
netdev_dbg(): prefered when you have a struct netdevice object
[something]_dbg(): prefered when you have a that something object

For the full answer see
https://stackoverflow.com/questions/22077540/order-of-preference-printk-vs-dev-dbg-vs-netdev-dbg

---
Yogesh

On 5 April 2014 10:32, HABI S RAVI <habisbc@xxxxxxxxx> wrote:
> Hi,
> I am trying to fix a coding issue . I get the following warning when my
> module is checked with checkpatch.pl.
> How can i remove the warning. I see a lot of drivers using printk()
> function.
>
> $ perl ~/linux-stable/scripts/checkpatch.pl -f hello.c
> WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then
> pr_debug(...  to printk(KERN_DEBUG ...
> #6: FILE: hello.c:6:
> +       printk(KERN_DEBUG "Hello World!\n");
>
> WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then
> pr_debug(...  to printk(KERN_DEBUG ...
> #12: FILE: hello.c:12:
> +       printk(KERN_DEBUG "hello module unloaded\n");
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>



-- 
DREAM IT, CODE IT

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux