aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-06-11 08:08:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-11 11:51:03 -0400
commit181bf1e815a2ad2a9a8b30ef6e92583d1530b255 (patch)
treece37e49b099759568b8b8f3dab07fc0813deef41 /drivers/parport
parent3aeda9bc95d064308a70664e6f4a158c96cc1918 (diff)
parport_pc: clean up the modified while loops using for
And tidy up a few bits coding style detectors missed Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/parport')
-rw-r--r--drivers/parport/parport_pc.c98
1 files changed, 57 insertions, 41 deletions
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index edf83e945853..151bf5bc8afe 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -626,7 +626,7 @@ static size_t parport_pc_fifo_write_block_dma(struct parport *port,
626 unsigned long start = (unsigned long) buf; 626 unsigned long start = (unsigned long) buf;
627 unsigned long end = (unsigned long) buf + length - 1; 627 unsigned long end = (unsigned long) buf + length - 1;
628 628
629dump_parport_state("enter fifo_write_block_dma", port); 629 dump_parport_state("enter fifo_write_block_dma", port);
630 if (end < MAX_DMA_ADDRESS) { 630 if (end < MAX_DMA_ADDRESS) {
631 /* If it would cross a 64k boundary, cap it at the end. */ 631 /* If it would cross a 64k boundary, cap it at the end. */
632 if ((start ^ end) & ~0xffffUL) 632 if ((start ^ end) & ~0xffffUL)
@@ -737,7 +737,7 @@ false_alarm:
737 if (dma_handle) 737 if (dma_handle)
738 dma_unmap_single(dev, dma_handle, length, DMA_TO_DEVICE); 738 dma_unmap_single(dev, dma_handle, length, DMA_TO_DEVICE);
739 739
740dump_parport_state("leave fifo_write_block_dma", port); 740 dump_parport_state("leave fifo_write_block_dma", port);
741 return length - left; 741 return length - left;
742} 742}
743#endif 743#endif
@@ -955,8 +955,8 @@ static size_t parport_pc_ecp_read_block_pio(struct parport *port,
955 char *bufp = buf; 955 char *bufp = buf;
956 956
957 port = port->physport; 957 port = port->physport;
958DPRINTK(KERN_DEBUG "parport_pc: parport_pc_ecp_read_block_pio\n"); 958 DPRINTK(KERN_DEBUG "parport_pc: parport_pc_ecp_read_block_pio\n");
959dump_parport_state("enter fcn", port); 959 dump_parport_state("enter fcn", port);
960 960
961 /* Special case: a timeout of zero means we cannot call schedule(). 961 /* Special case: a timeout of zero means we cannot call schedule().
962 * Also if O_NONBLOCK is set then use the default implementation. */ 962 * Also if O_NONBLOCK is set then use the default implementation. */
@@ -1112,14 +1112,15 @@ false_alarm:
1112 1112
1113 if (ecrval & 0x02) { 1113 if (ecrval & 0x02) {
1114 /* FIFO is full. */ 1114 /* FIFO is full. */
1115dump_parport_state("FIFO full", port); 1115 dump_parport_state("FIFO full", port);
1116 insb(fifo, bufp, fifo_depth); 1116 insb(fifo, bufp, fifo_depth);
1117 bufp += fifo_depth; 1117 bufp += fifo_depth;
1118 left -= fifo_depth; 1118 left -= fifo_depth;
1119 continue; 1119 continue;
1120 } 1120 }
1121 1121
1122DPRINTK(KERN_DEBUG "*** ecp_read_block_pio: reading one byte from the FIFO\n"); 1122 DPRINTK(KERN_DEBUG
1123 "*** ecp_read_block_pio: reading one byte from the FIFO\n");
1123 1124
1124 /* FIFO not filled. We will cycle this loop for a while 1125 /* FIFO not filled. We will cycle this loop for a while
1125 * and either the peripheral will fill it faster, 1126 * and either the peripheral will fill it faster,
@@ -1135,7 +1136,7 @@ DPRINTK(KERN_DEBUG "*** ecp_read_block_pio: reading one byte from the FIFO\n");
1135 } 1136 }
1136 1137
1137 port->ieee1284.phase = IEEE1284_PH_REV_IDLE; 1138 port->ieee1284.phase = IEEE1284_PH_REV_IDLE;
1138dump_parport_state("rev idle2", port); 1139 dump_parport_state("rev idle2", port);
1139 1140
1140out_no_data: 1141out_no_data:
1141 1142
@@ -1163,7 +1164,7 @@ out_no_data:
1163 port->name, lost); 1164 port->name, lost);
1164 } 1165 }
1165 1166
1166dump_parport_state("fwd idle", port); 1167 dump_parport_state("fwd idle", port);
1167 return length - left; 1168 return length - left;
1168} 1169}
1169#endif /* 0 */ 1170#endif /* 0 */
@@ -1216,10 +1217,23 @@ static const struct parport_operations parport_pc_ops = {
1216}; 1217};
1217 1218
1218#ifdef CONFIG_PARPORT_PC_SUPERIO 1219#ifdef CONFIG_PARPORT_PC_SUPERIO
1220
1221static struct superio_struct *find_free_superio(void)
1222{
1223 int i;
1224 for (i = 0; i < NR_SUPERIOS; i++)
1225 if (superios[i].io == 0)
1226 return &superios[i];
1227 return NULL;
1228}
1229
1230
1219/* Super-IO chipset detection, Winbond, SMSC */ 1231/* Super-IO chipset detection, Winbond, SMSC */
1220static void __devinit show_parconfig_smsc37c669(int io, int key) 1232static void __devinit show_parconfig_smsc37c669(int io, int key)
1221{ 1233{
1222 int cr1, cr4, cra, cr23, cr26, cr27, i = 0; 1234 int cr1, cr4, cra, cr23, cr26, cr27;
1235 struct superio_struct *s;
1236
1223 static const char *const modes[] = { 1237 static const char *const modes[] = {
1224 "SPP and Bidirectional (PS/2)", 1238 "SPP and Bidirectional (PS/2)",
1225 "EPP and SPP", 1239 "EPP and SPP",
@@ -1272,30 +1286,29 @@ static void __devinit show_parconfig_smsc37c669(int io, int key)
1272 are related, however DMA can be 1 or 3, assume DMA_A=DMA1, 1286 are related, however DMA can be 1 or 3, assume DMA_A=DMA1,
1273 DMA_C=DMA3 (this is true e.g. for TYAN 1564D Tomcat IV) */ 1287 DMA_C=DMA3 (this is true e.g. for TYAN 1564D Tomcat IV) */
1274 if (cr23 * 4 >= 0x100) { /* if active */ 1288 if (cr23 * 4 >= 0x100) { /* if active */
1275 while ((i < NR_SUPERIOS) && (superios[i].io != 0)) 1289 s = find_free_superio();
1276 i++; 1290 if (s == NULL)
1277 if (i == NR_SUPERIOS) {
1278 printk(KERN_INFO "Super-IO: too many chips!\n"); 1291 printk(KERN_INFO "Super-IO: too many chips!\n");
1279 } else { 1292 else {
1280 int d; 1293 int d;
1281 switch (cr23 * 4) { 1294 switch (cr23 * 4) {
1282 case 0x3bc: 1295 case 0x3bc:
1283 superios[i].io = 0x3bc; 1296 s->io = 0x3bc;
1284 superios[i].irq = 7; 1297 s->irq = 7;
1285 break; 1298 break;
1286 case 0x378: 1299 case 0x378:
1287 superios[i].io = 0x378; 1300 s->io = 0x378;
1288 superios[i].irq = 7; 1301 s->irq = 7;
1289 break; 1302 break;
1290 case 0x278: 1303 case 0x278:
1291 superios[i].io = 0x278; 1304 s->io = 0x278;
1292 superios[i].irq = 5; 1305 s->irq = 5;
1293 } 1306 }
1294 d = (cr26 & 0x0f); 1307 d = (cr26 & 0x0f);
1295 if (d == 1 || d == 3) 1308 if (d == 1 || d == 3)
1296 superios[i].dma = d; 1309 s->dma = d;
1297 else 1310 else
1298 superios[i].dma = PARPORT_DMA_NONE; 1311 s->dma = PARPORT_DMA_NONE;
1299 } 1312 }
1300 } 1313 }
1301} 1314}
@@ -1303,7 +1316,8 @@ static void __devinit show_parconfig_smsc37c669(int io, int key)
1303 1316
1304static void __devinit show_parconfig_winbond(int io, int key) 1317static void __devinit show_parconfig_winbond(int io, int key)
1305{ 1318{
1306 int cr30, cr60, cr61, cr70, cr74, crf0, i = 0; 1319 int cr30, cr60, cr61, cr70, cr74, crf0;
1320 struct superio_struct *s;
1307 static const char *const modes[] = { 1321 static const char *const modes[] = {
1308 "Standard (SPP) and Bidirectional(PS/2)", /* 0 */ 1322 "Standard (SPP) and Bidirectional(PS/2)", /* 0 */
1309 "EPP-1.9 and SPP", 1323 "EPP-1.9 and SPP",
@@ -1356,14 +1370,13 @@ static void __devinit show_parconfig_winbond(int io, int key)
1356 } 1370 }
1357 1371
1358 if (cr30 & 0x01) { /* the settings can be interrogated later ... */ 1372 if (cr30 & 0x01) { /* the settings can be interrogated later ... */
1359 while ((i < NR_SUPERIOS) && (superios[i].io != 0)) 1373 s = find_free_superio();
1360 i++; 1374 if (s == NULL)
1361 if (i == NR_SUPERIOS) {
1362 printk(KERN_INFO "Super-IO: too many chips!\n"); 1375 printk(KERN_INFO "Super-IO: too many chips!\n");
1363 } else { 1376 else {
1364 superios[i].io = (cr60<<8)|cr61; 1377 s->io = (cr60 << 8) | cr61;
1365 superios[i].irq = cr70&0x0f; 1378 s->irq = cr70 & 0x0f;
1366 superios[i].dma = (((cr74 & 0x07) > 3) ? 1379 s->dma = (((cr74 & 0x07) > 3) ?
1367 PARPORT_DMA_NONE : (cr74 & 0x07)); 1380 PARPORT_DMA_NONE : (cr74 & 0x07));
1368 } 1381 }
1369 } 1382 }
@@ -1618,25 +1631,28 @@ static void __devinit detect_and_report_it87(void)
1618} 1631}
1619#endif /* CONFIG_PARPORT_PC_SUPERIO */ 1632#endif /* CONFIG_PARPORT_PC_SUPERIO */
1620 1633
1621static int get_superio_dma(struct parport *p) 1634static struct superio_struct *find_superio(struct parport *p)
1622{ 1635{
1623 int i = 0; 1636 int i;
1637 for (i = 0; i < NR_SUPERIOS; i++)
1638 if (superios[i].io != p->base)
1639 return &superios[i];
1640 return NULL;
1641}
1624 1642
1625 while ((i < NR_SUPERIOS) && (superios[i].io != p->base)) 1643static int get_superio_dma(struct parport *p)
1626 i++; 1644{
1627 if (i != NR_SUPERIOS) 1645 struct superio_struct *s = find_superio(p);
1628 return superios[i].dma; 1646 if (s)
1647 return s->dma;
1629 return PARPORT_DMA_NONE; 1648 return PARPORT_DMA_NONE;
1630} 1649}
1631 1650
1632static int get_superio_irq(struct parport *p) 1651static int get_superio_irq(struct parport *p)
1633{ 1652{
1634 int i = 0; 1653 struct superio_struct *s = find_superio(p);
1635 1654 if (s)
1636 while ((i < NR_SUPERIOS) && (superios[i].io != p->base)) 1655 return s->irq;
1637 i++;
1638 if (i != NR_SUPERIOS)
1639 return superios[i].irq;
1640 return PARPORT_IRQ_NONE; 1656 return PARPORT_IRQ_NONE;
1641} 1657}
1642 1658