From 08e39f6e9e689aa623b2cb6fdab4a845f5f95d61 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Thu, 27 Jan 2005 06:14:55 -0500 Subject: [PATCH] ibmtr 1/2: iomem annotations - trivial part Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- include/linux/ibmtr.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include/linux') diff --git a/include/linux/ibmtr.h b/include/linux/ibmtr.h index dd8cbdc9f1a8..4b181de3ba8f 100644 --- a/include/linux/ibmtr.h +++ b/include/linux/ibmtr.h @@ -169,7 +169,7 @@ typedef enum { CLOSED, OPEN } open_state; struct tok_info { unsigned char irq; - void *mmio; + void __iomem *mmio; unsigned char hw_address[32]; unsigned char adapter_type; unsigned char data_rate; @@ -192,12 +192,12 @@ struct tok_info { /* Additions by Peter De Schrijver */ unsigned char page_mask; /* mask to select RAM page to Map*/ unsigned char mapped_ram_size; /* size of RAM page */ - __u32 sram_virt; /* Shared memory base address */ - __u32 init_srb; /* Initial System Request Block address */ - __u32 srb; /* System Request Block address */ - __u32 ssb; /* System Status Block address */ - __u32 arb; /* Adapter Request Block address */ - __u32 asb; /* Adapter Status Block address */ + __u32 sram_virt; /* Shared memory base address */ + void __iomem *init_srb; /* Initial System Request Block address */ + void __iomem *srb; /* System Request Block address */ + void __iomem *ssb; /* System Status Block address */ + void __iomem *arb; /* Adapter Request Block address */ + void __iomem *asb; /* Adapter Status Block address */ __u8 init_srb_page; __u8 srb_page; __u8 ssb_page; -- cgit v1.2.3 From 5e03b79d8a06f35794d7c86475e9af50ac97a84d Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Thu, 27 Jan 2005 06:15:07 -0500 Subject: [PATCH] ibmtr 2/2: ibmtr annotations - the rest The rest of annotations and cleanup: ->sram_virt abuse removed, we have separate ->sram_phys now (not remapped) and keep ->sram_virt an iomem pointer. Signed-off-by: Al Viro Signed-off-by: Jeff Garzik --- drivers/net/pcmcia/ibmtr_cs.c | 5 +- drivers/net/tokenring/ibmtr.c | 106 ++++++++++++++++++------------------------ include/linux/ibmtr.h | 3 +- 3 files changed, 51 insertions(+), 63 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index bcb7282fc4ca..3107ccfe8f3d 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -343,7 +343,8 @@ static void ibmtr_config(dev_link_t *link) CS_CHECK(MapMemPage, pcmcia_map_mem_page(info->sram_win_handle, &mem)); ti->sram_base = mem.CardOffset >> 12; - ti->sram_virt = (u_long)ioremap(req.Base, req.Size); + ti->sram_virt = ioremap(req.Base, req.Size); + ti->sram_phys = req.Base; CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); @@ -433,7 +434,7 @@ static int ibmtr_event(event_t event, int priority, if (link->state & DEV_CONFIG) { /* set flag to bypass normal interrupt code */ struct tok_info *priv = netdev_priv(dev); - priv->sram_virt |= 1; + priv->sram_phys |= 1; netif_device_detach(dev); } break; diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c index 9678f5101a09..c098863bdd9d 100644 --- a/drivers/net/tokenring/ibmtr.c +++ b/drivers/net/tokenring/ibmtr.c @@ -516,7 +516,7 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr) if (intr == 3) irq = 11; ti->global_int_enable = 0; ti->adapter_int_enable = 0; - ti->sram_virt=(__u32)(inb(PIOaddr+ADAPTRESETREL) & 0xfe) << 12; + ti->sram_phys=(__u32)(inb(PIOaddr+ADAPTRESETREL) & 0xfe) << 12; break; case TR_ISAPNP: if (!t_irq) { @@ -534,7 +534,7 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr) kfree(ti); return -ENODEV; } - ti->sram_virt = + ti->sram_phys = ((__u32)readb(ti->mmio+ACA_OFFSET+ACA_RW+RRR_EVEN)<<12); ti->adapter_int_enable = PIOaddr + ADAPTINTREL; break; @@ -543,7 +543,7 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr) if (ibmtr_debug_trace & TRC_INIT) { /* just report int */ DPRINTK("irq=%d", irq); - printk(", sram_virt=0x%x", ti->sram_virt); + printk(", sram_phys=0x%x", ti->sram_phys); if(ibmtr_debug_trace&TRC_INITV){ /* full chat in verbose only */ DPRINTK(", ti->mmio=%p", ti->mmio); printk(", segment=%02X", segment); @@ -682,7 +682,7 @@ static int __devinit ibmtr_probe1(struct net_device *dev, int PIOaddr) ibmtr_mem_base = chk_base; } } - else ti->sram_base = ti->sram_virt >> 12; + else ti->sram_base = ti->sram_phys >> 12; /* The PCMCIA has already got the interrupt line and the io port, so no chance of anybody else getting it - MLP */ @@ -894,7 +894,7 @@ static int tok_open(struct net_device *dev) */ dev->flags &= ~IFF_RUNNING; - ti->sram_virt &= ~1; /* to reverse what we do in tok_close */ + ti->sram_phys &= ~1; /* to reverse what we do in tok_close */ /* init the spinlock */ spin_lock_init(&ti->lock); init_timer(&ti->tr_timer); @@ -1069,7 +1069,7 @@ static int tok_close(struct net_device *dev) /* unloading the module from memory, and then if a timer pops, ouch */ del_timer_sync(&ti->tr_timer); outb(0, dev->base_addr + ADAPTRESET); - ti->sram_virt |= 1; + ti->sram_phys |= 1; ti->open_status = CLOSED; netif_stop_queue(dev); @@ -1095,31 +1095,33 @@ static char *printerror[]={"Function failure","Signal loss","Reserved", "IMPL force received","Duplicate modifier", "No monitor detected","Monitor contention failed for RPL"}; -void dir_open_adapter (struct net_device *dev) { +static void __iomem *map_address(struct tok_info *ti, unsigned index, __u8 *page) +{ + if (ti->page_mask) { + *page = (index >> 8) & ti->page_mask; + index &= ~(ti->page_mask << 8); + } + return ti->sram_virt + index; +} +void dir_open_adapter (struct net_device *dev) +{ struct tok_info *ti = (struct tok_info *) dev->priv; unsigned char ret_code; __u16 err; - __u16 srb, ssb, arb, asb; - - srb = ntohs(readw(ti->init_srb + SRB_ADDRESS_OFST)); - ssb = ntohs(readw(ti->init_srb + SSB_ADDRESS_OFST)); - arb = ntohs(readw(ti->init_srb + ARB_ADDRESS_OFST)); - asb = ntohs(readw(ti->init_srb + ASB_ADDRESS_OFST)); - if (ti->page_mask) { - ti->srb_page = (srb >> 8) & ti->page_mask; - srb &= ~(ti->page_mask << 8); - ti->ssb_page = (ssb >> 8) & ti->page_mask; - ssb &= ~(ti->page_mask << 8); - ti->arb_page = (arb >> 8) & ti->page_mask; - arb &= ~(ti->page_mask << 8); - ti->asb_page = (asb >> 8) & ti->page_mask; - asb &= ~(ti->page_mask << 8); - } - ti->srb = ti->sram_virt + srb; - ti->ssb = ti->sram_virt + ssb; - ti->arb = ti->sram_virt + arb; - ti->asb = ti->sram_virt + asb; + + ti->srb = map_address(ti, + ntohs(readw(ti->init_srb + SRB_ADDRESS_OFST)), + &ti->srb_page); + ti->ssb = map_address(ti, + ntohs(readw(ti->init_srb + SSB_ADDRESS_OFST)), + &ti->ssb_page); + ti->arb = map_address(ti, + ntohs(readw(ti->init_srb + ARB_ADDRESS_OFST)), + &ti->arb_page); + ti->asb = map_address(ti, + ntohs(readw(ti->init_srb + ASB_ADDRESS_OFST)), + &ti->asb_page); ti->current_skb = NULL; ret_code = readb(ti->init_srb + RETCODE_OFST); err = ntohs(readw(ti->init_srb + OPEN_ERROR_CODE_OFST)); @@ -1190,7 +1192,7 @@ irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs) DPRINTK("Int from tok_driver, dev : %p irq%d regs=%p\n", dev,irq,regs); #endif ti = (struct tok_info *) dev->priv; - if (ti->sram_virt & 1) + if (ti->sram_phys & 1) return IRQ_NONE; /* PCMCIA card extraction flag */ spin_lock(&(ti->lock)); #ifdef ENABLE_PAGING @@ -1222,15 +1224,11 @@ irqreturn_t tok_interrupt(int irq, void *dev_id, struct pt_regs *regs) if (status & ADAP_CHK_INT) { int i; - __u32 check_reason; + void __iomem *check_reason; __u8 check_reason_page = 0; - check_reason = - ntohs(readw(ti->mmio+ ACA_OFFSET+ACA_RW + WWCR_EVEN)); - if (ti->page_mask) { - check_reason_page = (check_reason >> 8) & ti->page_mask; - check_reason &= ~(ti->page_mask << 8); - } - check_reason += ti->sram_virt; + check_reason = map_address(ti, + ntohs(readw(ti->mmio+ ACA_OFFSET+ACA_RW + WWCR_EVEN)), + &check_reason_page); SET_PAGE(check_reason_page); DPRINTK("Adapter check interrupt\n"); @@ -1511,7 +1509,6 @@ static void initial_tok_int(struct net_device *dev) __u32 encoded_addr, hw_encoded_addr; struct tok_info *ti; unsigned char init_status; /*BMS 12/2000*/ - __u16 init_srb; ti = (struct tok_info *) dev->priv; @@ -1520,23 +1517,20 @@ static void initial_tok_int(struct net_device *dev) /* we assign the shared-ram address for ISA devices */ writeb(ti->sram_base, ti->mmio + ACA_OFFSET + ACA_RW + RRR_EVEN); #ifndef PCMCIA - ti->sram_virt = (u32)ioremap(((__u32)ti->sram_base << 12), ti->avail_shared_ram); + ti->sram_virt = ioremap(((__u32)ti->sram_base << 12), ti->avail_shared_ram); #endif - init_srb = ntohs(readw(ti->mmio + ACA_OFFSET + WRBR_EVEN)); - if (ti->page_mask) { - ti->init_srb_page = (init_srb >> 8) & ti->page_mask; - init_srb &= ~(ti->page_mask << 8); - } - ti->init_srb = ti->sram_virt + init_srb; + ti->init_srb = map_address(ti, + ntohs(readw(ti->mmio + ACA_OFFSET + WRBR_EVEN)), + &ti->init_srb_page); if (ti->page_mask && ti->avail_shared_ram == 127) { - int last_512 = 0xfe00, i; - int last_512_page=0; - last_512_page=(last_512>>8)&ti->page_mask; - last_512 &= ~(ti->page_mask << 8); + void __iomem *last_512; + __u8 last_512_page=0; + int i; + last_512 = map_address(ti, 0xfe00, &last_512_page); /* initialize high section of ram (if necessary) */ SET_PAGE(last_512_page); for (i = 0; i < 512; i++) - writeb(0, ti->sram_virt + last_512 + i); + writeb(0, last_512 + i); } SET_PAGE(ti->init_srb_page); @@ -1545,7 +1539,7 @@ static void initial_tok_int(struct net_device *dev) int i; DPRINTK("ti->init_srb_page=0x%x\n", ti->init_srb_page); - DPRINTK("init_srb(%x):", (ti->init_srb) ); + DPRINTK("init_srb(%p):", ti->init_srb ); for (i = 0; i < 20; i++) printk("%02X ", (int) readb(ti->init_srb + i)); printk("\n"); @@ -1709,11 +1703,7 @@ static void tr_rx(struct net_device *dev) SET_PAGE(ti->arb_page); memcpy_fromio(&rarb, ti->arb, sizeof(rarb)); rbuffer = ntohs(rarb.rec_buf_addr) ; - if (ti->page_mask) { - rbuffer_page = (rbuffer >> 8) & ti->page_mask; - rbuffer &= ~(ti->page_mask << 8); - } - rbuf = rbuffer + ti->sram_virt; + rbuf = map_address(ti, rbuffer, &rbuffer_page); SET_PAGE(ti->asb_page); @@ -1830,11 +1820,7 @@ static void tr_rx(struct net_device *dev) rbuffer -= 2; length -= rbuffer_len; data += rbuffer_len; - if (ti->page_mask) { - rbuffer_page = (rbuffer >> 8) & ti->page_mask; - rbuffer &= ~(ti->page_mask << 8); - } - rbuf = ti->sram_virt + rbuffer; + rbuf = map_address(ti, rbuffer, &rbuffer_page); SET_PAGE(rbuffer_page); rbuffer_len = ntohs(readw(rbuf + BUFFER_LENGTH_OFST)); rbufdata = rbuf + offsetof(struct rec_buf, data); diff --git a/include/linux/ibmtr.h b/include/linux/ibmtr.h index 4b181de3ba8f..2ef0b21517fb 100644 --- a/include/linux/ibmtr.h +++ b/include/linux/ibmtr.h @@ -192,7 +192,8 @@ struct tok_info { /* Additions by Peter De Schrijver */ unsigned char page_mask; /* mask to select RAM page to Map*/ unsigned char mapped_ram_size; /* size of RAM page */ - __u32 sram_virt; /* Shared memory base address */ + __u32 sram_phys; /* Shared memory base address */ + void __iomem *sram_virt; /* Shared memory base address */ void __iomem *init_srb; /* Initial System Request Block address */ void __iomem *srb; /* System Request Block address */ void __iomem *ssb; /* System Status Block address */ -- cgit v1.2.3