* [PATCH 5/9][TG3]: Add tg3_poll_fw().
@ 2006-09-27 20:34 Michael Chan
2006-09-27 20:47 ` Jeff Garzik
2006-09-27 23:03 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Michael Chan @ 2006-09-27 20:34 UTC (permalink / raw)
To: davem, linville; +Cc: netdev
[TG3]: Add tg3_poll_fw().
Put the firmware polling logic into a separate function. This makes
the code cleaner.
Signed-off-by: Michael Chan <mchan@broadcom.com>
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index d443b73..eafca2a 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -4662,6 +4662,35 @@ static void tg3_write_sig_legacy(struct
}
}
+static int tg3_poll_fw(struct tg3 *tp)
+{
+ int i;
+ u32 val;
+
+ /* Wait for firmware initialization to complete. */
+ for (i = 0; i < 100000; i++) {
+ tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val);
+ if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
+ break;
+ udelay(10);
+ }
+
+ /* Chip might not be fitted with firmware. Some Sun onboard
+ * parts are configured like that. So don't signal the timeout
+ * of the above loop as an error, but do report the lack of
+ * running firmware once.
+ */
+ if (i >= 100000 &&
+ !(tp->tg3_flags2 & TG3_FLG2_NO_FWARE_REPORTED)) {
+ tp->tg3_flags2 |= TG3_FLG2_NO_FWARE_REPORTED;
+
+ printk(KERN_INFO PFX "%s: No firmware running.\n",
+ tp->dev->name);
+ }
+
+ return 0;
+}
+
static void tg3_stop_fw(struct tg3 *);
/* tp->lock is held. */
@@ -4669,7 +4698,7 @@ static int tg3_chip_reset(struct tg3 *tp
{
u32 val;
void (*write_op)(struct tg3 *, u32, u32);
- int i;
+ int err;
tg3_nvram_lock(tp);
@@ -4829,26 +4858,9 @@ static int tg3_chip_reset(struct tg3 *tp
tw32_f(MAC_MODE, 0);
udelay(40);
- /* Wait for firmware initialization to complete. */
- for (i = 0; i < 100000; i++) {
- tg3_read_mem(tp, NIC_SRAM_FIRMWARE_MBOX, &val);
- if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
- break;
- udelay(10);
- }
-
- /* Chip might not be fitted with firmare. Some Sun onboard
- * parts are configured like that. So don't signal the timeout
- * of the above loop as an error, but do report the lack of
- * running firmware once.
- */
- if (i >= 100000 &&
- !(tp->tg3_flags2 & TG3_FLG2_NO_FWARE_REPORTED)) {
- tp->tg3_flags2 |= TG3_FLG2_NO_FWARE_REPORTED;
-
- printk(KERN_INFO PFX "%s: No firmware running.\n",
- tp->dev->name);
- }
+ err = tg3_poll_fw(tp);
+ if (err)
+ return err;
if ((tp->tg3_flags2 & TG3_FLG2_PCI_EXPRESS) &&
tp->pci_chip_rev_id != CHIPREV_ID_5750_A0) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 5/9][TG3]: Add tg3_poll_fw().
2006-09-27 20:34 [PATCH 5/9][TG3]: Add tg3_poll_fw() Michael Chan
@ 2006-09-27 20:47 ` Jeff Garzik
2006-09-27 20:49 ` Michael Chan
2006-09-27 23:03 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2006-09-27 20:47 UTC (permalink / raw)
To: Michael Chan; +Cc: davem, linville, netdev
Michael Chan wrote:
> + /* Chip might not be fitted with firmware. Some Sun onboard
> + * parts are configured like that. So don't signal the timeout
> + * of the above loop as an error, but do report the lack of
> + * running firmware once.
> + */
> + if (i >= 100000 &&
> + !(tp->tg3_flags2 & TG3_FLG2_NO_FWARE_REPORTED)) {
> + tp->tg3_flags2 |= TG3_FLG2_NO_FWARE_REPORTED;
> +
> + printk(KERN_INFO PFX "%s: No firmware running.\n",
> + tp->dev->name);
> + }
> +
> + return 0;
You need to actually return failure, for the failure case.
Currently, this function is written to return an error code, but always
returns zero.
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5/9][TG3]: Add tg3_poll_fw().
2006-09-27 20:47 ` Jeff Garzik
@ 2006-09-27 20:49 ` Michael Chan
0 siblings, 0 replies; 4+ messages in thread
From: Michael Chan @ 2006-09-27 20:49 UTC (permalink / raw)
To: Jeff Garzik; +Cc: davem, linville, netdev
On Wed, 2006-09-27 at 16:47 -0400, Jeff Garzik wrote:
> Michael Chan wrote:
> > + /* Chip might not be fitted with firmware. Some Sun onboard
> > + * parts are configured like that. So don't signal the timeout
> > + * of the above loop as an error, but do report the lack of
> > + * running firmware once.
> > + */
> > + if (i >= 100000 &&
> > + !(tp->tg3_flags2 & TG3_FLG2_NO_FWARE_REPORTED)) {
> > + tp->tg3_flags2 |= TG3_FLG2_NO_FWARE_REPORTED;
> > +
> > + printk(KERN_INFO PFX "%s: No firmware running.\n",
> > + tp->dev->name);
> > + }
> > +
> > + return 0;
>
> You need to actually return failure, for the failure case.
>
> Currently, this function is written to return an error code, but always
> returns zero.
>
It's actually not a failure. It was decided that we'll just print a
message once and continue. Some SUN onboard chips do not have firmware.
In the next patch (6/9) where we support a new chip with a new firmware
polling method, it can return -ENODEV.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 5/9][TG3]: Add tg3_poll_fw().
2006-09-27 20:34 [PATCH 5/9][TG3]: Add tg3_poll_fw() Michael Chan
2006-09-27 20:47 ` Jeff Garzik
@ 2006-09-27 23:03 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2006-09-27 23:03 UTC (permalink / raw)
To: mchan; +Cc: linville, netdev
From: "Michael Chan" <mchan@broadcom.com>
Date: Wed, 27 Sep 2006 13:34:49 -0700
> [TG3]: Add tg3_poll_fw().
>
> Put the firmware polling logic into a separate function. This makes
> the code cleaner.
>
> Signed-off-by: Michael Chan <mchan@broadcom.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-09-27 23:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-27 20:34 [PATCH 5/9][TG3]: Add tg3_poll_fw() Michael Chan
2006-09-27 20:47 ` Jeff Garzik
2006-09-27 20:49 ` Michael Chan
2006-09-27 23:03 ` David Miller
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).