@@ -45,10 +45,6 @@ struct tnt4882_priv {
4545 unsigned short imr0_bits ;
4646 unsigned short imr3_bits ;
4747 unsigned short auxg_bits ; // bits written to auxiliary register G
48- void (* io_writeb )(unsigned int value , void * address );
49- void (* io_writew )(unsigned int value , void * address );
50- unsigned int (* io_readb )(void * address );
51- unsigned int (* io_readw )(void * address );
5248};
5349
5450// interface functions
@@ -104,17 +100,17 @@ static const int atgpib_iosize = 32;
104100/* paged io */
105101static inline unsigned int tnt_paged_readb (struct tnt4882_priv * priv , unsigned long offset )
106102{
107- priv -> io_writeb (AUX_PAGEIN , priv -> nec7210_priv .iobase + AUXMR * priv -> nec7210_priv .offset );
103+ iowrite8 (AUX_PAGEIN , priv -> nec7210_priv .iobase + AUXMR * priv -> nec7210_priv .offset );
108104 udelay (1 );
109- return priv -> io_readb (priv -> nec7210_priv .iobase + offset );
105+ return ioread8 (priv -> nec7210_priv .iobase + offset );
110106}
111107
112108static inline void tnt_paged_writeb (struct tnt4882_priv * priv , unsigned int value ,
113109 unsigned long offset )
114110{
115- priv -> io_writeb (AUX_PAGEIN , priv -> nec7210_priv .iobase + AUXMR * priv -> nec7210_priv .offset );
111+ iowrite8 (AUX_PAGEIN , priv -> nec7210_priv .iobase + AUXMR * priv -> nec7210_priv .offset );
116112 udelay (1 );
117- priv -> io_writeb (value , priv -> nec7210_priv .iobase + offset );
113+ iowrite8 (value , priv -> nec7210_priv .iobase + offset );
118114}
119115
120116/* readb/writeb wrappers */
@@ -134,7 +130,7 @@ static inline unsigned short tnt_readb(struct tnt4882_priv *priv, unsigned long
134130 switch (priv -> nec7210_priv .type ) {
135131 case TNT4882 :
136132 case TNT5004 :
137- retval = priv -> io_readb (address );
133+ retval = ioread8 (address );
138134 break ;
139135 case NAT4882 :
140136 retval = tnt_paged_readb (priv , offset - tnt_pagein_offset );
@@ -149,7 +145,7 @@ static inline unsigned short tnt_readb(struct tnt4882_priv *priv, unsigned long
149145 }
150146 break ;
151147 default :
152- retval = priv -> io_readb (address );
148+ retval = ioread8 (address );
153149 break ;
154150 }
155151 spin_unlock_irqrestore (register_lock , flags );
@@ -170,7 +166,7 @@ static inline void tnt_writeb(struct tnt4882_priv *priv, unsigned short value, u
170166 switch (priv -> nec7210_priv .type ) {
171167 case TNT4882 :
172168 case TNT5004 :
173- priv -> io_writeb (value , address );
169+ iowrite8 (value , address );
174170 break ;
175171 case NAT4882 :
176172 tnt_paged_writeb (priv , value , offset - tnt_pagein_offset );
@@ -183,7 +179,7 @@ static inline void tnt_writeb(struct tnt4882_priv *priv, unsigned short value, u
183179 }
184180 break ;
185181 default :
186- priv -> io_writeb (value , address );
182+ iowrite8 (value , address );
187183 break ;
188184 }
189185 spin_unlock_irqrestore (register_lock , flags );
@@ -288,7 +284,7 @@ static int drain_fifo_words(struct tnt4882_priv *tnt_priv, uint8_t *buffer, int
288284 while (fifo_word_available (tnt_priv ) && count + 2 <= num_bytes ) {
289285 short word ;
290286
291- word = tnt_priv -> io_readw (nec_priv -> iobase + FIFOB );
287+ word = ioread16 (nec_priv -> iobase + FIFOB );
292288 buffer [count ++ ] = word & 0xff ;
293289 buffer [count ++ ] = (word >> 8 ) & 0xff ;
294290 }
@@ -573,7 +569,7 @@ static int generic_write(gpib_board_t *board, uint8_t *buffer, size_t length,
573569 word = buffer [count ++ ] & 0xff ;
574570 if (count < length )
575571 word |= (buffer [count ++ ] << 8 ) & 0xff00 ;
576- tnt_priv -> io_writew (word , nec_priv -> iobase + FIFOB );
572+ iowrite16 (word , nec_priv -> iobase + FIFOB );
577573 }
578574// avoid unnecessary HR_NFF interrupts
579575// tnt_priv->imr3_bits |= HR_NFF;
@@ -1269,10 +1265,6 @@ int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
12691265 if (tnt4882_allocate_private (board ))
12701266 return - ENOMEM ;
12711267 tnt_priv = board -> private_data ;
1272- tnt_priv -> io_writeb = writeb_wrapper ;
1273- tnt_priv -> io_readb = readb_wrapper ;
1274- tnt_priv -> io_writew = writew_wrapper ;
1275- tnt_priv -> io_readw = readw_wrapper ;
12761268 nec_priv = & tnt_priv -> nec7210_priv ;
12771269 nec_priv -> type = TNT4882 ;
12781270 nec_priv -> read_byte = nec7210_locking_iomem_read_byte ;
@@ -1408,10 +1400,6 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
14081400 if (tnt4882_allocate_private (board ))
14091401 return - ENOMEM ;
14101402 tnt_priv = board -> private_data ;
1411- tnt_priv -> io_writeb = outb_wrapper ;
1412- tnt_priv -> io_readb = inb_wrapper ;
1413- tnt_priv -> io_writew = outw_wrapper ;
1414- tnt_priv -> io_readw = inw_wrapper ;
14151403 nec_priv = & tnt_priv -> nec7210_priv ;
14161404 nec_priv -> type = chipset ;
14171405 nec_priv -> read_byte = nec7210_locking_ioport_read_byte ;
@@ -1438,7 +1426,9 @@ static int ni_isa_attach_common(gpib_board_t *board, const gpib_board_config_t *
14381426 pr_err ("tnt4882: failed to allocate ioports\n" );
14391427 return -1 ;
14401428 }
1441- nec_priv -> iobase = iobase ;
1429+ nec_priv -> iobase = ioport_map (iobase , atgpib_iosize );
1430+ if (!nec_priv -> iobase )
1431+ return -1 ;
14421432
14431433 // get irq
14441434 if (request_irq (irq , tnt4882_interrupt , isr_flags , "atgpib" , board )) {
@@ -1478,6 +1468,8 @@ void ni_isa_detach(gpib_board_t *board)
14781468 tnt4882_board_reset (tnt_priv , board );
14791469 if (tnt_priv -> irq )
14801470 free_irq (tnt_priv -> irq , board );
1471+ if (nec_priv -> iobase )
1472+ ioport_unmap (nec_priv -> iobase );
14811473 if (nec_priv -> iobase )
14821474 release_region ((unsigned long )(nec_priv -> iobase ), atgpib_iosize );
14831475 if (tnt_priv -> pnp_dev )
@@ -1817,10 +1809,6 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
18171809 if (tnt4882_allocate_private (board ))
18181810 return - ENOMEM ;
18191811 tnt_priv = board -> private_data ;
1820- tnt_priv -> io_writeb = outb_wrapper ;
1821- tnt_priv -> io_readb = inb_wrapper ;
1822- tnt_priv -> io_writew = outw_wrapper ;
1823- tnt_priv -> io_readw = inw_wrapper ;
18241812 nec_priv = & tnt_priv -> nec7210_priv ;
18251813 nec_priv -> type = TNT4882 ;
18261814 nec_priv -> read_byte = nec7210_locking_ioport_read_byte ;
@@ -1835,7 +1823,10 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
18351823 return - EIO ;
18361824 }
18371825
1838- nec_priv -> iobase = (void * )(unsigned long )curr_dev -> resource [0 ]-> start ;
1826+ nec_priv -> iobase = ioport_map (curr_dev -> resource [0 ]-> start ,
1827+ resource_size (curr_dev -> resource [0 ]));
1828+ if (!nec_priv -> iobase )
1829+ return -1 ;
18391830
18401831 // get irq
18411832 if (request_irq (curr_dev -> irq , tnt4882_interrupt , isr_flags , "tnt4882" , board )) {
@@ -1860,6 +1851,8 @@ void ni_pcmcia_detach(gpib_board_t *board)
18601851 nec_priv = & tnt_priv -> nec7210_priv ;
18611852 if (tnt_priv -> irq )
18621853 free_irq (tnt_priv -> irq , board );
1854+ if (nec_priv -> iobase )
1855+ ioport_unmap (nec_priv -> iobase );
18631856 if (nec_priv -> iobase ) {
18641857 tnt4882_board_reset (tnt_priv , board );
18651858 release_region ((unsigned long )nec_priv -> iobase , pcmcia_gpib_iosize );
0 commit comments