linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code
@ 2013-10-15 11:44 Kefeng Wang
  2013-10-15 11:44 ` [PATCH 01/18] netfilter: cleanup: delete Macro PRINTR Kefeng Wang
                   ` (17 more replies)
  0 siblings, 18 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Macro PRINTR is called only once in nfnetlink_log.c, and it can be 
replaced by wrappe function of net_ratelimit(), so kill it.

Meanwhile, I found many files could use wrappe functions of net_ratelimit()
to simplify, so I did.


Kefeng Wang (18):
  netfilter: cleanup: delete Macro PRINTR
  net: use wrapper functions of net_ratelimit() to simplify code
  rt18187se: use wrapper functions of net_ratelimit() to simplify code
  rt18192e: use wrapper functions of net_ratelimit() to simplify code
  rt18192u: use wrapper functions of net_ratelimit() to simplify code
  net: wireless: use wrapper functions of net_ratelimit() to simplify
    code
  net: ethernet: use wrapper functions of net_ratelimit() to simplify
    code
  atm: use wrapper functions of net_ratelimit() to simplify code
  block: aoe: use wrapper functions of net_ratelimit() to simplify code
  net: peak_usb: use wrapper functions of net_ratelimit() to simplify
    code
  net: hamradio: use wrapper functions of net_ratelimit() to simplify
    code
  net: irda: use wrapper functions of net_ratelimit() to simplify code
  net: ppp: use wrapper functions of net_ratelimit() to simplify code
  net: usb: use wrapper functions of net_ratelimit() to simplify code
  net: xen: use wrapper functions of net_ratelimit() to simplify code
  net: virtio: use wrapper functions of net_ratelimit() to simplify code
  net: vxlan: use wrapper functions of net_ratelimit() to simplify code
  net: wimax: use wrapper functions of net_ratelimit() to simplify code

 drivers/atm/solos-pci.c                            | 20 ++++-----
 drivers/block/aoe/aoenet.c                         |  4 +-
 drivers/net/can/usb/peak_usb/pcan_usb_core.c       | 11 ++---
 drivers/net/ethernet/aeroflex/greth.c              | 16 +++----
 drivers/net/ethernet/alteon/acenic.c               |  3 +-
 drivers/net/ethernet/arc/emac_main.c               |  7 ++--
 drivers/net/ethernet/broadcom/b44.c                |  4 +-
 drivers/net/ethernet/ethoc.c                       |  4 +-
 drivers/net/ethernet/faraday/ftgmac100.c           | 49 +++++++---------------
 drivers/net/ethernet/faraday/ftmac100.c            | 45 ++++++--------------
 drivers/net/ethernet/freescale/fec_mpc52xx.c       |  3 +-
 drivers/net/ethernet/ibm/emac/mal.c                | 15 ++-----
 drivers/net/ethernet/marvell/mv643xx_eth.c         |  6 +--
 drivers/net/ethernet/marvell/pxa168_eth.c          |  8 +---
 drivers/net/ethernet/marvell/sky2.c                | 42 +++++++------------
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c   |  5 +--
 drivers/net/ethernet/realtek/r8169.c               | 13 +++---
 drivers/net/ethernet/sfc/rx.c                      |  8 ++--
 drivers/net/ethernet/sfc/siena_sriov.c             | 27 ++++--------
 drivers/net/ethernet/ti/davinci_emac.c             |  4 +-
 drivers/net/ethernet/tundra/tsi108_eth.c           | 12 ++----
 drivers/net/hamradio/6pack.c                       |  3 +-
 drivers/net/hamradio/bpqether.c                    |  3 +-
 drivers/net/irda/stir4200.c                        |  3 +-
 drivers/net/ppp/ppp_generic.c                      | 11 +++--
 drivers/net/usb/usbnet.c                           |  4 +-
 drivers/net/virtio_net.c                           |  3 +-
 drivers/net/vxlan.c                                |  3 +-
 drivers/net/wimax/i2400m/netdev.c                  |  3 +-
 drivers/net/wireless/adm8211.c                     |  5 +--
 drivers/net/wireless/ath/carl9170/cmd.c            | 15 +++----
 drivers/net/wireless/ath/carl9170/phy.c            |  7 +---
 drivers/net/wireless/ath/carl9170/rx.c             | 45 ++++++--------------
 drivers/net/wireless/ath/carl9170/usb.c            | 12 ++----
 drivers/net/wireless/hostap/hostap_80211_rx.c      |  8 +---
 drivers/net/wireless/hostap/hostap_80211_tx.c      | 13 ++----
 drivers/net/wireless/hostap/hostap_ap.c            |  6 +--
 drivers/net/wireless/hostap/hostap_hw.c            | 17 +++-----
 drivers/net/wireless/iwlegacy/3945-mac.c           |  4 +-
 drivers/net/wireless/iwlegacy/4965-mac.c           |  6 +--
 drivers/net/wireless/iwlwifi/pcie/rx.c             |  7 ++--
 drivers/net/wireless/libertas_tf/cmd.c             |  6 +--
 drivers/net/wireless/mwl8k.c                       |  5 +--
 drivers/net/wireless/orinoco/hermes.c              |  6 +--
 drivers/net/wireless/orinoco/main.c                | 16 +++----
 drivers/net/wireless/orinoco/orinoco_usb.c         |  3 +-
 drivers/net/wireless/p54/p54pci.c                  |  6 +--
 drivers/net/xen-netback/netback.c                  | 21 ++++------
 drivers/net/xen-netfront.c                         | 27 ++++--------
 .../rtl8187se/ieee80211/ieee80211_crypt_ccmp.c     | 16 ++-----
 .../rtl8187se/ieee80211/ieee80211_crypt_tkip.c     | 27 ++++--------
 drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c |  4 +-
 drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c |  7 +---
 drivers/staging/rtl8192e/rtllib_crypt_ccmp.c       | 13 ++----
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c       | 21 +++-------
 drivers/staging/rtl8192e/rtllib_rx.c               |  6 +--
 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c      | 17 ++------
 .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c      | 22 +++-------
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |  7 +---
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |  4 +-
 net/bridge/br_fdb.c                                |  6 +--
 net/bridge/br_multicast.c                          | 13 ++----
 net/bridge/br_stp_bpdu.c                           | 11 ++---
 net/mac80211/rx.c                                  |  6 +--
 net/netfilter/ipset/ip_set_hash_gen.h              |  3 +-
 net/netfilter/nfnetlink_log.c                      |  5 +--
 66 files changed, 246 insertions(+), 516 deletions(-)

-- 
1.8.2.1



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

* [PATCH 01/18] netfilter: cleanup: delete Macro PRINTR
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
@ 2013-10-15 11:44 ` Kefeng Wang
  2013-10-15 11:44 ` [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code Kefeng Wang
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Macro PRINTR is only used once in nfnetlink_log.c, so it can be
replaced by helper function net_err_ratelimited().

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 net/netfilter/nfnetlink_log.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index d92cc31..8713111 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -47,9 +47,6 @@
 #define NFULNL_QTHRESH_DEFAULT 	100	/* 100 packets */
 #define NFULNL_COPY_RANGE_MAX	0xFFFF	/* max packet size is limited by 16-bit struct nfattr nfa_len field */
 
-#define PRINTR(x, args...)	do { if (net_ratelimit()) \
-				     printk(x, ## args); } while (0);
-
 struct nfulnl_instance {
 	struct hlist_node hlist;	/* global list of instances */
 	spinlock_t lock;
@@ -587,7 +584,7 @@ __build_packet_message(struct nfnl_log_net *log,
 	return 0;
 
 nla_put_failure:
-	PRINTR(KERN_ERR "nfnetlink_log: error creating log nlmsg\n");
+	net_err_ratelimited("nfnetlink_log: error creating log nlmsg\n");
 	return -1;
 }
 
-- 
1.8.2.1



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

* [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
  2013-10-15 11:44 ` [PATCH 01/18] netfilter: cleanup: delete Macro PRINTR Kefeng Wang
@ 2013-10-15 11:44 ` Kefeng Wang
  2013-10-15 16:24   ` Joe Perches
  2013-10-15 11:44 ` [PATCH 03/18] rt18187se: " Kefeng Wang
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 net/bridge/br_fdb.c                   |  6 ++----
 net/bridge/br_multicast.c             | 13 ++++---------
 net/bridge/br_stp_bpdu.c              | 11 ++++-------
 net/mac80211/rx.c                     |  6 ++----
 net/netfilter/ipset/ip_set_hash_gen.h |  3 +--
 5 files changed, 13 insertions(+), 26 deletions(-)

diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index ffd5874..e47dfe5 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -465,10 +465,8 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 	if (likely(fdb)) {
 		/* attempt to update an entry for a local interface */
 		if (unlikely(fdb->is_local)) {
-			if (net_ratelimit())
-				br_warn(br, "received packet on %s with "
-					"own address as source address\n",
-					source->dev->name);
+			net_ratelimited_function(br_warn, br, "received packet on %s "
+				"with own address as source address\n", source->dev->name);
 		} else {
 			/* fastpath: update of existing entry */
 			fdb->dst = source;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index d1c5786..c00d8a2 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -530,11 +530,8 @@ static struct net_bridge_mdb_entry *br_multicast_get_group(
 	max = mdb->max;
 
 	if (unlikely(count > br->hash_elasticity && count)) {
-		if (net_ratelimit())
-			br_info(br, "Multicast hash table "
-				"chain limit reached: %s\n",
-				port ? port->dev->name : br->dev->name);
-
+		net_ratelimited_function(br_info, br, "Multicast hash table "
+			"chain limit reached: %s\n", port ? port->dev->name : br->dev->name);
 		elasticity = br->hash_elasticity;
 	}
 
@@ -554,10 +551,8 @@ disable:
 
 	if (max > mdb->max || elasticity) {
 		if (mdb->old) {
-			if (net_ratelimit())
-				br_info(br, "Multicast hash table "
-					"on fire: %s\n",
-					port ? port->dev->name : br->dev->name);
+			net_ratelimited_function(br_info, br, "Multicast hash table "
+				"on fire: %s\n", port ? port->dev->name : br->dev->name);
 			err = -EEXIST;
 			goto err;
 		}
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 8660ea3..482ef11 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -220,13 +220,10 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
 		bpdu.forward_delay = br_get_ticks(buf+30);
 
 		if (bpdu.message_age > bpdu.max_age) {
-			if (net_ratelimit())
-				br_notice(p->br,
-					  "port %u config from %pM"
-					  " (message_age %ul > max_age %ul)\n",
-					  p->port_no,
-					  eth_hdr(skb)->h_source,
-					  bpdu.message_age, bpdu.max_age);
+			net_ratelimited_function(br_notice, p->br,
+				"port %u config from %pM (message_age %ul > max_age %ul)\n",
+				p->port_no, eth_hdr(skb)->h_source,
+				bpdu.message_age, bpdu.max_age);
 			goto out;
 		}
 
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 54395d7..35b8b1d 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -3156,10 +3156,8 @@ static bool ieee80211_prepare_and_rx_handle(struct ieee80211_rx_data *rx,
 	if (!consume) {
 		skb = skb_copy(skb, GFP_ATOMIC);
 		if (!skb) {
-			if (net_ratelimit())
-				wiphy_debug(local->hw.wiphy,
-					"failed to copy skb for %s\n",
-					sdata->name);
+			net_ratelimited_function(wiphy_debug, local->hw.wiphy,
+				"failed to copy skb for %s\n", sdata->name);
 			return true;
 		}
 
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 707bc52..6179436 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -607,8 +607,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
 		mtype_expire(h, NETS_LENGTH(set->family), h->dsize);
 
 	if (h->elements >= h->maxelem) {
-		if (net_ratelimit())
-			pr_warning("Set %s is full, maxelem %u reached\n",
+		net_warn_ratelimited("Set %s is full, maxelem %u reached\n",
 				   set->name, h->maxelem);
 		return -IPSET_ERR_HASH_FULL;
 	}
-- 
1.8.2.1



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

* [PATCH 03/18] rt18187se: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
  2013-10-15 11:44 ` [PATCH 01/18] netfilter: cleanup: delete Macro PRINTR Kefeng Wang
  2013-10-15 11:44 ` [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code Kefeng Wang
@ 2013-10-15 11:44 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 04/18] rt18192e: " Kefeng Wang
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 .../rtl8187se/ieee80211/ieee80211_crypt_ccmp.c     | 16 ++++---------
 .../rtl8187se/ieee80211/ieee80211_crypt_tkip.c     | 27 ++++++----------------
 drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c |  4 +---
 drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c |  7 ++----
 4 files changed, 14 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
index f5949e8..be6c5a1 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c
@@ -282,10 +282,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			pr_debug("received packet without ExtIV flag from %pM\n",
+		net_dbg_ratelimited("received packet without ExtIV flag from %pM\n",
 				 hdr->addr2);
-		}
 		key->dot11RSNAStatsCCMPFormatErrors++;
 		return -2;
 	}
@@ -296,10 +294,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!key->key_set) {
-		if (net_ratelimit()) {
-			pr_debug("received packet from %pM with keyid=%d that does not have a configured key\n",
+		net_dbg_ratelimited("received packet from %pM with keyid=%d that does not have a configured key\n",
 				 hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 
@@ -312,10 +308,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos += 8;
 
 	if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
-		if (net_ratelimit()) {
-			pr_debug("replay detected: STA=%pM previous PN %pm received PN %pm\n",
+		net_dbg_ratelimited("replay detected: STA=%pM previous PN %pm received PN %pm\n",
 				 hdr->addr2, key->rx_pn, pn);
-		}
 		key->dot11RSNAStatsCCMPReplays++;
 		return -4;
 	}
@@ -340,9 +334,7 @@ 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())
-			pr_debug("decrypt failed: STA=%pM\n", hdr->addr2);
-
+		net_dbg_ratelimited("decrypt failed: STA=%pM\n", hdr->addr2);
 		key->dot11RSNAStatsCCMPDecryptErrors++;
 		return -5;
 	}
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
index da24e43..03e1961 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c
@@ -381,10 +381,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+		net_dbg_ratelimited("TKIP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		return -2;
 	}
 	keyidx >>= 6;
@@ -394,11 +392,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!tkey->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet from %pM"
+		net_dbg_ratelimited("TKIP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 	iv16 = (pos[0] << 8) | pos[2];
@@ -407,12 +403,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
 	if (iv32 < tkey->rx_iv32 ||
 	    (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: replay detected: STA=%pM"
-			       " previous TSC %08x%04x received TSC "
-			       "%08x%04x\n", hdr->addr2,
-			       tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
-		}
+		net_dbg_ratelimited("TKIP: replay detected: STA=%pM"
+			" previous TSC %08x%04x received TSC %08x%04x\n",
+			hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
 		tkey->dot11RSNAStatsTKIPReplays++;
 		return -4;
 	}
@@ -427,11 +420,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
 	sg_init_one(&sg, pos, plen + 4);
 	if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG ": TKIP: failed to decrypt "
-			       "received packet from %pM\n",
+		net_dbg_ratelimited(": TKIP: failed to decrypt received packet from %pM\n",
 			       hdr->addr2);
-		}
 		return -7;
 	}
 
@@ -446,10 +436,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 			 * it needs to be recalculated for the next packet. */
 			tkey->rx_phase1_done = 0;
 		}
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: ICV error detected: STA="
-			       "%pM\n", hdr->addr2);
-		}
+		net_dbg_ratelimited("TKIP: ICV error detected: STA=%pM\n", hdr->addr2);
 		tkey->dot11RSNAStatsTKIPICVErrors++;
 		return -5;
 	}
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
index 10b2210..fa125f2 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c
@@ -307,11 +307,9 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
 	if (ieee->tkip_countermeasures &&
 	    strcmp(crypt->ops->name, "TKIP") == 0) {
-		if (net_ratelimit()) {
-			netdev_dbg(ieee->dev,
+		net_ratelimited_function(netdev_dbg, ieee->dev,
 				   "TKIP countermeasures: dropped received packet from %pM\n",
 				   ieee->dev->name, hdr->addr2);
-		}
 		return -1;
 	}
 #endif
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
index b346653..366b1df3 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c
@@ -196,11 +196,8 @@ int ieee80211_encrypt_fragment(
 	if (ieee->tkip_countermeasures &&
 	    crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
 		header = (struct ieee80211_hdr_4addr *)frag->data;
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
-			       "TX packet to %pM\n",
-			       ieee->dev->name, header->addr1);
-		}
+		net_dbg_ratelimited("%s: TKIP countermeasures: dropped "
+			"TX packet to %pM\n", ieee->dev->name, header->addr1);
 		return -1;
 	}
 #endif
-- 
1.8.2.1



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

* [PATCH 04/18] rt18192e: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (2 preceding siblings ...)
  2013-10-15 11:44 ` [PATCH 03/18] rt18187se: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 05/18] rt18192u: " Kefeng Wang
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 13 +++----------
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 21 +++++----------------
 drivers/staging/rtl8192e/rtllib_rx.c         |  6 ++----
 3 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index e51cb49..0d089c1 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -275,10 +275,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet without ExtIV"
+		net_dbg_ratelimited("CCMP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		key->dot11RSNAStatsCCMPFormatErrors++;
 		return -2;
 	}
@@ -289,11 +287,9 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!key->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet from %pM"
+		net_dbg_ratelimited("CCMP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 
@@ -338,10 +334,7 @@ static int rtllib_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);
-			}
+			net_dbg_ratelimited("CCMP: decrypt failed: STA= %pM\n", hdr->addr2);
 			key->dot11RSNAStatsCCMPDecryptErrors++;
 			return -5;
 		}
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 5cfd73b..c1f7683 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -396,10 +396,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+		net_dbg_ratelimited("TKIP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		return -2;
 	}
 	keyidx >>= 6;
@@ -409,11 +407,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!tkey->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet from %pM"
+		net_dbg_ratelimited("TKIP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 	iv16 = (pos[0] << 8) | pos[2];
@@ -424,12 +420,10 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		if ((iv32 < tkey->rx_iv32 ||
 		    (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) &&
 		    tkey->initialized) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "TKIP: replay detected: STA="
+			net_dbg_ratelimited("TKIP: replay detected: STA="
 				       " %pM previous TSC %08x%04x received "
 				      "TSC %08x%04x\n",hdr->addr2,
 				      tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
-			}
 			tkey->dot11RSNAStatsTKIPReplays++;
 			return -4;
 		}
@@ -448,11 +442,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
 		crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
 		if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG ": TKIP: failed to decrypt "
+			net_dbg_ratelimited(": TKIP: failed to decrypt "
 				       "received packet from %pM\n",
 				       hdr->addr2);
-			}
 			return -7;
 		}
 
@@ -469,10 +461,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 				 * next packet. */
 				tkey->rx_phase1_done = 0;
 			}
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "TKIP: ICV error detected: STA="
-				" %pM\n", hdr->addr2);
-			}
+			net_dbg_ratelimited("TKIP: ICV error detected: STA= %pM\n", hdr->addr2);
 			tkey->dot11RSNAStatsTKIPICVErrors++;
 			return -5;
 		}
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 8aeaed5..4335611 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -870,8 +870,7 @@ static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee,
 
 	hdrlen = rtllib_get_hdrlen(fc);
 	if (HTCCheck(ieee, skb->data)) {
-		if (net_ratelimit())
-			printk(KERN_INFO "%s: find HTCControl!\n", __func__);
+		net_info_ratelimited("%s: find HTCControl!\n", __func__);
 		hdrlen += 4;
 		rx_stats->bContainHTC = 1;
 	}
@@ -1439,8 +1438,7 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb,
 	}
 
 	if (HTCCheck(ieee, skb->data)) {
-		if (net_ratelimit())
-			printk(KERN_INFO "%s: Find HTCControl!\n", __func__);
+		net_info_ratelimited("%s: Find HTCControl!\n", __func__);
 		hdrlen += 4;
 	}
 
-- 
1.8.2.1



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

* [PATCH 05/18] rt18192u: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (3 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 04/18] rt18192e: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 06/18] net: wireless: " Kefeng Wang
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_XXX_ratelimited() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c      | 17 ++++-------------
 .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c      | 22 +++++-----------------
 drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c  |  7 ++-----
 drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c  |  4 +---
 4 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index f2b1677..534f0a4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -284,10 +284,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet without ExtIV"
+		net_dbg_ratelimited("CCMP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		key->dot11RSNAStatsCCMPFormatErrors++;
 		return -2;
 	}
@@ -298,11 +296,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!key->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet from %pM"
+		net_dbg_ratelimited("CCMP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 
@@ -315,11 +311,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos += 8;
 
 	if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: replay detected: STA=%pM"
+		net_dbg_ratelimited("CCMP: replay detected: STA=%pM"
 			       " previous PN %pm received PN %pm\n",
 			       hdr->addr2, key->rx_pn, pn);
-		}
 		key->dot11RSNAStatsCCMPReplays++;
 		return -4;
 	}
@@ -353,10 +347,7 @@ 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);
-			}
+			net_dbg_ratelimited("CCMP: decrypt failed: STA=%pM\n", hdr->addr2);
 			key->dot11RSNAStatsCCMPDecryptErrors++;
 			return -5;
 		}
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
index 93121b4..7bb5a96 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
@@ -406,10 +406,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+		net_dbg_ratelimited("TKIP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		return -2;
 	}
 	keyidx >>= 6;
@@ -419,11 +417,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!tkey->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet from %pM"
+		net_dbg_ratelimited("TKIP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 	iv16 = (pos[0] << 8) | pos[2];
@@ -434,12 +430,10 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	{
 		if (iv32 < tkey->rx_iv32 ||
 		(iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "TKIP: replay detected: STA=%pM"
+			net_dbg_ratelimited("TKIP: replay detected: STA=%pM"
 				" previous TSC %08x%04x received TSC "
 				"%08x%04x\n", hdr->addr2,
 				tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
-			}
 			tkey->dot11RSNAStatsTKIPReplays++;
 			return -4;
 		}
@@ -456,11 +450,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		sg_init_one(&sg, pos, plen+4);
 
 		if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG ": TKIP: failed to decrypt "
-						"received packet from %pM\n",
+			net_dbg_ratelimited("TKIP: failed to decrypt received packet from %pM\n",
 						hdr->addr2);
-			}
 			return -7;
 		}
 
@@ -476,10 +467,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 				* it needs to be recalculated for the next packet. */
 				tkey->rx_phase1_done = 0;
 			}
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "TKIP: ICV error detected: STA="
-				"%pM\n", hdr->addr2);
-			}
+			net_dbg_ratelimited("TKIP: ICV error detected: STA=%pM\n", hdr->addr2);
 			tkey->dot11RSNAStatsTKIPICVErrors++;
 			return -5;
 		}
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 59900bf..5e6c1eb 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -355,11 +355,9 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
 	if (ieee->tkip_countermeasures &&
 	    strcmp(crypt->ops->name, "TKIP") == 0) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+		net_dbg_ratelimited("%s: TKIP countermeasures: dropped "
 			       "received packet from %pM\n",
 			       ieee->dev->name, hdr->addr2);
-		}
 		return -1;
 	}
 #endif
@@ -946,8 +944,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
 
 	if(HTCCheck(ieee, skb->data))
 	{
-		if(net_ratelimit())
-		printk("find HTCControl\n");
+		net_info_ratelimited("find HTCControl\n");
 		hdrlen += 4;
 		rx_stats->bContainHTC = 1;
 	}
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index a7bcc64f..55c24d7 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -197,11 +197,9 @@ int ieee80211_encrypt_fragment(
 	if (ieee->tkip_countermeasures &&
 	    crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
 		header = (struct ieee80211_hdr *) frag->data;
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+		net_dbg_ratelimited("%s: TKIP countermeasures: dropped "
 			       "TX packet to %pM\n",
 			       ieee->dev->name, header->addr1);
-		}
 		return -1;
 	}
 #endif
-- 
1.8.2.1



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

* [PATCH 06/18] net: wireless: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (4 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 05/18] rt18192u: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 07/18] net: ethernet: " Kefeng Wang
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/wireless/adm8211.c                |  5 ++-
 drivers/net/wireless/ath/carl9170/cmd.c       | 15 +++------
 drivers/net/wireless/ath/carl9170/phy.c       |  7 ++---
 drivers/net/wireless/ath/carl9170/rx.c        | 45 ++++++++-------------------
 drivers/net/wireless/ath/carl9170/usb.c       | 12 +++----
 drivers/net/wireless/hostap/hostap_80211_rx.c |  8 ++---
 drivers/net/wireless/hostap/hostap_80211_tx.c | 13 +++-----
 drivers/net/wireless/hostap/hostap_ap.c       |  6 ++--
 drivers/net/wireless/hostap/hostap_hw.c       | 17 +++-------
 drivers/net/wireless/iwlegacy/3945-mac.c      |  4 +--
 drivers/net/wireless/iwlegacy/4965-mac.c      |  6 ++--
 drivers/net/wireless/iwlwifi/pcie/rx.c        |  7 ++---
 drivers/net/wireless/libertas_tf/cmd.c        |  6 ++--
 drivers/net/wireless/mwl8k.c                  |  5 ++-
 drivers/net/wireless/orinoco/hermes.c         |  6 ++--
 drivers/net/wireless/orinoco/main.c           | 16 +++-------
 drivers/net/wireless/orinoco/orinoco_usb.c    |  3 +-
 drivers/net/wireless/p54/p54pci.c             |  6 ++--
 18 files changed, 61 insertions(+), 126 deletions(-)

diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index f9a24e5..2fafb8a 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -374,9 +374,8 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
 
 		pktlen = status & RDES0_STATUS_FL;
 		if (pktlen > RX_PKT_SIZE) {
-			if (net_ratelimit())
-				wiphy_debug(dev->wiphy, "frame too long (%d)\n",
-					    pktlen);
+			net_ratelimited_function(wiphy_debug, dev->wiphy,
+				"frame too long (%d)\n", pktlen);
 			pktlen = RX_PKT_SIZE;
 		}
 
diff --git a/drivers/net/wireless/ath/carl9170/cmd.c b/drivers/net/wireless/ath/carl9170/cmd.c
index 39a6387..3f13398 100644
--- a/drivers/net/wireless/ath/carl9170/cmd.c
+++ b/drivers/net/wireless/ath/carl9170/cmd.c
@@ -50,12 +50,9 @@ int carl9170_write_reg(struct ar9170 *ar, const u32 reg, const u32 val)
 
 	err = carl9170_exec_cmd(ar, CARL9170_CMD_WREG, sizeof(buf),
 				(u8 *) buf, 0, NULL);
-	if (err) {
-		if (net_ratelimit()) {
-			wiphy_err(ar->hw->wiphy, "writing reg %#x "
-				"(val %#x) failed (%d)\n", reg, val, err);
-		}
-	}
+	if (err)
+		net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+			"writing reg %#x (val %#x) failed (%d)\n", reg, val, err);
 	return err;
 }
 
@@ -77,10 +74,8 @@ int carl9170_read_mreg(struct ar9170 *ar, const int nregs,
 				4 * nregs, (u8 *)offs,
 				4 * nregs, (u8 *)res);
 	if (err) {
-		if (net_ratelimit()) {
-			wiphy_err(ar->hw->wiphy, "reading regs failed (%d)\n",
-				  err);
-		}
+		net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+			"reading regs failed (%d)\n", err);
 		return err;
 	}
 
diff --git a/drivers/net/wireless/ath/carl9170/phy.c b/drivers/net/wireless/ath/carl9170/phy.c
index ab4ee7d..cae9125 100644
--- a/drivers/net/wireless/ath/carl9170/phy.c
+++ b/drivers/net/wireless/ath/carl9170/phy.c
@@ -1715,11 +1715,8 @@ int carl9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
 		err = carl9170_write_reg(ar, AR9170_PHY_REG_HEAVY_CLIP_ENABLE,
 					 0x200 | ar->heavy_clip);
 		if (err) {
-			if (net_ratelimit()) {
-				wiphy_err(ar->hw->wiphy, "failed to set "
-				       "heavy clip\n");
-			}
-
+			net_ratelimited_function(wiphy_err,
+				ar->hw->wiphy, "failed to set heavy clip\n");
 			return err;
 		}
 	}
diff --git a/drivers/net/wireless/ath/carl9170/rx.c b/drivers/net/wireless/ath/carl9170/rx.c
index e935f61..0ad905e 100644
--- a/drivers/net/wireless/ath/carl9170/rx.c
+++ b/drivers/net/wireless/ath/carl9170/rx.c
@@ -343,9 +343,8 @@ static int carl9170_rx_mac_status(struct ar9170 *ar,
 	if (unlikely(error)) {
 		/* TODO: update netdevice's RX dropped/errors statistics */
 
-		if (net_ratelimit())
-			wiphy_dbg(ar->hw->wiphy, "received frame with "
-			       "suspicious error code (%#x).\n", error);
+		net_ratelimited_function(wiphy_dbg, ar->hw->wiphy,
+			"received frame with suspicious error code (%#x).\n", error);
 
 		return -EINVAL;
 	}
@@ -374,11 +373,8 @@ static int carl9170_rx_mac_status(struct ar9170 *ar,
 			status->rate_idx = 3;
 			break;
 		default:
-			if (net_ratelimit()) {
-				wiphy_err(ar->hw->wiphy, "invalid plcp cck "
-				       "rate (%x).\n", head->plcp[0]);
-			}
-
+			net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+				"invalid plcp cck rate (%x).\n", head->plcp[0]);
 			return -EINVAL;
 		}
 		break;
@@ -411,11 +407,8 @@ static int carl9170_rx_mac_status(struct ar9170 *ar,
 			status->rate_idx = 7;
 			break;
 		default:
-			if (net_ratelimit()) {
-				wiphy_err(ar->hw->wiphy, "invalid plcp ofdm "
-					"rate (%x).\n", head->plcp[0]);
-			}
-
+			net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+				"invalid plcp ofdm rate (%x).\n", head->plcp[0]);
 			return -EINVAL;
 		}
 		if (status->band == IEEE80211_BAND_2GHZ)
@@ -742,11 +735,8 @@ static void carl9170_rx_untie_data(struct ar9170 *ar, u8 *buf, int len)
 
 			ar->rx_has_plcp = true;
 		} else {
-			if (net_ratelimit()) {
-				wiphy_err(ar->hw->wiphy, "plcp info "
-					"is clipped.\n");
-			}
-
+			net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+				"plcp info is clipped.\n");
 			goto drop;
 		}
 		break;
@@ -763,11 +753,8 @@ static void carl9170_rx_untie_data(struct ar9170 *ar, u8 *buf, int len)
 			mpdu_len -= sizeof(struct ar9170_rx_phystatus);
 			phy = (void *)(buf + mpdu_len);
 		} else {
-			if (net_ratelimit()) {
-				wiphy_err(ar->hw->wiphy, "frame tail "
-					"is clipped.\n");
-			}
-
+			net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+				"frame tail is clipped.\n");
 			goto drop;
 		}
 
@@ -900,11 +887,8 @@ static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len)
 			if (!ar->rx_failover_missing) {
 
 				/* this is not "short read". */
-				if (net_ratelimit()) {
-					wiphy_err(ar->hw->wiphy,
+				net_ratelimited_function(wiphy_err, ar->hw->wiphy,
 						"missing tag!\n");
-				}
-
 				__carl9170_rx(ar, tbuf, tlen);
 				return;
 			}
@@ -973,11 +957,8 @@ static void carl9170_rx_stream(struct ar9170 *ar, void *buf, unsigned int len)
 	}
 
 	if (tlen) {
-		if (net_ratelimit()) {
-			wiphy_err(ar->hw->wiphy, "%d bytes of unprocessed "
-				"data left in rx stream!\n", tlen);
-		}
-
+		net_ratelimited_function(wiphy_err, ar->hw->wiphy,
+			"%d bytes of unprocessed data left in rx stream!\n", tlen);
 		goto err_telluser;
 	}
 
diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
index 307bc0d..0369f0f 100644
--- a/drivers/net/wireless/ath/carl9170/usb.c
+++ b/drivers/net/wireless/ath/carl9170/usb.c
@@ -144,10 +144,8 @@ static void carl9170_usb_submit_data_urb(struct ar9170 *ar)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (unlikely(err)) {
-		if (net_ratelimit()) {
-			dev_err(&ar->udev->dev, "tx submit failed (%d)\n",
-				urb->status);
-		}
+		net_ratelimited_function(dev_err, &ar->udev->dev,
+			"tx submit failed (%d)\n", urb->status);
 
 		usb_unanchor_urb(urb);
 		usb_anchor_urb(urb, &ar->tx_err);
@@ -194,10 +192,8 @@ static void carl9170_usb_tx_data_complete(struct urb *urb)
 
 	/* a random transmission error has occurred? */
 	default:
-		if (net_ratelimit()) {
-			dev_err(&ar->udev->dev, "tx failed (%d)\n",
-				urb->status);
-		}
+		net_ratelimited_function(dev_err, &ar->udev->dev,
+			"tx failed (%d)\n", urb->status);
 
 		usb_anchor_urb(urb, &ar->tx_err);
 		break;
diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c
index d39e3e2..a547d79 100644
--- a/drivers/net/wireless/hostap/hostap_80211_rx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_rx.c
@@ -661,11 +661,9 @@ hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb,
 
 	if (local->tkip_countermeasures &&
 	    strcmp(crypt->ops->name, "TKIP") == 0) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
+		net_dbg_ratelimited("%s: TKIP countermeasures: dropped "
 			       "received packet from %pM\n",
 			       local->dev->name, hdr->addr2);
-		}
 		return -1;
 	}
 
@@ -995,11 +993,9 @@ void hostap_80211_rx(struct net_device *dev, struct sk_buff *skb,
 
 	if (local->drop_unencrypted && !(fc & IEEE80211_FCTL_PROTECTED) &&
 	    !hostap_is_eapol_frame(local, skb)) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: dropped unencrypted RX data "
+		net_dbg_ratelimited("%s: dropped unencrypted RX data "
 			       "frame from %pM (drop_unencrypted=1)\n",
 			       dev->name, hdr->addr2);
-		}
 		goto rx_dropped;
 	}
 
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c
index 344a981..7c8f798 100644
--- a/drivers/net/wireless/hostap/hostap_80211_tx.c
+++ b/drivers/net/wireless/hostap/hostap_80211_tx.c
@@ -330,11 +330,8 @@ static struct sk_buff * hostap_tx_encrypt(struct sk_buff *skb,
 	if (local->tkip_countermeasures &&
 	    strcmp(crypt->ops->name, "TKIP") == 0) {
 		hdr = (struct ieee80211_hdr *) skb->data;
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
-			       "TX packet to %pM\n",
-			       local->dev->name, hdr->addr1);
-		}
+		net_dbg_ratelimited("%s: TKIP countermeasures: dropped "
+			"TX packet to %pM\n", local->dev->name, hdr->addr1);
 		kfree_skb(skb);
 		return NULL;
 	}
@@ -502,10 +499,8 @@ netdev_tx_t hostap_master_start_xmit(struct sk_buff *skb,
 	} else if (local->drop_unencrypted &&
 		   ieee80211_is_data(hdr->frame_control) &&
 		   meta->ethertype != ETH_P_PAE) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: dropped unencrypted TX data "
-			       "frame (drop_unencrypted=1)\n", dev->name);
-		}
+		net_dbg_ratelimited("%s: dropped unencrypted TX data "
+			"frame (drop_unencrypted=1)\n", dev->name);
 		iface->stats.tx_dropped++;
 		ret = NETDEV_TX_OK;
 		goto fail;
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index d6033a8..9320dc7 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -2781,10 +2781,8 @@ ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx)
 		 * for a unicast frame. In this case, the packet is send to all
 		 * ports of the bridge. Since this is a valid scenario, do not
 		 * print out any errors here. */
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "AP: drop packet to non-associated "
-			       "STA %pM\n", hdr->addr1);
-		}
+		net_dbg_ratelimited("AP: drop packet to non-associatedSTA %pM\n",
+			hdr->addr1);
 #endif
 		local->ap->tx_drop_nonassoc++;
 		ret = AP_TX_DROP;
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index c275dc1..34b7246 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -1820,10 +1820,8 @@ static int prism2_tx_80211(struct sk_buff *skb, struct net_device *dev)
 
 	if ((local->func->card_present && !local->func->card_present(local)) ||
 	    !local->hw_ready || local->hw_downloading || local->pri_only) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: prism2_tx_80211: hw not ready -"
-			       " skipping\n", dev->name);
-		}
+		net_dbg_ratelimited("%s: prism2_tx_80211: hw not ready skipping\n",
+			dev->name);
 		goto fail;
 	}
 
@@ -2620,10 +2618,8 @@ static irqreturn_t prism2_interrupt(int irq, void *dev_id)
 	/* Detect early interrupt before driver is fully configured */
 	spin_lock(&local->irq_init_lock);
 	if (!dev->base_addr) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: Interrupt, but dev not configured\n",
-			       dev->name);
-		}
+		net_dbg_ratelimited("%s: Interrupt, but dev not configured\n",
+			dev->name);
 		spin_unlock(&local->irq_init_lock);
 		return IRQ_HANDLED;
 	}
@@ -2632,10 +2628,7 @@ static irqreturn_t prism2_interrupt(int irq, void *dev_id)
 	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INTERRUPT, 0, 0);
 
 	if (local->func->card_present && !local->func->card_present(local)) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "%s: Interrupt, but dev not OK\n",
-			       dev->name);
-		}
+		net_dbg_ratelimited("%s: Interrupt, but dev not OK\n", dev->name);
 		return IRQ_HANDLED;
 	}
 
diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
index 9581d07..920c0b8 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -1027,8 +1027,8 @@ il3945_rx_allocate(struct il_priv *il, gfp_t priority)
 		/* Alloc a new receive buffer */
 		page = alloc_pages(gfp_mask, il->hw_params.rx_page_order);
 		if (!page) {
-			if (net_ratelimit())
-				D_INFO("Failed to allocate SKB buffer.\n");
+			net_ratelimited_function(D_INFO,
+				"Failed to allocate SKB buffer.\n");
 			if (rxq->free_count <= RX_LOW_WATERMARK &&
 			    net_ratelimit())
 				IL_ERR("Failed to allocate SKB buffer with %0x."
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index 5ab50a5..4f8de71 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -340,9 +340,9 @@ il4965_rx_allocate(struct il_priv *il, gfp_t priority)
 		/* Alloc a new receive buffer */
 		page = alloc_pages(gfp_mask, il->hw_params.rx_page_order);
 		if (!page) {
-			if (net_ratelimit())
-				D_INFO("alloc_pages failed, " "order: %d\n",
-				       il->hw_params.rx_page_order);
+			net_ratelimited_function(D_INFO,
+				"alloc_pages failed, order: %d\n",
+				il->hw_params.rx_page_order);
 
 			if (rxq->free_count <= RX_LOW_WATERMARK &&
 			    net_ratelimit())
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
index 3f237b4..022f612 100644
--- a/drivers/net/wireless/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
@@ -293,10 +293,9 @@ static void iwl_pcie_rxq_alloc_rbs(struct iwl_trans *trans, gfp_t priority)
 		/* Alloc a new receive buffer */
 		page = alloc_pages(gfp_mask, trans_pcie->rx_page_order);
 		if (!page) {
-			if (net_ratelimit())
-				IWL_DEBUG_INFO(trans, "alloc_pages failed, "
-					   "order: %d\n",
-					   trans_pcie->rx_page_order);
+			net_ratelimited_function(IWL_DEBUG_INFO, trans,
+				"alloc_pages failed, order: %d\n",
+				trans_pcie->rx_page_order);
 
 			if ((rxq->free_count <= RX_LOW_WATERMARK) &&
 			    net_ratelimit())
diff --git a/drivers/net/wireless/libertas_tf/cmd.c b/drivers/net/wireless/libertas_tf/cmd.c
index 909ac36..806f750 100644
--- a/drivers/net/wireless/libertas_tf/cmd.c
+++ b/drivers/net/wireless/libertas_tf/cmd.c
@@ -737,10 +737,8 @@ int lbtf_process_rx_command(struct lbtf_private *priv)
 	respcmd = le16_to_cpu(resp->command);
 	result = le16_to_cpu(resp->result);
 
-	if (net_ratelimit())
-		pr_info("libertastf: cmd response 0x%04x, seq %d, size %d\n",
-			respcmd, le16_to_cpu(resp->seqnum),
-			le16_to_cpu(resp->size));
+	net_info_ratelimited("libertastf: cmd response 0x%04x, seq %d, size %d\n",
+		respcmd, le16_to_cpu(resp->seqnum), le16_to_cpu(resp->size));
 
 	if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
 		spin_unlock_irqrestore(&priv->driver_lock, flags);
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index a3707fd..fe19424 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -5060,9 +5060,8 @@ mwl8k_configure_filter_sniffer(struct ieee80211_hw *hw,
 	 * interface is active.
 	 */
 	if (!list_empty(&priv->vif_list)) {
-		if (net_ratelimit())
-			wiphy_info(hw->wiphy,
-				   "not enabling sniffer mode because STA interface is active\n");
+		net_ratelimited_function(wiphy_info, hw->wiphy,
+			"not enabling sniffer mode because STA interface is active\n");
 		return 0;
 	}
 
diff --git a/drivers/net/wireless/orinoco/hermes.c b/drivers/net/wireless/orinoco/hermes.c
index 75c15bc..e4ff42f 100644
--- a/drivers/net/wireless/orinoco/hermes.c
+++ b/drivers/net/wireless/orinoco/hermes.c
@@ -261,14 +261,12 @@ static int hermes_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0,
 	err = hermes_issue_cmd(hw, cmd, parm0, 0, 0);
 	if (err) {
 		if (!hermes_present(hw)) {
-			if (net_ratelimit())
-				printk(KERN_WARNING "hermes @ %p: "
+			net_warn_ratelimited("hermes @ %p: "
 				       "Card removed while issuing command "
 				       "0x%04x.\n", hw->iobase, cmd);
 			err = -ENODEV;
 		} else
-			if (net_ratelimit())
-				printk(KERN_ERR "hermes @ %p: "
+			net_err_ratelimited("hermes @ %p: "
 				       "Error %d issuing command 0x%04x.\n",
 				       hw->iobase, err, cmd);
 		goto out;
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 38ec8d1..22f3a6a 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -394,9 +394,7 @@ int orinoco_process_xmit_skb(struct sk_buff *skb,
 		int len = skb->len + sizeof(encaps_hdr) - (2 * ETH_ALEN);
 
 		if (skb_headroom(skb) < ENCAPS_OVERHEAD) {
-			if (net_ratelimit())
-				printk(KERN_ERR
-				       "%s: Not enough headroom for 802.2 headers %d\n",
+			net_err_ratelimited("%s: Not enough headroom for 802.2 headers %d\n",
 				       dev->name, skb_headroom(skb));
 			return -ENOMEM;
 		}
@@ -495,8 +493,7 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
 		err = hw->ops->bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
 					  txfid, 0);
 		if (err) {
-			if (net_ratelimit())
-				printk(KERN_ERR "%s: Error %d writing Tx "
+			net_err_ratelimited("%s: Error %d writing Tx "
 				       "descriptor to BAP\n", dev->name, err);
 			goto busy;
 		}
@@ -509,8 +506,7 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
 		err = hw->ops->bap_pwrite(hw, USER_BAP, &desc, sizeof(desc),
 					  txfid, 0);
 		if (err) {
-			if (net_ratelimit())
-				printk(KERN_ERR "%s: Error %d writing Tx "
+			net_err_ratelimited("%s: Error %d writing Tx "
 				       "descriptor to BAP\n", dev->name, err);
 			goto busy;
 		}
@@ -554,8 +550,7 @@ static netdev_tx_t orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
 				txfid, NULL);
 	if (err) {
 		netif_start_queue(dev);
-		if (net_ratelimit())
-			printk(KERN_ERR "%s: Error %d transmitting packet\n",
+		net_err_ratelimited("%s: Error %d transmitting packet\n",
 				dev->name, err);
 		goto busy;
 	}
@@ -1622,8 +1617,7 @@ EXPORT_SYMBOL(__orinoco_ev_info);
 
 static void __orinoco_ev_infdrop(struct net_device *dev, struct hermes *hw)
 {
-	if (net_ratelimit())
-		printk(KERN_DEBUG "%s: Information frame lost.\n", dev->name);
+	net_dbg_ratelimited("%s: Information frame lost.\n", dev->name);
 }
 
 /********************************************************************/
diff --git a/drivers/net/wireless/orinoco/orinoco_usb.c b/drivers/net/wireless/orinoco/orinoco_usb.c
index bdfe637..65a43d6 100644
--- a/drivers/net/wireless/orinoco/orinoco_usb.c
+++ b/drivers/net/wireless/orinoco/orinoco_usb.c
@@ -1286,8 +1286,7 @@ static netdev_tx_t ezusb_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	if (err) {
 		netif_start_queue(dev);
-		if (net_ratelimit())
-			printk(KERN_ERR "%s: Error %d transmitting packet\n",
+		net_err_ratelimited("%s: Error %d transmitting packet\n",
 				dev->name, err);
 		goto busy;
 	}
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index 57e3af8..1609084 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -212,10 +212,8 @@ static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index,
 		}
 
 		if (unlikely(len > priv->common.rx_mtu)) {
-			if (net_ratelimit())
-				dev_err(&priv->pdev->dev, "rx'd frame size "
-					"exceeds length threshold.\n");
-
+			net_ratelimited_function(dev_err, &priv->pdev->dev,
+				"rx'd frame size exceeds length threshold.\n");
 			len = priv->common.rx_mtu;
 		}
 		dma_addr = le32_to_cpu(desc->host_addr);
-- 
1.8.2.1



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

* [PATCH 07/18] net: ethernet: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (5 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 06/18] net: wireless: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 08/18] atm: " Kefeng Wang
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/ethernet/aeroflex/greth.c            | 16 ++++----
 drivers/net/ethernet/alteon/acenic.c             |  3 +-
 drivers/net/ethernet/arc/emac_main.c             |  7 ++--
 drivers/net/ethernet/broadcom/b44.c              |  4 +-
 drivers/net/ethernet/ethoc.c                     |  4 +-
 drivers/net/ethernet/faraday/ftgmac100.c         | 49 +++++++-----------------
 drivers/net/ethernet/faraday/ftmac100.c          | 45 +++++++---------------
 drivers/net/ethernet/freescale/fec_mpc52xx.c     |  3 +-
 drivers/net/ethernet/ibm/emac/mal.c              | 15 ++------
 drivers/net/ethernet/marvell/mv643xx_eth.c       |  6 +--
 drivers/net/ethernet/marvell/pxa168_eth.c        |  8 +---
 drivers/net/ethernet/marvell/sky2.c              | 42 ++++++++------------
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c |  5 +--
 drivers/net/ethernet/realtek/r8169.c             | 13 +++----
 drivers/net/ethernet/sfc/rx.c                    |  8 ++--
 drivers/net/ethernet/sfc/siena_sriov.c           | 27 +++++--------
 drivers/net/ethernet/ti/davinci_emac.c           |  4 +-
 drivers/net/ethernet/tundra/tsi108_eth.c         | 12 ++----
 18 files changed, 90 insertions(+), 181 deletions(-)

diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
index e066945..6a1a97f 100644
--- a/drivers/net/ethernet/aeroflex/greth.c
+++ b/drivers/net/ethernet/aeroflex/greth.c
@@ -569,8 +569,8 @@ frag_map_error:
 		greth_write_bd(&bdp->stat, 0);
 	}
 map_error:
-	if (net_ratelimit())
-		dev_warn(greth->dev, "Could not create TX DMA mapping\n");
+	net_ratelimited_function(dev_warn,
+		greth->dev, "Could not create TX DMA mapping\n");
 	dev_kfree_skb(skb);
 out:
 	return err;
@@ -778,8 +778,8 @@ static int greth_rx(struct net_device *dev, int limit)
 
 			if (unlikely(skb == NULL)) {
 
-				if (net_ratelimit())
-					dev_warn(&dev->dev, "low on memory - " "packet dropped\n");
+				net_ratelimited_function(dev_warn, &dev->dev,
+						"low on memory - packet dropped\n");
 
 				dev->stats.rx_dropped++;
 
@@ -918,8 +918,8 @@ static int greth_rx_gbit(struct net_device *dev, int limit)
 				greth->rx_skbuff[greth->rx_cur] = newskb;
 				greth_write_bd(&bdp->addr, dma_addr);
 			} else {
-				if (net_ratelimit())
-					dev_warn(greth->dev, "Could not create DMA mapping, dropping packet\n");
+				net_ratelimited_function(dev_warn, greth->dev,
+					"Could not create DMA mapping, dropping packet\n");
 				dev_kfree_skb(newskb);
 				/* reusing current skb, so it is a drop */
 				dev->stats.rx_dropped++;
@@ -934,8 +934,8 @@ static int greth_rx_gbit(struct net_device *dev, int limit)
 			 * table handling should be divided into cleaning and
 			 * filling as the TX part of the driver
 			 */
-			if (net_ratelimit())
-				dev_warn(greth->dev, "Could not allocate SKB, dropping packet\n");
+			net_ratelimited_function(dev_warn, greth->dev,
+				"Could not allocate SKB, dropping packet\n");
 			/* reusing current skb, so it is a drop */
 			dev->stats.rx_dropped++;
 		}
diff --git a/drivers/net/ethernet/alteon/acenic.c b/drivers/net/ethernet/alteon/acenic.c
index 219be1b..432640b 100644
--- a/drivers/net/ethernet/alteon/acenic.c
+++ b/drivers/net/ethernet/alteon/acenic.c
@@ -1799,8 +1799,7 @@ static void ace_load_jumbo_rx_ring(struct net_device *dev, int nr_bufs)
 	clear_bit(0, &ap->jumbo_refill_busy);
 	return;
  error_out:
-	if (net_ratelimit())
-		printk(KERN_INFO "Out of memory when allocating "
+	net_info_ratelimited("Out of memory when allocating "
 		       "jumbo receive buffers\n");
 	goto out;
 }
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index 9e16014..fe659b8 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -221,8 +221,8 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
 			/* We pre-allocate buffers of MTU size so incoming
 			 * packets won't be split/chained.
 			 */
-			if (net_ratelimit())
-				netdev_err(ndev, "incomplete packet received\n");
+			net_ratelimited_funciton(netdev_err, ndev,
+				"incomplete packet received\n");
 
 			/* Return ownership to EMAC */
 			rxbd->info = cpu_to_le32(FOR_EMAC | EMAC_BUFFER_SIZE);
@@ -258,8 +258,7 @@ static int arc_emac_rx(struct net_device *ndev, int budget)
 		addr = dma_map_single(&ndev->dev, (void *)rx_buff->skb->data,
 				      EMAC_BUFFER_SIZE, DMA_FROM_DEVICE);
 		if (dma_mapping_error(&ndev->dev, addr)) {
-			if (net_ratelimit())
-				netdev_err(ndev, "cannot dma map\n");
+			net_ratelimited_function(netdev_err, ndev, "cannot dma map\n");
 			dev_kfree_skb(rx_buff->skb);
 			stats->rx_errors++;
 			continue;
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 9b017d9..7e422dc 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -187,8 +187,8 @@ static int b44_wait_bit(struct b44 *bp, unsigned long reg,
 		udelay(10);
 	}
 	if (i == timeout) {
-		if (net_ratelimit())
-			netdev_err(bp->dev, "BUG!  Timeout waiting for bit %08x of register %lx to %s\n",
+		net_ratelimited_function(netdev_err, bp->dev,
+				"BUG!  Timeout waiting for bit %08x of register %lx to %s\n",
 				   bit, reg, clear ? "clear" : "set");
 
 		return -ENODEV;
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 4de8cfd..b61b56d 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -446,10 +446,8 @@ static int ethoc_rx(struct net_device *dev, int limit)
 				dev->stats.rx_bytes += size;
 				netif_receive_skb(skb);
 			} else {
-				if (net_ratelimit())
-					dev_warn(&dev->dev,
+				net_ratelimited_function(dev_warn, &dev->dev,
 					    "low on memory - packet dropped\n");
-
 				dev->stats.rx_dropped++;
 				break;
 			}
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index 212f44b..a289337 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -354,42 +354,30 @@ static bool ftgmac100_rx_packet_error(struct ftgmac100 *priv,
 	bool error = false;
 
 	if (unlikely(ftgmac100_rxdes_rx_error(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx err\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx err\n");
 		netdev->stats.rx_errors++;
 		error = true;
 	}
 
 	if (unlikely(ftgmac100_rxdes_crc_error(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx crc err\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx crc err\n");
 		netdev->stats.rx_crc_errors++;
 		error = true;
 	} else if (unlikely(ftgmac100_rxdes_ipcs_err(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx IP checksum err\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx IP checksum err\n");
 		error = true;
 	}
 
 	if (unlikely(ftgmac100_rxdes_frame_too_long(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx frame too long\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx frame too long\n");
 		netdev->stats.rx_length_errors++;
 		error = true;
 	} else if (unlikely(ftgmac100_rxdes_runt(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx runt\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx runt\n");
 		netdev->stats.rx_length_errors++;
 		error = true;
 	} else if (unlikely(ftgmac100_rxdes_odd_nibble(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx odd nibble\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx odd bibble\n");
 		netdev->stats.rx_length_errors++;
 		error = true;
 	}
@@ -403,8 +391,7 @@ static void ftgmac100_rx_drop_packet(struct ftgmac100 *priv)
 	struct ftgmac100_rxdes *rxdes = ftgmac100_current_rxdes(priv);
 	bool done = false;
 
-	if (net_ratelimit())
-		netdev_dbg(netdev, "drop packet %p\n", rxdes);
+	net_ratelimited_function(netdev_dbg, netdev, "drop packet %p\n", rxdes);
 
 	do {
 		if (ftgmac100_rxdes_last_segment(rxdes))
@@ -437,9 +424,7 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int *processed)
 	/* start processing */
 	skb = netdev_alloc_skb_ip_align(netdev, 128);
 	if (unlikely(!skb)) {
-		if (net_ratelimit())
-			netdev_err(netdev, "rx skb alloc failed\n");
-
+		net_ratelimited_function(netdev_err, netdev, "rx skb alloc failed\n");
 		ftgmac100_rx_drop_packet(priv);
 		return true;
 	}
@@ -723,15 +708,13 @@ static int ftgmac100_alloc_rx_page(struct ftgmac100 *priv,
 
 	page = alloc_page(gfp);
 	if (!page) {
-		if (net_ratelimit())
-			netdev_err(netdev, "failed to allocate rx page\n");
+		net_ratelimited_function(netdev_err, netdev, "failed to allocate rx page\n");
 		return -ENOMEM;
 	}
 
 	map = dma_map_page(priv->dev, page, 0, RX_BUF_SIZE, DMA_FROM_DEVICE);
 	if (unlikely(dma_mapping_error(priv->dev, map))) {
-		if (net_ratelimit())
-			netdev_err(netdev, "failed to map rx page\n");
+		net_ratelimited_function(netdev_err, netdev, "failed to map rx page\n");
 		__free_page(page);
 		return -ENOMEM;
 	}
@@ -1043,8 +1026,8 @@ static int ftgmac100_poll(struct napi_struct *napi, int budget)
 
 	if (status & (FTGMAC100_INT_NO_RXBUF | FTGMAC100_INT_RPKT_LOST |
 		      FTGMAC100_INT_AHB_ERR | FTGMAC100_INT_PHYSTS_CHG)) {
-		if (net_ratelimit())
-			netdev_info(netdev, "[ISR] = 0x%x: %s%s%s%s\n", status,
+		net_ratelimited_function(netdev_info, netdev, "[ISR] = 0x%x: %s%s%s%s\n",
+					status,
 				    status & FTGMAC100_INT_NO_RXBUF ? "NO_RXBUF " : "",
 				    status & FTGMAC100_INT_RPKT_LOST ? "RPKT_LOST " : "",
 				    status & FTGMAC100_INT_AHB_ERR ? "AHB_ERR " : "",
@@ -1145,9 +1128,7 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
 	dma_addr_t map;
 
 	if (unlikely(skb->len > MAX_PKT_SIZE)) {
-		if (net_ratelimit())
-			netdev_dbg(netdev, "tx packet too big\n");
-
+		net_ratelimited_function(netdev_dbg, netdev, "tx packet too big\n");
 		netdev->stats.tx_dropped++;
 		dev_kfree_skb(skb);
 		return NETDEV_TX_OK;
@@ -1156,9 +1137,7 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
 	map = dma_map_single(priv->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
 	if (unlikely(dma_mapping_error(priv->dev, map))) {
 		/* drop packet */
-		if (net_ratelimit())
-			netdev_err(netdev, "map socket buffer failed\n");
-
+		net_ratelimited_function(netdev_err, netdev, "map socket buffer failed\n");
 		netdev->stats.tx_dropped++;
 		dev_kfree_skb(skb);
 		return NETDEV_TX_OK;
diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
index 8be5b40..ec8afe2 100644
--- a/drivers/net/ethernet/faraday/ftmac100.c
+++ b/drivers/net/ethernet/faraday/ftmac100.c
@@ -335,37 +335,27 @@ static bool ftmac100_rx_packet_error(struct ftmac100 *priv,
 	bool error = false;
 
 	if (unlikely(ftmac100_rxdes_rx_error(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx err\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx err\n");
 		netdev->stats.rx_errors++;
 		error = true;
 	}
 
 	if (unlikely(ftmac100_rxdes_crc_error(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx crc err\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx crc err\n");
 		netdev->stats.rx_crc_errors++;
 		error = true;
 	}
 
 	if (unlikely(ftmac100_rxdes_frame_too_long(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx frame too long\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx frame too long\n");
 		netdev->stats.rx_length_errors++;
 		error = true;
 	} else if (unlikely(ftmac100_rxdes_runt(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx runt\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx runt\n");
 		netdev->stats.rx_length_errors++;
 		error = true;
 	} else if (unlikely(ftmac100_rxdes_odd_nibble(rxdes))) {
-		if (net_ratelimit())
-			netdev_info(netdev, "rx odd nibble\n");
-
+		net_ratelimited_function(netdev_info, netdev, "rx odd nibble\n");
 		netdev->stats.rx_length_errors++;
 		error = true;
 	}
@@ -379,8 +369,7 @@ static void ftmac100_rx_drop_packet(struct ftmac100 *priv)
 	struct ftmac100_rxdes *rxdes = ftmac100_current_rxdes(priv);
 	bool done = false;
 
-	if (net_ratelimit())
-		netdev_dbg(netdev, "drop packet %p\n", rxdes);
+	net_ratelimited_function(netdev_dbg, netdev, "drop packet %p\n", rxdes);
 
 	do {
 		if (ftmac100_rxdes_last_segment(rxdes))
@@ -422,9 +411,7 @@ static bool ftmac100_rx_packet(struct ftmac100 *priv, int *processed)
 	/* start processing */
 	skb = netdev_alloc_skb_ip_align(netdev, 128);
 	if (unlikely(!skb)) {
-		if (net_ratelimit())
-			netdev_err(netdev, "rx skb alloc failed\n");
-
+		net_ratelimited_function(netdev_err, netdev, "rx skb alloc failed\n");
 		ftmac100_rx_drop_packet(priv);
 		return true;
 	}
@@ -676,15 +663,13 @@ static int ftmac100_alloc_rx_page(struct ftmac100 *priv,
 
 	page = alloc_page(gfp);
 	if (!page) {
-		if (net_ratelimit())
-			netdev_err(netdev, "failed to allocate rx page\n");
+		net_ratelimited_function(netdev_err, netdev, "failed to allocate rx page\n");
 		return -ENOMEM;
 	}
 
 	map = dma_map_page(priv->dev, page, 0, RX_BUF_SIZE, DMA_FROM_DEVICE);
 	if (unlikely(dma_mapping_error(priv->dev, map))) {
-		if (net_ratelimit())
-			netdev_err(netdev, "failed to map rx page\n");
+		net_ratelimited_function(netdev_err, netdev, "failed to map rx page\n");
 		__free_page(page);
 		return -ENOMEM;
 	}
@@ -919,8 +904,8 @@ static int ftmac100_poll(struct napi_struct *napi, int budget)
 
 	if (status & (FTMAC100_INT_NORXBUF | FTMAC100_INT_RPKT_LOST |
 		      FTMAC100_INT_AHB_ERR | FTMAC100_INT_PHYSTS_CHG)) {
-		if (net_ratelimit())
-			netdev_info(netdev, "[ISR] = 0x%x: %s%s%s%s\n", status,
+		net_ratelimited_function(netdev_info, netdev, "[ISR] = 0x%x: %s%s%s%s\n",
+					status,
 				    status & FTMAC100_INT_NORXBUF ? "NORXBUF " : "",
 				    status & FTMAC100_INT_RPKT_LOST ? "RPKT_LOST " : "",
 				    status & FTMAC100_INT_AHB_ERR ? "AHB_ERR " : "",
@@ -1015,9 +1000,7 @@ static int ftmac100_hard_start_xmit(struct sk_buff *skb, struct net_device *netd
 	dma_addr_t map;
 
 	if (unlikely(skb->len > MAX_PKT_SIZE)) {
-		if (net_ratelimit())
-			netdev_dbg(netdev, "tx packet too big\n");
-
+		net_ratelimited_function(netdev_dbg, netdev, "tx packet too big\n");
 		netdev->stats.tx_dropped++;
 		dev_kfree_skb(skb);
 		return NETDEV_TX_OK;
@@ -1026,9 +1009,7 @@ static int ftmac100_hard_start_xmit(struct sk_buff *skb, struct net_device *netd
 	map = dma_map_single(priv->dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE);
 	if (unlikely(dma_mapping_error(priv->dev, map))) {
 		/* drop packet */
-		if (net_ratelimit())
-			netdev_err(netdev, "map socket buffer failed\n");
-
+		net_ratelimited_function(netdev_err, netdev, "map socket buffer failed\n");
 		netdev->stats.tx_dropped++;
 		dev_kfree_skb(skb);
 		return NETDEV_TX_OK;
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 9947765..6b1feeb 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -313,8 +313,7 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	unsigned long flags;
 
 	if (bcom_queue_full(priv->tx_dmatsk)) {
-		if (net_ratelimit())
-			dev_err(&dev->dev, "transmit queue overrun\n");
+		net_ratelimited_function(dev_err, &dev->dev, "transmit queue overrun\n");
 		return NETDEV_TX_BUSY;
 	}
 
diff --git a/drivers/net/ethernet/ibm/emac/mal.c b/drivers/net/ethernet/ibm/emac/mal.c
index dac564c..9177345 100644
--- a/drivers/net/ethernet/ibm/emac/mal.c
+++ b/drivers/net/ethernet/ibm/emac/mal.c
@@ -240,20 +240,15 @@ static irqreturn_t mal_serr(int irq, void *dev_instance)
 			/* PLB error, it's probably buggy hardware or
 			 * incorrect physical address in BD (i.e. bug)
 			 */
-			if (net_ratelimit())
-				printk(KERN_ERR
-				       "mal%d: system error, "
-				       "PLB (ESR = 0x%08x)\n",
-				       mal->index, esr);
+			net_err_ratelimited("mal%d: system error, "
+				"PLB (ESR = 0x%08x)\n", mal->index, esr);
 			return IRQ_HANDLED;
 		}
 
 		/* OPB error, it's probably buggy hardware or incorrect
 		 * EBC setup
 		 */
-		if (net_ratelimit())
-			printk(KERN_ERR
-			       "mal%d: system error, OPB (ESR = 0x%08x)\n",
+		net_err_ratelimited("mal%d: system error, OPB (ESR = 0x%08x)\n",
 			       mal->index, esr);
 	}
 	return IRQ_HANDLED;
@@ -318,9 +313,7 @@ static irqreturn_t mal_txde(int irq, void *dev_instance)
 
 	MAL_DBG(mal, "txde %08x" NL, deir);
 
-	if (net_ratelimit())
-		printk(KERN_ERR
-		       "mal%d: TX descriptor error (TXDEIR = 0x%08x)\n",
+	net_err_ratelimited("mal%d: TX descriptor error (TXDEIR = 0x%08x)\n",
 		       mal->index, deir);
 
 	return IRQ_HANDLED;
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 7fb5677..d1e23d7 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -573,8 +573,7 @@ err:
 
 		if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) !=
 			(RX_FIRST_DESC | RX_LAST_DESC)) {
-			if (net_ratelimit())
-				netdev_err(mp->dev,
+			net_ratelimited_function(netdev_err, mp->dev,
 					   "received packet spanning multiple descriptors\n");
 		}
 
@@ -818,8 +817,7 @@ static netdev_tx_t mv643xx_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	if (txq->tx_ring_size - txq->tx_desc_count < MAX_SKB_FRAGS + 1) {
-		if (net_ratelimit())
-			netdev_err(dev, "tx queue full?!\n");
+		net_ratelimited_function(netdev_err, dev, "tx queue full?!\n");
 		kfree_skb(skb);
 		return NETDEV_TX_OK;
 	}
diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c
index fff6246..ce36745 100644
--- a/drivers/net/ethernet/marvell/pxa168_eth.c
+++ b/drivers/net/ethernet/marvell/pxa168_eth.c
@@ -744,8 +744,7 @@ static int txq_reclaim(struct net_device *dev, int force)
 			pep->tx_skb[tx_index] = NULL;
 
 		if (cmd_sts & TX_ERROR) {
-			if (net_ratelimit())
-				printk(KERN_ERR "%s: Error in TX\n", dev->name);
+			net_err_ratelimited("%s: Error in TX\n", dev->name);
 			dev->stats.tx_errors++;
 		}
 		dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE);
@@ -832,10 +831,7 @@ static int rxq_process(struct net_device *dev, int budget)
 			stats->rx_dropped++;
 			if ((cmd_sts & (RX_FIRST_DESC | RX_LAST_DESC)) !=
 			    (RX_FIRST_DESC | RX_LAST_DESC)) {
-				if (net_ratelimit())
-					printk(KERN_ERR
-					       "%s: Rx pkt on multiple desc\n",
-					       dev->name);
+				net_err_ratelimited("%s: Rx pkt on multiple desc\n", dev->name);
 			}
 			if (cmd_sts & RX_ERROR)
 				stats->rx_errors++;
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index e09a8c6..42cad5d 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -1250,8 +1250,7 @@ map_page_error:
 			 PCI_DMA_FROMDEVICE);
 
 mapping_error:
-	if (net_ratelimit())
-		dev_warn(&pdev->dev, "%s: rx mapping error\n",
+	net_ratelimited_function(dev_warn, &pdev->dev, "%s: rx mapping error\n",
 			 skb->dev->name);
 	return -EIO;
 }
@@ -1998,8 +1997,8 @@ mapping_unwind:
 	}
 
 mapping_error:
-	if (net_ratelimit())
-		dev_warn(&hw->pdev->dev, "%s: tx mapping error\n", dev->name);
+	net_ratelimited_function(dev_warn, &hw->pdev->dev,
+		"%s: tx mapping error\n", dev->name);
 	dev_kfree_skb(skb);
 	return NETDEV_TX_OK;
 }
@@ -2633,8 +2632,7 @@ resubmit:
 error:
 	++dev->stats.rx_errors;
 
-	if (net_ratelimit())
-		netif_info(sky2, rx_err, dev,
+	net_ratelimited_function(netif_info, sky2, rx_err, dev,
 			   "rx error, status 0x%x length %d\n", status, length);
 
 	goto resubmit;
@@ -2809,8 +2807,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
 			break;
 
 		default:
-			if (net_ratelimit())
-				pr_warning("unknown status opcode 0x%x\n", opcode);
+			net_warn_ratelimited("unknown status opcode 0x%x\n", opcode);
 		}
 	} while (hw->st_idx != idx);
 
@@ -2828,38 +2825,33 @@ static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
 {
 	struct net_device *dev = hw->dev[port];
 
-	if (net_ratelimit())
-		netdev_info(dev, "hw error interrupt status 0x%x\n", status);
+	net_ratelimited_function(netdev_info, dev, "hw error interrupt status 0x%x\n",
+		status);
 
 	if (status & Y2_IS_PAR_RD1) {
-		if (net_ratelimit())
-			netdev_err(dev, "ram data read parity error\n");
+		net_ratelimited_function(netdev_err, dev, "ram data read parity error\n");
 		/* Clear IRQ */
 		sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_RD_PERR);
 	}
 
 	if (status & Y2_IS_PAR_WR1) {
-		if (net_ratelimit())
-			netdev_err(dev, "ram data write parity error\n");
+		net_ratelimited_function(netdev_err, dev, "ram data write parity error\n");
 
 		sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_WR_PERR);
 	}
 
 	if (status & Y2_IS_PAR_MAC1) {
-		if (net_ratelimit())
-			netdev_err(dev, "MAC parity error\n");
+		net_ratelimited_function(netdev_err, dev, "MAC parity error\n");
 		sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_PE);
 	}
 
 	if (status & Y2_IS_PAR_RX1) {
-		if (net_ratelimit())
-			netdev_err(dev, "RX parity error\n");
+		net_ratelimited_function(netdev_err, dev, "RX parity error\n");
 		sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), BMU_CLR_IRQ_PAR);
 	}
 
 	if (status & Y2_IS_TCP_TXA1) {
-		if (net_ratelimit())
-			netdev_err(dev, "TCP segmentation error\n");
+		net_ratelimited_function(netdev_err, dev, "TCP segmentation error\n");
 		sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_CLR_IRQ_TCP);
 	}
 }
@@ -2880,8 +2872,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
 
 		sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
 		pci_err = sky2_pci_read16(hw, PCI_STATUS);
-		if (net_ratelimit())
-			dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
+		net_ratelimited_function(dev_err, &pdev->dev, "PCI hardware error (0x%x)\n",
 			        pci_err);
 
 		sky2_pci_write16(hw, PCI_STATUS,
@@ -2897,8 +2888,7 @@ static void sky2_hw_intr(struct sky2_hw *hw)
 		err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
 		sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
 			     0xfffffffful);
-		if (net_ratelimit())
-			dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
+		net_ratelimited_function(dev_err, &pdev->dev, "PCI Express error (0x%x)\n", err);
 
 		sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
 		sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
@@ -3017,8 +3007,8 @@ static void sky2_watchdog(unsigned long arg)
 /* Hardware/software error handling */
 static void sky2_err_intr(struct sky2_hw *hw, u32 status)
 {
-	if (net_ratelimit())
-		dev_warn(&hw->pdev->dev, "error interrupt status=%#x\n", status);
+	net_ratelimited_function(dev_warn, &hw->pdev->dev,
+		"error interrupt status=%#x\n", status);
 
 	if (status & Y2_IS_HW_ERR)
 		sky2_hw_intr(hw);
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index 149355b..920ef96 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -3559,9 +3559,8 @@ myri10ge_check_slice(struct myri10ge_slice_state *ss, int *reset_needed,
 	    ss->watchdog_tx_req != ss->watchdog_tx_done) {
 		/* nic seems like it might be stuck.. */
 		if (rx_pause_cnt != mgp->watchdog_pause) {
-			if (net_ratelimit())
-				netdev_warn(mgp->dev, "slice %d: TX paused, "
-					    "check link partner\n", slice);
+			net_ratelimited_function(netdev_warn, mgp->dev,
+				"slice %d: TX paused, check link partner\n", slice);
 		} else {
 			netdev_warn(mgp->dev,
 				    "slice %d: TX stuck %d %d %d %d %d %d\n",
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 3397cee..5e0ee96 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -1496,8 +1496,7 @@ static void __rtl8169_check_link_status(struct net_device *dev,
 		if (pm)
 			pm_request_resume(&tp->pci_dev->dev);
 		netif_carrier_on(dev);
-		if (net_ratelimit())
-			netif_info(tp, ifup, dev, "link up\n");
+		net_ratelimited_function(netif_info, tp, ifup, dev, "link up\n");
 	} else {
 		netif_carrier_off(dev);
 		netif_info(tp, ifdown, dev, "link down\n");
@@ -5732,8 +5731,8 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
 	mapping = dma_map_single(d, rtl8169_align(data), rx_buf_sz,
 				 DMA_FROM_DEVICE);
 	if (unlikely(dma_mapping_error(d, mapping))) {
-		if (net_ratelimit())
-			netif_err(tp, drv, tp->dev, "Failed to map RX DMA!\n");
+		net_ratelimited_function(netif_err,
+			tp, drv, tp->dev, "Failed to map RX DMA!\n");
 		goto err_out;
 	}
 
@@ -5895,8 +5894,7 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
 		addr = skb_frag_address(frag);
 		mapping = dma_map_single(d, addr, len, DMA_TO_DEVICE);
 		if (unlikely(dma_mapping_error(d, mapping))) {
-			if (net_ratelimit())
-				netif_err(tp, drv, tp->dev,
+			net_ratelimited_function(netif_err, tp, drv, tp->dev,
 					  "Failed to map TX fragments DMA!\n");
 			goto err_out;
 		}
@@ -5996,8 +5994,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 	len = skb_headlen(skb);
 	mapping = dma_map_single(d, skb->data, len, DMA_TO_DEVICE);
 	if (unlikely(dma_mapping_error(d, mapping))) {
-		if (net_ratelimit())
-			netif_err(tp, drv, dev, "Failed to map TX DMA!\n");
+		net_ratelimited_function(netif_err, tp, drv, dev, "Failed to map TX DMA!\n");
 		goto err_dma_0;
 	}
 
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
index 4a59672..b53f16d 100644
--- a/drivers/net/ethernet/sfc/rx.c
+++ b/drivers/net/ethernet/sfc/rx.c
@@ -397,19 +397,17 @@ static void efx_rx_packet__check_len(struct efx_rx_queue *rx_queue,
 	rx_buf->flags |= EFX_RX_PKT_DISCARD;
 
 	if ((len > rx_buf->len) && EFX_WORKAROUND_8071(efx)) {
-		if (net_ratelimit())
-			netif_err(efx, rx_err, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, rx_err, efx->net_dev,
 				  " RX queue %d seriously overlength "
 				  "RX event (0x%x > 0x%x+0x%x). Leaking\n",
 				  efx_rx_queue_index(rx_queue), len, max_len,
 				  efx->type->rx_buffer_padding);
 		efx_schedule_reset(efx, RESET_TYPE_RX_RECOVERY);
 	} else {
-		if (net_ratelimit())
-			netif_err(efx, rx_err, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, rx_err, efx->net_dev,
 				  " RX queue %d overlength RX event "
 				  "(0x%x > 0x%x)\n",
-				  efx_rx_queue_index(rx_queue), len, max_len);
+		efx_rx_queue_index(rx_queue), len, max_len);
 	}
 
 	efx_rx_queue_channel(rx_queue)->n_rx_overlength++;
diff --git a/drivers/net/ethernet/sfc/siena_sriov.c b/drivers/net/ethernet/sfc/siena_sriov.c
index 0c38f92..71ec42d 100644
--- a/drivers/net/ethernet/sfc/siena_sriov.c
+++ b/drivers/net/ethernet/sfc/siena_sriov.c
@@ -532,8 +532,7 @@ static int efx_vfdi_init_evq(struct efx_vf *vf)
 
 	if (bad_vf_index(efx, vf_evq) ||
 	    bad_buf_count(buf_count, EFX_MAX_VF_EVQ_SIZE)) {
-		if (net_ratelimit())
-			netif_err(efx, hw, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 				  "ERROR: Invalid INIT_EVQ from %s: evq %d bufs %d\n",
 				  vf->pci_name, vf_evq, buf_count);
 		return VFDI_RC_EINVAL;
@@ -575,8 +574,7 @@ static int efx_vfdi_init_rxq(struct efx_vf *vf)
 	if (bad_vf_index(efx, vf_evq) || bad_vf_index(efx, vf_rxq) ||
 	    vf_rxq >= VF_MAX_RX_QUEUES ||
 	    bad_buf_count(buf_count, EFX_MAX_DMAQ_SIZE)) {
-		if (net_ratelimit())
-			netif_err(efx, hw, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 				  "ERROR: Invalid INIT_RXQ from %s: rxq %d evq %d "
 				  "buf_count %d\n", vf->pci_name, vf_rxq,
 				  vf_evq, buf_count);
@@ -616,8 +614,7 @@ static int efx_vfdi_init_txq(struct efx_vf *vf)
 	if (bad_vf_index(efx, vf_evq) || bad_vf_index(efx, vf_txq) ||
 	    vf_txq >= vf_max_tx_channels ||
 	    bad_buf_count(buf_count, EFX_MAX_DMAQ_SIZE)) {
-		if (net_ratelimit())
-			netif_err(efx, hw, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 				  "ERROR: Invalid INIT_TXQ from %s: txq %d evq %d "
 				  "buf_count %d\n", vf->pci_name, vf_txq,
 				  vf_evq, buf_count);
@@ -759,8 +756,7 @@ static int efx_vfdi_insert_filter(struct efx_vf *vf)
 	unsigned flags;
 
 	if (bad_vf_index(efx, vf_rxq) || vf->rx_filtering) {
-		if (net_ratelimit())
-			netif_err(efx, hw, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 				  "ERROR: Invalid INSERT_FILTER from %s: rxq %d "
 				  "flags 0x%x\n", vf->pci_name, vf_rxq,
 				  req->u.mac_filter.flags);
@@ -802,8 +798,7 @@ static int efx_vfdi_set_status_page(struct efx_vf *vf)
 		/ sizeof(req->u.set_status_page.peer_page_addr[0]);
 
 	if (!req->u.set_status_page.dma_addr || page_count > max_page_count) {
-		if (net_ratelimit())
-			netif_err(efx, hw, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 				  "ERROR: Invalid SET_STATUS_PAGE from %s\n",
 				  vf->pci_name);
 		return VFDI_RC_EINVAL;
@@ -875,8 +870,7 @@ static void efx_sriov_vfdi(struct work_struct *work)
 	rc = efx_sriov_memcpy(efx, copy, 1);
 	if (rc) {
 		/* If we can't get the request, we can't reply to the caller */
-		if (net_ratelimit())
-			netif_err(efx, hw, efx->net_dev,
+		net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 				  "ERROR: Unable to fetch VFDI request from %s rc %d\n",
 				  vf->pci_name, -rc);
 		vf->busy = false;
@@ -963,8 +957,7 @@ static void efx_sriov_reset_vf(struct efx_vf *vf, struct efx_buffer *buffer)
 		}
 		rc = efx_sriov_memcpy(efx, copy_req, count);
 		if (rc) {
-			if (net_ratelimit())
-				netif_err(efx, hw, efx->net_dev,
+			net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 					  "ERROR: Unable to notify %s of reset"
 					  ": %d\n", vf->pci_name, -rc);
 			break;
@@ -1420,8 +1413,7 @@ void efx_sriov_event(struct efx_channel *channel, efx_qword_t *event)
 	}
 
 error:
-	if (net_ratelimit())
-		netif_err(efx, hw, efx->net_dev,
+	net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 			  "ERROR: Screaming VFDI request from %s\n",
 			  vf->pci_name);
 	/* Reset the request and sequence number */
@@ -1509,8 +1501,7 @@ void efx_sriov_desc_fetch_err(struct efx_nic *efx, unsigned dmaq)
 	if (map_vi_index(efx, dmaq, &vf, &rel))
 		return;
 
-	if (net_ratelimit())
-		netif_err(efx, hw, efx->net_dev,
+	net_ratelimited_function(netif_err, efx, hw, efx->net_dev,
 			  "VF %d DMA Q %d reports descriptor fetch error.\n",
 			  vf->index, rel);
 	queue_work(vfdi_workqueue, &vf->reset_work);
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 67df09e..caab0a9 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1408,10 +1408,8 @@ static int emac_poll(struct napi_struct *napi, int budget)
 		if (cause) {
 			ch = ((status & EMAC_MACSTATUS_TXERRCH_MASK) >>
 			      EMAC_MACSTATUS_TXERRCH_SHIFT);
-			if (net_ratelimit()) {
-				dev_err(emac_dev, "TX Host error %s on ch=%d\n",
+			net_ratelimited_function(dev_err, emac_dev, "TX Host error %s on ch=%d\n",
 					&emac_txhost_errcodes[cause][0], ch);
-			}
 		}
 		cause = ((status & EMAC_MACSTATUS_RXERRCODE_MASK) >>
 			 EMAC_MACSTATUS_RXERRCODE_SHIFT);
diff --git a/drivers/net/ethernet/tundra/tsi108_eth.c b/drivers/net/ethernet/tundra/tsi108_eth.c
index c4dbf98..467d76d 100644
--- a/drivers/net/ethernet/tundra/tsi108_eth.c
+++ b/drivers/net/ethernet/tundra/tsi108_eth.c
@@ -669,10 +669,7 @@ static int tsi108_send_packet(struct sk_buff * skb, struct net_device *dev)
 
 	if (data->txfree < MAX_SKB_FRAGS + 1) {
 		netif_stop_queue(dev);
-
-		if (net_ratelimit())
-			printk(KERN_ERR "%s: Transmit with full tx ring!\n",
-			       dev->name);
+		net_err_ratelimited("%s: Transmit with full tx ring!\n", dev->name);
 		return NETDEV_TX_BUSY;
 	}
 
@@ -869,9 +866,7 @@ static int tsi108_poll(struct napi_struct *napi, int budget)
 		TSI_WRITE(TSI108_EC_RXERR, err);
 
 		if (err) {
-			if (net_ratelimit())
-				printk(KERN_DEBUG "%s: RX error %x\n",
-				       dev->name, err);
+			net_dbg_ratelimited("%s: RX error %x\n", dev->name, err);
 
 			if (!(TSI_READ(TSI108_EC_RXSTAT) &
 			      TSI108_EC_RXSTAT_QUEUE0))
@@ -1024,8 +1019,7 @@ static irqreturn_t tsi108_irq(int irq, void *dev_id)
 		tsi108_rx_int(dev);
 
 	if (stat & TSI108_INT_SFN) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "%s: SFN error\n", dev->name);
+		net_dbg_ratelimited("%s: SFN error\n", dev->name);
 		TSI_WRITE(TSI108_EC_INTSTAT, TSI108_INT_SFN);
 	}
 
-- 
1.8.2.1



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

* [PATCH 08/18] atm: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (6 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 07/18] net: ethernet: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 09/18] block: aoe: " Kefeng Wang
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/atm/solos-pci.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 32784d1..a4d20e9 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -807,8 +807,8 @@ void solos_bh(unsigned long card_arg)
 
 				skb = alloc_skb(size + 1, GFP_ATOMIC);
 				if (!skb) {
-					if (net_ratelimit())
-						dev_warn(&card->dev->dev, "Failed to allocate sk_buff for RX\n");
+					net_ratelimited_function(dev_warn, &card->dev->dev,
+						"Failed to allocate sk_buff for RX\n");
 					continue;
 				}
 
@@ -829,8 +829,8 @@ void solos_bh(unsigned long card_arg)
 				vcc = find_vcc(card->atmdev[port], le16_to_cpu(header->vpi),
 					       le16_to_cpu(header->vci));
 				if (!vcc) {
-					if (net_ratelimit())
-						dev_warn(&card->dev->dev, "Received packet for unknown VPI.VCI %d.%d on port %d\n",
+					net_ratelimited_function(dev_warn, &card->dev->dev,
+						"Received packet for unknown VPI.VCI %d.%d on port %d\n",
 							 le16_to_cpu(header->vpi), le16_to_cpu(header->vci),
 							 port);
 					dev_kfree_skb_any(skb);
@@ -856,9 +856,8 @@ void solos_bh(unsigned long card_arg)
 					break;
 				spin_lock(&card->cli_queue_lock);
 				if (skb_queue_len(&card->cli_queue[port]) > 10) {
-					if (net_ratelimit())
-						dev_warn(&card->dev->dev, "Dropping console response on port %d\n",
-							 port);
+					net_ratelimited_function(dev_warn, &card->dev->dev,
+						"Dropping console response on port %d\n", port);
 					dev_kfree_skb_any(skb);
 				} else
 					skb_queue_tail(&card->cli_queue[port], skb);
@@ -878,8 +877,7 @@ void solos_bh(unsigned long card_arg)
 					  card->config_regs + RX_DMA_ADDR(port));
 				card->rx_skb[port] = skb;
 			} else {
-				if (net_ratelimit())
-					dev_warn(&card->dev->dev, "Failed to allocate RX skb");
+				net_ratelimited_function(dev_warn, &card->dev->dev, "Failed to allocate RX skb");
 
 				/* We'll have to try again later */
 				tasklet_schedule(&card->tlet);
@@ -927,8 +925,8 @@ static int popen(struct atm_vcc *vcc)
 
 	skb = alloc_skb(sizeof(*header), GFP_KERNEL);
 	if (!skb) {
-		if (net_ratelimit())
-			dev_warn(&card->dev->dev, "Failed to allocate sk_buff in popen()\n");
+		net_ratelimited_function(dev_warn, &card->dev->dev,
+			"Failed to allocate sk_buff in popen()\n");
 		return -ENOMEM;
 	}
 	header = (void *)skb_put(skb, sizeof(*header));
-- 
1.8.2.1



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

* [PATCH 09/18] block: aoe: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (7 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 08/18] atm: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 10/18] net: peak_usb: " Kefeng Wang
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_err_ratelimited() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/block/aoe/aoenet.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
index 63773a9..25e8764 100644
--- a/drivers/block/aoe/aoenet.c
+++ b/drivers/block/aoe/aoenet.c
@@ -159,9 +159,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,
 		n = h->err;
 		if (n > NECODES)
 			n = 0;
-		if (net_ratelimit())
-			printk(KERN_ERR
-				"%s%d.%d@%s; ecode=%d '%s'\n",
+		net_err_ratelimited("%s%d.%d@%s; ecode=%d '%s'\n",
 				"aoe: error packet from ",
 				get_unaligned_be16(&h->major),
 				h->minor, skb->dev->name,
-- 
1.8.2.1



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

* [PATCH 10/18] net: peak_usb: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (8 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 09/18] block: aoe: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 11/18] net: hamradio: " Kefeng Wang
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/can/usb/peak_usb/pcan_usb_core.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 0b7a4c3..5166a1f 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -191,8 +191,7 @@ static void peak_usb_read_bulk_callback(struct urb *urb)
 		return;
 
 	default:
-		if (net_ratelimit())
-			netdev_err(netdev,
+		net_ratelimited_function(netdev_err, netdev,
 				   "Rx urb aborted (%d)\n", urb->status);
 		goto resubmit_urb;
 	}
@@ -260,9 +259,8 @@ static void peak_usb_write_bulk_callback(struct urb *urb)
 		break;
 
 	default:
-		if (net_ratelimit())
-			netdev_err(netdev, "Tx urb aborted (%d)\n",
-				   urb->status);
+		net_ratelimited_function(netdev_err, netdev,
+			"Tx urb aborted (%d)\n", urb->status);
 	case -EPROTO:
 	case -ENOENT:
 	case -ECONNRESET:
@@ -314,8 +312,7 @@ static netdev_tx_t peak_usb_ndo_start_xmit(struct sk_buff *skb,
 
 	err = dev->adapter->dev_encode_msg(dev, skb, obuf, &size);
 	if (err) {
-		if (net_ratelimit())
-			netdev_err(netdev, "packet dropped\n");
+		net_ratelimited_function(netdev_err, netdev, "packet dropped\n");
 		dev_kfree_skb(skb);
 		stats->tx_dropped++;
 		return NETDEV_TX_OK;
-- 
1.8.2.1



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

* [PATCH 11/18] net: hamradio: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (9 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 10/18] net: peak_usb: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 12/18] net: irda: " Kefeng Wang
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_XXX_ratelimited() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/hamradio/6pack.c    | 3 +--
 drivers/net/hamradio/bpqether.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 1450e33..9e97eba 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -237,8 +237,7 @@ static void sp_encaps(struct sixpack *sp, unsigned char *icp, int len)
 out_drop:
 	sp->dev->stats.tx_dropped++;
 	netif_start_queue(sp->dev);
-	if (net_ratelimit())
-		printk(KERN_DEBUG "%s: %s - dropped.\n", sp->dev->name, msg);
+	net_dbg_ratelimited("%s: %s - dropped.\n", sp->dev->name, msg);
 }
 
 /* Encapsulate an IP datagram and kick it into a TTY queue. */
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index f91bf0d..1522b4a 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -269,8 +269,7 @@ static netdev_tx_t bpq_xmit(struct sk_buff *skb, struct net_device *dev)
 	 * space for the BPQ headers.
 	 */
 	if (skb_cow(skb, AX25_BPQ_HEADER_LEN)) {
-		if (net_ratelimit())
-			pr_err("bpqether: out of memory\n");
+		net_err_ratelimited("pqether: out of memory\n");
 		kfree_skb(skb);
 
 		return NETDEV_TX_OK;
-- 
1.8.2.1



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

* [PATCH 12/18] net: irda: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (10 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 11/18] net: hamradio: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 13/18] net: ppp: " Kefeng Wang
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/irda/stir4200.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 876e709..d499b2b 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -783,8 +783,7 @@ static int stir_transmit_thread(void *arg)
 				break;
 
 			if (unlikely(receive_start(stir))) {
-				if (net_ratelimit())
-					dev_info(&dev->dev,
+				net_ratelimited_function(dev_info, &dev->dev,
 						 "%s: receive usb submit failed\n",
 						 stir->netdev->name);
 				stir->receiving = 0;
-- 
1.8.2.1



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

* [PATCH 13/18] net: ppp: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (11 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 12/18] net: irda: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 14/18] net: usb: " Kefeng Wang
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/ppp/ppp_generic.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index 72ff14b..53900cd 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1125,8 +1125,8 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
 		ppp->xcomp->comp_extra + PPP_HDRLEN;
 	new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
 	if (!new_skb) {
-		if (net_ratelimit())
-			netdev_err(ppp->dev, "PPP: no memory (comp pkt)\n");
+		net_ratelimited_function(netdev_err, ppp->dev,
+			"PPP: no memory (comp pkt)\n");
 		return NULL;
 	}
 	if (ppp->dev->hard_header_len > PPP_HDRLEN)
@@ -1155,8 +1155,8 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
 		 * the compress_proto because MPPE and MPPC share
 		 * the same number.
 		 */
-		if (net_ratelimit())
-			netdev_err(ppp->dev, "ppp: compressor dropped pkt\n");
+		net_ratelimited_function(netdev_err, ppp->dev,
+			"ppp: compressor dropped pkt\n");
 		kfree_skb(skb);
 		consume_skb(new_skb);
 		new_skb = NULL;
@@ -1251,8 +1251,7 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
 	if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state &&
 	    proto != PPP_LCP && proto != PPP_CCP) {
 		if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
-			if (net_ratelimit())
-				netdev_err(ppp->dev,
+			net_ratelimited_function(netdev_err, ppp->dev,
 					   "ppp: compression required but "
 					   "down - pkt dropped.\n");
 			goto drop;
-- 
1.8.2.1



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

* [PATCH 14/18] net: usb: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (12 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 13/18] net: ppp: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 19:06   ` Sergei Shtylyov
  2013-10-15 11:45 ` [PATCH 15/18] net: xen: " Kefeng Wang
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/usb/usbnet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index bf94e10..edf81de 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -450,8 +450,8 @@ void usbnet_defer_kevent (struct usbnet *dev, int work)
 {
 	set_bit (work, &dev->flags);
 	if (!schedule_work (&dev->kevent)) {
-		if (net_ratelimit())
-			netdev_err(dev->net, "kevent %d may have been dropped\n", work);
+		net_ratelimited_function(netdev_err, dev->net,
+			"kevent %d may have been dropped\n", work);
 	} else {
 		netdev_dbg(dev->net, "kevent %d scheduled\n", work);
 	}
-- 
1.8.2.1



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

* [PATCH 15/18] net: xen: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (13 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 14/18] net: usb: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 16/18] net: virtio: " Kefeng Wang
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/xen-netback/netback.c | 21 +++++++++------------
 drivers/net/xen-netfront.c        | 27 +++++++++------------------
 2 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index f3e591c..bceb2ad 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -776,10 +776,9 @@ static int xenvif_count_requests(struct xenvif *vif,
 		 * dropped
 		 */
 		if (!drop_err && slots >= XEN_NETBK_LEGACY_SLOTS_MAX) {
-			if (net_ratelimit())
-				netdev_dbg(vif->dev,
-					   "Too many slots (%d) exceeding limit (%d), dropping packet\n",
-					   slots, XEN_NETBK_LEGACY_SLOTS_MAX);
+			net_ratelimited_function(netdev_dbg, vif->dev,
+				"Too many slots (%d) exceeding limit (%d), dropping packet\n",
+				slots, XEN_NETBK_LEGACY_SLOTS_MAX);
 			drop_err = -E2BIG;
 		}
 
@@ -799,10 +798,9 @@ static int xenvif_count_requests(struct xenvif *vif,
 		 * Consume all slots and drop the packet.
 		 */
 		if (!drop_err && txp->size > first->size) {
-			if (net_ratelimit())
-				netdev_dbg(vif->dev,
-					   "Invalid tx request, slot size %u > remaining size %u\n",
-					   txp->size, first->size);
+			net_ratelimited_function(netdev_dbg, vif->dev,
+				"Invalid tx request, slot size %u > remaining size %u\n",
+				txp->size, first->size);
 			drop_err = -EIO;
 		}
 
@@ -1170,10 +1168,9 @@ static int checksum_setup(struct xenvif *vif, struct sk_buff *skb)
 		}
 		break;
 	default:
-		if (net_ratelimit())
-			netdev_err(vif->dev,
-				   "Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n",
-				   iph->protocol);
+		net_ratelimited_function(netdev_err, vif->dev,
+			"Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n",
+			iph->protocol);
 		goto out;
 	}
 
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 36808bf..11eeef1 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -690,8 +690,7 @@ static int xennet_get_extras(struct netfront_info *np,
 		grant_ref_t ref;
 
 		if (unlikely(cons + 1 == rp)) {
-			if (net_ratelimit())
-				dev_warn(dev, "Missing extra info\n");
+			net_ratelimited_function(dev_warn, dev, "Missing extra info\n");
 			err = -EBADR;
 			break;
 		}
@@ -701,8 +700,7 @@ static int xennet_get_extras(struct netfront_info *np,
 
 		if (unlikely(!extra->type ||
 			     extra->type >= XEN_NETIF_EXTRA_TYPE_MAX)) {
-			if (net_ratelimit())
-				dev_warn(dev, "Invalid extra type: %d\n",
+			net_ratelimited_function(dev_warn, dev, "Invalid extra type: %d\n",
 					extra->type);
 			err = -EINVAL;
 		} else {
@@ -742,8 +740,7 @@ static int xennet_get_responses(struct netfront_info *np,
 	for (;;) {
 		if (unlikely(rx->status < 0 ||
 			     rx->offset + rx->status > PAGE_SIZE)) {
-			if (net_ratelimit())
-				dev_warn(dev, "rx->offset: %x, size: %u\n",
+			net_ratelimited_function(dev_warn, dev, "rx->offset: %x, size: %u\n",
 					 rx->offset, rx->status);
 			xennet_move_rx_slot(np, skb, ref);
 			err = -EINVAL;
@@ -756,8 +753,7 @@ static int xennet_get_responses(struct netfront_info *np,
 		 * situation to the system controller to reboot the backend.
 		 */
 		if (ref == GRANT_INVALID_REF) {
-			if (net_ratelimit())
-				dev_warn(dev, "Bad rx response id %d.\n",
+			net_ratelimited_function(dev_warn, dev, "Bad rx response id %d.\n",
 					 rx->id);
 			err = -EINVAL;
 			goto next;
@@ -775,8 +771,7 @@ next:
 			break;
 
 		if (cons + slots == rp) {
-			if (net_ratelimit())
-				dev_warn(dev, "Need more slots\n");
+			net_ratelimited_function(dev_warn, dev, "Need more slots\n");
 			err = -ENOENT;
 			break;
 		}
@@ -788,8 +783,7 @@ next:
 	}
 
 	if (unlikely(slots > max)) {
-		if (net_ratelimit())
-			dev_warn(dev, "Too many slots\n");
+		net_ratelimited_function(dev_warn, dev, "Too many slots\n");
 		err = -E2BIG;
 	}
 
@@ -803,15 +797,13 @@ static int xennet_set_skb_gso(struct sk_buff *skb,
 			      struct xen_netif_extra_info *gso)
 {
 	if (!gso->u.gso.size) {
-		if (net_ratelimit())
-			pr_warn("GSO size must not be zero\n");
+		net_warn_ratelimited("GSO size must not be zero\n");
 		return -EINVAL;
 	}
 
 	/* Currently only TCPv4 S.O. is supported. */
 	if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) {
-		if (net_ratelimit())
-			pr_warn("Bad GSO type %d\n", gso->u.gso.type);
+		net_warn_ratelimited("Bad GSO type %d\n", gso->u.gso.type);
 		return -EINVAL;
 	}
 
@@ -910,8 +902,7 @@ static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
 		}
 		break;
 	default:
-		if (net_ratelimit())
-			pr_err("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n",
+		net_err_ratelimited("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n",
 			       iph->protocol);
 		goto out;
 	}
-- 
1.8.2.1



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

* [PATCH 16/18] net: virtio: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (14 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 15/18] net: xen: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 17/18] net: vxlan: " Kefeng Wang
  2013-10-15 11:45 ` [PATCH 18/18] net: wimax: " Kefeng Wang
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/virtio_net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index defec2b..4f63c12 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -753,8 +753,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
 	/* This should not happen! */
 	if (unlikely(err)) {
 		dev->stats.tx_fifo_errors++;
-		if (net_ratelimit())
-			dev_warn(&dev->dev,
+		net_ratelimited_function(dev_warn, &dev->dev,
 				 "Unexpected TXQ (%d) queue failure: %d\n", qnum, err);
 		dev->stats.tx_dropped++;
 		kfree_skb(skb);
-- 
1.8.2.1



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

* [PATCH 17/18] net: vxlan: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (15 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 16/18] net: virtio: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  2013-10-15 11:45 ` [PATCH 18/18] net: wimax: " Kefeng Wang
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/vxlan.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 2ef5b62..56583ab 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -893,8 +893,7 @@ static bool vxlan_snoop(struct net_device *dev,
 		if (f->state & NUD_NOARP)
 			return true;
 
-		if (net_ratelimit())
-			netdev_info(dev,
+		net_ratelimited_function(netdev_info, dev,
 				    "%pM migrated from %pIS to %pIS\n",
 				    src_mac, &rdst->remote_ip, &src_ip);
 
-- 
1.8.2.1



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

* [PATCH 18/18] net: wimax: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
                   ` (16 preceding siblings ...)
  2013-10-15 11:45 ` [PATCH 17/18] net: vxlan: " Kefeng Wang
@ 2013-10-15 11:45 ` Kefeng Wang
  17 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-15 11:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, David S. Miller, Pablo Neira Ayuso,
	Stephen Hemminger, Johannes Berg, John W. Linville,
	Stanislaw Gruszka, Johannes Berg, Francois Romieu, Ben Hutchings,
	Chas Williams, Marc Kleine-Budde, Samuel Ortiz, Paul Mackerras,
	Oliver Neukum, Konrad Rzeszutek Wilk, Boris Ostrovsky,
	David Vrabel, Rusty Russell, Michael S. Tsirkin, netfilter,
	netdev, linux-wireless, guohanjun

net_ratelimited_function() is called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 drivers/net/wimax/i2400m/netdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c
index 4889613..678717a 100644
--- a/drivers/net/wimax/i2400m/netdev.c
+++ b/drivers/net/wimax/i2400m/netdev.c
@@ -305,8 +305,7 @@ int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
 		 * queue -- blame the queue disciplines that
 		 * queue without looking -- I guess there is a reason
 		 * for that. */
-		if (net_ratelimit())
-			d_printf(1, dev, "NETTX: device exiting idle, "
+		net_ratelimited_function(d_printf, 1, dev, "NETTX: device exiting idle, "
 				 "dropping skb %p, queue running %d\n",
 				 skb, netif_queue_stopped(net_dev));
 		result = -EBUSY;
-- 
1.8.2.1



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

* Re: [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:44 ` [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code Kefeng Wang
@ 2013-10-15 16:24   ` Joe Perches
  2013-10-16  3:24     ` Kefeng Wang
  0 siblings, 1 reply; 23+ messages in thread
From: Joe Perches @ 2013-10-15 16:24 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: linux-kernel, Greg Kroah-Hartman, David S. Miller,
	Pablo Neira Ayuso, Stephen Hemminger, Johannes Berg,
	John W. Linville, Stanislaw Gruszka, Johannes Berg,
	Francois Romieu, Ben Hutchings, Chas Williams, Marc Kleine-Budde,
	Samuel Ortiz, Paul Mackerras, Oliver Neukum,
	Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel,
	Rusty Russell, Michael S. Tsirkin, netfilter, netdev,
	linux-wireless, guohanjun

On Tue, 2013-10-15 at 19:44 +0800, Kefeng Wang wrote:
> Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
> are called to simplify code.
[]
> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
[]
> @@ -465,10 +465,8 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
>  	if (likely(fdb)) {
>  		/* attempt to update an entry for a local interface */
>  		if (unlikely(fdb->is_local)) {
> -			if (net_ratelimit())
> -				br_warn(br, "received packet on %s with "
> -					"own address as source address\n",
> -					source->dev->name);
> +			net_ratelimited_function(br_warn, br, "received packet on %s "
> +				"with own address as source address\n", source->dev->name);

Hello Kefeng.

When these types of lines are changed, please coalesce the
fragmented format pieces into a single string.

It makes grep a bit easier and 80 columns limits don't
apply to formats.

I think using net_ratelimited_function is not particularly
clarifying here.

Maybe net_ratelimited_function should be removed instead
of its use sites expanded.

Perhaps adding macros like #define br_warn_ratelimited()
would be better.

This comment applies to the whole series.


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

* Re: [PATCH 14/18] net: usb: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 11:45 ` [PATCH 14/18] net: usb: " Kefeng Wang
@ 2013-10-15 19:06   ` Sergei Shtylyov
  2013-10-16  3:27     ` Kefeng Wang
  0 siblings, 1 reply; 23+ messages in thread
From: Sergei Shtylyov @ 2013-10-15 19:06 UTC (permalink / raw)
  To: Kefeng Wang
  Cc: linux-kernel, Greg Kroah-Hartman, David S. Miller,
	Pablo Neira Ayuso, Stephen Hemminger, Johannes Berg,
	John W. Linville, Stanislaw Gruszka, Johannes Berg,
	Francois Romieu, Ben Hutchings, Chas Williams, Marc Kleine-Budde,
	Samuel Ortiz, Paul Mackerras, Oliver Neukum,
	Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel,
	Rusty Russell, Michael S. Tsirkin, netfilter, netdev,
	linux-wireless, guohanjun

Hello.

On 10/15/2013 03:45 PM, Kefeng Wang wrote:

> net_ratelimited_function() is called to simplify code.

> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   drivers/net/usb/usbnet.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index bf94e10..edf81de 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -450,8 +450,8 @@ void usbnet_defer_kevent (struct usbnet *dev, int work)
>   {
>   	set_bit (work, &dev->flags);
>   	if (!schedule_work (&dev->kevent)) {
> -		if (net_ratelimit())
> -			netdev_err(dev->net, "kevent %d may have been dropped\n", work);
> +		net_ratelimited_function(netdev_err, dev->net,
> +			"kevent %d may have been dropped\n", work);

    The continuation line should start under 'netdev_err'. Same about the 
other patches where you didn't change the indentation of the continuation 
lines though you should have.

WBR, Sergei


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

* Re: [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 16:24   ` Joe Perches
@ 2013-10-16  3:24     ` Kefeng Wang
  0 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-16  3:24 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-kernel, Greg Kroah-Hartman, David S. Miller,
	Pablo Neira Ayuso, Stephen Hemminger, Johannes Berg,
	John W. Linville, Stanislaw Gruszka, Johannes Berg,
	Francois Romieu, Ben Hutchings, Chas Williams, Marc Kleine-Budde,
	Samuel Ortiz, Paul Mackerras, Oliver Neukum,
	Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel,
	Rusty Russell, Michael S. Tsirkin, netfilter, netdev,
	linux-wireless, guohanjun

Thanks for your reply.

On 10/16 0:24, Joe Perches wrote:
> On Tue, 2013-10-15 at 19:44 +0800, Kefeng Wang wrote:
>> Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
>> are called to simplify code.
> []
>> diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
> []
>> @@ -465,10 +465,8 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
>>  	if (likely(fdb)) {
>>  		/* attempt to update an entry for a local interface */
>>  		if (unlikely(fdb->is_local)) {
>> -			if (net_ratelimit())
>> -				br_warn(br, "received packet on %s with "
>> -					"own address as source address\n",
>> -					source->dev->name);
>> +			net_ratelimited_function(br_warn, br, "received packet on %s "
>> +				"with own address as source address\n", source->dev->name);
> 
> Hello Kefeng.
> 
> When these types of lines are changed, please coalesce the
> fragmented format pieces into a single string.
> 
> It makes grep a bit easier and 80 columns limits don't
> apply to formats.

Got it, I will coalesce them, but 80 columns limits will be
broken.

> I think using net_ratelimited_function is not particularly
> clarifying here.
> 
> Maybe net_ratelimited_function should be removed instead
> of its use sites expanded.
> 
> Perhaps adding macros like #define br_warn_ratelimited()
> would be better.

yes, I found dev_emerg_ratelimited already exists. I should
use them and will add some similar mcaros.

> This comment applies to the whole series.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> .
> 



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

* Re: [PATCH 14/18] net: usb: use wrapper functions of net_ratelimit() to simplify code
  2013-10-15 19:06   ` Sergei Shtylyov
@ 2013-10-16  3:27     ` Kefeng Wang
  0 siblings, 0 replies; 23+ messages in thread
From: Kefeng Wang @ 2013-10-16  3:27 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: linux-kernel, Greg Kroah-Hartman, David S. Miller,
	Pablo Neira Ayuso, Stephen Hemminger, Johannes Berg,
	John W. Linville, Stanislaw Gruszka, Johannes Berg,
	Francois Romieu, Ben Hutchings, Chas Williams, Marc Kleine-Budde,
	Samuel Ortiz, Paul Mackerras, Oliver Neukum,
	Konrad Rzeszutek Wilk, Boris Ostrovsky, David Vrabel,
	Rusty Russell, Michael S. Tsirkin, netfilter, netdev,
	linux-wireless, guohanjun

Thanks for you reply.
On 10/16 3:06, Sergei Shtylyov wrote:
> Hello.
> 
> On 10/15/2013 03:45 PM, Kefeng Wang wrote:
> 
>> net_ratelimited_function() is called to simplify code.
> 
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>>   drivers/net/usb/usbnet.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
>> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
>> index bf94e10..edf81de 100644
>> --- a/drivers/net/usb/usbnet.c
>> +++ b/drivers/net/usb/usbnet.c
>> @@ -450,8 +450,8 @@ void usbnet_defer_kevent (struct usbnet *dev, int work)
>>   {
>>       set_bit (work, &dev->flags);
>>       if (!schedule_work (&dev->kevent)) {
>> -        if (net_ratelimit())
>> -            netdev_err(dev->net, "kevent %d may have been dropped\n", work);
>> +        net_ratelimited_function(netdev_err, dev->net,
>> +            "kevent %d may have been dropped\n", work);
> 
>    The continuation line should start under 'netdev_err'. Same about the other patches where you didn't change the indentation of the continuation lines though you should have.

Got it, indentation will be changed.

> WBR, Sergei
> 
> 
> .
> 



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

end of thread, other threads:[~2013-10-16  3:29 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-15 11:44 [PATCH 00/18] cleanup: wrapper functions of net_ratelimit() called to simplify code Kefeng Wang
2013-10-15 11:44 ` [PATCH 01/18] netfilter: cleanup: delete Macro PRINTR Kefeng Wang
2013-10-15 11:44 ` [PATCH 02/18] net: use wrapper functions of net_ratelimit() to simplify code Kefeng Wang
2013-10-15 16:24   ` Joe Perches
2013-10-16  3:24     ` Kefeng Wang
2013-10-15 11:44 ` [PATCH 03/18] rt18187se: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 04/18] rt18192e: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 05/18] rt18192u: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 06/18] net: wireless: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 07/18] net: ethernet: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 08/18] atm: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 09/18] block: aoe: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 10/18] net: peak_usb: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 11/18] net: hamradio: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 12/18] net: irda: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 13/18] net: ppp: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 14/18] net: usb: " Kefeng Wang
2013-10-15 19:06   ` Sergei Shtylyov
2013-10-16  3:27     ` Kefeng Wang
2013-10-15 11:45 ` [PATCH 15/18] net: xen: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 16/18] net: virtio: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 17/18] net: vxlan: " Kefeng Wang
2013-10-15 11:45 ` [PATCH 18/18] net: wimax: " Kefeng Wang

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).