linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] staging: rtl8192u: Replace printk() with more standardize output format.
@ 2018-03-07 10:39 Arushi Singhal
  2018-03-07 10:47 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Arushi Singhal @ 2018-03-07 10:39 UTC (permalink / raw)
  To: gregkh; +Cc: devel, outreachy-kernel, linux-kernel

printk() is the raw way to print output and should be avoided.

For drivers with defined "struct device object", dev_*macro() is
prefer and for "struct netdevice object", netdev_*macro() is prefer over
dev_*macro() to standardize the output format within the subsystem.

If no "struct device object" is defined prefer pr_*macro() over printk().

This patch Replace printk having a log level with the appropriate output
format according to the order of preference.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
Changes in v3
*In version2 net_*macro_ratelimited was used which is not helping in
standardizing the output format.

Changes in v2
*change the subject line, driver name was wrong.

 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c      | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index e6648f7..a4b4042 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -73,7 +73,7 @@ static void *ieee80211_ccmp_init(int key_idx)
 
 	priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(priv->tfm)) {
-		printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate crypto API aes\n");
+		pr_debug("ieee80211_crypt_ccmp: could not allocate crypto API aes\n");
 		priv->tfm = NULL;
 		goto fail;
 	}
@@ -276,22 +276,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
 		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n",
-				hdr->addr2);
+			netdev_dbg(skb->dev, "CCMP: received packet without ExtIV flag from %pM\n",
+				   hdr->addr2);
 		}
 		key->dot11RSNAStatsCCMPFormatErrors++;
 		return -2;
 	}
 	keyidx >>= 6;
 	if (key->key_idx != keyidx) {
-		printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
-			key->key_idx, keyidx, priv);
+		netdev_dbg(skb->dev, "CCMP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
+			   key->key_idx, keyidx, priv);
 		return -6;
 	}
 	if (!key->key_set) {
 		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet from %pM with keyid=%d that does not have a configured key\n",
-				hdr->addr2, keyidx);
+			netdev_dbg(skb->dev, "CCMP: received packet from %pM with keyid=%d that does not have a configured key\n",
+				   hdr->addr2, keyidx);
 		}
 		return -3;
 	}
@@ -306,8 +306,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
 	if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
 		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: replay detected: STA=%pM previous PN %pm received PN %pm\n",
-			       hdr->addr2, key->rx_pn, pn);
+			netdev_dbg(skb->dev, "CCMP: replay detected: STA=%pM previous PN %pm received PN %pm\n",
+				   hdr->addr2, key->rx_pn, pn);
 		}
 		key->dot11RSNAStatsCCMPReplays++;
 		return -4;
@@ -341,8 +341,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
 		if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
 			if (net_ratelimit()) {
-				printk(KERN_DEBUG "CCMP: decrypt failed: STA=%pM\n",
-					hdr->addr2);
+				netdev_dbg(skb->dev, "CCMP: decrypt failed: STA=%pM\n",
+					   hdr->addr2);
 			}
 			key->dot11RSNAStatsCCMPDecryptErrors++;
 			return -5;
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] staging: rtl8192u: Replace printk() with more standardize output format.
  2018-03-07 10:39 [PATCH v3] staging: rtl8192u: Replace printk() with more standardize output format Arushi Singhal
@ 2018-03-07 10:47 ` Dan Carpenter
  2018-03-07 10:52   ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2018-03-07 10:47 UTC (permalink / raw)
  To: Arushi Singhal; +Cc: devel, gregkh, linux-kernel, outreachy-kernel

On Wed, Mar 07, 2018 at 04:09:09PM +0530, Arushi Singhal wrote:
> @@ -276,22 +276,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
>  	keyidx = pos[3];
>  	if (!(keyidx & (1 << 5))) {
>  		if (net_ratelimit()) {
> -			printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n",
> -				hdr->addr2);
> +			netdev_dbg(skb->dev, "CCMP: received packet without ExtIV flag from %pM\n",
> +				   hdr->addr2);
>  		}

I'm sorry.  I really hate to do this to you...  But the right thing here
is to use net_dbg_ratelimited() but get rid of the if (net_ratelimit())
check.  So it looks like this:

	if (!(keyidx & (1 << 5))) {
		net_dbg_ratelimited(skb->dev,
				    "CCMP: received packet without ExtIV flag from %pM\n",
				    hdr->addr2);
	}

Sorry again, when I looked at it before I just replied what my fast
thinking lizard brain said instead of taking time to look at what I was
saying.


regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] Re: [PATCH v3] staging: rtl8192u: Replace printk() with more standardize output format.
  2018-03-07 10:47 ` Dan Carpenter
@ 2018-03-07 10:52   ` Julia Lawall
  2018-03-07 11:01     ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2018-03-07 10:52 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Arushi Singhal, gregkh, devel, linux-kernel, outreachy-kernel



On Wed, 7 Mar 2018, Dan Carpenter wrote:

> On Wed, Mar 07, 2018 at 04:09:09PM +0530, Arushi Singhal wrote:
> > @@ -276,22 +276,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
> >  	keyidx = pos[3];
> >  	if (!(keyidx & (1 << 5))) {
> >  		if (net_ratelimit()) {
> > -			printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n",
> > -				hdr->addr2);
> > +			netdev_dbg(skb->dev, "CCMP: received packet without ExtIV flag from %pM\n",
> > +				   hdr->addr2);
> >  		}
>
> I'm sorry.  I really hate to do this to you...  But the right thing here
> is to use net_dbg_ratelimited() but get rid of the if (net_ratelimit())
> check.  So it looks like this:
>
> 	if (!(keyidx & (1 << 5))) {
> 		net_dbg_ratelimited(skb->dev,
> 				    "CCMP: received packet without ExtIV flag from %pM\n",
> 				    hdr->addr2);
> 	}
>
> Sorry again, when I looked at it before I just replied what my fast
> thinking lizard brain said instead of taking time to look at what I was
> saying.

I don't think that net_dbg_ratelimited wants a skb->dev argument.  The
various definitions in include/linux/net.h just have fmt as the first
argument.

julia

>
>
> regards,
> dan carpenter
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20180307104741.mdy2wa7hplfwxmb3%40mwanda.
> For more options, visit https://groups.google.com/d/optout.
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] Re: [PATCH v3] staging: rtl8192u: Replace printk() with more standardize output format.
  2018-03-07 10:52   ` [Outreachy kernel] " Julia Lawall
@ 2018-03-07 11:01     ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-03-07 11:01 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Arushi Singhal, gregkh, devel, linux-kernel, outreachy-kernel

On Wed, Mar 07, 2018 at 11:52:16AM +0100, Julia Lawall wrote:
> 
> 
> On Wed, 7 Mar 2018, Dan Carpenter wrote:
> 
> > On Wed, Mar 07, 2018 at 04:09:09PM +0530, Arushi Singhal wrote:
> > > @@ -276,22 +276,22 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
> > >  	keyidx = pos[3];
> > >  	if (!(keyidx & (1 << 5))) {
> > >  		if (net_ratelimit()) {
> > > -			printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n",
> > > -				hdr->addr2);
> > > +			netdev_dbg(skb->dev, "CCMP: received packet without ExtIV flag from %pM\n",
> > > +				   hdr->addr2);
> > >  		}
> >
> > I'm sorry.  I really hate to do this to you...  But the right thing here
> > is to use net_dbg_ratelimited() but get rid of the if (net_ratelimit())
> > check.  So it looks like this:
> >
> > 	if (!(keyidx & (1 << 5))) {
> > 		net_dbg_ratelimited(skb->dev,
> > 				    "CCMP: received packet without ExtIV flag from %pM\n",
> > 				    hdr->addr2);
> > 	}
> >
> > Sorry again, when I looked at it before I just replied what my fast
> > thinking lizard brain said instead of taking time to look at what I was
> > saying.
> 
> I don't think that net_dbg_ratelimited wants a skb->dev argument.  The
> various definitions in include/linux/net.h just have fmt as the first
> argument.
>

Ah....  That's fine then.  Don't worry about it.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-07 11:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-07 10:39 [PATCH v3] staging: rtl8192u: Replace printk() with more standardize output format Arushi Singhal
2018-03-07 10:47 ` Dan Carpenter
2018-03-07 10:52   ` [Outreachy kernel] " Julia Lawall
2018-03-07 11:01     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).