#include <linux/unistd.h>
#include <linux/ctype.h>
#include <linux/moduleparam.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/bitops.h>
#include <asm/uaccess.h>
-#include <asm/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
static int depca_device_remove (struct device *device);
#ifdef CONFIG_EISA
-struct eisa_device_id depca_eisa_ids[] = {
+static struct eisa_device_id depca_eisa_ids[] = {
{ "DEC4220", de422 },
{ "" }
};
+MODULE_DEVICE_TABLE(eisa, depca_eisa_ids);
static int depca_eisa_probe (struct device *device);
-struct eisa_driver depca_eisa_driver = {
+static struct eisa_driver depca_eisa_driver = {
.id_table = depca_eisa_ids,
.driver = {
.name = depca_string,
};
#endif
-static int depca_isa_probe (struct device *);
+static int depca_isa_probe (struct platform_device *);
-static struct device_driver depca_isa_driver = {
- .name = depca_string,
- .bus = &platform_bus_type,
+static int __devexit depca_isa_remove(struct platform_device *pdev)
+{
+ return depca_device_remove(&pdev->dev);
+}
+
+static struct platform_driver depca_isa_driver = {
.probe = depca_isa_probe,
- .remove = __devexit_p(depca_device_remove),
+ .remove = __devexit_p(depca_isa_remove),
+ .driver = {
+ .name = depca_string,
+ },
};
/*
} depca_bus; /* type of bus */
struct depca_init init_block; /* Shadow Initialization block */
/* CPU address space fields */
- struct depca_rx_desc *rx_ring; /* Pointer to start of RX descriptor ring */
- struct depca_tx_desc *tx_ring; /* Pointer to start of TX descriptor ring */
- void *rx_buff[NUM_RX_DESC]; /* CPU virt address of sh'd memory buffs */
- void *tx_buff[NUM_TX_DESC]; /* CPU virt address of sh'd memory buffs */
- void *sh_mem; /* CPU mapped virt address of device RAM */
+ struct depca_rx_desc __iomem *rx_ring; /* Pointer to start of RX descriptor ring */
+ struct depca_tx_desc __iomem *tx_ring; /* Pointer to start of TX descriptor ring */
+ void __iomem *rx_buff[NUM_RX_DESC]; /* CPU virt address of sh'd memory buffs */
+ void __iomem *tx_buff[NUM_TX_DESC]; /* CPU virt address of sh'd memory buffs */
+ void __iomem *sh_mem; /* CPU mapped virt address of device RAM */
u_long mem_start; /* Bus address of device RAM (before remap) */
u_long mem_len; /* device memory size */
/* Device address space fields */
outb(nicsr, DEPCA_NICSR);
}
- lp->lock = SPIN_LOCK_UNLOCKED;
+ spin_lock_init(&lp->lock);
sprintf(lp->adapter_name, "%s (%s)",
depca_signature[lp->adapter], device->bus_id);
status = -EBUSY;
/* Tx & Rx descriptors (aligned to a quadword boundary) */
offset = (offset + DEPCA_ALIGN) & ~DEPCA_ALIGN;
- lp->rx_ring = (struct depca_rx_desc *) (lp->sh_mem + offset);
+ lp->rx_ring = (struct depca_rx_desc __iomem *) (lp->sh_mem + offset);
lp->rx_ring_offset = offset;
offset += (sizeof(struct depca_rx_desc) * NUM_RX_DESC);
- lp->tx_ring = (struct depca_tx_desc *) (lp->sh_mem + offset);
+ lp->tx_ring = (struct depca_tx_desc __iomem *) (lp->sh_mem + offset);
lp->tx_ring_offset = offset;
offset += (sizeof(struct depca_tx_desc) * NUM_TX_DESC);
/* clear IDON by writing a "1", enable interrupts and start lance */
outw(IDON | INEA | STRT, DEPCA_DATA);
if (depca_debug > 2) {
- printk("%s: DEPCA open after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, virt_to_phys(lp->sh_mem), inw(DEPCA_DATA));
+ printk("%s: DEPCA open after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, lp->mem_start, inw(DEPCA_DATA));
}
} else {
- printk("%s: DEPCA unopen after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, virt_to_phys(lp->sh_mem), inw(DEPCA_DATA));
+ printk("%s: DEPCA unopen after %d ticks, init block 0x%08lx csr0 %4.4x.\n", dev->name, i, lp->mem_start, inw(DEPCA_DATA));
status = -1;
}
** ISA bus I/O device probe
*/
-static void depca_platform_release (struct device *device)
-{
- struct platform_device *pldev;
-
- /* free device */
- pldev = to_platform_device (device);
- kfree (pldev);
-}
-
static void __init depca_platform_probe (void)
{
int i;
* line, use it (if valid) */
if (io && io != depca_io_ports[i].iobase)
continue;
-
- if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL)))
+
+ pldev = platform_device_alloc(depca_string, i);
+ if (!pldev)
continue;
- memset (pldev, 0, sizeof (*pldev));
- pldev->name = depca_string;
- pldev->id = i;
pldev->dev.platform_data = (void *) depca_io_ports[i].iobase;
- pldev->dev.release = depca_platform_release;
depca_io_ports[i].device = pldev;
- if (platform_device_register (pldev)) {
- kfree (pldev);
+ if (platform_device_add(pldev)) {
+ platform_device_put(pldev);
depca_io_ports[i].device = NULL;
continue;
}
* allocated structure */
depca_io_ports[i].device = NULL;
+ pldev->dev.platform_data = NULL;
platform_device_unregister (pldev);
}
}
return adapter;
}
-static int __init depca_isa_probe (struct device *device)
+static int __init depca_isa_probe (struct platform_device *device)
{
struct net_device *dev;
struct depca_private *lp;
enum depca_type adapter = unknown;
int status = 0;
- ioaddr = (u_long) device->platform_data;
+ ioaddr = (u_long) device->dev.platform_data;
if ((status = depca_common_init (ioaddr, &dev)))
goto out;
lp->adapter = adapter;
lp->mem_start = mem_start;
- if ((status = depca_hw_init(dev, device)))
+ if ((status = depca_hw_init(dev, &device->dev)))
goto out_free;
return 0;
static int __init DepcaSignature(char *name, u_long base_addr)
{
u_int i, j, k;
- void *ptr;
+ void __iomem *ptr;
char tmpstr[16];
u_long prom_addr = base_addr + 0xc000;
u_long mem_addr = base_addr + 0x8000; /* 32KB */
/* set up the buffer descriptors */
len = (skb->len < ETH_ZLEN) ? ETH_ZLEN : skb->len;
- for (i = entry; i != end; i = (++i) & lp->txRingMask) {
+ for (i = entry; i != end; i = (i+1) & lp->txRingMask) {
/* clean out flags */
writel(readl(&lp->tx_ring[i].base) & ~T_FLAGS, &lp->tx_ring[i].base);
writew(0x0000, &lp->tx_ring[i].misc); /* clears other error flags */
printk("Descriptor addresses (CPU):\nRX: ");
for (i = 0; i < lp->rxRingMask; i++) {
if (i < 3) {
- printk("0x%8.8lx ", (long) &lp->rx_ring[i].base);
+ printk("%p ", &lp->rx_ring[i].base);
}
}
- printk("...0x%8.8lx\n", (long) &lp->rx_ring[i].base);
+ printk("...%p\n", &lp->rx_ring[i].base);
printk("TX: ");
for (i = 0; i < lp->txRingMask; i++) {
if (i < 3) {
- printk("0x%8.8lx ", (long) &lp->tx_ring[i].base);
+ printk("%p ", &lp->tx_ring[i].base);
}
}
- printk("...0x%8.8lx\n", (long) &lp->tx_ring[i].base);
+ printk("...%p\n", &lp->tx_ring[i].base);
printk("\nDescriptor buffers (Device):\nRX: ");
for (i = 0; i < lp->rxRingMask; i++) {
if (i < 3) {
}
}
printk("...0x%8.8x\n", readl(&lp->tx_ring[i].base));
- printk("Initialisation block at 0x%8.8lx(Phys)\n", virt_to_phys(lp->sh_mem));
+ printk("Initialisation block at 0x%8.8lx(Phys)\n", lp->mem_start);
printk(" mode: 0x%4.4x\n", p->mode);
printk(" physical address: ");
for (i = 0; i < ETH_ALEN - 1; i++) {
printk("%2.2x\n", p->mcast_table[i]);
printk(" rx_ring at: 0x%8.8x\n", p->rx_ring);
printk(" tx_ring at: 0x%8.8x\n", p->tx_ring);
- printk("buffers (Phys): 0x%8.8lx\n", virt_to_phys(lp->sh_mem) + lp->buffs_offset);
+ printk("buffers (Phys): 0x%8.8lx\n", lp->mem_start + lp->buffs_offset);
printk("Ring size:\nRX: %d Log2(rxRingMask): 0x%8.8x\n", (int) lp->rxRingMask + 1, lp->rx_rlen);
printk("TX: %d Log2(txRingMask): 0x%8.8x\n", (int) lp->txRingMask + 1, lp->tx_rlen);
outw(CSR2, DEPCA_ADDR);
#ifdef CONFIG_EISA
err |= eisa_driver_register (&depca_eisa_driver);
#endif
- err |= driver_register (&depca_isa_driver);
+ err |= platform_driver_register (&depca_isa_driver);
depca_platform_probe ();
return err;
#ifdef CONFIG_EISA
eisa_driver_unregister (&depca_eisa_driver);
#endif
- driver_unregister (&depca_isa_driver);
+ platform_driver_unregister (&depca_isa_driver);
for (i = 0; depca_io_ports[i].iobase; i++) {
if (depca_io_ports[i].device) {
+ depca_io_ports[i].device->dev.platform_data = NULL;
platform_device_unregister (depca_io_ports[i].device);
depca_io_ports[i].device = NULL;
}