@@ -45,10 +45,6 @@ struct tnt4882_priv {
45
45
unsigned short imr0_bits ;
46
46
unsigned short imr3_bits ;
47
47
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 );
52
48
};
53
49
54
50
// interface functions
@@ -104,17 +100,17 @@ static const int atgpib_iosize = 32;
104
100
/* paged io */
105
101
static inline unsigned int tnt_paged_readb (struct tnt4882_priv * priv , unsigned long offset )
106
102
{
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 );
108
104
udelay (1 );
109
- return priv -> io_readb (priv -> nec7210_priv .iobase + offset );
105
+ return ioread8 (priv -> nec7210_priv .iobase + offset );
110
106
}
111
107
112
108
static inline void tnt_paged_writeb (struct tnt4882_priv * priv , unsigned int value ,
113
109
unsigned long offset )
114
110
{
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 );
116
112
udelay (1 );
117
- priv -> io_writeb (value , priv -> nec7210_priv .iobase + offset );
113
+ iowrite8 (value , priv -> nec7210_priv .iobase + offset );
118
114
}
119
115
120
116
/* readb/writeb wrappers */
@@ -134,7 +130,7 @@ static inline unsigned short tnt_readb(struct tnt4882_priv *priv, unsigned long
134
130
switch (priv -> nec7210_priv .type ) {
135
131
case TNT4882 :
136
132
case TNT5004 :
137
- retval = priv -> io_readb (address );
133
+ retval = ioread8 (address );
138
134
break ;
139
135
case NAT4882 :
140
136
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
149
145
}
150
146
break ;
151
147
default :
152
- retval = priv -> io_readb (address );
148
+ retval = ioread8 (address );
153
149
break ;
154
150
}
155
151
spin_unlock_irqrestore (register_lock , flags );
@@ -170,7 +166,7 @@ static inline void tnt_writeb(struct tnt4882_priv *priv, unsigned short value, u
170
166
switch (priv -> nec7210_priv .type ) {
171
167
case TNT4882 :
172
168
case TNT5004 :
173
- priv -> io_writeb (value , address );
169
+ iowrite8 (value , address );
174
170
break ;
175
171
case NAT4882 :
176
172
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
183
179
}
184
180
break ;
185
181
default :
186
- priv -> io_writeb (value , address );
182
+ iowrite8 (value , address );
187
183
break ;
188
184
}
189
185
spin_unlock_irqrestore (register_lock , flags );
@@ -288,7 +284,7 @@ static int drain_fifo_words(struct tnt4882_priv *tnt_priv, uint8_t *buffer, int
288
284
while (fifo_word_available (tnt_priv ) && count + 2 <= num_bytes ) {
289
285
short word ;
290
286
291
- word = tnt_priv -> io_readw (nec_priv -> iobase + FIFOB );
287
+ word = ioread16 (nec_priv -> iobase + FIFOB );
292
288
buffer [count ++ ] = word & 0xff ;
293
289
buffer [count ++ ] = (word >> 8 ) & 0xff ;
294
290
}
@@ -573,7 +569,7 @@ static int generic_write(gpib_board_t *board, uint8_t *buffer, size_t length,
573
569
word = buffer [count ++ ] & 0xff ;
574
570
if (count < length )
575
571
word |= (buffer [count ++ ] << 8 ) & 0xff00 ;
576
- tnt_priv -> io_writew (word , nec_priv -> iobase + FIFOB );
572
+ iowrite16 (word , nec_priv -> iobase + FIFOB );
577
573
}
578
574
// avoid unnecessary HR_NFF interrupts
579
575
// tnt_priv->imr3_bits |= HR_NFF;
@@ -1269,10 +1265,6 @@ int ni_pci_attach(gpib_board_t *board, const gpib_board_config_t *config)
1269
1265
if (tnt4882_allocate_private (board ))
1270
1266
return - ENOMEM ;
1271
1267
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 ;
1276
1268
nec_priv = & tnt_priv -> nec7210_priv ;
1277
1269
nec_priv -> type = TNT4882 ;
1278
1270
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 *
1408
1400
if (tnt4882_allocate_private (board ))
1409
1401
return - ENOMEM ;
1410
1402
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 ;
1415
1403
nec_priv = & tnt_priv -> nec7210_priv ;
1416
1404
nec_priv -> type = chipset ;
1417
1405
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 *
1438
1426
pr_err ("tnt4882: failed to allocate ioports\n" );
1439
1427
return -1 ;
1440
1428
}
1441
- nec_priv -> iobase = iobase ;
1429
+ nec_priv -> iobase = ioport_map (iobase , atgpib_iosize );
1430
+ if (!nec_priv -> iobase )
1431
+ return -1 ;
1442
1432
1443
1433
// get irq
1444
1434
if (request_irq (irq , tnt4882_interrupt , isr_flags , "atgpib" , board )) {
@@ -1478,6 +1468,8 @@ void ni_isa_detach(gpib_board_t *board)
1478
1468
tnt4882_board_reset (tnt_priv , board );
1479
1469
if (tnt_priv -> irq )
1480
1470
free_irq (tnt_priv -> irq , board );
1471
+ if (nec_priv -> iobase )
1472
+ ioport_unmap (nec_priv -> iobase );
1481
1473
if (nec_priv -> iobase )
1482
1474
release_region ((unsigned long )(nec_priv -> iobase ), atgpib_iosize );
1483
1475
if (tnt_priv -> pnp_dev )
@@ -1817,10 +1809,6 @@ int ni_pcmcia_attach(gpib_board_t *board, const gpib_board_config_t *config)
1817
1809
if (tnt4882_allocate_private (board ))
1818
1810
return - ENOMEM ;
1819
1811
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 ;
1824
1812
nec_priv = & tnt_priv -> nec7210_priv ;
1825
1813
nec_priv -> type = TNT4882 ;
1826
1814
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)
1835
1823
return - EIO ;
1836
1824
}
1837
1825
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 ;
1839
1830
1840
1831
// get irq
1841
1832
if (request_irq (curr_dev -> irq , tnt4882_interrupt , isr_flags , "tnt4882" , board )) {
@@ -1860,6 +1851,8 @@ void ni_pcmcia_detach(gpib_board_t *board)
1860
1851
nec_priv = & tnt_priv -> nec7210_priv ;
1861
1852
if (tnt_priv -> irq )
1862
1853
free_irq (tnt_priv -> irq , board );
1854
+ if (nec_priv -> iobase )
1855
+ ioport_unmap (nec_priv -> iobase );
1863
1856
if (nec_priv -> iobase ) {
1864
1857
tnt4882_board_reset (tnt_priv , board );
1865
1858
release_region ((unsigned long )nec_priv -> iobase , pcmcia_gpib_iosize );
0 commit comments