Commit b97c402b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] starfire iomem annotations

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
parent 82718086
......@@ -779,6 +779,7 @@ struct netdev_private {
struct mii_if_info mii_if; /* MII lib hooks/info */
int phy_cnt; /* MII device addresses. */
unsigned char phys[PHY_CNT]; /* MII device addresses. */
void __iomem *base;
};
......@@ -849,6 +850,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
struct net_device *dev;
static int card_idx = -1;
long ioaddr;
void __iomem *base;
int drv_flags, io_size;
int boguscnt;
......@@ -887,14 +889,12 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
}
/* ioremap is borken in Linux-2.2.x/sparc64 */
#if !defined(CONFIG_SPARC64) || LINUX_VERSION_CODE > 0x20300
ioaddr = (long) ioremap(ioaddr, io_size);
if (!ioaddr) {
base = ioremap(ioaddr, io_size);
if (!base) {
printk(KERN_ERR DRV_NAME " %d: cannot remap %#x @ %#lx, aborting\n",
card_idx, io_size, ioaddr);
goto err_out_free_res;
}
#endif /* !CONFIG_SPARC64 || Linux 2.3.0+ */
pci_set_master(pdev);
......@@ -921,27 +921,27 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
/* Serial EEPROM reads are hidden by the hardware. */
for (i = 0; i < 6; i++)
dev->dev_addr[i] = readb(ioaddr + EEPROMCtrl + 20 - i);
dev->dev_addr[i] = readb(base + EEPROMCtrl + 20 - i);
#if ! defined(final_version) /* Dump the EEPROM contents during development. */
if (debug > 4)
for (i = 0; i < 0x20; i++)
printk("%2.2x%s",
(unsigned int)readb(ioaddr + EEPROMCtrl + i),
(unsigned int)readb(base + EEPROMCtrl + i),
i % 16 != 15 ? " " : "\n");
#endif
/* Issue soft reset */
writel(MiiSoftReset, ioaddr + TxMode);
writel(MiiSoftReset, base + TxMode);
udelay(1000);
writel(0, ioaddr + TxMode);
writel(0, base + TxMode);
/* Reset the chip to erase previous misconfiguration. */
writel(1, ioaddr + PCIDeviceConfig);
writel(1, base + PCIDeviceConfig);
boguscnt = 1000;
while (--boguscnt > 0) {
udelay(10);
if ((readl(ioaddr + PCIDeviceConfig) & 1) == 0)
if ((readl(base + PCIDeviceConfig) & 1) == 0)
break;
}
if (boguscnt == 0)
......@@ -949,10 +949,11 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
/* wait a little longer */
udelay(1000);
dev->base_addr = ioaddr;
dev->base_addr = (unsigned long)base;
dev->irq = irq;
np = netdev_priv(dev);
np->base = base;
spin_lock_init(&np->lock);
pci_set_drvdata(pdev, dev);
......@@ -1024,8 +1025,8 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
if (register_netdev(dev))
goto err_out_cleardev;
printk(KERN_INFO "%s: %s at %#lx, ",
dev->name, netdrv_tbl[chip_idx].name, ioaddr);
printk(KERN_INFO "%s: %s at %p, ",
dev->name, netdrv_tbl[chip_idx].name, base);
for (i = 0; i < 5; i++)
printk("%2.2x:", dev->dev_addr[i]);
printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
......@@ -1068,7 +1069,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
err_out_cleardev:
pci_set_drvdata(pdev, NULL);
iounmap((void *)ioaddr);
iounmap(base);
err_out_free_res:
pci_release_regions (pdev);
err_out_free_netdev:
......@@ -1080,7 +1081,8 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
/* Read the MII Management Data I/O (MDIO) interfaces. */
static int mdio_read(struct net_device *dev, int phy_id, int location)
{
long mdio_addr = dev->base_addr + MIICtrl + (phy_id<<7) + (location<<2);
struct netdev_private *np = netdev_priv(dev);
void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);
int result, boguscnt=1000;
/* ??? Should we add a busy-wait here? */
do
......@@ -1096,7 +1098,8 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
{
long mdio_addr = dev->base_addr + MIICtrl + (phy_id<<7) + (location<<2);
struct netdev_private *np = netdev_priv(dev);
void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);
writel(value, mdio_addr);
/* The busy-wait will occur before a read. */
}
......@@ -1105,7 +1108,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
static int netdev_open(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
long ioaddr = dev->base_addr;
void __iomem *ioaddr = np->base;
int i, retval;
size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;
......@@ -1201,7 +1204,7 @@ static int netdev_open(struct net_device *dev)
writew(0, ioaddr + PerfFilterTable + 8);
for (i = 1; i < 16; i++) {
u16 *eaddrs = (u16 *)dev->dev_addr;
long setup_frm = ioaddr + PerfFilterTable + i * 16;
void __iomem *setup_frm = ioaddr + PerfFilterTable + i * 16;
writew(cpu_to_be16(eaddrs[2]), setup_frm); setup_frm += 4;
writew(cpu_to_be16(eaddrs[1]), setup_frm); setup_frm += 4;
writew(cpu_to_be16(eaddrs[0]), setup_frm); setup_frm += 8;
......@@ -1305,7 +1308,7 @@ static void check_duplex(struct net_device *dev)
static void tx_timeout(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
long ioaddr = dev->base_addr;
void __iomem *ioaddr = np->base;
int old_debug;
printk(KERN_WARNING "%s: Transmit timed out, status %#8.8x, "
......@@ -1353,7 +1356,7 @@ static void init_ring(struct net_device *dev)
/* Grrr, we cannot offset to correctly align the IP header. */
np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid);
}
writew(i - 1, dev->base_addr + RxDescQIdx);
writew(i - 1, np->base + RxDescQIdx);
np->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
/* Clear the remainder of the Rx buffer ring. */
......@@ -1474,7 +1477,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
wmb();
/* Update the producer index. */
writel(entry * (sizeof(starfire_tx_desc) / 8), dev->base_addr + TxProducerIdx);
writel(entry * (sizeof(starfire_tx_desc) / 8), np->base + TxProducerIdx);
/* 4 is arbitrary, but should be ok */
if ((np->cur_tx - np->dirty_tx) + 4 > TX_RING_SIZE)
......@@ -1491,16 +1494,13 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
{
struct net_device *dev = dev_instance;
struct netdev_private *np;
long ioaddr;
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
int boguscnt = max_interrupt_work;
int consumer;
int tx_status;
int handled = 0;
ioaddr = dev->base_addr;
np = netdev_priv(dev);
do {
u32 intr_status = readl(ioaddr + IntrClear);
......@@ -1707,7 +1707,7 @@ static int __netdev_rx(struct net_device *dev, int *quota)
desc->status = 0;
np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE;
}
writew(np->rx_done, dev->base_addr + CompletionQConsumerIdx);
writew(np->rx_done, np->base + CompletionQConsumerIdx);
out:
refill_rx_ring(dev);
......@@ -1722,7 +1722,8 @@ static int __netdev_rx(struct net_device *dev, int *quota)
static int netdev_poll(struct net_device *dev, int *budget)
{
u32 intr_status;
long ioaddr = dev->base_addr;
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
int retcode = 0, quota = dev->quota;
do {
......@@ -1776,14 +1777,14 @@ static void refill_rx_ring(struct net_device *dev)
np->rx_ring[entry].rxaddr |= cpu_to_dma(RxDescEndRing);
}
if (entry >= 0)
writew(entry, dev->base_addr + RxDescQIdx);
writew(entry, np->base + RxDescQIdx);
}
static void netdev_media_change(struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
long ioaddr = dev->base_addr;
void __iomem *ioaddr = np->base;
u16 reg0, reg1, reg4, reg5;
u32 new_tx_mode;
u32 new_intr_timer_ctrl;
......@@ -1862,7 +1863,7 @@ static void netdev_error(struct net_device *dev, int intr_status)
/* Came close to underrunning the Tx FIFO, increase threshold. */
if (intr_status & IntrTxDataLow) {
if (np->tx_threshold <= PKT_BUF_SZ / 16) {
writel(++np->tx_threshold, dev->base_addr + TxThreshold);
writel(++np->tx_threshold, np->base + TxThreshold);
printk(KERN_NOTICE "%s: PCI bus congestion, increasing Tx FIFO threshold to %d bytes\n",
dev->name, np->tx_threshold * 16);
} else
......@@ -1884,8 +1885,8 @@ static void netdev_error(struct net_device *dev, int intr_status)
static struct net_device_stats *get_stats(struct net_device *dev)
{
long ioaddr = dev->base_addr;
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
/* This adapter architecture needs no SMP locks. */
np->stats.tx_bytes = readl(ioaddr + 0x57010);
......@@ -1914,17 +1915,17 @@ static struct net_device_stats *get_stats(struct net_device *dev)
*/
static void set_rx_mode(struct net_device *dev)
{
long ioaddr = dev->base_addr;
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
u32 rx_mode = MinVLANPrio;
struct dev_mc_list *mclist;
int i;
#ifdef VLAN_SUPPORT
struct netdev_private *np = netdev_priv(dev);
rx_mode |= VlanMode;
if (np->vlgrp) {
int vlan_count = 0;
long filter_addr = ioaddr + HashTable + 8;
void __iomem *filter_addr = ioaddr + HashTable + 8;
for (i = 0; i < VLAN_VID_MASK; i++) {
if (np->vlgrp->vlan_devices[i]) {
if (vlan_count >= 32)
......@@ -1953,7 +1954,7 @@ static void set_rx_mode(struct net_device *dev)
rx_mode |= AcceptBroadcast|AcceptAllMulticast|PerfectFilter;
} else if (dev->mc_count <= 14) {
/* Use the 16 element perfect filter, skip first two entries. */
long filter_addr = ioaddr + PerfFilterTable + 2 * 16;
void __iomem *filter_addr = ioaddr + PerfFilterTable + 2 * 16;
u16 *eaddrs;
for (i = 2, mclist = dev->mc_list; mclist && i < dev->mc_count + 2;
i++, mclist = mclist->next) {
......@@ -1971,7 +1972,7 @@ static void set_rx_mode(struct net_device *dev)
rx_mode |= AcceptBroadcast|PerfectFilter;
} else {
/* Must use a multicast hash table. */
long filter_addr;
void __iomem *filter_addr;
u16 *eaddrs;
u16 mc_filter[32] __attribute__ ((aligned(sizeof(long)))); /* Multicast hash filter */
......@@ -2087,8 +2088,8 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
static int netdev_close(struct net_device *dev)
{
long ioaddr = dev->base_addr;
struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base;
int i;
netif_stop_queue(dev);
......@@ -2174,7 +2175,7 @@ static void __devexit starfire_remove_one (struct pci_dev *pdev)
pci_set_power_state(pdev, 3); /* go to sleep in D3 mode */
pci_disable_device(pdev);
iounmap((char *)dev->base_addr);
iounmap(np->base);
pci_release_regions(pdev);
pci_set_drvdata(pdev, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment