* [PATCH] ibmtr -- convert to new probeing
@ 2003-11-13 19:24 Stephen Hemminger
2003-11-15 1:07 ` Jeff Garzik
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2003-11-13 19:24 UTC (permalink / raw)
To: Mike_Phillips@URSCorp.com, Jeff Garzik; +Cc: netdev
This patch applies against net-drivers-2.5-exp. The line number offsets assume
the earlier patchset, but this change doesn't overlap all those ether changes.
* convert ibmtr driver to using the new probe interface -- ibmtr_probe2
* keep old ibmtr_probe for use as init handle because ibmtr_cs uses it
* cleanup error paths in ibmtr_probe1 and module init
* make only used locally functions static
* do request_region before doing i/o
* irq and mem were not really settable as module parameters so removed
diff -Nru a/drivers/net/Space.c b/drivers/net/Space.c
--- a/drivers/net/Space.c Thu Nov 13 11:22:59 2003
+++ b/drivers/net/Space.c Thu Nov 13 11:22:59 2003
@@ -336,12 +336,15 @@
#ifdef CONFIG_TR
/* Token-ring device probe */
-extern int ibmtr_probe(struct net_device *);
+extern struct net_device *ibmtr_probe2(int unit);
extern struct net_device *sk_isa_probe(int unit);
extern struct net_device *proteon_probe(int unit);
extern struct net_device *smctr_probe(int unit);
-static struct devprobe2 tr_probes2[] __initdata = {
+static struct devprobe2 tr_probes[] __initdata = {
+#ifdef CONFIG_IBMTR
+ {ibmtr_probe2, 0},
+#endif
#ifdef CONFIG_SKISA
{sk_isa_probe, 0},
#endif
@@ -354,37 +357,13 @@
{NULL, 0},
};
-static __init int trif_probe(int unit)
-{
- struct net_device *dev;
- int err = -ENODEV;
-
- dev = alloc_trdev(0);
- if (!dev)
- return -ENOMEM;
-
- sprintf(dev->name, "tr%d", unit);
- netdev_boot_setup_check(dev);
- if (
-#ifdef CONFIG_IBMTR
- ibmtr_probe(dev) == 0 ||
-#endif
- 0 )
- err = register_netdev(dev);
-
- if (err)
- free_netdev(dev);
- return err;
-
-}
-
static void __init trif_probe2(int unit)
{
unsigned long base_addr = netdev_boot_base("tr", unit);
if (base_addr == 1)
return;
- probe_list2(unit, tr_probes2, base_addr == 0);
+ probe_list2(unit, tr_probes, base_addr == 0);
}
#endif
@@ -411,8 +390,7 @@
#endif
#ifdef CONFIG_TR
for (num = 0; num < 8; ++num)
- if (!trif_probe(num))
- trif_probe2(num);
+ trif_probe2(num);
#endif
for (num = 0; num < 8; ++num)
ethif_probe2(num);
diff -Nru a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
--- a/drivers/net/tokenring/ibmtr.c Thu Nov 13 11:22:59 2003
+++ b/drivers/net/tokenring/ibmtr.c Thu Nov 13 11:22:59 2003
@@ -193,7 +193,7 @@
static int trdev_init(struct net_device *dev);
static int tok_open(struct net_device *dev);
static int tok_init_card(struct net_device *dev);
-void tok_open_adapter(unsigned long dev_addr);
+static void tok_open_adapter(unsigned long dev_addr);
static void open_sap(unsigned char type, struct net_device *dev);
static void tok_set_multicast_list(struct net_device *dev);
static int tok_send_packet(struct sk_buff *skb, struct net_device *dev);
@@ -202,11 +202,11 @@
static void initial_tok_int(struct net_device *dev);
static void tr_tx(struct net_device *dev);
static void tr_rx(struct net_device *dev);
-void ibmtr_reset_timer(struct timer_list*tmr,struct net_device *dev);
+static void ibmtr_reset_timer(struct timer_list*tmr,struct net_device *dev);
static void tok_rerun(unsigned long dev_addr);
-void ibmtr_readlog(struct net_device *dev);
+static void ibmtr_readlog(struct net_device *dev);
static struct net_device_stats *tok_get_stats(struct net_device *dev);
-int ibmtr_change_mtu(struct net_device *dev, int mtu);
+static int ibmtr_change_mtu(struct net_device *dev, int mtu);
static void find_turbo_adapters(int *iolist);
static int ibmtr_portlist[IBMTR_MAX_ADAPTERS+1] __devinitdata = {
@@ -332,19 +332,45 @@
if (base_addr && base_addr <= 0x1ff) /* Don't probe at all. */
return -ENXIO;
- if (base_addr > 0x1ff) { /* Check a single specified location. */
- if (!ibmtr_probe1(dev, base_addr)) return 0;
- return -ENODEV;
- }
+ if (base_addr > 0x1ff) /* Check a single specified location. */
+ return ibmtr_probe1(dev, base_addr);
find_turbo_adapters(ibmtr_portlist);
for (i = 0; ibmtr_portlist[i]; i++) {
- int ioaddr = ibmtr_portlist[i];
-
- if (!ibmtr_probe1(dev, ioaddr)) return 0;
+ if (!ibmtr_probe1(dev, ibmtr_portlist[i]))
+ return 0;
}
return -ENODEV;
}
+#ifndef MODULE
+/*
+ * Called from Space.c to probe for token ring devices at boot
+ * time.
+ */
+struct net_device * __devinit ibmtr_probe2(int unit)
+{
+ struct net_device *dev = alloc_trdev(sizeof(struct tok_info));
+ int err = 0;
+
+ if (!dev)
+ return ERR_PTR(-ENOMEM);
+
+ if (unit >= 0) {
+ sprintf(dev->name, "tr%d", unit);
+ netdev_boot_setup_check(dev);
+ }
+
+ dev->init = &ibmtr_probe;
+
+ err = register_netdev(dev);
+ if (!err)
+ return dev;
+
+ free_netdev(dev);
+ return ERR_PTR(err);
+}
+#endif
+
/*****************************************************************************/
static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr)
@@ -360,6 +386,15 @@
unsigned long timeout;
static int version_printed;
#endif
+ int err = -ENODEV;
+
+ /*?? Now, allocate some of the PIO PORTs for this driver.. */
+ /* record PIOaddr range as busy */
+ if (!request_region(PIOaddr, IBMTR_IO_EXTENT, "ibmtr")) {
+ DPRINTK("Could not grab PIO range. Halting driver.\n");
+ err = -EBUSY;
+ goto out1;
+ }
/* Query the adapter PIO base port which will return
* indication of where MMIO was placed. We also have a
@@ -374,7 +409,7 @@
DPRINTK("ibmtr_probe1(): unhappy that inb(0x%X) == 0x%X, "
"Hardware Problem?\n",PIOaddr,segment);
#endif
- return -ENODEV;
+ goto out2;
}
/*
* Compute the linear base address of the MMIO area
@@ -383,7 +418,7 @@
t_mmio = ioremap(((__u32) (segment & 0xfc) << 11) + 0x80000,2048);
if (!t_mmio) {
DPRINTK("Cannot remap mmiobase memory area") ;
- return -ENODEV ;
+ goto out2;
}
intr = segment & 0x03; /* low bits is coded interrupt # */
if (ibmtr_debug_trace & TRC_INIT)
@@ -427,12 +462,9 @@
if (cardpresent == TR_ISA && (readb(AIPFID + t_mmio) == 0x0e))
cardpresent = TR_ISAPNP;
if (cardpresent == NOTOK) { /* "channel_id" did not match, report */
- if (!(ibmtr_debug_trace & TRC_INIT)) {
-#ifndef PCMCIA
- iounmap(t_mmio);
-#endif
- return -ENODEV;
- }
+ if (!(ibmtr_debug_trace & TRC_INIT))
+ goto out3;
+
DPRINTK( "Channel ID string not found for PIOaddr: %4hx\n",
PIOaddr);
DPRINTK("Expected for ISA: ");
@@ -497,9 +529,7 @@
while (!readb(ti->mmio + ACA_OFFSET + ACA_RW + RRR_EVEN)){
if (!time_after(jiffies, timeout)) continue;
DPRINTK( "Hardware timeout during initialization.\n");
- iounmap(t_mmio);
- kfree(ti);
- return -ENODEV;
+ goto out3;
}
ti->sram_virt =
((__u32)readb(ti->mmio+ACA_OFFSET+ACA_RW+RRR_EVEN)<<12);
@@ -611,10 +641,7 @@
default:
DPRINTK("Unknown shared ram paging info %01X\n",
ti->shared_ram_paging);
- iounmap(t_mmio);
- kfree(ti);
- return -ENODEV;
- break;
+ goto out3;
} /*end switch shared_ram_paging */
if (ibmtr_debug_trace & TRC_INIT)
@@ -641,9 +668,7 @@
DPRINTK("Shared RAM for this adapter (%05x) exceeds "
"driver limit (%05x), adapter not started.\n",
chk_base, ibmtr_mem_base + IBMTR_SHARED_RAM_SIZE);
- iounmap(t_mmio);
- kfree(ti);
- return -ENODEV;
+ goto out3;
} else { /* seems cool, record what we have figured out */
ti->sram_base = new_base >> 12;
ibmtr_mem_base = chk_base;
@@ -656,18 +681,7 @@
if (request_irq(dev->irq = irq, &tok_interrupt, 0, "ibmtr", dev) != 0) {
DPRINTK("Could not grab irq %d. Halting Token Ring driver.\n",
irq);
- iounmap(t_mmio);
- kfree(ti);
- return -ENODEV;
- }
- /*?? Now, allocate some of the PIO PORTs for this driver.. */
- /* record PIOaddr range as busy */
- if (!request_region(PIOaddr, IBMTR_IO_EXTENT, "ibmtr")) {
- DPRINTK("Could not grab PIO range. Halting driver.\n");
- free_irq(dev->irq, dev);
- iounmap(t_mmio);
- kfree(ti);
- return -EBUSY;
+ goto out3;
}
if (!version_printed++) {
@@ -767,6 +781,15 @@
dev->mem_end = dev->mem_start + (ti->mapped_ram_size << 9) - 1;
trdev_init(dev);
return 0; /* Return 0 to indicate we have found a Token Ring card. */
+
+ out3:
+#ifndef PCMCIA
+ iounmap(t_mmio);
+#endif
+ out2:
+ release_region(PIOaddr, IBMTR_IO_EXTENT);
+ out1:
+ return err;
} /*ibmtr_probe1() */
/*****************************************************************************/
@@ -900,7 +923,7 @@
#define DLC_MAX_SAP_OFST 32
#define DLC_MAX_STA_OFST 33
-void tok_open_adapter(unsigned long dev_addr)
+static void tok_open_adapter(unsigned long dev_addr)
{
struct net_device *dev = (struct net_device *) dev_addr;
struct tok_info *ti;
@@ -1825,7 +1848,7 @@
/*****************************************************************************/
-void ibmtr_reset_timer(struct timer_list *tmr, struct net_device *dev)
+static void ibmtr_reset_timer(struct timer_list *tmr, struct net_device *dev)
{
tmr->expires = jiffies + TR_RETRY_INTERVAL;
tmr->data = (unsigned long) dev;
@@ -1836,7 +1859,7 @@
/*****************************************************************************/
-void tok_rerun(unsigned long dev_addr){
+static void tok_rerun(unsigned long dev_addr){
struct net_device *dev = (struct net_device *)dev_addr;
struct tok_info *ti = (struct tok_info *) dev->priv;
@@ -1857,7 +1880,7 @@
/*****************************************************************************/
-void ibmtr_readlog(struct net_device *dev)
+static void ibmtr_readlog(struct net_device *dev)
{
struct tok_info *ti;
@@ -1890,7 +1913,7 @@
/*****************************************************************************/
-int ibmtr_change_mtu(struct net_device *dev, int mtu)
+static int ibmtr_change_mtu(struct net_device *dev, int mtu)
{
struct tok_info *ti = (struct tok_info *) dev->priv;
@@ -1908,40 +1931,38 @@
/* 3COM 3C619C supports 8 interrupts, 32 I/O ports */
static struct net_device *dev_ibmtr[IBMTR_MAX_ADAPTERS];
static int io[IBMTR_MAX_ADAPTERS] = { 0xa20, 0xa24 };
-static int irq[IBMTR_MAX_ADAPTERS];
-static int mem[IBMTR_MAX_ADAPTERS];
MODULE_LICENSE("GPL");
MODULE_PARM(io, "1-" __MODULE_STRING(IBMTR_MAX_ADAPTERS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(IBMTR_MAX_ADAPTERS) "i");
-MODULE_PARM(mem, "1-" __MODULE_STRING(IBMTR_MAX_ADAPTERS) "i");
+
static int __init ibmtr_init(void)
{
int i;
int count=0;
+ int err = -EIO;
find_turbo_adapters(io);
for (i = 0; io[i] && (i < IBMTR_MAX_ADAPTERS); i++) {
- irq[i] = 0;
- mem[i] = 0;
- dev_ibmtr[i] = alloc_trdev(sizeof(struct tok_info));
- if (dev_ibmtr[i] == NULL) {
- if (i == 0)
- return -ENOMEM;
+ struct net_device *dev = alloc_trdev(sizeof(struct tok_info));
+
+ if (!dev) {
+ err = -ENOMEM;
break;
}
- dev_ibmtr[i]->base_addr = io[i];
- dev_ibmtr[i]->irq = irq[i];
- dev_ibmtr[i]->mem_start = mem[i];
- dev_ibmtr[i]->init = &ibmtr_probe;
- if (register_netdev(dev_ibmtr[i]) != 0) {
- kfree(dev_ibmtr[i]);
- dev_ibmtr[i] = NULL;
+
+ SET_MODULE_OWNER(dev);
+ dev->init = &ibmtr_probe;
+ dev->base_addr = io[i];
+
+ err = register_netdev(dev);
+ if (err) {
+ free_netdev(dev);
continue;
}
+ dev_ibmtr[i] = dev;
count++;
}
if (count) return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmtr -- convert to new probeing
2003-11-13 19:24 [PATCH] ibmtr -- convert to new probeing Stephen Hemminger
@ 2003-11-15 1:07 ` Jeff Garzik
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2003-11-15 1:07 UTC (permalink / raw)
To: Stephen Hemminger, Mike_Phillips@URSCorp.com; +Cc: netdev
Stephen Hemminger wrote:
> This patch applies against net-drivers-2.5-exp. The line number offsets assume
> the earlier patchset, but this change doesn't overlap all those ether changes.
>
> * convert ibmtr driver to using the new probe interface -- ibmtr_probe2
> * keep old ibmtr_probe for use as init handle because ibmtr_cs uses it
> * cleanup error paths in ibmtr_probe1 and module init
> * make only used locally functions static
> * do request_region before doing i/o
> * irq and mem were not really settable as module parameters so removed
Given that there has been some other activity in this driver, I would
prefer to wait for Mike's ACK, before applying to net-drivers-2.5-exp
(and eventually 2.6 when it re-opens).
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmtr -- convert to new probeing
@ 2003-11-15 4:50 Mike_Phillips
0 siblings, 0 replies; 5+ messages in thread
From: Mike_Phillips @ 2003-11-15 4:50 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, Stephen Hemminger
Jeff,
Thanks. I'll try this out over the weekend and provide the feedback.
Mike
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmtr -- convert to new probeing
@ 2003-11-15 5:53 Mike_Phillips
2003-11-18 0:47 ` Stephen Hemminger
0 siblings, 1 reply; 5+ messages in thread
From: Mike_Phillips @ 2003-11-15 5:53 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, Stephen Hemminger
Big badda boom !!
Applied all patches (including mine to get ibmtr_cs working), insert pcmcia
card, boom, panic, kernel halt, bye, bye system.
It's getting very, very confused. Stephen's patch changes the behaviour in
ibmtr.c so that it tries to probe the PIOAddr even when call via ibmtr_cs,
can't do that, ibmtr_cs has already allocated the PIOAddr as part of the
pcmcia setup. So ibmtr fails to allocate the same port. ibmtr.c tries to
sanely exit, but ibmtr_cs isn't having any of it. Interrupts then decide to
arrive, but none of the structures have been setup correctly and the kernel
panics in the spinlock in tok_interrupt.
Making sure ibmtr_cs is working is actually more important than ibmtr. IBM
doesn't sell the isa cards anymore (I hope !!), but the pcmcia adapter is
still being sold (in addition to the olympic based cardbus adapter)
I need to dig up a real ISA adapter to try this with too.
Mike
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ibmtr -- convert to new probeing
2003-11-15 5:53 Mike_Phillips
@ 2003-11-18 0:47 ` Stephen Hemminger
0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2003-11-18 0:47 UTC (permalink / raw)
To: Mike_Phillips; +Cc: Jeff Garzik, netdev
The way ibmtr_cs.c #include's ibmtr.c is gross, but adding a few more #ifdef's
should fix it again.
This applies on top of earlier patch. It also cleans up some more things
that should be defined as static.
diff -Nru a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
--- a/drivers/net/pcmcia/ibmtr_cs.c Mon Nov 17 14:02:43 2003
+++ b/drivers/net/pcmcia/ibmtr_cs.c Mon Nov 17 14:02:43 2003
@@ -125,10 +125,6 @@
static dev_link_t *dev_list;
-extern int ibmtr_probe(struct net_device *dev);
-extern int trdev_init(struct net_device *dev);
-extern irqreturn_t tok_interrupt (int irq, void *dev_id, struct pt_regs *regs);
-
/*====================================================================*/
typedef struct ibmtr_dev_t {
diff -Nru a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
--- a/drivers/net/tokenring/ibmtr.c Mon Nov 17 14:02:43 2003
+++ b/drivers/net/tokenring/ibmtr.c Mon Nov 17 14:02:43 2003
@@ -152,7 +152,7 @@
/* this allows displaying full adapter information */
-char *channel_def[] __devinitdata = { "ISA", "MCA", "ISA P&P" };
+static const char *channel_def[] __devinitdata = { "ISA", "MCA", "ISA P&P" };
static char pcchannelid[] __devinitdata = {
0x05, 0x00, 0x04, 0x09,
@@ -172,7 +172,7 @@
0x03, 0x08, 0x02, 0x00
};
-char __devinit *adapter_def(char type)
+static const char __devinit *adapter_def(char type)
{
switch (type) {
case 0xF: return "PC Adapter | PC Adapter II | Adapter/A";
@@ -187,7 +187,6 @@
#define TRC_INITV 0x02 /* verbose init trace points */
unsigned char ibmtr_debug_trace = 0;
-int ibmtr_probe(struct net_device *dev);
static int ibmtr_probe1(struct net_device *dev, int ioaddr);
static unsigned char get_sram_size(struct tok_info *adapt_info);
static int trdev_init(struct net_device *dev);
@@ -198,7 +197,7 @@
static void tok_set_multicast_list(struct net_device *dev);
static int tok_send_packet(struct sk_buff *skb, struct net_device *dev);
static int tok_close(struct net_device *dev);
-irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs);
static void initial_tok_int(struct net_device *dev);
static void tr_tx(struct net_device *dev);
static void tr_rx(struct net_device *dev);
@@ -207,6 +206,7 @@
static void ibmtr_readlog(struct net_device *dev);
static struct net_device_stats *tok_get_stats(struct net_device *dev);
static int ibmtr_change_mtu(struct net_device *dev, int mtu);
+#ifndef PCMCIA
static void find_turbo_adapters(int *iolist);
static int ibmtr_portlist[IBMTR_MAX_ADAPTERS+1] __devinitdata = {
@@ -216,7 +216,6 @@
static int __devinitdata turbo_irq[IBMTR_MAX_ADAPTERS] = {0};
static int __devinitdata turbo_searched = 0;
-#ifndef PCMCIA
static __u32 ibmtr_mem_base __initdata = 0xd0000;
#endif
@@ -240,6 +239,7 @@
* going away.
*/
+#ifndef PCMCIA
static void __devinit find_turbo_adapters(int *iolist) {
int ram_addr;
int index=0;
@@ -312,6 +312,7 @@
}
}
}
+#endif
/****************************************************************************
* ibmtr_probe(): Routine specified in the network device structure
@@ -325,24 +326,28 @@
* which references it.
****************************************************************************/
-int __devinit ibmtr_probe(struct net_device *dev)
+static int __devinit ibmtr_probe(struct net_device *dev)
{
- int i;
int base_addr = dev->base_addr;
+#ifndef PCMCIA
+ int i;
+#endif
if (base_addr && base_addr <= 0x1ff) /* Don't probe at all. */
return -ENXIO;
if (base_addr > 0x1ff) /* Check a single specified location. */
return ibmtr_probe1(dev, base_addr);
+#ifndef PCMCIA
find_turbo_adapters(ibmtr_portlist);
for (i = 0; ibmtr_portlist[i]; i++) {
if (!ibmtr_probe1(dev, ibmtr_portlist[i]))
return 0;
}
+#endif
return -ENODEV;
}
-#ifndef MODULE
+#if !defined(MODULE) && !defined(PCMCIA)
/*
* Called from Space.c to probe for token ring devices at boot
* time.
@@ -388,13 +393,14 @@
#endif
int err = -ENODEV;
- /*?? Now, allocate some of the PIO PORTs for this driver.. */
+#ifndef PCMCIA
/* record PIOaddr range as busy */
if (!request_region(PIOaddr, IBMTR_IO_EXTENT, "ibmtr")) {
DPRINTK("Could not grab PIO range. Halting driver.\n");
err = -EBUSY;
goto out1;
}
+#endif
/* Query the adapter PIO base port which will return
* indication of where MMIO was placed. We also have a
@@ -787,8 +793,10 @@
iounmap(t_mmio);
#endif
out2:
+#ifndef PCMCIA
release_region(PIOaddr, IBMTR_IO_EXTENT);
out1:
+#endif
return err;
} /*ibmtr_probe1() */
@@ -1164,7 +1172,7 @@
/******************************************************************************/
-irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs)
{
unsigned char status;
/* unsigned char status_even ; */
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-11-18 0:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-13 19:24 [PATCH] ibmtr -- convert to new probeing Stephen Hemminger
2003-11-15 1:07 ` Jeff Garzik
-- strict thread matches above, loose matches on Subject: below --
2003-11-15 4:50 Mike_Phillips
2003-11-15 5:53 Mike_Phillips
2003-11-18 0:47 ` Stephen Hemminger
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).