提交 504ff16c 编写于 作者: J Jochen Friedrich 提交者: Jeff Garzik

[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: NJochen Friedrich <jochen@scram.de>
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NJeff Garzik <jgarzik@pobox.com>
上级 6b38aefe
...@@ -323,12 +323,6 @@ extern struct net_device *proteon_probe(int unit); ...@@ -323,12 +323,6 @@ extern struct net_device *proteon_probe(int unit);
extern struct net_device *smctr_probe(int unit); extern struct net_device *smctr_probe(int unit);
static struct devprobe2 tr_probes2[] __initdata = { static struct devprobe2 tr_probes2[] __initdata = {
#ifdef CONFIG_SKISA
{sk_isa_probe, 0},
#endif
#ifdef CONFIG_PROTEON
{proteon_probe, 0},
#endif
#ifdef CONFIG_SMCTR #ifdef CONFIG_SMCTR
{smctr_probe, 0}, {smctr_probe, 0},
#endif #endif
......
...@@ -139,7 +139,7 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_ ...@@ -139,7 +139,7 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_
*/ */
dev->base_addr += 0x10; dev->base_addr += 0x10;
ret = tmsdev_init(dev, PCI_MAX_ADDRESS, pdev); ret = tmsdev_init(dev, PCI_MAX_ADDRESS, &pdev->dev);
if (ret) { if (ret) {
printk("%s: unable to get memory for dev->priv.\n", printk("%s: unable to get memory for dev->priv.\n",
dev->name); dev->name);
......
...@@ -62,8 +62,7 @@ static int dmalist[] __initdata = { ...@@ -62,8 +62,7 @@ static int dmalist[] __initdata = {
}; };
static char cardname[] = "Proteon 1392\0"; static char cardname[] = "Proteon 1392\0";
static u64 dma_mask = ISA_MAX_ADDRESS;
struct net_device *proteon_probe(int unit);
static int proteon_open(struct net_device *dev); static int proteon_open(struct net_device *dev);
static void proteon_read_eeprom(struct net_device *dev); static void proteon_read_eeprom(struct net_device *dev);
static unsigned short proteon_setnselout_pins(struct net_device *dev); 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) ...@@ -116,7 +115,7 @@ static int __init proteon_probe1(struct net_device *dev, int ioaddr)
return -ENODEV; return -ENODEV;
} }
static int __init setup_card(struct net_device *dev) static int __init setup_card(struct net_device *dev, struct device *pdev)
{ {
struct net_local *tp; struct net_local *tp;
static int versionprinted; static int versionprinted;
...@@ -137,7 +136,7 @@ static int __init setup_card(struct net_device *dev) ...@@ -137,7 +136,7 @@ static int __init setup_card(struct net_device *dev)
} }
} }
if (err) if (err)
goto out4; goto out5;
/* At this point we have found a valid card. */ /* At this point we have found a valid card. */
...@@ -145,14 +144,15 @@ static int __init setup_card(struct net_device *dev) ...@@ -145,14 +144,15 @@ static int __init setup_card(struct net_device *dev)
printk(KERN_DEBUG "%s", version); printk(KERN_DEBUG "%s", version);
err = -EIO; err = -EIO;
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) pdev->dma_mask = &dma_mask;
if (tmsdev_init(dev, ISA_MAX_ADDRESS, pdev))
goto out4; goto out4;
dev->base_addr &= ~3; dev->base_addr &= ~3;
proteon_read_eeprom(dev); proteon_read_eeprom(dev);
printk(KERN_DEBUG "%s: Ring Station Address: ", dev->name); printk(KERN_DEBUG "proteon.c: Ring Station Address: ");
printk("%2.2x", dev->dev_addr[0]); printk("%2.2x", dev->dev_addr[0]);
for (j = 1; j < 6; j++) for (j = 1; j < 6; j++)
printk(":%2.2x", dev->dev_addr[j]); printk(":%2.2x", dev->dev_addr[j]);
...@@ -185,7 +185,7 @@ static int __init setup_card(struct net_device *dev) ...@@ -185,7 +185,7 @@ static int __init setup_card(struct net_device *dev)
if(irqlist[j] == 0) if(irqlist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name); printk(KERN_INFO "proteon.c: AutoSelect no IRQ available\n");
goto out3; goto out3;
} }
} }
...@@ -196,15 +196,15 @@ static int __init setup_card(struct net_device *dev) ...@@ -196,15 +196,15 @@ static int __init setup_card(struct net_device *dev)
break; break;
if (irqlist[j] == 0) if (irqlist[j] == 0)
{ {
printk(KERN_INFO "%s: Illegal IRQ %d specified\n", printk(KERN_INFO "proteon.c: Illegal IRQ %d specified\n",
dev->name, dev->irq); dev->irq);
goto out3; goto out3;
} }
if (request_irq(dev->irq, tms380tr_interrupt, 0, if (request_irq(dev->irq, tms380tr_interrupt, 0,
cardname, dev)) cardname, dev))
{ {
printk(KERN_INFO "%s: Selected IRQ %d not available\n", printk(KERN_INFO "proteon.c: Selected IRQ %d not available\n",
dev->name, dev->irq); dev->irq);
goto out3; goto out3;
} }
} }
...@@ -220,7 +220,7 @@ static int __init setup_card(struct net_device *dev) ...@@ -220,7 +220,7 @@ static int __init setup_card(struct net_device *dev)
if(dmalist[j] == 0) if(dmalist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name); printk(KERN_INFO "proteon.c: AutoSelect no DMA available\n");
goto out2; goto out2;
} }
} }
...@@ -231,25 +231,25 @@ static int __init setup_card(struct net_device *dev) ...@@ -231,25 +231,25 @@ static int __init setup_card(struct net_device *dev)
break; break;
if (dmalist[j] == 0) if (dmalist[j] == 0)
{ {
printk(KERN_INFO "%s: Illegal DMA %d specified\n", printk(KERN_INFO "proteon.c: Illegal DMA %d specified\n",
dev->name, dev->dma); dev->dma);
goto out2; goto out2;
} }
if (request_dma(dev->dma, cardname)) if (request_dma(dev->dma, cardname))
{ {
printk(KERN_INFO "%s: Selected DMA %d not available\n", printk(KERN_INFO "proteon.c: Selected DMA %d not available\n",
dev->name, dev->dma); dev->dma);
goto out2; goto out2;
} }
} }
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma);
err = register_netdev(dev); err = register_netdev(dev);
if (err) if (err)
goto out; goto out;
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma);
return 0; return 0;
out: out:
free_dma(dev->dma); free_dma(dev->dma);
...@@ -259,33 +259,10 @@ static int __init setup_card(struct net_device *dev) ...@@ -259,33 +259,10 @@ static int __init setup_card(struct net_device *dev)
tmsdev_term(dev); tmsdev_term(dev);
out4: out4:
release_region(dev->base_addr, PROTEON_IO_EXTENT); release_region(dev->base_addr, PROTEON_IO_EXTENT);
out5:
return err; return err;
} }
struct net_device * __init proteon_probe(int unit)
{
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
int err = 0;
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "tr%d", unit);
netdev_boot_setup_check(dev);
}
err = setup_card(dev);
if (err)
goto out;
return dev;
out:
free_netdev(dev);
return ERR_PTR(err);
}
/* /*
* Reads MAC address from adapter RAM, which should've read it from * Reads MAC address from adapter RAM, which should've read it from
* the onboard ROM. * the onboard ROM.
...@@ -352,8 +329,6 @@ static int proteon_open(struct net_device *dev) ...@@ -352,8 +329,6 @@ static int proteon_open(struct net_device *dev)
return tms380tr_open(dev); return tms380tr_open(dev);
} }
#ifdef MODULE
#define ISATR_MAX_ADAPTERS 3 #define ISATR_MAX_ADAPTERS 3
static int io[ISATR_MAX_ADAPTERS]; static int io[ISATR_MAX_ADAPTERS];
...@@ -366,13 +341,23 @@ module_param_array(io, int, NULL, 0); ...@@ -366,13 +341,23 @@ module_param_array(io, int, NULL, 0);
module_param_array(irq, int, NULL, 0); module_param_array(irq, int, NULL, 0);
module_param_array(dma, int, NULL, 0); module_param_array(dma, int, NULL, 0);
static struct net_device *proteon_dev[ISATR_MAX_ADAPTERS]; static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS];
int init_module(void) static struct device_driver proteon_driver = {
.name = "proteon",
.bus = &platform_bus_type,
};
static int __init proteon_init(void)
{ {
struct net_device *dev; struct net_device *dev;
struct platform_device *pdev;
int i, num = 0, err = 0; int i, num = 0, err = 0;
err = driver_register(&proteon_driver);
if (err)
return err;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
dev = alloc_trdev(sizeof(struct net_local)); dev = alloc_trdev(sizeof(struct net_local));
if (!dev) if (!dev)
...@@ -381,11 +366,15 @@ int init_module(void) ...@@ -381,11 +366,15 @@ int init_module(void)
dev->base_addr = io[i]; dev->base_addr = io[i];
dev->irq = irq[i]; dev->irq = irq[i];
dev->dma = dma[i]; dev->dma = dma[i];
err = setup_card(dev); pdev = platform_device_register_simple("proteon",
i, NULL, 0);
err = setup_card(dev, &pdev->dev);
if (!err) { if (!err) {
proteon_dev[i] = dev; proteon_dev[i] = pdev;
dev_set_drvdata(&pdev->dev, dev);
++num; ++num;
} else { } else {
platform_device_unregister(pdev);
free_netdev(dev); free_netdev(dev);
} }
} }
...@@ -399,23 +388,28 @@ int init_module(void) ...@@ -399,23 +388,28 @@ int init_module(void)
return (0); return (0);
} }
void cleanup_module(void) static void __exit proteon_cleanup(void)
{ {
struct net_device *dev;
int i; int i;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
struct net_device *dev = proteon_dev[i]; struct platform_device *pdev = proteon_dev[i];
if (!dev) if (!pdev)
continue; continue;
dev = dev_get_drvdata(&pdev->dev);
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, PROTEON_IO_EXTENT); release_region(dev->base_addr, PROTEON_IO_EXTENT);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
free_dma(dev->dma); free_dma(dev->dma);
tmsdev_term(dev); tmsdev_term(dev);
free_netdev(dev); free_netdev(dev);
dev_set_drvdata(&pdev->dev, NULL);
platform_device_unregister(pdev);
} }
driver_unregister(&proteon_driver);
} }
#endif /* MODULE */
module_init(proteon_init);
module_exit(proteon_cleanup);
...@@ -68,8 +68,7 @@ static int dmalist[] __initdata = { ...@@ -68,8 +68,7 @@ static int dmalist[] __initdata = {
}; };
static char isa_cardname[] = "SK NET TR 4/16 ISA\0"; static char isa_cardname[] = "SK NET TR 4/16 ISA\0";
static u64 dma_mask = ISA_MAX_ADDRESS;
struct net_device *sk_isa_probe(int unit);
static int sk_isa_open(struct net_device *dev); static int sk_isa_open(struct net_device *dev);
static void sk_isa_read_eeprom(struct net_device *dev); static void sk_isa_read_eeprom(struct net_device *dev);
static unsigned short sk_isa_setnselout_pins(struct net_device *dev); static unsigned short sk_isa_setnselout_pins(struct net_device *dev);
...@@ -133,7 +132,7 @@ static int __init sk_isa_probe1(struct net_device *dev, int ioaddr) ...@@ -133,7 +132,7 @@ static int __init sk_isa_probe1(struct net_device *dev, int ioaddr)
return 0; return 0;
} }
static int __init setup_card(struct net_device *dev) static int __init setup_card(struct net_device *dev, struct device *pdev)
{ {
struct net_local *tp; struct net_local *tp;
static int versionprinted; static int versionprinted;
...@@ -154,7 +153,7 @@ static int __init setup_card(struct net_device *dev) ...@@ -154,7 +153,7 @@ static int __init setup_card(struct net_device *dev)
} }
} }
if (err) if (err)
goto out4; goto out5;
/* At this point we have found a valid card. */ /* At this point we have found a valid card. */
...@@ -162,14 +161,15 @@ static int __init setup_card(struct net_device *dev) ...@@ -162,14 +161,15 @@ static int __init setup_card(struct net_device *dev)
printk(KERN_DEBUG "%s", version); printk(KERN_DEBUG "%s", version);
err = -EIO; err = -EIO;
if (tmsdev_init(dev, ISA_MAX_ADDRESS, NULL)) pdev->dma_mask = &dma_mask;
if (tmsdev_init(dev, ISA_MAX_ADDRESS, pdev))
goto out4; goto out4;
dev->base_addr &= ~3; dev->base_addr &= ~3;
sk_isa_read_eeprom(dev); sk_isa_read_eeprom(dev);
printk(KERN_DEBUG "%s: Ring Station Address: ", dev->name); printk(KERN_DEBUG "skisa.c: Ring Station Address: ");
printk("%2.2x", dev->dev_addr[0]); printk("%2.2x", dev->dev_addr[0]);
for (j = 1; j < 6; j++) for (j = 1; j < 6; j++)
printk(":%2.2x", dev->dev_addr[j]); printk(":%2.2x", dev->dev_addr[j]);
...@@ -202,7 +202,7 @@ static int __init setup_card(struct net_device *dev) ...@@ -202,7 +202,7 @@ static int __init setup_card(struct net_device *dev)
if(irqlist[j] == 0) if(irqlist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no IRQ available\n", dev->name); printk(KERN_INFO "skisa.c: AutoSelect no IRQ available\n");
goto out3; goto out3;
} }
} }
...@@ -213,15 +213,15 @@ static int __init setup_card(struct net_device *dev) ...@@ -213,15 +213,15 @@ static int __init setup_card(struct net_device *dev)
break; break;
if (irqlist[j] == 0) if (irqlist[j] == 0)
{ {
printk(KERN_INFO "%s: Illegal IRQ %d specified\n", printk(KERN_INFO "skisa.c: Illegal IRQ %d specified\n",
dev->name, dev->irq); dev->irq);
goto out3; goto out3;
} }
if (request_irq(dev->irq, tms380tr_interrupt, 0, if (request_irq(dev->irq, tms380tr_interrupt, 0,
isa_cardname, dev)) isa_cardname, dev))
{ {
printk(KERN_INFO "%s: Selected IRQ %d not available\n", printk(KERN_INFO "skisa.c: Selected IRQ %d not available\n",
dev->name, dev->irq); dev->irq);
goto out3; goto out3;
} }
} }
...@@ -237,7 +237,7 @@ static int __init setup_card(struct net_device *dev) ...@@ -237,7 +237,7 @@ static int __init setup_card(struct net_device *dev)
if(dmalist[j] == 0) if(dmalist[j] == 0)
{ {
printk(KERN_INFO "%s: AutoSelect no DMA available\n", dev->name); printk(KERN_INFO "skisa.c: AutoSelect no DMA available\n");
goto out2; goto out2;
} }
} }
...@@ -248,25 +248,25 @@ static int __init setup_card(struct net_device *dev) ...@@ -248,25 +248,25 @@ static int __init setup_card(struct net_device *dev)
break; break;
if (dmalist[j] == 0) if (dmalist[j] == 0)
{ {
printk(KERN_INFO "%s: Illegal DMA %d specified\n", printk(KERN_INFO "skisa.c: Illegal DMA %d specified\n",
dev->name, dev->dma); dev->dma);
goto out2; goto out2;
} }
if (request_dma(dev->dma, isa_cardname)) if (request_dma(dev->dma, isa_cardname))
{ {
printk(KERN_INFO "%s: Selected DMA %d not available\n", printk(KERN_INFO "skisa.c: Selected DMA %d not available\n",
dev->name, dev->dma); dev->dma);
goto out2; goto out2;
} }
} }
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma);
err = register_netdev(dev); err = register_netdev(dev);
if (err) if (err)
goto out; goto out;
printk(KERN_DEBUG "%s: IO: %#4lx IRQ: %d DMA: %d\n",
dev->name, dev->base_addr, dev->irq, dev->dma);
return 0; return 0;
out: out:
free_dma(dev->dma); free_dma(dev->dma);
...@@ -276,32 +276,10 @@ static int __init setup_card(struct net_device *dev) ...@@ -276,32 +276,10 @@ static int __init setup_card(struct net_device *dev)
tmsdev_term(dev); tmsdev_term(dev);
out4: out4:
release_region(dev->base_addr, SK_ISA_IO_EXTENT); release_region(dev->base_addr, SK_ISA_IO_EXTENT);
out5:
return err; return err;
} }
struct net_device * __init sk_isa_probe(int unit)
{
struct net_device *dev = alloc_trdev(sizeof(struct net_local));
int err = 0;
if (!dev)
return ERR_PTR(-ENOMEM);
if (unit >= 0) {
sprintf(dev->name, "tr%d", unit);
netdev_boot_setup_check(dev);
}
err = setup_card(dev);
if (err)
goto out;
return dev;
out:
free_netdev(dev);
return ERR_PTR(err);
}
/* /*
* Reads MAC address from adapter RAM, which should've read it from * Reads MAC address from adapter RAM, which should've read it from
* the onboard ROM. * the onboard ROM.
...@@ -361,8 +339,6 @@ static int sk_isa_open(struct net_device *dev) ...@@ -361,8 +339,6 @@ static int sk_isa_open(struct net_device *dev)
return tms380tr_open(dev); return tms380tr_open(dev);
} }
#ifdef MODULE
#define ISATR_MAX_ADAPTERS 3 #define ISATR_MAX_ADAPTERS 3
static int io[ISATR_MAX_ADAPTERS]; static int io[ISATR_MAX_ADAPTERS];
...@@ -375,13 +351,23 @@ module_param_array(io, int, NULL, 0); ...@@ -375,13 +351,23 @@ module_param_array(io, int, NULL, 0);
module_param_array(irq, int, NULL, 0); module_param_array(irq, int, NULL, 0);
module_param_array(dma, int, NULL, 0); module_param_array(dma, int, NULL, 0);
static struct net_device *sk_isa_dev[ISATR_MAX_ADAPTERS]; static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS];
static struct device_driver sk_isa_driver = {
.name = "skisa",
.bus = &platform_bus_type,
};
int init_module(void) static int __init sk_isa_init(void)
{ {
struct net_device *dev; struct net_device *dev;
struct platform_device *pdev;
int i, num = 0, err = 0; int i, num = 0, err = 0;
err = driver_register(&sk_isa_driver);
if (err)
return err;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
dev = alloc_trdev(sizeof(struct net_local)); dev = alloc_trdev(sizeof(struct net_local));
if (!dev) if (!dev)
...@@ -390,12 +376,15 @@ int init_module(void) ...@@ -390,12 +376,15 @@ int init_module(void)
dev->base_addr = io[i]; dev->base_addr = io[i];
dev->irq = irq[i]; dev->irq = irq[i];
dev->dma = dma[i]; dev->dma = dma[i];
err = setup_card(dev); pdev = platform_device_register_simple("skisa",
i, NULL, 0);
err = setup_card(dev, &pdev->dev);
if (!err) { if (!err) {
sk_isa_dev[i] = dev; sk_isa_dev[i] = pdev;
dev_set_drvdata(&sk_isa_dev[i]->dev, dev);
++num; ++num;
} else { } else {
platform_device_unregister(pdev);
free_netdev(dev); free_netdev(dev);
} }
} }
...@@ -409,23 +398,28 @@ int init_module(void) ...@@ -409,23 +398,28 @@ int init_module(void)
return (0); return (0);
} }
void cleanup_module(void) static void __exit sk_isa_cleanup(void)
{ {
struct net_device *dev;
int i; int i;
for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) { for (i = 0; i < ISATR_MAX_ADAPTERS ; i++) {
struct net_device *dev = sk_isa_dev[i]; struct platform_device *pdev = sk_isa_dev[i];
if (!dev) if (!pdev)
continue; continue;
dev = dev_get_drvdata(&pdev->dev);
unregister_netdev(dev); unregister_netdev(dev);
release_region(dev->base_addr, SK_ISA_IO_EXTENT); release_region(dev->base_addr, SK_ISA_IO_EXTENT);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
free_dma(dev->dma); free_dma(dev->dma);
tmsdev_term(dev); tmsdev_term(dev);
free_netdev(dev); free_netdev(dev);
dev_set_drvdata(&pdev->dev, NULL);
platform_device_unregister(pdev);
} }
driver_unregister(&sk_isa_driver);
} }
#endif /* MODULE */
module_init(sk_isa_init);
module_exit(sk_isa_cleanup);
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
* normal operation. * normal operation.
* 30-Dec-02 JF Removed incorrect __init from * 30-Dec-02 JF Removed incorrect __init from
* tms380tr_init_card. * tms380tr_init_card.
* 22-Jul-05 JF Converted to dma-mapping.
* *
* To do: * To do:
* 1. Multi/Broadcast packet handling (this may have fixed itself) * 1. Multi/Broadcast packet handling (this may have fixed itself)
...@@ -89,7 +90,7 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A ...@@ -89,7 +90,7 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
#include <linux/time.h> #include <linux/time.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/pci.h> #include <linux/dma-mapping.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
...@@ -114,8 +115,6 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A ...@@ -114,8 +115,6 @@ static const char version[] = "tms380tr.c: v1.10 30/12/2002 by Christoph Goos, A
#endif #endif
static unsigned int tms380tr_debug = TMS380TR_DEBUG; static unsigned int tms380tr_debug = TMS380TR_DEBUG;
static struct device tms_device;
/* Index to functions, as function prototypes. /* Index to functions, as function prototypes.
* Alphabetical by function name. * Alphabetical by function name.
*/ */
...@@ -434,7 +433,7 @@ static void tms380tr_init_net_local(struct net_device *dev) ...@@ -434,7 +433,7 @@ static void tms380tr_init_net_local(struct net_device *dev)
skb_put(tp->Rpl[i].Skb, tp->MaxPacketSize); skb_put(tp->Rpl[i].Skb, tp->MaxPacketSize);
/* data unreachable for DMA ? then use local buffer */ /* data unreachable for DMA ? then use local buffer */
dmabuf = pci_map_single(tp->pdev, tp->Rpl[i].Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE); dmabuf = dma_map_single(tp->pdev, tp->Rpl[i].Skb->data, tp->MaxPacketSize, DMA_FROM_DEVICE);
if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit)) if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))
{ {
tp->Rpl[i].SkbStat = SKB_DATA_COPY; tp->Rpl[i].SkbStat = SKB_DATA_COPY;
...@@ -638,10 +637,10 @@ static int tms380tr_hardware_send_packet(struct sk_buff *skb, struct net_device ...@@ -638,10 +637,10 @@ static int tms380tr_hardware_send_packet(struct sk_buff *skb, struct net_device
/* Is buffer reachable for Busmaster-DMA? */ /* Is buffer reachable for Busmaster-DMA? */
length = skb->len; length = skb->len;
dmabuf = pci_map_single(tp->pdev, skb->data, length, PCI_DMA_TODEVICE); dmabuf = dma_map_single(tp->pdev, skb->data, length, DMA_TO_DEVICE);
if(tp->dmalimit && (dmabuf + length > tp->dmalimit)) { if(tp->dmalimit && (dmabuf + length > tp->dmalimit)) {
/* Copy frame to local buffer */ /* Copy frame to local buffer */
pci_unmap_single(tp->pdev, dmabuf, length, PCI_DMA_TODEVICE); dma_unmap_single(tp->pdev, dmabuf, length, DMA_TO_DEVICE);
dmabuf = 0; dmabuf = 0;
i = tp->TplFree->TPLIndex; i = tp->TplFree->TPLIndex;
buf = tp->LocalTxBuffers[i]; buf = tp->LocalTxBuffers[i];
...@@ -1284,9 +1283,7 @@ static int tms380tr_reset_adapter(struct net_device *dev) ...@@ -1284,9 +1283,7 @@ static int tms380tr_reset_adapter(struct net_device *dev)
unsigned short count, c, count2; unsigned short count, c, count2;
const struct firmware *fw_entry = NULL; const struct firmware *fw_entry = NULL;
strncpy(tms_device.bus_id,dev->name, BUS_ID_SIZE); if (request_firmware(&fw_entry, "tms380tr.bin", tp->pdev) != 0) {
if (request_firmware(&fw_entry, "tms380tr.bin", &tms_device) != 0) {
printk(KERN_ALERT "%s: firmware %s is missing, cannot start.\n", printk(KERN_ALERT "%s: firmware %s is missing, cannot start.\n",
dev->name, "tms380tr.bin"); dev->name, "tms380tr.bin");
return (-1); return (-1);
...@@ -2021,7 +2018,7 @@ static void tms380tr_cancel_tx_queue(struct net_local* tp) ...@@ -2021,7 +2018,7 @@ static void tms380tr_cancel_tx_queue(struct net_local* tp)
printk(KERN_INFO "Cancel tx (%08lXh).\n", (unsigned long)tpl); printk(KERN_INFO "Cancel tx (%08lXh).\n", (unsigned long)tpl);
if (tpl->DMABuff) if (tpl->DMABuff)
pci_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, PCI_DMA_TODEVICE); dma_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, DMA_TO_DEVICE);
dev_kfree_skb_any(tpl->Skb); dev_kfree_skb_any(tpl->Skb);
} }
...@@ -2090,7 +2087,7 @@ static void tms380tr_tx_status_irq(struct net_device *dev) ...@@ -2090,7 +2087,7 @@ static void tms380tr_tx_status_irq(struct net_device *dev)
tp->MacStat.tx_packets++; tp->MacStat.tx_packets++;
if (tpl->DMABuff) if (tpl->DMABuff)
pci_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, PCI_DMA_TODEVICE); dma_unmap_single(tp->pdev, tpl->DMABuff, tpl->Skb->len, DMA_TO_DEVICE);
dev_kfree_skb_irq(tpl->Skb); dev_kfree_skb_irq(tpl->Skb);
tpl->BusyFlag = 0; /* "free" TPL */ tpl->BusyFlag = 0; /* "free" TPL */
} }
...@@ -2209,7 +2206,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev) ...@@ -2209,7 +2206,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
tp->MacStat.rx_errors++; tp->MacStat.rx_errors++;
} }
if (rpl->DMABuff) if (rpl->DMABuff)
pci_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, PCI_DMA_TODEVICE); dma_unmap_single(tp->pdev, rpl->DMABuff, tp->MaxPacketSize, DMA_TO_DEVICE);
rpl->DMABuff = 0; rpl->DMABuff = 0;
/* Allocate new skb for rpl */ /* Allocate new skb for rpl */
...@@ -2227,7 +2224,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev) ...@@ -2227,7 +2224,7 @@ static void tms380tr_rcv_status_irq(struct net_device *dev)
skb_put(rpl->Skb, tp->MaxPacketSize); skb_put(rpl->Skb, tp->MaxPacketSize);
/* Data unreachable for DMA ? then use local buffer */ /* Data unreachable for DMA ? then use local buffer */
dmabuf = pci_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, PCI_DMA_FROMDEVICE); dmabuf = dma_map_single(tp->pdev, rpl->Skb->data, tp->MaxPacketSize, DMA_FROM_DEVICE);
if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit)) if(tp->dmalimit && (dmabuf + tp->MaxPacketSize > tp->dmalimit))
{ {
rpl->SkbStat = SKB_DATA_COPY; rpl->SkbStat = SKB_DATA_COPY;
...@@ -2332,12 +2329,12 @@ void tmsdev_term(struct net_device *dev) ...@@ -2332,12 +2329,12 @@ void tmsdev_term(struct net_device *dev)
struct net_local *tp; struct net_local *tp;
tp = netdev_priv(dev); tp = netdev_priv(dev);
pci_unmap_single(tp->pdev, tp->dmabuffer, sizeof(struct net_local), dma_unmap_single(tp->pdev, tp->dmabuffer, sizeof(struct net_local),
PCI_DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
} }
int tmsdev_init(struct net_device *dev, unsigned long dmalimit, int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
struct pci_dev *pdev) struct device *pdev)
{ {
struct net_local *tms_local; struct net_local *tms_local;
...@@ -2346,8 +2343,8 @@ int tmsdev_init(struct net_device *dev, unsigned long dmalimit, ...@@ -2346,8 +2343,8 @@ int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
init_waitqueue_head(&tms_local->wait_for_tok_int); init_waitqueue_head(&tms_local->wait_for_tok_int);
tms_local->dmalimit = dmalimit; tms_local->dmalimit = dmalimit;
tms_local->pdev = pdev; tms_local->pdev = pdev;
tms_local->dmabuffer = pci_map_single(pdev, (void *)tms_local, tms_local->dmabuffer = dma_map_single(pdev, (void *)tms_local,
sizeof(struct net_local), PCI_DMA_BIDIRECTIONAL); sizeof(struct net_local), DMA_BIDIRECTIONAL);
if (tms_local->dmabuffer + sizeof(struct net_local) > dmalimit) if (tms_local->dmabuffer + sizeof(struct net_local) > dmalimit)
{ {
printk(KERN_INFO "%s: Memory not accessible for DMA\n", printk(KERN_INFO "%s: Memory not accessible for DMA\n",
...@@ -2370,8 +2367,6 @@ int tmsdev_init(struct net_device *dev, unsigned long dmalimit, ...@@ -2370,8 +2367,6 @@ int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
return 0; return 0;
} }
#ifdef MODULE
EXPORT_SYMBOL(tms380tr_open); EXPORT_SYMBOL(tms380tr_open);
EXPORT_SYMBOL(tms380tr_close); EXPORT_SYMBOL(tms380tr_close);
EXPORT_SYMBOL(tms380tr_interrupt); EXPORT_SYMBOL(tms380tr_interrupt);
...@@ -2379,6 +2374,8 @@ EXPORT_SYMBOL(tmsdev_init); ...@@ -2379,6 +2374,8 @@ EXPORT_SYMBOL(tmsdev_init);
EXPORT_SYMBOL(tmsdev_term); EXPORT_SYMBOL(tmsdev_term);
EXPORT_SYMBOL(tms380tr_wait); EXPORT_SYMBOL(tms380tr_wait);
#ifdef MODULE
static struct module *TMS380_module = NULL; static struct module *TMS380_module = NULL;
int init_module(void) int init_module(void)
......
...@@ -18,7 +18,7 @@ int tms380tr_open(struct net_device *dev); ...@@ -18,7 +18,7 @@ int tms380tr_open(struct net_device *dev);
int tms380tr_close(struct net_device *dev); int tms380tr_close(struct net_device *dev);
irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs); irqreturn_t tms380tr_interrupt(int irq, void *dev_id, struct pt_regs *regs);
int tmsdev_init(struct net_device *dev, unsigned long dmalimit, int tmsdev_init(struct net_device *dev, unsigned long dmalimit,
struct pci_dev *pdev); struct device *pdev);
void tmsdev_term(struct net_device *dev); void tmsdev_term(struct net_device *dev);
void tms380tr_wait(unsigned long time); void tms380tr_wait(unsigned long time);
...@@ -719,7 +719,7 @@ struct s_TPL { /* Transmit Parameter List (align on even word boundaries) */ ...@@ -719,7 +719,7 @@ struct s_TPL { /* Transmit Parameter List (align on even word boundaries) */
struct sk_buff *Skb; struct sk_buff *Skb;
unsigned char TPLIndex; unsigned char TPLIndex;
volatile unsigned char BusyFlag;/* Flag: TPL busy? */ volatile unsigned char BusyFlag;/* Flag: TPL busy? */
dma_addr_t DMABuff; /* DMA IO bus address from pci_map */ dma_addr_t DMABuff; /* DMA IO bus address from dma_map */
}; };
/* ---------------------Receive Functions-------------------------------* /* ---------------------Receive Functions-------------------------------*
...@@ -1060,7 +1060,7 @@ struct s_RPL { /* Receive Parameter List */ ...@@ -1060,7 +1060,7 @@ struct s_RPL { /* Receive Parameter List */
struct sk_buff *Skb; struct sk_buff *Skb;
SKB_STAT SkbStat; SKB_STAT SkbStat;
int RPLIndex; int RPLIndex;
dma_addr_t DMABuff; /* DMA IO bus address from pci_map */ dma_addr_t DMABuff; /* DMA IO bus address from dma_map */
}; };
/* Information that need to be kept for each board. */ /* Information that need to be kept for each board. */
...@@ -1091,7 +1091,7 @@ typedef struct net_local { ...@@ -1091,7 +1091,7 @@ typedef struct net_local {
RPL *RplTail; RPL *RplTail;
unsigned char LocalRxBuffers[RPL_NUM][DEFAULT_PACKET_SIZE]; unsigned char LocalRxBuffers[RPL_NUM][DEFAULT_PACKET_SIZE];
struct pci_dev *pdev; struct device *pdev;
int DataRate; int DataRate;
unsigned char ScbInUse; unsigned char ScbInUse;
unsigned short CMDqueue; unsigned short CMDqueue;
......
...@@ -143,7 +143,7 @@ static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_devic ...@@ -143,7 +143,7 @@ static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_devic
printk(":%2.2x", dev->dev_addr[i]); printk(":%2.2x", dev->dev_addr[i]);
printk("\n"); printk("\n");
ret = tmsdev_init(dev, PCI_MAX_ADDRESS, pdev); ret = tmsdev_init(dev, PCI_MAX_ADDRESS, &pdev->dev);
if (ret) { if (ret) {
printk("%s: unable to get memory for dev->priv.\n", dev->name); printk("%s: unable to get memory for dev->priv.\n", dev->name);
goto err_out_irq; goto err_out_irq;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册