From: John Tyner <jtyner@cs.ucr.edu>
To: <linuxppc-embedded@lists.linuxppc.org>
Subject: [PATCH] fix ifconfig oops for ibm ocp enet
Date: Tue, 14 May 2002 13:56:58 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.30.0205141354450.18953-101000@hill.cs.ucr.edu> (raw)
[-- Attachment #1: Type: TEXT/PLAIN, Size: 3321 bytes --]
The priv structure is not initialized until the open for the ibm
ocp ethernet adapter. This causes ifconfig to cause a kernel oops if run
before the device is brought "up".
Please correct if necessary, but it is working for me. Patch was made from
a pull about 20 minutes ago.
--- drivers/net/ibm_ocp/ibm_ocp_enet.c.orig Tue May 14 13:40:17 2002
+++ drivers/net/ibm_ocp/ibm_ocp_enet.c Tue May 14 13:48:17 2002
@@ -226,12 +226,11 @@
static int
ppc405_enet_open(struct net_device *dev)
{
- int loop, i, emac_num;
+ int loop, i;
unsigned long mode_reg;
struct fec_enet_private *fep;
volatile emac_t *emacp;
unsigned long emac_ier;
- struct ocp_driver *emac_driver;
int already_opened;
for (i = 0; i < ocp_dev_count(EMAC); i++)
@@ -240,35 +239,9 @@
already_opened = ((i < ocp_dev_count(EMAC))
&& (get_ocp_dev(EMAC, i) != NULL));
- if (already_opened) {
- fep = (struct fec_enet_private *) EMAC_DEV(ocpdev);
- emacp = (emac_t *) EMAC_DEV(paddr);
- } else {
- if ((emac_driver =
- ocp_alloc_dev(sizeof (struct fec_enet_private))) == NULL)
- return -ENOMEM;
- strcpy(emac_driver->name, "emac");
- emac_driver->type = EMAC;
- /* this returns the next emac number */
- if ((emac_num = ocp_register(emac_driver)) >= 0) {
- dev->priv = (void *) emac_driver;
- emac_driver->priv_index = dev->ifindex;
- emacp =
- (emac_t *) ((struct ocp_driver *) dev->priv)->paddr;
- fep = (struct fec_enet_private *) ((struct ocp_driver *)
- dev->priv)->ocpdev;
- fep->emac_num = emac_num;
- fep->mal = MBASE[0];
- fep->irq_resource = irq_resource[emac_num];
- fep->sequence_done = 0;
- init_zmii(ZMII_AUTO, dev);
- find_phy(dev);
- fep->link = 1;
- } else {
- ocp_free_dev(emac_driver);
- return -ENODEV;
- }
- }
+
+ fep = (struct fec_enet_private *) EMAC_DEV(ocpdev);
+ emacp = (emac_t *) EMAC_DEV(paddr);
if (!fep->phy) {
printk(KERN_NOTICE "%s: Cannot open interface without phy\n",
@@ -658,6 +631,11 @@
emac_max = ocp_get_max(EMAC);
printk("emac max %d\n", emac_max);
for (curr_emac = 0; curr_emac < emac_max; curr_emac++) {
+ int emac_num;
+ struct ocp_driver *emac_driver;
+ struct fec_enet_private *fep;
+ volatile emac_t *emacp;
+
dev = init_etherdev(NULL, sizeof (struct ocp_driver));
dev->irq = irq_resource[curr_emac][BL_MAC_WOL].irq;
/* read the MAC Address */
@@ -676,6 +654,31 @@
dev->set_multicast_list = &ppc405_enet_set_multicast_list;
dev->do_ioctl = &fec_enet_ioctl;
emac_dev[curr_emac] = dev;
+
+ if ((emac_driver =
+ ocp_alloc_dev(sizeof (struct fec_enet_private))) == NULL)
+ return -ENOMEM;
+ strcpy(emac_driver->name, "emac");
+ emac_driver->type = EMAC;
+ /* this returns the next emac number */
+ if ((emac_num = ocp_register(emac_driver)) >= 0) {
+ dev->priv = (void *) emac_driver;
+ emac_driver->priv_index = dev->ifindex;
+ emacp =
+ (emac_t *) ((struct ocp_driver *) dev->priv)->paddr;
+ fep = (struct fec_enet_private *) ((struct ocp_driver *)
+ dev->priv)->ocpdev;
+ fep->emac_num = emac_num;
+ fep->mal = MBASE[0];
+ fep->irq_resource = irq_resource[emac_num];
+ fep->sequence_done = 0;
+ init_zmii(ZMII_AUTO, dev);
+ find_phy(dev);
+ fep->link = 1;
+ } else {
+ ocp_free_dev(emac_driver);
+ break;
+ }
}
for (i = 0; i < NMII - 1; i++)
[-- Attachment #2: Type: APPLICATION/octet-stream, Size: 1094 bytes --]
reply other threads:[~2002-05-14 20:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.30.0205141354450.18953-101000@hill.cs.ucr.edu \
--to=jtyner@cs.ucr.edu \
--cc=linuxppc-embedded@lists.linuxppc.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).