Skip to content

Commit 504ff16

Browse files
JochenFriedrichjgarzik
authored andcommitted
[PATCH] tms380tr: move to DMA API
This patch makes tms380tr use the new DMA API. Now that on Alpha, this API also supports bus master DMA for ISA (platform) devices, i changed the driver to use this new API. This also works around a bug in the firmware loader: The example provided in Documentation/firmware_class no longer works, as the firmware loader now calls get_kobj_path_length() and the kernel promptly oopses, as the home-grown device doesn't have a parent. Of course, this doesn't happen with a "real" device which has its bus (or pseudo bus in the case of platform) as parent. Converted tms380tr to use new DMA API: - proteon.c, skisa.c: use platform pseudo bus to create a struct device - Space.c: delete init hooks - abyss.c, tmspci.c: pass struct device to tms380tr.c - tms380tr.c, tms380tr.h: new DMA API, use real device fo firmware loader Signed-off-by: Jochen Friedrich <jochen@scram.de> Cc: Jeff Garzik <jgarzik@pobox.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
1 parent 6b38aef commit 504ff16

7 files changed

Lines changed: 122 additions & 143 deletions

File tree

‎drivers/net/Space.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,6 @@ extern struct net_device *proteon_probe(int unit);
323323
extern struct net_device *smctr_probe(int unit);
324324

325325
static struct devprobe2 tr_probes2[] __initdata = {
326-
#ifdef CONFIG_SKISA
327-
{sk_isa_probe, 0},
328-
#endif
329-
#ifdef CONFIG_PROTEON
330-
{proteon_probe, 0},
331-
#endif
332326
#ifdef CONFIG_SMCTR
333327
{smctr_probe, 0},
334328
#endif

‎drivers/net/tokenring/abyss.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_
139139
*/
140140
dev->base_addr += 0x10;
141141

142-
ret = tmsdev_init(dev, PCI_MAX_ADDRESS, pdev);
142+
ret = tmsdev_init(dev, PCI_MAX_ADDRESS, &pdev->dev);
143143
if (ret) {
144144
printk("%s: unable to get memory for dev->priv.\n",
145145
dev->name);

‎drivers/net/tokenring/proteon.c‎

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ static int dmalist[] __initdata = {
6262
};
6363

6464
static char cardname[] = "Proteon 1392\0";
65-
66-
struct net_device *proteon_probe(int unit);
65+
static u64 dma_mask = ISA_MAX_ADDRESS;
6766
static int proteon_open(struct net_device *dev);
6867
static void proteon_read_eeprom(struct net_device *dev);
6968
static unsigned short proteon_setnselout_pins(struct net_device *dev);
@@ -116,7 +115,7 @@ static int __init proteon_probe1(struct net_device *dev, int ioaddr)
116115
return -ENODEV;
117116
}
118117

119-
static int __init setup_card(struct net_device *dev)
118+
static int __init setup_card(struct net_device *dev, struct device *pdev)
120119
{
121120
struct net_local *tp;
122121
static int versionprinted;
@@ -137,22 +136,23 @@ static int __init setup_card(struct net_device *dev)
137136
}
138137
}
139138
if (err)
140-
goto out4;
139+
goto out5;
141140

142141
/* At this point we have found a valid card. */
143142

144143
if (versionprinted++ == 0)
145144
printk(KERN_DEBUG "%s", version);
146145

147146
err = -EIO;
148-
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL))
147+
pdev->dma_mask = &dma_mask;
148+
if (tmsdev_init(dev, ISA_MAX_ADDRESS, pdev))
149149
goto out4;
150150

151151
dev->base_addr &= ~3;
152152

153153
proteon_read_eeprom(dev);
154154

155-
printk(KERN_DEBUG "%s: Ring Station Address: ", dev->name);
155+
printk(KERN_DEBUG "proteon.c: Ring Station Address: ");
156156
printk("%2.2x", dev->dev_addr[0]);
157157
for (j = 1; j < 6; j++)
158158
printk(":%2.2x", dev->dev_addr[j]);
@@ -185,7 +185,7 @@ static int __init setup_card(struct net_device *dev)
185185

186186
if(irqlist[j] == 0)
187187
{
188-
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name);
188+
printk(KERN_INFO "proteon.c: AutoSelect no IRQ available\n");
189189
goto out3;
190190
}
191191
}
@@ -196,15 +196,15 @@ static int __init setup_card(struct net_device *dev)
196196
break;
197197
if (irqlist[j] == 0)
198198
{
199-
printk(KERN_INFO "%s: Illegal IRQ %d specified\n",
200-
dev->name, dev->irq);
199+
printk(KERN_INFO "proteon.c: Illegal IRQ %d specified\n",
200+
dev->irq);
201201
goto out3;
202202
}
203203
if (request_irq(dev->irq, tms380tr_interrupt, 0,
204204
cardname, dev))
205205
{
206-
printk(KERN_INFO "%s: Selected IRQ %d not available\n",
207-
dev->name, dev->irq);
206+
printk(KERN_INFO "proteon.c: Selected IRQ %d not available\n",
207+
dev->irq);
208208
goto out3;
209209
}
210210
}
@@ -220,7 +220,7 @@ static int __init setup_card(struct net_device *dev)
220220

221221
if(dmalist[j] == 0)
222222
{
223-
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name);
223+
printk(KERN_INFO "proteon.c: AutoSelect no DMA available\n");
224224
goto out2;
225225
}
226226
}
@@ -231,25 +231,25 @@ static int __init setup_card(struct net_device *dev)
231231
break;
232232
if (dmalist[j] == 0)
233233
{
234-
printk(KERN_INFO "%s: Illegal DMA %d specified\n",
235-
dev->name, dev->dma);
234+
printk(KERN_INFO "proteon.c: Illegal DMA %d specified\n",
235+
dev->dma);
236236
goto out2;
237237
}
238238
if (request_dma(dev->dma, cardname))
239239
{
240-
printk(KERN_INFO "%s: Selected DMA %d not available\n",
241-
dev->name, dev->dma);
240+
printk(KERN_INFO "proteon.c: Selected DMA %d not available\n",
241+
dev->dma);
242242
goto out2;
243243
}
244244
}
245245

246-
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
247-
dev->name, dev->base_addr, dev->irq, dev->dma);
248-
249246
err = register_netdev(dev);
250247
if (err)
251248
goto out;
252249

250+
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
251+
dev->name, dev->base_addr, dev->irq, dev->dma);
252+
253253
return 0;
254254
out:
255255
free_dma(dev->dma);
@@ -258,34 +258,11 @@ static int __init setup_card(struct net_device *dev)
258258
out3:
259259
tmsdev_term(dev);
260260
out4:
261-
release_region(dev->base_addr, PROTEON_IO_EXTENT);
261+
release_region(dev->base_addr, PROTEON_IO_EXTENT);
262+
out5:
262263
return err;
263264
}
264265

265-
struct net_device * __init proteon_probe(int unit)
266-
{
267-
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
268-
int err = 0;
269-
270-
if (!dev)
271-
return ERR_PTR(-ENOMEM);
272-
273-
if (unit >= 0) {
274-
sprintf(dev->name, "tr%d", unit);
275-
netdev_boot_setup_check(dev);
276-
}
277-
278-
err = setup_card(dev);
279-
if (err)
280-
goto out;
281-
282-
return dev;
283-
284-
out:
285-
free_netdev(dev);
286-
return ERR_PTR(err);
287-
}
288-
289266
/*
290267
* Reads MAC address from adapter RAM, which should've read it from
291268
* the onboard ROM.
@@ -352,8 +329,6 @@ static int proteon_open(struct net_device *dev)
352329
return tms380tr_open(dev);
353330
}
354331

355-
#ifdef MODULE
356-
357332
#define ISATR_MAX_ADAPTERS 3
358333

359334
static int io[ISATR_MAX_ADAPTERS];
@@ -366,13 +341,23 @@ module_param_array(io, int, NULL, 0);
366341
module_param_array(irq, int, NULL, 0);
367342
module_param_array(dma, int, NULL, 0);
368343

369-
static struct net_device *proteon_dev[ISATR_MAX_ADAPTERS];
344+
static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS];
345+
346+
static struct device_driver proteon_driver = {
347+
.name = "proteon",
348+
.bus = &platform_bus_type,
349+
};
370350

371-
int init_module(void)
351+
static int __init proteon_init(void)
372352
{
373353
struct net_device *dev;
354+
struct platform_device *pdev;
374355
int i, num = 0, err = 0;
375356

357+
err = driver_register(&proteon_driver);
358+
if (err)
359+
return err;
360+
376361
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
377362
dev = alloc_trdev(sizeof(struct net_local));
378363
if (!dev)
@@ -381,11 +366,15 @@ int init_module(void)
381366
dev->base_addr = io[i];
382367
dev->irq = irq[i];
383368
dev->dma = dma[i];
384-
err = setup_card(dev);
369+
pdev = platform_device_register_simple("proteon",
370+
i, NULL, 0);
371+
err = setup_card(dev, &pdev->dev);
385372
if (!err) {
386-
proteon_dev[i] = dev;
373+
proteon_dev[i] = pdev;
374+
dev_set_drvdata(&pdev->dev, dev);
387375
++num;
388376
} else {
377+
platform_device_unregister(pdev);
389378
free_netdev(dev);
390379
}
391380
}
@@ -399,23 +388,28 @@ int init_module(void)
399388
return (0);
400389
}
401390

402-
void cleanup_module(void)
391+
static void __exit proteon_cleanup(void)
403392
{
393+
struct net_device *dev;
404394
int i;
405395

406396
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
407-
struct net_device *dev = proteon_dev[i];
397+
struct platform_device *pdev = proteon_dev[i];
408398

409-
if (!dev)
399+
if (!pdev)
410400
continue;
411-
401+
dev = dev_get_drvdata(&pdev->dev);
412402
unregister_netdev(dev);
413403
release_region(dev->base_addr, PROTEON_IO_EXTENT);
414404
free_irq(dev->irq, dev);
415405
free_dma(dev->dma);
416406
tmsdev_term(dev);
417407
free_netdev(dev);
408+
dev_set_drvdata(&pdev->dev, NULL);
409+
platform_device_unregister(pdev);
418410
}
411+
driver_unregister(&proteon_driver);
419412
}
420-
#endif /* MODULE */
421413

414+
module_init(proteon_init);
415+
module_exit(proteon_cleanup);

0 commit comments

Comments
 (0)