Netdev List
 help / color / mirror / Atom feed
* [PATCH net-2.6.24] s2io: sparse warnings fix (rev2)
From: Stephen Hemminger @ 2007-10-05 19:39 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: David S. Miller, Ramkrishna Vepa, Raapur Santosh,
	Sivakumar Subramani, Sreenivasa Honnur, netdev
In-Reply-To: <470679B7.2060901@pobox.com>

Fix warnings from sparse checker about shadowed definition and improperly
formatted ethtool_strings.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>

---
  CHECK   drivers/net/s2io.c
drivers/net/s2io.c:2892:15: warning: symbol 'lro' shadows an earlier one
drivers/net/s2io.c:471:1: originally declared here
drivers/net/s2io.c:7021:13: warning: symbol 'lro' shadows an earlier one
drivers/net/s2io.c:471:1: originally declared here
drivers/net/s2io.c:279:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:280:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:281:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:282:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:283:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:284:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:285:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:286:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:287:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:288:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:289:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:290:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:291:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:292:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:293:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:294:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:295:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:296:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:297:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:298:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:299:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:300:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:301:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:302:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:303:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:304:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:305:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:306:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:307:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:308:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:309:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:310:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:311:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:312:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:313:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:314:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:315:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:316:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:317:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:318:3: warning: array initialized from parenthesized string constant
drivers/net/s2io.c:1762:6: warning: symbol 'en_dis_err_alarms' was not declared. Should it be static?
include/linux/mm.h:587:9: warning: potentially expensive pointer subtraction
drivers/net/s2io.c:4231:5: warning: symbol 'do_s2io_chk_alarm_bit' was not declared. Should it be static?
drivers/net/s2io.c:7801:12: warning: symbol 's2io_starter' was not declared. Should it be static?


--- a/drivers/net/s2io.c	2007-10-05 11:53:55.000000000 -0700
+++ b/drivers/net/s2io.c	2007-10-05 11:58:44.000000000 -0700
@@ -38,7 +38,7 @@
  * Tx descriptors that can be associated with each corresponding FIFO.
  * intr_type: This defines the type of interrupt. The values can be 0(INTA),
  *     2(MSI_X). Default value is '2(MSI_X)'
- * lro: Specifies whether to enable Large Receive Offload (LRO) or not.
+ * lro_enable: Specifies whether to enable Large Receive Offload (LRO) or not.
  *     Possible values '1' for enable '0' for disable. Default is '0'
  * lro_max_pkts: This parameter defines maximum number of packets can be
  *     aggregated as a single large packet
@@ -276,46 +276,46 @@ static char ethtool_driver_stats_keys[][
 	{"ring_5_full_cnt"},
 	{"ring_6_full_cnt"},
 	{"ring_7_full_cnt"},
-	("alarm_transceiver_temp_high"),
-	("alarm_transceiver_temp_low"),
-	("alarm_laser_bias_current_high"),
-	("alarm_laser_bias_current_low"),
-	("alarm_laser_output_power_high"),
-	("alarm_laser_output_power_low"),
-	("warn_transceiver_temp_high"),
-	("warn_transceiver_temp_low"),
-	("warn_laser_bias_current_high"),
-	("warn_laser_bias_current_low"),
-	("warn_laser_output_power_high"),
-	("warn_laser_output_power_low"),
-	("lro_aggregated_pkts"),
-	("lro_flush_both_count"),
-	("lro_out_of_sequence_pkts"),
-	("lro_flush_due_to_max_pkts"),
-	("lro_avg_aggr_pkts"),
-	("mem_alloc_fail_cnt"),
-	("pci_map_fail_cnt"),
-	("watchdog_timer_cnt"),
-	("mem_allocated"),
-	("mem_freed"),
-	("link_up_cnt"),
-	("link_down_cnt"),
-	("link_up_time"),
-	("link_down_time"),
-	("tx_tcode_buf_abort_cnt"),
-	("tx_tcode_desc_abort_cnt"),
-	("tx_tcode_parity_err_cnt"),
-	("tx_tcode_link_loss_cnt"),
-	("tx_tcode_list_proc_err_cnt"),
-	("rx_tcode_parity_err_cnt"),
-	("rx_tcode_abort_cnt"),
-	("rx_tcode_parity_abort_cnt"),
-	("rx_tcode_rda_fail_cnt"),
-	("rx_tcode_unkn_prot_cnt"),
-	("rx_tcode_fcs_err_cnt"),
-	("rx_tcode_buf_size_err_cnt"),
-	("rx_tcode_rxd_corrupt_cnt"),
-	("rx_tcode_unkn_err_cnt"),
+	{"alarm_transceiver_temp_high"},
+	{"alarm_transceiver_temp_low"},
+	{"alarm_laser_bias_current_high"},
+	{"alarm_laser_bias_current_low"},
+	{"alarm_laser_output_power_high"},
+	{"alarm_laser_output_power_low"},
+	{"warn_transceiver_temp_high"},
+	{"warn_transceiver_temp_low"},
+	{"warn_laser_bias_current_high"},
+	{"warn_laser_bias_current_low"},
+	{"warn_laser_output_power_high"},
+	{"warn_laser_output_power_low"},
+	{"lro_aggregated_pkts"},
+	{"lro_flush_both_count"},
+	{"lro_out_of_sequence_pkts"},
+	{"lro_flush_due_to_max_pkts"},
+	{"lro_avg_aggr_pkts"},
+	{"mem_alloc_fail_cnt"},
+	{"pci_map_fail_cnt"},
+	{"watchdog_timer_cnt"},
+	{"mem_allocated"},
+	{"mem_freed"},
+	{"link_up_cnt"},
+	{"link_down_cnt"},
+	{"link_up_time"},
+	{"link_down_time"},
+	{"tx_tcode_buf_abort_cnt"},
+	{"tx_tcode_desc_abort_cnt"},
+	{"tx_tcode_parity_err_cnt"},
+	{"tx_tcode_link_loss_cnt"},
+	{"tx_tcode_list_proc_err_cnt"},
+	{"rx_tcode_parity_err_cnt"},
+	{"rx_tcode_abort_cnt"},
+	{"rx_tcode_parity_abort_cnt"},
+	{"rx_tcode_rda_fail_cnt"},
+	{"rx_tcode_unkn_prot_cnt"},
+	{"rx_tcode_fcs_err_cnt"},
+	{"rx_tcode_buf_size_err_cnt"},
+	{"rx_tcode_rxd_corrupt_cnt"},
+	{"rx_tcode_unkn_err_cnt"},
 	{"tda_err_cnt"},
 	{"pfc_err_cnt"},
 	{"pcc_err_cnt"},
@@ -468,7 +468,9 @@ S2IO_PARM_INT(rxsync_frequency, 3);
 /* Interrupt type. Values can be 0(INTA), 2(MSI_X) */
 S2IO_PARM_INT(intr_type, 2);
 /* Large receive offload feature */
-S2IO_PARM_INT(lro, 0);
+static unsigned int lro_enable;
+module_param_named(lro, lro_enable, uint, 0);
+
 /* Max pkts to be aggregated by LRO at one time. If not specified,
  * aggregation happens until we hit max IP pkt size(64K)
  */
@@ -1759,7 +1761,7 @@ static void do_s2io_write_bits(u64 value
 	writeq(temp64, addr);
 }
 
-void en_dis_err_alarms(struct s2io_nic *nic, u16 mask, int flag)
+static void en_dis_err_alarms(struct s2io_nic *nic, u16 mask, int flag)
 {
 	struct XENA_dev_config __iomem *bar0 = nic->bar0;
 	register u64 gen_int_mask = 0;
@@ -4228,7 +4230,7 @@ static void s2io_txpic_intr_handle(struc
  *  1 - if alarm bit set
  *  0 - if alarm bit is not set
  */
-int do_s2io_chk_alarm_bit(u64 value, void __iomem * addr,
+static int do_s2io_chk_alarm_bit(u64 value, void __iomem * addr,
 			  unsigned long long *cnt)
 {
 	u64 val64;
@@ -7135,7 +7137,8 @@ static int rx_osm_handler(struct ring_in
 				int ret = 0;
 
 				ret = s2io_club_tcp_session(skb->data, &tcp,
-						&tcp_len, &lro, rxdp, sp);
+							    &tcp_len, &lro,
+							    rxdp, sp);
 				switch (ret) {
 					case 3: /* Begin anew */
 						lro->parent = skb;
@@ -7451,7 +7454,7 @@ s2io_init_nic(struct pci_dev *pdev, cons
 	else
 		sp->device_type = XFRAME_I_DEVICE;
 
-	sp->lro = lro;
+	sp->lro = lro_enable;
 
 	/* Initialize some PCI/PCI-X fields of the NIC. */
 	s2io_init_pci(sp);
@@ -7798,7 +7801,7 @@ static void __devexit s2io_rem_nic(struc
  * the module loadable parameters and initializes PCI configuration space.
  */
 
-int __init s2io_starter(void)
+static int __init s2io_starter(void)
 {
 	return pci_register_driver(&s2io_driver);
 }


-- 
Stephen Hemminger <shemminger@linux-foundation.org>

^ permalink raw reply

* Re: e1000e oops
From: David Miller @ 2007-10-05 20:53 UTC (permalink / raw)
  To: max; +Cc: netdev, linux-kernel
In-Reply-To: <20071005131115.GA31453@stro.at>

From: maximilian attems <max@stro.at>
Date: Fri, 5 Oct 2007 15:11:15 +0200

> net eth1: device_rename: sysfs_create_symlink failed (-17)
 ...
> no idea if aboves belongs to netdev or sysfs dep.

I think the report belongs to udev.

It tries to rename network devices even if they already
have the name it desires.

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:12 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005084036.52dc943c@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:40:36 -0700

> WARNING: braces {} are not necessary for single statement blocks
> #691: FILE: drivers/net/niu.c:603:
> +	if (lp->loopback_mode == LOOPBACK_PHY) {
> +		test_cfg_val |= ((ENET_TEST_MD_PAD_LOOPBACK <<
> +				  ENET_SERDES_TEST_MD_0_SHIFT) |
> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
> +				  ENET_SERDES_TEST_MD_1_SHIFT) |
> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
> +				  ENET_SERDES_TEST_MD_2_SHIFT) |
> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
> +				  ENET_SERDES_TEST_MD_3_SHIFT));
> +	}

This is why I don't run checkpatch on my work.

This statement is a "single statement" but it's broken up
into multiple lines for readability, and it make perfect
sense to put braces around this basic block so it's easier
for humans to see what's going on.

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:12 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005083924.4e7f5d59@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:39:24 -0700

> Build failed on x86_64
> 
> ERROR: "__bad_udelay" [drivers/net/niu.ko] undefined!

Can you figure out which udelay() call is too big and
thus causing problems?

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: Jeff Garzik @ 2007-10-05 21:14 UTC (permalink / raw)
  To: David Miller
  Cc: shemminger, netdev, Ariel.Hendel, greg.onufer, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005.141217.41646184.davem@davemloft.net>

David Miller wrote:
> From: Stephen Hemminger <shemminger@linux-foundation.org>
> Date: Fri, 5 Oct 2007 08:40:36 -0700
> 
>> WARNING: braces {} are not necessary for single statement blocks
>> #691: FILE: drivers/net/niu.c:603:
>> +	if (lp->loopback_mode == LOOPBACK_PHY) {
>> +		test_cfg_val |= ((ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_0_SHIFT) |
>> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_1_SHIFT) |
>> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_2_SHIFT) |
>> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_3_SHIFT));
>> +	}
> 
> This is why I don't run checkpatch on my work.

IMO it -is- useful.

You just have to ignore some of its complaints.  Part of my coding style 
includes the multiple assignment thing that checkpatch complains about:

	status =
	msi->status = br32(QDMA_STAT);

and I am not going to stop doing that just because checkpatch complains :)


> This statement is a "single statement" but it's broken up
> into multiple lines for readability, and it make perfect
> sense to put braces around this basic block so it's easier
> for humans to see what's going on.

Strongly agreed.

	Jeff




^ permalink raw reply

* [PATCH 1/2] e1000: Simple optimizations in e1000_xmit_frame
From: Auke Kok @ 2007-10-05 21:15 UTC (permalink / raw)
  To: jeff; +Cc: netdev, krkumar2

From: Krishna Kumar <krkumar2@in.ibm.com>

Some simple optimizations in e1000_xmit_frame.

Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
---

 drivers/net/e1000/e1000_main.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 10505de..0472638 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -3261,14 +3261,13 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 	unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD;
 	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
 	unsigned int tx_flags = 0;
-	unsigned int len = skb->len;
+	unsigned int len = skb->len - skb->data_len;
 	unsigned long flags;
-	unsigned int nr_frags = 0;
-	unsigned int mss = 0;
+	unsigned int nr_frags;
+	unsigned int mss;
 	int count = 0;
 	int tso;
 	unsigned int f;
-	len -= skb->data_len;
 
 	/* This goes back to the question of how to logically map a tx queue
 	 * to a flow.  Right now, performance is impacted slightly negatively
@@ -3302,7 +3301,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 		* points to just header, pull a few bytes of payload from
 		* frags into skb->data */
 		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-		if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
+		if (skb->data_len && hdr_len == len) {
 			switch (adapter->hw.mac_type) {
 				unsigned int pull_size;
 			case e1000_82544:

^ permalink raw reply related

* [PATCH 2/2] e1000e: Simple optimizations in e1000_xmit_frame
From: Auke Kok @ 2007-10-05 21:15 UTC (permalink / raw)
  To: jeff; +Cc: netdev, krkumar2
In-Reply-To: <20071005211516.13167.80891.stgit@localhost.localdomain>

After an e1000 patch from Krishna Kumar <krkumar2@in.ibm.com>.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---

 drivers/net/e1000e/netdev.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 71c9fed..033e124 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3424,14 +3424,13 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 	unsigned int max_per_txd = E1000_MAX_PER_TXD;
 	unsigned int max_txd_pwr = E1000_MAX_TXD_PWR;
 	unsigned int tx_flags = 0;
-	unsigned int len = skb->len;
+	unsigned int len = skb->len - skb->data_len;
 	unsigned long irq_flags;
-	unsigned int nr_frags = 0;
-	unsigned int mss = 0;
+	unsigned int nr_frags;
+	unsigned int mss;
 	int count = 0;
 	int tso;
 	unsigned int f;
-	len -= skb->data_len;
 
 	if (test_bit(__E1000_DOWN, &adapter->state)) {
 		dev_kfree_skb_any(skb);
@@ -3459,7 +3458,7 @@ static int e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
 		* points to just header, pull a few bytes of payload from
 		* frags into skb->data */
 		hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
-		if (skb->data_len && (hdr_len == (skb->len - skb->data_len))) {
+		if (skb->data_len && (hdr_len == len)) {
 			unsigned int pull_size;
 
 			pull_size = min((unsigned int)4, skb->data_len);

^ permalink raw reply related

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:18 UTC (permalink / raw)
  To: netdev
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <200710051846.19965.netdev@axxeo.de>

From: Ingo Oeser <netdev@axxeo.de>
Date: Fri, 5 Oct 2007 18:46:19 +0200

> Could this driver be split into more files. 8k lines per file
> is quite a lot. Although GCC might optimize it best this way :-)

Absolutely not!!!!!!!

I hate multiple file drivers, with a passion, they absolutely and
positivel suck.  I cringe every time I have to study a driver that
is broken up into multiple files.

They are a nightmare to hack on.  You have to keep typing in grep
commands, be a cscope wizard, or whatever to search around and find
the file in which the function or variable you want to learn about.

If it's all in one file, you can just sit in your single editor
buffer and get a lot of work done.

And to top it off such multi-file drivers tend to be a lot larger
and thus even harder to understand.

Multi-file drivers, just say no.

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: Stephen Hemminger @ 2007-10-05 21:18 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005.141247.71101713.davem@davemloft.net>

On Fri, 05 Oct 2007 14:12:47 -0700 (PDT)
David Miller <davem@davemloft.net> wrote:

> From: Stephen Hemminger <shemminger@linux-foundation.org>
> Date: Fri, 5 Oct 2007 08:39:24 -0700
> 
> > Build failed on x86_64
> > 
> > ERROR: "__bad_udelay" [drivers/net/niu.ko] undefined!
> 
> Can you figure out which udelay() call is too big and
> thus causing problems?
--- a/drivers/net/niu.c	2007-10-05 08:09:31.000000000 -0700
+++ b/drivers/net/niu.c	2007-10-05 08:42:06.000000000 -0700
@@ -804,7 +804,7 @@ static int bcm8704_init_user_dev3(struct
 	if (err)
 		return err;
 
-	udelay(1000000);
+	mdelay(1000);
 
 	return 0;
 }


-- 
Stephen Hemminger <shemminger@linux-foundation.org>

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:20 UTC (permalink / raw)
  To: netdev
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <200710051846.19965.netdev@axxeo.de>

From: Ingo Oeser <netdev@axxeo.de>
Date: Fri, 5 Oct 2007 18:46:19 +0200

> David Miller schrieb:
> > +#define nr64(reg)		readq(np->regs + (reg))
> > +#define nw64(reg, val)		writeq((val), np->regs + (reg))
> > +
> > +#define nr64_mac(reg)		readq(np->mac_regs + (reg))
> > +#define nw64_mac(reg, val)	writeq((val), np->mac_regs + (reg))
> > +
> > +#define nr64_ipp(reg)		readq(np->regs + np->ipp_off + (reg))
> > +#define nw64_ipp(reg, val)	writeq((val), np->regs + np->ipp_off + (reg))
> > +
> > +#define nr64_pcs(reg)		readq(np->regs + np->pcs_off + (reg))
> > +#define nw64_pcs(reg, val)	writeq((val), np->regs + np->pcs_off + (reg))
> > +
> > +#define nr64_xpcs(reg)		readq(np->regs + np->xpcs_off + (reg))
> > +#define nw64_xpcs(reg, val)	writeq((val), np->regs + np->xpcs_off + (reg))
> 
> Can these be static inline and get the "struct niu *np" passed?

Absolutely not, this was discussed to death in the first review.  This
is a common sequence which is used in several driver, which saves a
lot of typing and carpel-tunnel syndrome.

^ permalink raw reply

* Re: e1000e oops, sysfs related?
From: Eric W. Biederman @ 2007-10-05 21:21 UTC (permalink / raw)
  To: Kok, Auke; +Cc: maximilian attems, netdev, linux-kernel, Greg KH
In-Reply-To: <47066838.7030209@intel.com>

"Kok, Auke" <auke-jan.h.kok@intel.com> writes:

> maximilian attems wrote:
>> Linux tau 2.6.23-rc8-mm2-686 #1 SMP Wed Oct 3 23:56:32 CEST 2007 i686
>> GNU/Linux
>> 
>> eth0 renamed to eth1
>> sysfs: duplicate filename 'eth1' can not be created
>> WARNING: at fs/sysfs/dir.c:433 sysfs_add_one()
>>  [<c0104f9c>] dump_trace+0x68/0x1d5
>>  [<c0105121>] show_trace_log_lvl+0x18/0x2c
>>  [<c0105b9b>] show_trace+0xf/0x11
>>  [<c0105c81>] dump_stack+0x12/0x14
>>  [<c01ac02e>] sysfs_add_one+0x54/0xb8
>>  [<c01acc2a>] sysfs_create_link+0xb3/0x125
>>  [<c023c05f>] device_rename+0x13d/0x196
>>  [<c025a970>] dev_change_name+0x137/0x205
>>  [<c025b12c>] dev_ioctl+0x357/0x44f
>>  [<c017b05f>] do_ioctl+0x1f/0x62
>>  [<c017b2d9>] vfs_ioctl+0x237/0x249
>>  [<c017b330>] sys_ioctl+0x45/0x5d
>>  [<c0103eda>] syscall_call+0x7/0xb
>>  [<b7edbde4>] 0xb7edbde4
>>  =======================
>> net eth1: device_rename: sysfs_create_symlink failed (-17)
>> 

> I'm seeing the same when removing/inserting network drivers frequently, ixgbe
> does
> the same thing: (git://davem/net-2.6.24)
>
> ixgbe 0000:01:00.0: (PCI Express:2.5Gb/s:Width x8) 00:1a:64:3b:81:c3
> ixgbe 0000:01:00.0: MAC: 0, PHY: 0, PBA No: d95854-003
> ixgbe 0000:01:00.0: Intel(R) 10 Gigabit Network Connection
> net eth2: device_rename: sysfs_create_symlink failed (-17)
>
> but I can't make it throw a stack trace.
>
> perhaps one of the sysfs knowledgeable people can take a look at this. We might
> be
> doing something wrong in e1000e / ixgbe at setup time, but I have no idea what.

To reach this path you need to run the equivalent of:
ip link set eth0 name eth1

I have seen this a bit and my memory is that the error is generally
harmless.  It is trying to create a symlink with the same name as the
directory or something like that.  Which makes with one setting of
CONFIG_SYSFS_DEPRECATED but not the other.

So I don't believe this is a driver bug, and I suspect the renames
come from using something like /etc/mactab which forces ethernet
devices with specific mac addresses to specific ethernet device
names.

With whatever is sitting in my development tree I'm pretty certain
this error isn't present.  I don't recall if I did anything specific
to fix this though.  In particular I don't recall if this still
happens with gregkh's queued sysfs patches applied.

Eric

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: Stephen Hemminger @ 2007-10-05 21:21 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: David Miller, netdev, Ariel.Hendel, greg.onufer, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <4706A937.3060304@garzik.org>

On Fri, 05 Oct 2007 17:14:31 -0400
Jeff Garzik <jeff@garzik.org> wrote:

> David Miller wrote:
> > From: Stephen Hemminger <shemminger@linux-foundation.org>
> > Date: Fri, 5 Oct 2007 08:40:36 -0700
> > 
> >> WARNING: braces {} are not necessary for single statement blocks
> >> #691: FILE: drivers/net/niu.c:603:
> >> +	if (lp->loopback_mode == LOOPBACK_PHY) {
> >> +		test_cfg_val |= ((ENET_TEST_MD_PAD_LOOPBACK <<
> >> +				  ENET_SERDES_TEST_MD_0_SHIFT) |
> >> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
> >> +				  ENET_SERDES_TEST_MD_1_SHIFT) |
> >> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
> >> +				  ENET_SERDES_TEST_MD_2_SHIFT) |
> >> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
> >> +				  ENET_SERDES_TEST_MD_3_SHIFT));
> >> +	}
> > 
> > This is why I don't run checkpatch on my work.
> 
> IMO it -is- useful.
> 
> You just have to ignore some of its complaints.  Part of my coding style 
> includes the multiple assignment thing that checkpatch complains about:
> 
> 	status =
> 	msi->status = br32(QDMA_STAT);
> 
> and I am not going to stop doing that just because checkpatch complains :)
> 
> 
> > This statement is a "single statement" but it's broken up
> > into multiple lines for readability, and it make perfect
> > sense to put braces around this basic block so it's easier
> > for humans to see what's going on.
> 
> Strongly agreed.
> 
> 	Jeff

Agreed, don't turn into a bot.
All it's complaints don't have to be fixed, same goes for sparse.
It just helps catch unintentional cruft.

-- 
Stephen Hemminger <shemminger@linux-foundation.org>

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:24 UTC (permalink / raw)
  To: Matheos.Worku
  Cc: netdev, netdev, Ariel.Hendel, Greg.Onufer, jeff, Ashley.Saulsbury
In-Reply-To: <470677A0.5060502@sun.com>


Matheos, no developers, including me, are going to read this since it
was in HTML, please post in plain ASCII text if you'd like to discuss
the driver with us, thanks.

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:38 UTC (permalink / raw)
  To: jeff
  Cc: shemminger, netdev, Ariel.Hendel, greg.onufer, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <4706A937.3060304@garzik.org>

From: Jeff Garzik <jeff@garzik.org>
Date: Fri, 05 Oct 2007 17:14:31 -0400

> You just have to ignore some of its complaints.  Part of my coding style 
> includes the multiple assignment thing that checkpatch complains about:
> 
> 	status =
> 	msi->status = br32(QDMA_STAT);
> 
> and I am not going to stop doing that just because checkpatch complains :)

Whilst I wouldn't condone this practice personally, I fail to
see a reason to prevent someone willing to write and maintain
a 10,000 line driver from doing so :-)

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 21:40 UTC (permalink / raw)
  To: shemminger
  Cc: jeff, netdev, Ariel.Hendel, greg.onufer, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005142148.14c57903@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 14:21:48 -0700

> All it's complaints don't have to be fixed, same goes for sparse.
> It just helps catch unintentional cruft.

That's true.

^ permalink raw reply

* Re: MSI interrupts and disable_irq
From: Eric W. Biederman @ 2007-10-05 22:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, linux-kernel
In-Reply-To: <20070928200801.28f9bab7@freepuppy.rosehill>

Stephen Hemminger <shemminger@linux-foundation.org> writes:

> On Fri, 28 Sep 2007 22:47:16 -0400
> Jeff Garzik <jgarzik@pobox.com> wrote:
>
>> Ayaz Abdulla wrote:
>> > I am trying to track down a forcedeth driver issue described by bug 9047 
>> > in bugzilla (2.6.23-rc7-git1 forcedeth w/ MCP55 oops under heavy load). 
>> > I added a patch to synchronize the timer handlers so that one handler 
>> > doesn't accidently enable the IRQ while another timer handler is running 
>> > (see attachment 'Add timer lock' in bug report) and for other processing 
>> > protection.
>> > 
>> > However, the system still had an Oops. So I added a lock around the 
>> > nv_rx_process_optimized() and the Oops has not happened (see attachment 
>> > 'New patch for locking' in bug report). This would imply a 
>> > synchronization issue. However, the only callers of that function are 
>> > the IRQ handler and the timer handlers (in non-NAPI case). The timer 
>> > handlers  use disable_irq so that the IRQ handler does not contend with 
>> > them. It looks as if disable_irq is not working properly.
>> > 
>> > This issue repros only with MSI interrupt and not legacy INTx 
>> > interrupts. Any ideas?
>> 
>> (added linux-kernel to CC, since I think it's more of a general kernel 
>> issue)

I didn't see anything in disable_irq that would cause it to fail in
the suggested way.  But I couldn't quite convince myself we were
race free either.  I didn't see anything that was specific to MSI
that would cause something.  But switching from level to edge
triggered, and to a lower latency delivery path may have caused
some behavior changes.

>> To be brutally frank, I always thought this disable_irq() mess was a 
>> hack both ugly and fragile.  This disable_irq() work that appeared in a 
>> couple net drivers was correct at the time, so I didn't feel I had the 
>> justification to reject it, but it still gave me a bad feeling.
>> 
>> I think the scenario you outline is an illustration of the approach's 
>> fragility:  disable_irq() is a heavy hammer that originated with INTx, 
>> and it relies on a chip-specific disable method (kernel/irq/manage.c) 
>> that practically guarantees behavior will vary across MSI/INTx/etc.
>> 
>> 
>> Based on your report, it is certainly possible that there is a problem 
>> with MSI's desc->chip->disable() method...  but I would actually 
>> recommend working around the problem by making the forcedeth locking 
>> more standardized by removing all those disable_irq() hacks.
>> 
>
> I'll try and clean it up if the author doesn't get to it first.

I took a look at the underlying side of this.

I don't know if the MSI capability for the forcedeth supports a mask
bit or not.  Mine doesn't even have a msi capability.  If it doesn't
support a mask bit the pci spec provides not valid way to mask the
interrupt, so what we do is actually disable the msi capability.
At which point we might get weird INTx interactions.

We have a similar case with ioapics and INTx that also turns
a hardware level disable into a reroute to another irq command.
So I'm going to take a look and see how infrequently we can use
hardware level disabled.

Since it looks like hardware level disables tend to be creatively
implemented I recommend using disable_irq as little as possible.

Eric

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: Matheos Worku @ 2007-10-05 22:18 UTC (permalink / raw)
  To: Ingo Oeser
  Cc: David Miller, netdev, Ariel.Hendel, Greg.Onufer, jeff,
	Ashley.Saulsbury
In-Reply-To: <200710051846.19965.netdev@axxeo.de>

Ingo Oeser wrote:
> Hi David,

Repost since my last post ended up being html
Regards,

matheos

> 
> some minor nits.

Some  Neptune HW  info to explain some of the constants ...

> 
> Could this driver be split into more files. 8k lines per file

>> +	case 0:
>> +		ctrl_reg = ENET_SERDES_0_CTRL_CFG;
>> +		test_cfg_reg = ENET_SERDES_0_TEST_CFG;
>> +		break;
>> +	case 1:
>> +		ctrl_reg = ENET_SERDES_1_CTRL_CFG;
>> +		test_cfg_reg = ENET_SERDES_1_TEST_CFG;
>> +		break;
>> +
>> +	default:
>> +		return -EINVAL;
>> +	}
> 
> 
> Maybe small table?
> 
>> +	ctrl_val = (ENET_SERDES_CTRL_SDET_0 |
>> +		    ENET_SERDES_CTRL_SDET_1 |
>> +		    ENET_SERDES_CTRL_SDET_2 |
>> +		    ENET_SERDES_CTRL_SDET_3 |
>> +		    (0x5 << ENET_SERDES_CTRL_EMPH_0_SHIFT) |
>> +		    (0x5 << ENET_SERDES_CTRL_EMPH_1_SHIFT) |
>> +		    (0x5 << ENET_SERDES_CTRL_EMPH_2_SHIFT) |
>> +		    (0x5 << ENET_SERDES_CTRL_EMPH_3_SHIFT) |
>> +		    (0x1 << ENET_SERDES_CTRL_LADJ_0_SHIFT) |
>> +		    (0x1 << ENET_SERDES_CTRL_LADJ_1_SHIFT) |
>> +		    (0x1 << ENET_SERDES_CTRL_LADJ_2_SHIFT) |
>> +		    (0x1 << ENET_SERDES_CTRL_LADJ_3_SHIFT));
>> +	test_cfg_val = 0;
>> +
>> +	if (lp->loopback_mode == LOOPBACK_PHY) {
>> +		test_cfg_val |= ((ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_0_SHIFT) |
>> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_1_SHIFT) |
>> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_2_SHIFT) |
>> +				 (ENET_TEST_MD_PAD_LOOPBACK <<
>> +				  ENET_SERDES_TEST_MD_3_SHIFT));
>> +	}
>> +
>> +	nw64(ctrl_reg, ctrl_val);
>> +	nw64(test_cfg_reg, test_cfg_val);
>> +
>> +	for (i = 0; i < 4; i++) {
> 
> why 4? (magic number)

The MAC HW has 4 SERDES lanes. Need to configure each lane.

> 
>> +		u32 rxtx_ctrl, glue0;
>> +		int err;
>> +
>> +		err = esr_read_rxtx_ctrl(np, i, &rxtx_ctrl);
>> +		if (err)
>> +			return err;
>> +		err = esr_read_glue0(np, i, &glue0);

>> +
> 

> 
> [...]
> 
>> +static void niu_set_max_burst(struct niu *np, struct tx_ring_info *rp)
>> +{
>> +	int mtu = np->dev->mtu;
>> +
>> +	rp->max_burst = mtu + 32;
>> +	if (rp->max_burst > 4096)
>> +		rp->max_burst = 4096;
> 
> Why 32 and 4096? (Magic values)

These values were recommended by the HW designers for fair utilization 
of DRR feature among TX/RX rings.

> 
>> +}
>> +
> 
> ... ok, I stop here, since this drivers is damn big :-)
> 
> Best Regards
> 
> Ingo Oeser


^ permalink raw reply

* [PATCH] e1000e: restore flow control settings properly
From: Auke Kok @ 2007-10-05 22:22 UTC (permalink / raw)
  To: jeff; +Cc: netdev

After a cable unplug the forced flow control settings were lost
accidentally and the flow control settings fell back to the default
EEPROM determined values. This breaks for people who want to
run without fc enabled - after a cable reset the driver would
refuse to run with fc disabled.

Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
---

 drivers/net/e1000e/ethtool.c |    1 +
 drivers/net/e1000e/lib.c     |   12 +++++++++---
 drivers/net/e1000e/netdev.c  |    1 +
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index 2e8218f..b7a7e2a 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -301,6 +301,7 @@ static int e1000_set_pauseparam(struct net_device *netdev,
 	hw->mac.original_fc = hw->mac.fc;
 
 	if (adapter->fc_autoneg == AUTONEG_ENABLE) {
+		hw->mac.fc = e1000_fc_default;
 		if (netif_running(adapter->netdev)) {
 			e1000e_down(adapter);
 			e1000e_up(adapter);
diff --git a/drivers/net/e1000e/lib.c b/drivers/net/e1000e/lib.c
index 3bbfe60..0bdeca3 100644
--- a/drivers/net/e1000e/lib.c
+++ b/drivers/net/e1000e/lib.c
@@ -639,9 +639,15 @@ s32 e1000e_setup_link(struct e1000_hw *hw)
 	if (e1000_check_reset_block(hw))
 		return 0;
 
-	ret_val = e1000_set_default_fc_generic(hw);
-	if (ret_val)
-		return ret_val;
+	/*
+	 * If flow control is set to default, set flow control based on
+	 * the EEPROM flow control settings.
+	 */
+	if (mac->fc == e1000_fc_default) {
+		ret_val = e1000_set_default_fc_generic(hw);
+		if (ret_val)
+			return ret_val;
+	}
 
 	/* We want to save off the original Flow Control configuration just
 	 * in case we get disconnected and then reconnected into a different
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 3a0bb2a..71c9fed 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4196,6 +4196,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 
 	/* Initialize link parameters. User can change them with ethtool */
 	adapter->hw.mac.autoneg = 1;
+	adapter->fc_autoneg = 1;
 	adapter->hw.mac.original_fc = e1000_fc_default;
 	adapter->hw.mac.fc = e1000_fc_default;
 	adapter->hw.phy.autoneg_advertised = 0x2f;

^ permalink raw reply related

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 22:43 UTC (permalink / raw)
  To: Matheos.Worku
  Cc: netdev, netdev, Ariel.Hendel, Greg.Onufer, jeff, Ashley.Saulsbury
In-Reply-To: <4706B83D.40306@sun.com>

From: Matheos Worku <Matheos.Worku@Sun.COM>
Date: Fri, 05 Oct 2007 15:18:37 -0700

> > 
> >> +static void niu_set_max_burst(struct niu *np, struct tx_ring_info *rp)
> >> +{
> >> +	int mtu = np->dev->mtu;
> >> +
> >> +	rp->max_burst = mtu + 32;
> >> +	if (rp->max_burst > 4096)
> >> +		rp->max_burst = 4096;
> > 
> > Why 32 and 4096? (Magic values)
> 
> These values were recommended by the HW designers for fair utilization 
> of DRR feature among TX/RX rings.

I'll add macro defines for these, thanks for the feedback.

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 22:49 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005083556.7076dd43@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:35:56 -0700

> These match with existing netif_msg_XXX and your
> driver already has msglvl ethtool hook.
 ...
> Do you really want to print all these at KERN_ERR level?

Both fixed, thanks!

>From c97391da9c6f0c92a9babdf7ecd569e2effa9828 Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@sunset.davemloft.net>
Date: Fri, 5 Oct 2007 15:41:43 -0700
Subject: [PATCH] [NIU]: Use netif_msg_*().

Suggested by Stephen Hemminger.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/niu.c |  100 +++++++++++++++++++++++++---------------------------
 1 files changed, 48 insertions(+), 52 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 0dfabbe..1d56a1a 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -86,34 +86,26 @@ MODULE_DEVICE_TABLE(pci, niu_pci_tbl);
 #define nr64_xpcs(reg)		readq(np->regs + np->xpcs_off + (reg))
 #define nw64_xpcs(reg, val)	writeq((val), np->regs + np->xpcs_off + (reg))
 
-static unsigned int niu_debug;
-#define NIU_DEBUG_INTERRUPT	0x00000001
-#define NIU_DEBUG_TX_WORK	0x00000002
-#define NIU_DEBUG_RX_WORK	0x00000004
-#define NIU_DEBUG_POLL		0x00000008
-#define NIU_DEBUG_PROBE		0x00010000
-#define NIU_DEBUG_MDIO		0x00020000
-#define NIU_DEBUG_MII		0x00040000
-#define NIU_DEBUG_INIT_HW	0x00080000
-#define NIU_DEBUG_STOP_HW	0x00100000
-
-module_param(niu_debug, int, 0);
-MODULE_PARM_DESC(niu_debug,
-"NIU bitmapped debugging message enable value:\n"
-"	0x00000001	Log interrupt events\n"
-"	0x00000002	Log TX work\n"
-"	0x00000004	Log RX work\n"
-"	0x00000008	Log NAPI poll\n"
-"	0x00010000	Log device probe events\n"
-"	0x00020000	Log MDIO reads and writes\n"
-"	0x00040000	Log MII reads and writes\n"
-"	0x00080000	Log HW initialization\n"
-"	0x00100000	Log HW shutdown\n"
-);
+#define NIU_MSG_DEFAULT (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
+
+static int niu_debug = 0;
+static int debug = -1;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "NIU debug level");
 
 #define niudbg(TYPE, f, a...) \
-do {	if (niu_debug & NIU_DEBUG_##TYPE) \
-		printk(KERN_ERR PFX f, ## a); \
+do {	if ((np)->msg_enable & NETIF_MSG_##TYPE) \
+		printk(KERN_DEBUG PFX f, ## a); \
+} while (0)
+
+#define niuinfo(TYPE, f, a...) \
+do {	if ((np)->msg_enable & NETIF_MSG_##TYPE) \
+		printk(KERN_INFO PFX f, ## a); \
+} while (0)
+
+#define niuwarn(TYPE, f, a...) \
+do {	if ((np)->msg_enable & NETIF_MSG_##TYPE) \
+		printk(KERN_WARNING PFX f, ## a); \
 } while (0)
 
 #define niu_lock_parent(np, flags) \
@@ -1071,7 +1063,7 @@ static int niu_link_status_common(struct niu *np, int link_up)
 	unsigned long flags;
 
 	if (!netif_carrier_ok(dev) && link_up) {
-		printk(KERN_INFO PFX "%s: Link is up at %s, %s duplex\n",
+		niuinfo(LINK, "%s: Link is up at %s, %s duplex\n",
 		       dev->name,
 		       (lp->active_speed == SPEED_10000 ?
 			"10Gb/sec" :
@@ -1088,7 +1080,7 @@ static int niu_link_status_common(struct niu *np, int link_up)
 
 		netif_carrier_on(dev);
 	} else if (netif_carrier_ok(dev) && !link_up) {
-		printk(KERN_WARNING PFX "%s: Link is down\n", dev->name);
+		niuwarn(LINK, "%s: Link is down\n", dev->name);
 		netif_carrier_off(dev);
 	}
 
@@ -2359,7 +2351,7 @@ static void niu_tx_work(struct niu *np, struct tx_ring_info *rp)
 
 	cons = rp->cons;
 
-	niudbg(TX_WORK, "%s: niu_tx_work() pkt_cnt[%u] cons[%d]\n",
+	niudbg(TX_DONE, "%s: niu_tx_work() pkt_cnt[%u] cons[%d]\n",
 	       np->dev->name, pkt_cnt, cons);
 
 	while (pkt_cnt--)
@@ -2395,7 +2387,7 @@ static int niu_rx_work(struct niu *np, struct rx_ring_info *rp, int budget)
 	mbox->rx_dma_ctl_stat = 0;
 	mbox->rcrstat_a = 0;
 
-	niudbg(RX_WORK, "%s: niu_rx_work(chan[%d]), stat[%llx] qlen=%d\n",
+	niudbg(RX_STATUS, "%s: niu_rx_work(chan[%d]), stat[%llx] qlen=%d\n",
 	       np->dev->name, rp->rx_channel, (unsigned long long) stat, qlen);
 
 	rcr_done = work_done = 0;
@@ -2429,7 +2421,7 @@ static int niu_poll_core(struct niu *np, struct niu_ldg *lp, int budget)
 	u32 rx_vec = (v0 & 0xffffffff);
 	int i, work_done = 0;
 
-	niudbg(POLL, "%s: niu_poll_core() v0[%016llx]\n",
+	niudbg(INTR, "%s: niu_poll_core() v0[%016llx]\n",
 	       np->dev->name, (unsigned long long) v0);
 
 	for (i = 0; i < np->num_tx_rings; i++) {
@@ -2823,7 +2815,7 @@ static void niu_rxchan_intr(struct niu *np, struct rx_ring_info *rp,
 		      RX_DMA_CTL_STAT_RCRTO);
 	nw64(RX_DMA_CTL_STAT(rp->rx_channel), stat_write);
 
-	niudbg(INTERRUPT, "%s: rxchan_intr stat[%llx]\n",
+	niudbg(INTR, "%s: rxchan_intr stat[%llx]\n",
 	       np->dev->name, (unsigned long long) stat);
 }
 
@@ -2832,7 +2824,7 @@ static void niu_txchan_intr(struct niu *np, struct tx_ring_info *rp,
 {
 	rp->tx_cs = nr64(TX_CS(rp->tx_channel));
 
-	niudbg(INTERRUPT, "%s: txchan_intr cs[%llx]\n",
+	niudbg(INTR, "%s: txchan_intr cs[%llx]\n",
 	       np->dev->name, (unsigned long long) rp->tx_cs);
 }
 
@@ -2890,7 +2882,7 @@ static irqreturn_t niu_interrupt(int irq, void *dev_id)
 	unsigned long flags;
 	u64 v0, v1, v2;
 
-	if (niu_debug & NIU_DEBUG_INTERRUPT)
+	if (netif_msg_intr(np))
 		printk(KERN_ERR PFX "niu_interrupt() ldg[%p](%d) ",
 		       lp, ldg);
 
@@ -2900,7 +2892,7 @@ static irqreturn_t niu_interrupt(int irq, void *dev_id)
 	v1 = nr64(LDSV1(ldg));
 	v2 = nr64(LDSV2(ldg));
 
-	if (niu_debug & NIU_DEBUG_INTERRUPT)
+	if (netif_msg_intr(np))
 		printk("v0[%llx] v1[%llx] v2[%llx]\n",
 		       (unsigned long long) v0,
 		       (unsigned long long) v1,
@@ -4581,12 +4573,12 @@ static int niu_init_hw(struct niu *np)
 {
 	int i, err;
 
-	niudbg(INIT_HW, "%s: Initialize TXC\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize TXC\n", np->dev->name);
 	niu_txc_enable_port(np, 1);
 	niu_txc_port_dma_enable(np, 1);
 	niu_txc_set_imask(np, 0);
 
-	niudbg(INIT_HW, "%s: Initialize TX channels\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize TX channels\n", np->dev->name);
 	for (i = 0; i < np->num_tx_rings; i++) {
 		struct tx_ring_info *rp = &np->tx_rings[i];
 
@@ -4595,27 +4587,27 @@ static int niu_init_hw(struct niu *np)
 			return err;
 	}
 
-	niudbg(INIT_HW, "%s: Initialize RX channels\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize RX channels\n", np->dev->name);
 	err = niu_init_rx_channels(np);
 	if (err)
 		goto out_uninit_tx_channels;
 
-	niudbg(INIT_HW, "%s: Initialize classifier\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize classifier\n", np->dev->name);
 	err = niu_init_classifier_hw(np);
 	if (err)
 		goto out_uninit_rx_channels;
 
-	niudbg(INIT_HW, "%s: Initialize ZCP\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize ZCP\n", np->dev->name);
 	err = niu_init_zcp(np);
 	if (err)
 		goto out_uninit_rx_channels;
 
-	niudbg(INIT_HW, "%s: Initialize IPP\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize IPP\n", np->dev->name);
 	err = niu_init_ipp(np);
 	if (err)
 		goto out_uninit_rx_channels;
 
-	niudbg(INIT_HW, "%s: Initialize MAC\n", np->dev->name);
+	niudbg(IFUP, "%s: Initialize MAC\n", np->dev->name);
 	err = niu_init_mac(np);
 	if (err)
 		goto out_uninit_ipp;
@@ -4623,16 +4615,16 @@ static int niu_init_hw(struct niu *np)
 	return 0;
 
 out_uninit_ipp:
-	niudbg(INIT_HW, "%s: Uninit IPP\n", np->dev->name);
+	niudbg(IFUP, "%s: Uninit IPP\n", np->dev->name);
 	niu_disable_ipp(np);
 
 out_uninit_rx_channels:
-	niudbg(INIT_HW, "%s: Uninit RX channels\n", np->dev->name);
+	niudbg(IFUP, "%s: Uninit RX channels\n", np->dev->name);
 	niu_stop_rx_channels(np);
 	niu_reset_rx_channels(np);
 
 out_uninit_tx_channels:
-	niudbg(INIT_HW, "%s: Uninit TX channels\n", np->dev->name);
+	niudbg(IFUP, "%s: Uninit TX channels\n", np->dev->name);
 	niu_stop_tx_channels(np);
 	niu_reset_tx_channels(np);
 
@@ -4641,25 +4633,25 @@ out_uninit_tx_channels:
 
 static void niu_stop_hw(struct niu *np)
 {
-	niudbg(STOP_HW, "%s: Disable interrupts\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Disable interrupts\n", np->dev->name);
 	niu_enable_interrupts(np, 0);
 
-	niudbg(STOP_HW, "%s: Disable RX MAC\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Disable RX MAC\n", np->dev->name);
 	niu_enable_rx_mac(np, 0);
 
-	niudbg(STOP_HW, "%s: Disable IPP\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Disable IPP\n", np->dev->name);
 	niu_disable_ipp(np);
 
-	niudbg(STOP_HW, "%s: Stop TX channels\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Stop TX channels\n", np->dev->name);
 	niu_stop_tx_channels(np);
 
-	niudbg(STOP_HW, "%s: Stop RX channels\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Stop RX channels\n", np->dev->name);
 	niu_stop_rx_channels(np);
 
-	niudbg(STOP_HW, "%s: Reset TX channels\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Reset TX channels\n", np->dev->name);
 	niu_reset_tx_channels(np);
 
-	niudbg(STOP_HW, "%s: Reset RX channels\n", np->dev->name);
+	niudbg(IFDOWN, "%s: Reset RX channels\n", np->dev->name);
 	niu_reset_rx_channels(np);
 }
 
@@ -7376,6 +7368,8 @@ static struct net_device * __devinit niu_alloc_and_init(struct device *gen_dev,
 	np->device = gen_dev;
 	np->ops = ops;
 
+	np->msg_enable = niu_debug;
+
 	spin_lock_init(&np->lock);
 	INIT_WORK(&np->reset_task, niu_reset_task);
 
@@ -7913,6 +7907,8 @@ static int __init niu_init(void)
 		       (PAGE_SIZE % (8 * 1024)) != 0 &&
 		       (PAGE_SIZE % (4 * 1024)) != 0)));
 
+	niu_debug = netif_msg_init(debug, NIU_MSG_DEFAULT);
+
 #ifdef CONFIG_SPARC64
 	err = of_register_driver(&niu_of_driver, &of_bus_type);
 #endif
-- 
1.5.3.3


^ permalink raw reply related

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 22:54 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005083556.7076dd43@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:35:56 -0700

> pr_info() ?

All corrected, thanks!

>From 11aaa8adc8e9141a440faaa3260ad5922c71eeda Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@sunset.davemloft.net>
Date: Fri, 5 Oct 2007 15:53:21 -0700
Subject: [PATCH] [NIU]: Use pr_info().

Suggested by Stephen Hemminger.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/niu.c |   78 ++++++++++++++++++++++++++--------------------------
 1 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 1d56a1a..92059d7 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -845,21 +845,21 @@ static int xcvr_init_10g(struct niu *np)
 			MII_STAT1000);
 	if (err < 0)
 		return err;
-	printk(KERN_INFO PFX "Port %u PMA_PMD(MII_STAT1000) [%04x]\n",
-	       np->port, err);
+	pr_info(PFX "Port %u PMA_PMD(MII_STAT1000) [%04x]\n",
+		np->port, err);
 
 	err = mdio_read(np, np->phy_addr, BCM8704_USER_DEV3_ADDR, 0x20);
 	if (err < 0)
 		return err;
-	printk(KERN_INFO PFX "Port %u USER_DEV3(0x20) [%04x]\n",
-	       np->port, err);
+	pr_info(PFX "Port %u USER_DEV3(0x20) [%04x]\n",
+		np->port, err);
 
 	err = mdio_read(np, np->phy_addr, BCM8704_PHYXS_DEV_ADDR,
 			MII_NWAYTEST);
 	if (err < 0)
 		return err;
-	printk(KERN_INFO PFX "Port %u PHYXS(MII_NWAYTEST) [%04x]\n",
-	       np->port, err);
+	pr_info(PFX "Port %u PHYXS(MII_NWAYTEST) [%04x]\n",
+		np->port, err);
 #endif
 
 	/* XXX dig this out it might not be so useful XXX */
@@ -885,11 +885,11 @@ static int xcvr_init_10g(struct niu *np)
 
 	if (analog_stat0 != 0x03fc) {
 		if ((analog_stat0 == 0x43bc) && (tx_alarm_status != 0)) {
-			printk(KERN_INFO PFX "Port %u cable not connected "
-			       "or bad cable.\n", np->port);
+			pr_info(PFX "Port %u cable not connected "
+				"or bad cable.\n", np->port);
 		} else if (analog_stat0 == 0x639c) {
-			printk(KERN_INFO PFX "Port %u optical module is bad "
-			       "or missing.\n", np->port);
+			pr_info(PFX "Port %u optical module is bad "
+				"or missing.\n", np->port);
 		}
 	}
 
@@ -6295,13 +6295,13 @@ static int __devinit phy_record(struct niu_parent *parent,
 			return 0;
 	}
 
-	printk(KERN_INFO PFX "niu%d: Found PHY %08x type %s at phy_port %u\n",
-	       parent->index, id,
-	       (type == PHY_TYPE_PMA_PMD ?
-		"PMA/PMD" :
-		(type == PHY_TYPE_PCS ?
-		 "PCS" : "MII")),
-	       phy_port);
+	pr_info("niu%d: Found PHY %08x type %s at phy_port %u\n",
+		parent->index, id,
+		(type == PHY_TYPE_PMA_PMD ?
+		 "PMA/PMD" :
+		 (type == PHY_TYPE_PCS ?
+		  "PCS" : "MII")),
+		phy_port);
 
 	if (p->cur[type] >= NIU_MAX_PORTS) {
 		printk(KERN_ERR PFX "Too many PHY ports.\n");
@@ -6365,11 +6365,11 @@ static void __devinit niu_n2_divide_channels(struct niu_parent *parent)
 		parent->rxchan_per_port[i] = (16 / num_ports);
 		parent->txchan_per_port[i] = (16 / num_ports);
 
-		printk(KERN_INFO PFX "niu%d: Port %u [%u RX chans] "
-		       "[%u TX chans]\n",
-		       parent->index, i,
-		       parent->rxchan_per_port[i],
-		       parent->txchan_per_port[i]);
+		pr_info(PFX "niu%d: Port %u [%u RX chans] "
+			"[%u TX chans]\n",
+			parent->index, i,
+			parent->rxchan_per_port[i],
+			parent->txchan_per_port[i]);
 	}
 }
 
@@ -6409,11 +6409,11 @@ static void __devinit niu_divide_channels(struct niu_parent *parent,
 			parent->rxchan_per_port[i] = rx_chans_per_1g;
 			parent->txchan_per_port[i] = tx_chans_per_1g;
 		}
-		printk(KERN_INFO PFX "niu%d: Port %u [%u RX chans] "
-		       "[%u TX chans]\n",
-		       parent->index, i,
-		       parent->rxchan_per_port[i],
-		       parent->txchan_per_port[i]);
+		pr_info(PFX "niu%d: Port %u [%u RX chans] "
+			"[%u TX chans]\n",
+			parent->index, i,
+			parent->rxchan_per_port[i],
+			parent->txchan_per_port[i]);
 		tot_rx += parent->rxchan_per_port[i];
 		tot_tx += parent->txchan_per_port[i];
 	}
@@ -6463,8 +6463,8 @@ static void __devinit niu_divide_rdc_groups(struct niu_parent *parent,
 			struct rdc_table *rt = &tp->tables[grp];
 			int slot;
 
-			printk(KERN_INFO PFX "niu%d: Port %d RDC tbl(%d) [ ",
-			       parent->index, i, tp->first_table_num + grp);
+			pr_info(PFX "niu%d: Port %d RDC tbl(%d) [ ",
+				parent->index, i, tp->first_table_num + grp);
 			for (slot = 0; slot < NIU_RDC_TABLE_SLOTS; slot++) {
 				rt->rxdma_channel[slot] =
 					rdc_channel_base + this_channel_offset;
@@ -7342,7 +7342,7 @@ static void __devinit niu_driver_version(void)
 	static int niu_version_printed = 0;
 
 	if (niu_version_printed++ == 0)
-		printk(KERN_INFO "%s", version);
+		pr_info("%s", version);
 }
 
 static struct net_device * __devinit niu_alloc_and_init(struct device *gen_dev,
@@ -7398,19 +7398,19 @@ static void __devinit niu_device_announce(struct niu *np)
 	struct net_device *dev = np->dev;
 	int i;
 
-	printk(KERN_INFO "%s: NIU Ethernet ", dev->name);
+	pr_info("%s: NIU Ethernet ", dev->name);
 	for (i = 0; i < 6; i++)
 		printk("%2.2x%c", dev->dev_addr[i],
 		       i == 5 ? '\n' : ':');
 
-	printk(KERN_INFO "%s: Port type[%s] mode[%s:%s] XCVR[%s] phy[%s]\n",
-	       dev->name,
-	       (np->flags & NIU_FLAGS_XMAC ? "XMAC" : "BMAC"),
-	       (np->flags & NIU_FLAGS_10G ? "10G" : "1G"),
-	       (np->flags & NIU_FLAGS_FIBER ? "FIBER" : "COPPER"),
-	       (np->mac_xcvr == MAC_XCVR_MII ? "MII" :
-		(np->mac_xcvr == MAC_XCVR_PCS ? "PCS" : "XPCS")),
-	       np->vpd.phy_type);
+	pr_info("%s: Port type[%s] mode[%s:%s] XCVR[%s] phy[%s]\n",
+		dev->name,
+		(np->flags & NIU_FLAGS_XMAC ? "XMAC" : "BMAC"),
+		(np->flags & NIU_FLAGS_10G ? "10G" : "1G"),
+		(np->flags & NIU_FLAGS_FIBER ? "FIBER" : "COPPER"),
+		(np->mac_xcvr == MAC_XCVR_MII ? "MII" :
+		 (np->mac_xcvr == MAC_XCVR_PCS ? "PCS" : "XPCS")),
+		np->vpd.phy_type);
 }
 
 static int __devinit niu_pci_init_one(struct pci_dev *pdev,
-- 
1.5.3.3


^ permalink raw reply related

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 22:56 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005083556.7076dd43@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:35:56 -0700

> > +static int __niu_wait_bits_clear(struct niu *np, unsigned long reg,
> > +				 u64 bits, int limit, int delay)
> > +{
> > +	BUILD_BUG_ON(limit <= 0 || delay < 0);
> 
> redundant you already checked

Good catch, fixed!

>From 63f926e5b11d3d03815aeb7bd769e8116a3061fb Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@sunset.davemloft.net>
Date: Fri, 5 Oct 2007 15:55:55 -0700
Subject: [PATCH] [NIU]: Remove redundant BUILD_BUG_ON() in __niu_wait_bits_clear().

Noticed by Stephen Hemminger.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/niu.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 92059d7..450d95e 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -192,7 +192,6 @@ static int __niu_set_and_wait_clear_ipp(struct niu *np, unsigned long reg,
 static int __niu_wait_bits_clear(struct niu *np, unsigned long reg,
 				 u64 bits, int limit, int delay)
 {
-	BUILD_BUG_ON(limit <= 0 || delay < 0);
 	while (--limit >= 0) {
 		u64 val = nr64(reg);
 
-- 
1.5.3.3


^ permalink raw reply related

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 23:07 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005083556.7076dd43@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:35:56 -0700

> > +		BUG_ON(!page);
> 
> BUG_ON checks for NULL are useless if the code following is
> just going to dereference the pointer anyway. 

Agreed, all such cases fixed in the patch below, thanks!

> > +	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
> > +		tb = &rp->tx_buffs[idx];
> > +		BUG_ON(tb->skb != NULL);
> 
> > +		np->ops->unmap_page(np->device, tb->mapping,
> > +				    skb_shinfo(skb)->frags[i].size,
> > +				    DMA_TO_DEVICE);
> 
> Shouldn't this be skb_shinfo(tb->skb)->frags...

Nope, look at the logic, the assertion is making surethat
tb->skb == NULL.

When transmitting, the first descriptor holds the SKB pointer
and the rest of the descriptors for that packet explicitly
set the slots' SKB to NULL.

> > +		idx = NEXT_TX(rp, idx);
> > +	}
> > +
> > +	dev_kfree_skb(skb);
> 
> Should be dev_kfree_skb_any() if you plan on supporting
> netconsole.

I have no such plans at this time :-)

I think I've covered all of your feedback from this email,
thanks again for the review.

>From 418d57645f3132241eb180f9d381ef6541745e23 Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@sunset.davemloft.net>
Date: Fri, 5 Oct 2007 16:04:16 -0700
Subject: [PATCH] [NIU]: Remove BUG_ON() NULL pointer checks.

As mentioned by Stephen Hemminger, these are superfluous
if we are about to dereference the thing anyways.  The
OOPS has the same effect and will show the problem just
as clearly.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/niu.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 450d95e..c29235e 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -2134,7 +2134,6 @@ static int niu_rx_pkt_ignore(struct niu *np, struct rx_ring_info *rp)
 		addr = (val & RCR_ENTRY_PKT_BUF_ADDR) <<
 			RCR_ENTRY_PKT_BUF_ADDR_SHIFT;
 		page = niu_find_rxpage(rp, addr, &link);
-		BUG_ON(!page);
 
 		rcr_size = rp->rbr_sizes[(val & RCR_ENTRY_PKTBUFSZ) >>
 					 RCR_ENTRY_PKTBUFSZ_SHIFT];
@@ -2185,7 +2184,6 @@ static int niu_process_rx_pkt(struct niu *np, struct rx_ring_info *rp)
 		addr = (val & RCR_ENTRY_PKT_BUF_ADDR) <<
 			RCR_ENTRY_PKT_BUF_ADDR_SHIFT;
 		page = niu_find_rxpage(rp, addr, &link);
-		BUG_ON(!page);
 
 		rcr_size = rp->rbr_sizes[(val & RCR_ENTRY_PKTBUFSZ) >>
 					 RCR_ENTRY_PKTBUFSZ_SHIFT];
@@ -2294,8 +2292,6 @@ static int release_tx_packet(struct niu *np, struct tx_ring_info *rp, int idx)
 	u64 tx_flags;
 	int i, len;
 
-	BUG_ON(!skb);
-
 	tp = (struct tx_pkt_hdr *) skb->data;
 	tx_flags = le64_to_cpup(&tp->flags);
 
-- 
1.5.3.3


^ permalink raw reply related

* Re: [ofa-general] InfiniBand/RDMA merge plans for 2.6.24
From: Roland Dreier @ 2007-10-05 23:10 UTC (permalink / raw)
  To: Sean Hefty; +Cc: general, linux-kernel, netdev
In-Reply-To: <000601c80525$0b661f30$ff0da8c0@amr.corp.intel.com>

 > I tested this by simulating a slow passive side responder, and it worked as
 > expected for those tests.  Using an MRA does add another MAD to the CM exchange,
 > which is why it is sent only after seeing a duplicate request.  Alternatively,
 > we can take the OFED module parameter patch.

What the heck, I added this for 2.6.24.  If it doesn't work out we can
back it out.

 - R.

^ permalink raw reply

* Re: [PATCH]: Third (final?) release of Sun Neptune driver
From: David Miller @ 2007-10-05 23:24 UTC (permalink / raw)
  To: shemminger
  Cc: netdev, Ariel.Hendel, greg.onufer, jeff, Ashley.Saulsbury,
	Matheos.Worku
In-Reply-To: <20071005083556.7076dd43@freepuppy.rosehill>

From: Stephen Hemminger <shemminger@linux-foundation.org>
Date: Fri, 5 Oct 2007 08:35:56 -0700

> > +static void niu_log_rxchan_errors(struct niu *np, struct rx_ring_info *rp,
> > +				  u64 stat)
> > +{
> > +	printk(KERN_ERR PFX "%s: RX channel %u errors ( ",
> > +	       np->dev->name, rp->rx_channel);
> dev_err??

I've made conversions over to dev_err() where possible.

Thanks!

>From cbc4b58382eab08aa231f23d21839c011b4c9f8c Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@sunset.davemloft.net>
Date: Fri, 5 Oct 2007 16:22:39 -0700
Subject: [PATCH] [NIU]: Use dev_err().

Suggested by Stephen Hemminger.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/niu.c |  317 +++++++++++++++++++++++++++--------------------------
 1 files changed, 161 insertions(+), 156 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index c29235e..1669a0f 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -137,10 +137,10 @@ static int __niu_set_and_wait_clear_mac(struct niu *np, unsigned long reg,
 	nw64_mac(reg, bits);
 	err = __niu_wait_bits_clear_mac(np, reg, bits, limit, delay);
 	if (err)
-		printk(KERN_ERR PFX "%s: bits (%llx) of register %s "
-		       "would not clear, val[%llx]\n",
-		       np->dev->name, (unsigned long long) bits, reg_name,
-		       (unsigned long long) nr64_mac(reg));
+		dev_err(np->device, PFX "%s: bits (%llx) of register %s "
+			"would not clear, val[%llx]\n",
+			np->dev->name, (unsigned long long) bits, reg_name,
+			(unsigned long long) nr64_mac(reg));
 	return err;
 }
 
@@ -177,10 +177,10 @@ static int __niu_set_and_wait_clear_ipp(struct niu *np, unsigned long reg,
 
 	err = __niu_wait_bits_clear_ipp(np, reg, bits, limit, delay);
 	if (err)
-		printk(KERN_ERR PFX "%s: bits (%llx) of register %s "
-		       "would not clear, val[%llx]\n",
-		       np->dev->name, (unsigned long long) bits, reg_name,
-		       (unsigned long long) nr64_ipp(reg));
+		dev_err(np->device, PFX "%s: bits (%llx) of register %s "
+			"would not clear, val[%llx]\n",
+			np->dev->name, (unsigned long long) bits, reg_name,
+			(unsigned long long) nr64_ipp(reg));
 	return err;
 }
 
@@ -218,10 +218,10 @@ static int __niu_set_and_wait_clear(struct niu *np, unsigned long reg,
 	nw64(reg, bits);
 	err = __niu_wait_bits_clear(np, reg, bits, limit, delay);
 	if (err)
-		printk(KERN_ERR PFX "%s: bits (%llx) of register %s "
-		       "would not clear, val[%llx]\n",
-		       np->dev->name, (unsigned long long) bits, reg_name,
-		       (unsigned long long) nr64(reg));
+		dev_err(np->device, PFX "%s: bits (%llx) of register %s "
+			"would not clear, val[%llx]\n",
+			np->dev->name, (unsigned long long) bits, reg_name,
+			(unsigned long long) nr64(reg));
 	return err;
 }
 
@@ -549,8 +549,9 @@ static int esr_reset(struct niu *np)
 	if (err)
 		return err;
 	if (reset != 0) {
-		printk(KERN_ERR PFX "Port %u ESR_RESET did not clear [%08x]\n",
-		       np->port, reset);
+		dev_err(np->device, PFX "Port %u ESR_RESET "
+			"did not clear [%08x]\n",
+			np->port, reset);
 		return -ENODEV;
 	}
 
@@ -670,8 +671,8 @@ static int serdes_init_10g(struct niu *np)
 	}
 
 	if ((sig & mask) != val) {
-		printk(KERN_ERR PFX "Port %u signal bits [%08x] are not "
-		       "[%08x]\n", np->port, (int) (sig & mask), (int) val);
+		dev_err(np->device, PFX "Port %u signal bits [%08x] are not "
+			"[%08x]\n", np->port, (int) (sig & mask), (int) val);
 		return -ENODEV;
 	}
 
@@ -729,8 +730,8 @@ static int bcm8704_reset(struct niu *np)
 			break;
 	}
 	if (limit < 0) {
-		printk(KERN_ERR PFX "Port %u PHY will not reset "
-		       "(bmcr=%04x)\n", np->port, (err & 0xffff));
+		dev_err(np->device, PFX "Port %u PHY will not reset "
+			"(bmcr=%04x)\n", np->port, (err & 0xffff));
 		return -ENODEV;
 	}
 	return 0;
@@ -910,8 +911,8 @@ static int mii_reset(struct niu *np)
 			break;
 	}
 	if (limit < 0) {
-		printk(KERN_ERR PFX "Port %u MII would not reset, "
-		       "bmcr[%04x]\n", np->port, err);
+		dev_err(np->device, PFX "Port %u MII would not reset, "
+			"bmcr[%04x]\n", np->port, err);
 		return -ENODEV;
 	}
 
@@ -1010,8 +1011,8 @@ static int mii_init_common(struct niu *np)
 	if (err < 0)
 		return err;
 #if 0
-	printk(KERN_ERR PFX "Port %u after MII init bmcr[%04x] bmsr[%04x]\n",
-	       np->port, bmcr, bmsr);
+	pr_info(PFX "Port %u after MII init bmcr[%04x] bmsr[%04x]\n",
+		np->port, bmcr, bmsr);
 #endif
 
 	return 0;
@@ -2462,8 +2463,8 @@ static int niu_poll(struct napi_struct *napi, int budget)
 static void niu_log_rxchan_errors(struct niu *np, struct rx_ring_info *rp,
 				  u64 stat)
 {
-	printk(KERN_ERR PFX "%s: RX channel %u errors ( ",
-	       np->dev->name, rp->rx_channel);
+	dev_err(np->device, PFX "%s: RX channel %u errors ( ",
+		np->dev->name, rp->rx_channel);
 
 	if (stat & RX_DMA_CTL_STAT_RBR_TMOUT)
 		printk("RBR_TMOUT ");
@@ -2502,8 +2503,8 @@ static int niu_rx_error(struct niu *np, struct rx_ring_info *rp)
 	u64 stat = nr64(RX_DMA_CTL_STAT(rp->rx_channel));
 	int err = 0;
 
-	printk(KERN_ERR PFX "%s: RX channel %u error, stat[%llx]\n",
-	       np->dev->name, rp->rx_channel, (unsigned long long) stat);
+	dev_err(np->device, PFX "%s: RX channel %u error, stat[%llx]\n",
+		np->dev->name, rp->rx_channel, (unsigned long long) stat);
 
 	niu_log_rxchan_errors(np, rp, stat);
 
@@ -2520,8 +2521,8 @@ static int niu_rx_error(struct niu *np, struct rx_ring_info *rp)
 static void niu_log_txchan_errors(struct niu *np, struct tx_ring_info *rp,
 				  u64 cs)
 {
-	printk(KERN_ERR PFX "%s: TX channel %u errors ( ",
-	       np->dev->name, rp->tx_channel);
+	dev_err(np->device, PFX "%s: TX channel %u errors ( ",
+		np->dev->name, rp->tx_channel);
 
 	if (cs & TX_CS_MBOX_ERR)
 		printk("MBOX ");
@@ -2551,12 +2552,12 @@ static int niu_tx_error(struct niu *np, struct tx_ring_info *rp)
 	logh = nr64(TX_RNG_ERR_LOGH(rp->tx_channel));
 	logl = nr64(TX_RNG_ERR_LOGL(rp->tx_channel));
 
-	printk(KERN_ERR PFX "%s: TX channel %u error, "
-	       "cs[%llx] logh[%llx] logl[%llx]\n",
-	       np->dev->name, rp->tx_channel,
-	       (unsigned long long) cs,
-	       (unsigned long long) logh,
-	       (unsigned long long) logl);
+	dev_err(np->device, PFX "%s: TX channel %u error, "
+		"cs[%llx] logh[%llx] logl[%llx]\n",
+		np->dev->name, rp->tx_channel,
+		(unsigned long long) cs,
+		(unsigned long long) logh,
+		(unsigned long long) logl);
 
 	niu_log_txchan_errors(np, rp, cs);
 
@@ -2575,9 +2576,9 @@ static int niu_mif_interrupt(struct niu *np)
 			phy_mdint = 1;
 	}
 
-	printk(KERN_ERR PFX "%s: MIF interrupt, "
-	       "stat[%llx] phy_mdint(%d)\n",
-	       np->dev->name, (unsigned long long) mif_status, phy_mdint);
+	dev_err(np->device, PFX "%s: MIF interrupt, "
+		"stat[%llx] phy_mdint(%d)\n",
+		np->dev->name, (unsigned long long) mif_status, phy_mdint);
 
 	return -ENODEV;
 }
@@ -2702,8 +2703,8 @@ static int niu_mac_interrupt(struct niu *np)
 
 static void niu_log_device_error(struct niu *np, u64 stat)
 {
-	printk(KERN_ERR PFX "%s: Core device errors ( ",
-	       np->dev->name);
+	dev_err(np->device, PFX "%s: Core device errors ( ",
+		np->dev->name);
 
 	if (stat & SYS_ERR_MASK_META2)
 		printk("META2 ");
@@ -2735,8 +2736,8 @@ static int niu_device_error(struct niu *np)
 {
 	u64 stat = nr64(SYS_ERR_STAT);
 
-	printk(KERN_ERR PFX "%s: Core device error, stat[%llx]\n",
-	       np->dev->name, (unsigned long long) stat);
+	dev_err(np->device, PFX "%s: Core device error, stat[%llx]\n",
+		np->dev->name, (unsigned long long) stat);
 
 	niu_log_device_error(np, stat);
 
@@ -2878,7 +2879,7 @@ static irqreturn_t niu_interrupt(int irq, void *dev_id)
 	u64 v0, v1, v2;
 
 	if (netif_msg_intr(np))
-		printk(KERN_ERR PFX "niu_interrupt() ldg[%p](%d) ",
+		printk(KERN_DEBUG PFX "niu_interrupt() ldg[%p](%d) ",
 		       lp, ldg);
 
 	spin_lock_irqsave(&np->lock, flags);
@@ -3013,8 +3014,8 @@ static int niu_alloc_rx_ring_info(struct niu *np,
 	if (!rp->mbox)
 		return -ENOMEM;
 	if ((unsigned long)rp->mbox & (64UL - 1)) {
-		printk(KERN_ERR PFX "%s: Coherent alloc gives misaligned "
-		       "RXDMA mailbox %p\n", np->dev->name, rp->mbox);
+		dev_err(np->device, PFX "%s: Coherent alloc gives misaligned "
+			"RXDMA mailbox %p\n", np->dev->name, rp->mbox);
 		return -EINVAL;
 	}
 
@@ -3024,8 +3025,8 @@ static int niu_alloc_rx_ring_info(struct niu *np,
 	if (!rp->rcr)
 		return -ENOMEM;
 	if ((unsigned long)rp->rcr & (64UL - 1)) {
-		printk(KERN_ERR PFX "%s: Coherent alloc gives misaligned "
-		       "RXDMA RCR table %p\n", np->dev->name, rp->rcr);
+		dev_err(np->device, PFX "%s: Coherent alloc gives misaligned "
+			"RXDMA RCR table %p\n", np->dev->name, rp->rcr);
 		return -EINVAL;
 	}
 	rp->rcr_table_size = MAX_RCR_RING_SIZE;
@@ -3037,8 +3038,8 @@ static int niu_alloc_rx_ring_info(struct niu *np,
 	if (!rp->rbr)
 		return -ENOMEM;
 	if ((unsigned long)rp->rbr & (64UL - 1)) {
-		printk(KERN_ERR PFX "%s: Coherent alloc gives misaligned "
-		       "RXDMA RBR table %p\n", np->dev->name, rp->rbr);
+		dev_err(np->device, PFX "%s: Coherent alloc gives misaligned "
+			"RXDMA RBR table %p\n", np->dev->name, rp->rbr);
 		return -EINVAL;
 	}
 	rp->rbr_table_size = MAX_RBR_RING_SIZE;
@@ -3068,8 +3069,8 @@ static int niu_alloc_tx_ring_info(struct niu *np,
 	if (!rp->mbox)
 		return -ENOMEM;
 	if ((unsigned long)rp->mbox & (64UL - 1)) {
-		printk(KERN_ERR PFX "%s: Coherent alloc gives misaligned "
-		       "TXDMA mailbox %p\n", np->dev->name, rp->mbox);
+		dev_err(np->device, PFX "%s: Coherent alloc gives misaligned "
+			"TXDMA mailbox %p\n", np->dev->name, rp->mbox);
 		return -EINVAL;
 	}
 
@@ -3079,8 +3080,8 @@ static int niu_alloc_tx_ring_info(struct niu *np,
 	if (!rp->descr)
 		return -ENOMEM;
 	if ((unsigned long)rp->descr & (64UL - 1)) {
-		printk(KERN_ERR PFX "%s: Coherent alloc gives misaligned "
-		       "TXDMA descr table %p\n", np->dev->name, rp->descr);
+		dev_err(np->device, PFX "%s: Coherent alloc gives misaligned "
+			"TXDMA descr table %p\n", np->dev->name, rp->descr);
 		return -EINVAL;
 	}
 
@@ -3353,10 +3354,10 @@ static int niu_init_one_tx_channel(struct niu *np, struct tx_ring_info *rp)
 
 	if (rp->descr_dma & ~(TX_RNG_CFIG_STADDR_BASE |
 			      TX_RNG_CFIG_STADDR)) {
-		printk(KERN_ERR PFX "%s: TX ring channel %d "
-		       "DMA addr (%llx) is not aligned.\n",
-		       np->dev->name, channel,
-		       (unsigned long long) rp->descr_dma);
+		dev_err(np->device, PFX "%s: TX ring channel %d "
+			"DMA addr (%llx) is not aligned.\n",
+			np->dev->name, channel,
+			(unsigned long long) rp->descr_dma);
 		return -EINVAL;
 	}
 
@@ -3373,10 +3374,10 @@ static int niu_init_one_tx_channel(struct niu *np, struct tx_ring_info *rp)
 
 	if (((rp->mbox_dma >> 32) & ~TXDMA_MBH_MBADDR) ||
 	    ((u32)rp->mbox_dma & ~TXDMA_MBL_MBADDR)) {
-		printk(KERN_ERR PFX "%s: TX ring channel %d "
-		       "MBOX addr (%llx) is has illegal bits.\n",
-		       np->dev->name, channel,
-		       (unsigned long long) rp->mbox_dma);
+		dev_err(np->device, PFX "%s: TX ring channel %d "
+			"MBOX addr (%llx) is has illegal bits.\n",
+			np->dev->name, channel,
+			(unsigned long long) rp->mbox_dma);
 		return -EINVAL;
 	}
 	nw64(TXDMA_MBH(channel), rp->mbox_dma >> 32);
@@ -3771,9 +3772,9 @@ static int niu_zcp_read(struct niu *np, int index, u64 *data)
 	err = niu_wait_bits_clear(np, ZCP_RAM_ACC, ZCP_RAM_ACC_BUSY,
 				  1000, 100);
 	if (err) {
-		printk(KERN_ERR PFX "%s: ZCP read busy won't clear, "
-		       "ZCP_RAM_ACC[%llx]\n", np->dev->name,
-		       (unsigned long long) nr64(ZCP_RAM_ACC));
+		dev_err(np->device, PFX "%s: ZCP read busy won't clear, "
+			"ZCP_RAM_ACC[%llx]\n", np->dev->name,
+			(unsigned long long) nr64(ZCP_RAM_ACC));
 		return err;
 	}
 
@@ -3785,9 +3786,9 @@ static int niu_zcp_read(struct niu *np, int index, u64 *data)
 	err = niu_wait_bits_clear(np, ZCP_RAM_ACC, ZCP_RAM_ACC_BUSY,
 				  1000, 100);
 	if (err) {
-		printk(KERN_ERR PFX "%s: ZCP read busy2 won't clear, "
-		       "ZCP_RAM_ACC[%llx]\n", np->dev->name,
-		       (unsigned long long) nr64(ZCP_RAM_ACC));
+		dev_err(np->device, PFX "%s: ZCP read busy2 won't clear, "
+			"ZCP_RAM_ACC[%llx]\n", np->dev->name,
+			(unsigned long long) nr64(ZCP_RAM_ACC));
 		return err;
 	}
 
@@ -4114,10 +4115,10 @@ static int niu_reset_tx_bmac(struct niu *np)
 		udelay(100);
 	}
 	if (limit < 0) {
-		printk(KERN_ERR PFX "Port %u TX BMAC would not reset, "
-		       "BTXMAC_SW_RST[%llx]\n",
-		       np->port,
-		       (unsigned long long) nr64_mac(BTXMAC_SW_RST));
+		dev_err(np->device, PFX "Port %u TX BMAC would not reset, "
+			"BTXMAC_SW_RST[%llx]\n",
+			np->port,
+			(unsigned long long) nr64_mac(BTXMAC_SW_RST));
 		return -ENODEV;
 	}
 
@@ -4220,10 +4221,10 @@ static int niu_reset_rx_xmac(struct niu *np)
 		udelay(100);
 	}
 	if (limit < 0) {
-		printk(KERN_ERR PFX "Port %u RX XMAC would not reset, "
-		       "XRXMAC_SW_RST[%llx]\n",
-		       np->port,
-		       (unsigned long long) nr64_mac(XRXMAC_SW_RST));
+		dev_err(np->device, PFX "Port %u RX XMAC would not reset, "
+			"XRXMAC_SW_RST[%llx]\n",
+			np->port,
+			(unsigned long long) nr64_mac(XRXMAC_SW_RST));
 		return -ENODEV;
 	}
 
@@ -4242,10 +4243,10 @@ static int niu_reset_rx_bmac(struct niu *np)
 		udelay(100);
 	}
 	if (limit < 0) {
-		printk(KERN_ERR PFX "Port %u RX BMAC would not reset, "
-		       "BRXMAC_SW_RST[%llx]\n",
-		       np->port,
-		       (unsigned long long) nr64_mac(BRXMAC_SW_RST));
+		dev_err(np->device, PFX "Port %u RX BMAC would not reset, "
+			"BRXMAC_SW_RST[%llx]\n",
+			np->port,
+			(unsigned long long) nr64_mac(BRXMAC_SW_RST));
 		return -ENODEV;
 	}
 
@@ -4547,11 +4548,11 @@ static void niu_disable_ipp(struct niu *np)
 	}
 	if (limit < 0 &&
 	    (rd != 0 && wr != 1)) {
-		printk(KERN_ERR PFX "%s: IPP would not quiesce, "
-		       "rd_ptr[%llx] wr_ptr[%llx]\n",
-		       np->dev->name,
-		       (unsigned long long) nr64_ipp(IPP_DFIFO_RD_PTR),
-		       (unsigned long long) nr64_ipp(IPP_DFIFO_WR_PTR));
+		dev_err(np->device, PFX "%s: IPP would not quiesce, "
+			"rd_ptr[%llx] wr_ptr[%llx]\n",
+			np->dev->name,
+			(unsigned long long) nr64_ipp(IPP_DFIFO_RD_PTR),
+			(unsigned long long) nr64_ipp(IPP_DFIFO_WR_PTR));
 	}
 
 	val = nr64_ipp(IPP_CFIG);
@@ -5068,8 +5069,8 @@ static void niu_tx_timeout(struct net_device *dev)
 {
 	struct niu *np = netdev_priv(dev);
 
-	printk(KERN_ERR PFX "%s: Transmit timed out, resetting\n",
-	       dev->name);
+	dev_err(np->device, PFX "%s: Transmit timed out, resetting\n",
+		dev->name);
 
 	schedule_work(&np->reset_task);
 }
@@ -5171,8 +5172,8 @@ static int niu_start_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	if (niu_tx_avail(rp) <= (skb_shinfo(skb)->nr_frags + 1)) {
 		netif_stop_queue(dev);
-		printk(KERN_ERR PFX "%s: BUG! Tx ring full when "
-		       "queue awake!\n", dev->name);
+		dev_err(np->device, PFX "%s: BUG! Tx ring full when "
+			"queue awake!\n", dev->name);
 		rp->tx_errors++;
 		return NETDEV_TX_BUSY;
 	}
@@ -5687,10 +5688,11 @@ static int niu_ldg_assign_ldn(struct niu *np, struct niu_parent *parent,
 		 * interrupts and that's painful to debug.
 		 */
 		if (nr64(LDG_NUM(ldn)) != ldg) {
-			printk(KERN_ERR PFX "Port %u, mis-matched LDG assignment "
-			       "for ldn %d, should be %d is %llu\n",
-			       np->port, ldn, ldg,
-			       (unsigned long long) nr64(LDG_NUM(ldn)));
+			dev_err(np->device, PFX "Port %u, mis-matched "
+				"LDG assignment "
+				"for ldn %d, should be %d is %llu\n",
+				np->port, ldn, ldg,
+				(unsigned long long) nr64(LDG_NUM(ldn)));
 			return -EINVAL;
 		}
 	} else
@@ -5741,8 +5743,8 @@ static int __devinit niu_pci_eeprom_read(struct niu *np, u32 addr)
 			break;
 	} while (limit--);
 	if (!(frame & ESPC_PIO_STAT_READ_END)) {
-		printk(KERN_ERR PFX "EEPROM read timeout frame[%llx]\n",
-		       (unsigned long long) frame);
+		dev_err(np->device, PFX "EEPROM read timeout frame[%llx]\n",
+			(unsigned long long) frame);
 		return -ENODEV;
 	}
 
@@ -5756,8 +5758,8 @@ static int __devinit niu_pci_eeprom_read(struct niu *np, u32 addr)
 			break;
 	} while (limit--);
 	if (!(frame & ESPC_PIO_STAT_READ_END)) {
-		printk(KERN_ERR PFX "EEPROM read timeout frame[%llx]\n",
-		       (unsigned long long) frame);
+		dev_err(np->device, PFX "EEPROM read timeout frame[%llx]\n",
+			(unsigned long long) frame);
 		return -ENODEV;
 	}
 
@@ -5913,8 +5915,8 @@ static int __devinit niu_pci_vpd_scan_props(struct niu *np,
 		}
 
 		if (max_len && prop_len > max_len) {
-			printk(KERN_ERR PFX "Property '%s' length (%d) is "
-			       "too long.\n", namebuf, prop_len);
+			dev_err(np->device, PFX "Property '%s' length (%d) is "
+				"too long.\n", namebuf, prop_len);
 			return -EINVAL;
 		}
 
@@ -6060,17 +6062,17 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
 	u8 val8;
 
 	if (!is_valid_ether_addr(&vpd->local_mac[0])) {
-		printk(KERN_ERR PFX "VPD MAC invalid, "
-		       "falling back to SPROM.\n");
+		dev_err(np->device, PFX "VPD MAC invalid, "
+			"falling back to SPROM.\n");
 
 		np->flags &= ~NIU_FLAGS_VPD_VALID;
 		return;
 	}
 
 	if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) {
-		printk(KERN_ERR PFX "Illegal phy string [%s].\n",
-		       np->vpd.phy_type);
-		printk(KERN_ERR PFX "Falling back to SPROM.\n");
+		dev_err(np->device, PFX "Illegal phy string [%s].\n",
+			np->vpd.phy_type);
+		dev_err(np->device, PFX "Falling back to SPROM.\n");
 		np->flags &= ~NIU_FLAGS_VPD_VALID;
 		return;
 	}
@@ -6110,8 +6112,8 @@ static int __devinit niu_pci_probe_sprom(struct niu *np)
 	}
 	niudbg(PROBE, "SPROM: Checksum %x\n", (int)(sum & 0xff));
 	if ((sum & 0xff) != 0xab) {
-		printk(KERN_ERR PFX "Bad SPROM checksum "
-		       "(%x, should be 0xab)\n", (int) (sum & 0xff));
+		dev_err(np->device, PFX "Bad SPROM checksum "
+			"(%x, should be 0xab)\n", (int) (sum & 0xff));
 		return -EINVAL;
 	}
 
@@ -6134,8 +6136,8 @@ static int __devinit niu_pci_probe_sprom(struct niu *np)
 			ESPC_PHY_TYPE_PORT3_SHIFT;
 		break;
 	default:
-		printk(KERN_ERR PFX "Bogus port number %u\n",
-		       np->port);
+		dev_err(np->device, PFX "Bogus port number %u\n",
+			np->port);
 		return -EINVAL;
 	}
 	niudbg(PROBE, "SPROM: PHY type %llx\n", (unsigned long long) val);
@@ -6170,8 +6172,8 @@ static int __devinit niu_pci_probe_sprom(struct niu *np)
 		break;
 
 	default:
-		printk(KERN_ERR PFX "Bogus SPROM phy type %llu\n",
-		       (unsigned long long) val);
+		dev_err(np->device, PFX "Bogus SPROM phy type %llu\n",
+			(unsigned long long) val);
 		return -EINVAL;
 	}
 
@@ -6190,8 +6192,8 @@ static int __devinit niu_pci_probe_sprom(struct niu *np)
 	dev->perm_addr[5] = (val >>  8) & 0xff;
 
 	if (!is_valid_ether_addr(&dev->perm_addr[0])) {
-		printk(KERN_ERR PFX "SPROM MAC address invalid\n");
-		printk(KERN_ERR PFX "[ \n");
+		dev_err(np->device, PFX "SPROM MAC address invalid\n");
+		dev_err(np->device, PFX "[ \n");
 		for (i = 0; i < 6; i++)
 			printk("%02x ", dev->perm_addr[i]);
 		printk("]\n");
@@ -6716,8 +6718,8 @@ static int __devinit niu_init_mac_ipp_pcs_base(struct niu *np)
 		break;
 
 	default:
-		printk(KERN_ERR PFX "Port %u is invalid, cannot "
-		       "compute MAC block offset.\n", np->port);
+		dev_err(np->device, PFX "Port %u is invalid, cannot "
+			"compute MAC block offset.\n", np->port);
 		return -EINVAL;
 	}
 
@@ -6926,8 +6928,9 @@ static int __devinit niu_get_of_props(struct niu *np)
 
 	phy_type = of_get_property(dp, "phy-type", &prop_len);
 	if (!phy_type) {
-		printk(KERN_ERR PFX "%s: OF node lacks phy-type property\n",
-		       dp->full_name);
+		dev_err(np->device, PFX "%s: OF node lacks "
+			"phy-type property\n",
+			dp->full_name);
 		return -EINVAL;
 	}
 
@@ -6937,29 +6940,31 @@ static int __devinit niu_get_of_props(struct niu *np)
 	strcpy(np->vpd.phy_type, phy_type);
 
 	if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) {
-		printk(KERN_ERR PFX "%s: Illegal phy string [%s].\n",
-		       dp->full_name, np->vpd.phy_type);
+		dev_err(np->device, PFX "%s: Illegal phy string [%s].\n",
+			dp->full_name, np->vpd.phy_type);
 		return -EINVAL;
 	}
 
 	mac_addr = of_get_property(dp, "local-mac-address", &prop_len);
 	if (!mac_addr) {
-		printk(KERN_ERR PFX "%s: OF node lacks local-mac-address property\n",
-		       dp->full_name);
+		dev_err(np->device, PFX "%s: OF node lacks "
+			"local-mac-address property\n",
+			dp->full_name);
 		return -EINVAL;
 	}
 	if (prop_len != dev->addr_len) {
-		printk(KERN_ERR PFX "%s: OF MAC address prop len (%d) is wrong.\n",
-		       dp->full_name, prop_len);
+		dev_err(np->device, PFX "%s: OF MAC address prop len (%d) "
+			"is wrong.\n",
+			dp->full_name, prop_len);
 	}
 	memcpy(dev->perm_addr, mac_addr, dev->addr_len);
 	if (!is_valid_ether_addr(&dev->perm_addr[0])) {
 		int i;
 
-		printk(KERN_ERR PFX "%s: OF MAC address is invalid\n",
-		       dp->full_name);
-		printk(KERN_ERR PFX "%s: [ \n",
-		       dp->full_name);
+		dev_err(np->device, PFX "%s: OF MAC address is invalid\n",
+			dp->full_name);
+		dev_err(np->device, PFX "%s: [ \n",
+			dp->full_name);
 		for (i = 0; i < 6; i++)
 			printk("%02x ", dev->perm_addr[i]);
 		printk("]\n");
@@ -7350,7 +7355,7 @@ static struct net_device * __devinit niu_alloc_and_init(struct device *gen_dev,
 	struct niu *np;
 
 	if (!dev) {
-		printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
+		dev_err(gen_dev, PFX "Etherdev alloc failed, aborting.\n");
 		return NULL;
 	}
 
@@ -7423,30 +7428,30 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev,
 
 	err = pci_enable_device(pdev);
 	if (err) {
-		printk(KERN_ERR PFX "Cannot enable PCI device, "
-		       "aborting.\n");
+		dev_err(&pdev->dev, PFX "Cannot enable PCI device, "
+			"aborting.\n");
 		return err;
 	}
 
 	if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM) ||
 	    !(pci_resource_flags(pdev, 2) & IORESOURCE_MEM)) {
-		printk(KERN_ERR PFX "Cannot find proper PCI device "
-		       "base addresses, aborting.\n");
+		dev_err(&pdev->dev, PFX "Cannot find proper PCI device "
+			"base addresses, aborting.\n");
 		err = -ENODEV;
 		goto err_out_disable_pdev;
 	}
 
 	err = pci_request_regions(pdev, DRV_MODULE_NAME);
 	if (err) {
-		printk(KERN_ERR PFX "Cannot obtain PCI resources, "
-		       "aborting.\n");
+		dev_err(&pdev->dev, PFX "Cannot obtain PCI resources, "
+			"aborting.\n");
 		goto err_out_disable_pdev;
 	}
 
 	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
 	if (pos <= 0) {
-		printk(KERN_ERR PFX "Cannot find PCI Express capability, "
-		       "aborting.\n");
+		dev_err(&pdev->dev, PFX "Cannot find PCI Express capability, "
+			"aborting.\n");
 		goto err_out_free_res;
 	}
 
@@ -7485,17 +7490,17 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev,
 		dev->features |= NETIF_F_HIGHDMA;
 		err = pci_set_consistent_dma_mask(pdev, dma_mask);
 		if (err) {
-			printk(KERN_ERR PFX "Unable to obtain 44 bit "
-			       "DMA for consistent allocations, "
-			       "aborting.\n");
+			dev_err(&pdev->dev, PFX "Unable to obtain 44 bit "
+				"DMA for consistent allocations, "
+				"aborting.\n");
 			goto err_out_release_parent;
 		}
 	}
 	if (err || dma_mask == DMA_32BIT_MASK) {
 		err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
 		if (err) {
-			printk(KERN_ERR PFX "No usable DMA configuration, "
-			       "aborting.\n");
+			dev_err(&pdev->dev, PFX "No usable DMA configuration, "
+				"aborting.\n");
 			goto err_out_release_parent;
 		}
 	}
@@ -7507,8 +7512,8 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev,
 
 	np->regs = ioremap_nocache(niureg_base, niureg_len);
 	if (!np->regs) {
-		printk(KERN_ERR PFX "Cannot map device registers, "
-		       "aborting.\n");
+		dev_err(&pdev->dev, PFX "Cannot map device registers, "
+			"aborting.\n");
 		err = -ENOMEM;
 		goto err_out_release_parent;
 	}
@@ -7523,15 +7528,15 @@ static int __devinit niu_pci_init_one(struct pci_dev *pdev,
 	err = niu_get_invariants(np);
 	if (err) {
 		if (err != -ENODEV)
-			printk(KERN_ERR PFX "Problem fetching invariants "
-			       "of chip, aborting.\n");
+			dev_err(&pdev->dev, PFX "Problem fetching invariants "
+				"of chip, aborting.\n");
 		goto err_out_iounmap;
 	}
 
 	err = register_netdev(dev);
 	if (err) {
-		printk(KERN_ERR PFX "Cannot register net device, "
-		       "aborting.\n");
+		dev_err(&pdev->dev, PFX "Cannot register net device, "
+			"aborting.\n");
 		goto err_out_iounmap;
 	}
 
@@ -7729,8 +7734,8 @@ static int __devinit niu_of_probe(struct of_device *op, const struct of_device_i
 
 	reg = of_get_property(op->node, "reg", NULL);
 	if (!reg) {
-		printk(KERN_ERR PFX "%s: No 'reg' property, aborting.\n",
-		       op->node->full_name);
+		dev_err(&op->dev, PFX "%s: No 'reg' property, aborting.\n",
+			op->node->full_name);
 		return -ENODEV;
 	}
 
@@ -7758,8 +7763,8 @@ static int __devinit niu_of_probe(struct of_device *op, const struct of_device_i
 			      res_size(&op->resource[1]),
 			      "niu regs");
 	if (!np->regs) {
-		printk(KERN_ERR PFX "Cannot map device registers, "
-		       "aborting.\n");
+		dev_err(&op->dev, PFX "Cannot map device registers, "
+			"aborting.\n");
 		err = -ENOMEM;
 		goto err_out_release_parent;
 	}
@@ -7768,8 +7773,8 @@ static int __devinit niu_of_probe(struct of_device *op, const struct of_device_i
 				    res_size(&op->resource[2]),
 				    "niu vregs-1");
 	if (!np->vir_regs_1) {
-		printk(KERN_ERR PFX "Cannot map device vir registers 1, "
-		       "aborting.\n");
+		dev_err(&op->dev, PFX "Cannot map device vir registers 1, "
+			"aborting.\n");
 		err = -ENOMEM;
 		goto err_out_iounmap;
 	}
@@ -7778,8 +7783,8 @@ static int __devinit niu_of_probe(struct of_device *op, const struct of_device_i
 				    res_size(&op->resource[3]),
 				    "niu vregs-2");
 	if (!np->vir_regs_2) {
-		printk(KERN_ERR PFX "Cannot map device vir registers 2, "
-		       "aborting.\n");
+		dev_err(&op->dev, PFX "Cannot map device vir registers 2, "
+			"aborting.\n");
 		err = -ENOMEM;
 		goto err_out_iounmap;
 	}
@@ -7789,15 +7794,15 @@ static int __devinit niu_of_probe(struct of_device *op, const struct of_device_i
 	err = niu_get_invariants(np);
 	if (err) {
 		if (err != -ENODEV)
-			printk(KERN_ERR PFX "Problem fetching invariants "
-			       "of chip, aborting.\n");
+			dev_err(&op->dev, PFX "Problem fetching invariants "
+				"of chip, aborting.\n");
 		goto err_out_iounmap;
 	}
 
 	err = register_netdev(dev);
 	if (err) {
-		printk(KERN_ERR PFX "Cannot register net device, "
-		       "aborting.\n");
+		dev_err(&op->dev, PFX "Cannot register net device, "
+			"aborting.\n");
 		goto err_out_iounmap;
 	}
 
-- 
1.5.3.3


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox