Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Char: ip2, macros cleanup

- remove i2os.h -- there was only macro to macro renaming or useless
stuff
- remove another uselless stuf (NULLFUNC, NULLPTR, YES, NO)
- use outb/inb directly
- use locking functions directly
- don't define another ROUNDUP, use roundup(x, 2) instead
- some comments and whitespace cleanup
- remove some commented crap
- prepend the rest by I2 prefix to not collide with rest of the world
like in following output (pointed out by akpm)

In file included from drivers/char/ip2/ip2main.c:128:
drivers/char/ip2/i2ellis.h:608:1: warning: "COMPLETE" redefined
In file included from include/net/netns/ipv4.h:8,
from include/net/net_namespace.h:13,
from include/linux/seq_file.h:7,
from include/asm/machdep.h:12,
from include/asm/pci.h:17,
from include/linux/pci.h:951,
from drivers/char/ip2/ip2main.c:95:
include/net/inet_frag.h:28:1: warning: this is the location of the previous definition

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jiri Slaby and committed by
Linus Torvalds
cf1c63c3 83e422b7

+211 -383
+93 -101
drivers/char/ip2/i2ellis.c
··· 53 53 54 54 static int iiDelayed; // Set when the iiResetDelay function is 55 55 // called. Cleared when ANY board is reset. 56 - static rwlock_t Dl_spinlock; 56 + static DEFINE_RWLOCK(Dl_spinlock); 57 57 58 58 //******** 59 59 //* Code * ··· 82 82 static void 83 83 iiEllisInit(void) 84 84 { 85 - LOCK_INIT(&Dl_spinlock); 86 85 } 87 86 88 87 //****************************************************************************** ··· 131 132 || (address & 0x7) 132 133 ) 133 134 { 134 - COMPLETE(pB,I2EE_BADADDR); 135 + I2_COMPLETE(pB, I2EE_BADADDR); 135 136 } 136 137 137 138 // Initialize accelerators ··· 151 152 pB->i2eValid = I2E_MAGIC; 152 153 pB->i2eState = II_STATE_COLD; 153 154 154 - COMPLETE(pB, I2EE_GOOD); 155 + I2_COMPLETE(pB, I2EE_GOOD); 155 156 } 156 157 157 158 //****************************************************************************** ··· 176 177 // Magic number should be set, else even the address is suspect 177 178 if (pB->i2eValid != I2E_MAGIC) 178 179 { 179 - COMPLETE(pB, I2EE_BADMAGIC); 180 + I2_COMPLETE(pB, I2EE_BADMAGIC); 180 181 } 181 182 182 - OUTB(pB->i2eBase + FIFO_RESET, 0); // Any data will do 183 + outb(0, pB->i2eBase + FIFO_RESET); /* Any data will do */ 183 184 iiDelay(pB, 50); // Pause between resets 184 - OUTB(pB->i2eBase + FIFO_RESET, 0); // Second reset 185 + outb(0, pB->i2eBase + FIFO_RESET); /* Second reset */ 185 186 186 187 // We must wait before even attempting to read anything from the FIFO: the 187 188 // board's P.O.S.T may actually attempt to read and write its end of the ··· 202 203 // Ensure anything which would have been of use to standard loadware is 203 204 // blanked out, since board has now forgotten everything!. 204 205 205 - pB->i2eUsingIrq = IRQ_UNDEFINED; // Not set up to use an interrupt yet 206 + pB->i2eUsingIrq = I2_IRQ_UNDEFINED; /* to not use an interrupt so far */ 206 207 pB->i2eWaitingForEmptyFifo = 0; 207 208 pB->i2eOutMailWaiting = 0; 208 209 pB->i2eChannelPtr = NULL; ··· 214 215 pB->i2eFatalTrap = NULL; 215 216 pB->i2eFatal = 0; 216 217 217 - COMPLETE(pB, I2EE_GOOD); 218 + I2_COMPLETE(pB, I2EE_GOOD); 218 219 } 219 220 220 221 //****************************************************************************** ··· 234 235 iiResetDelay(i2eBordStrPtr pB) 235 236 { 236 237 if (pB->i2eValid != I2E_MAGIC) { 237 - COMPLETE(pB, I2EE_BADMAGIC); 238 + I2_COMPLETE(pB, I2EE_BADMAGIC); 238 239 } 239 240 if (pB->i2eState != II_STATE_RESET) { 240 - COMPLETE(pB, I2EE_BADSTATE); 241 + I2_COMPLETE(pB, I2EE_BADSTATE); 241 242 } 242 243 iiDelay(pB,2000); /* Now we wait for two seconds. */ 243 244 iiDelayed = 1; /* Delay has been called: ok to initialize */ 244 - COMPLETE(pB, I2EE_GOOD); 245 + I2_COMPLETE(pB, I2EE_GOOD); 245 246 } 246 247 247 248 //****************************************************************************** ··· 272 273 273 274 if (pB->i2eValid != I2E_MAGIC) 274 275 { 275 - COMPLETE(pB, I2EE_BADMAGIC); 276 + I2_COMPLETE(pB, I2EE_BADMAGIC); 276 277 } 277 278 278 279 if (pB->i2eState != II_STATE_RESET || !iiDelayed) 279 280 { 280 - COMPLETE(pB, I2EE_BADSTATE); 281 + I2_COMPLETE(pB, I2EE_BADSTATE); 281 282 } 282 283 283 284 // In case there is a failure short of our completely reading the power-up ··· 290 291 for (itemp = 0; itemp < sizeof(porStr); itemp++) 291 292 { 292 293 // We expect the entire message is ready. 293 - if (HAS_NO_INPUT(pB)) 294 - { 294 + if (!I2_HAS_INPUT(pB)) { 295 295 pB->i2ePomSize = itemp; 296 - COMPLETE(pB, I2EE_PORM_SHORT); 296 + I2_COMPLETE(pB, I2EE_PORM_SHORT); 297 297 } 298 298 299 - pB->i2ePom.c[itemp] = c = BYTE_FROM(pB); 299 + pB->i2ePom.c[itemp] = c = inb(pB->i2eData); 300 300 301 301 // We check the magic numbers as soon as they are supposed to be read 302 302 // (rather than after) to minimize effect of reading something we ··· 304 306 (itemp == POR_2_INDEX && c != POR_MAGIC_2)) 305 307 { 306 308 pB->i2ePomSize = itemp+1; 307 - COMPLETE(pB, I2EE_BADMAGIC); 309 + I2_COMPLETE(pB, I2EE_BADMAGIC); 308 310 } 309 311 } 310 312 311 313 pB->i2ePomSize = itemp; 312 314 313 315 // Ensure that this was all the data... 314 - if (HAS_INPUT(pB)) 315 - COMPLETE(pB, I2EE_PORM_LONG); 316 + if (I2_HAS_INPUT(pB)) 317 + I2_COMPLETE(pB, I2EE_PORM_LONG); 316 318 317 319 // For now, we'll fail to initialize if P.O.S.T reports bad chip mapper: 318 320 // Implying we will not be able to download any code either: That's ok: the 319 321 // condition is pretty explicit. 320 322 if (pB->i2ePom.e.porDiag1 & POR_BAD_MAPPER) 321 323 { 322 - COMPLETE(pB, I2EE_POSTERR); 324 + I2_COMPLETE(pB, I2EE_POSTERR); 323 325 } 324 326 325 327 // Determine anything which must be done differently depending on the family ··· 330 332 331 333 pB->i2eFifoStyle = FIFO_II; 332 334 pB->i2eFifoSize = 512; // 512 bytes, always 333 - pB->i2eDataWidth16 = NO; 335 + pB->i2eDataWidth16 = false; 334 336 335 337 pB->i2eMaxIrq = 15; // Because board cannot tell us it is in an 8-bit 336 338 // slot, we do allow it to be done (documentation!) ··· 352 354 // should always be consistent for IntelliPort-II. Ditto below... 353 355 if (pB->i2ePom.e.porPorts1 != 4) 354 356 { 355 - COMPLETE(pB, I2EE_INCONSIST); 357 + I2_COMPLETE(pB, I2EE_INCONSIST); 356 358 } 357 359 break; 358 360 ··· 362 364 pB->i2eChannelMap[0] = 0xff; // Eight port 363 365 if (pB->i2ePom.e.porPorts1 != 8) 364 366 { 365 - COMPLETE(pB, I2EE_INCONSIST); 367 + I2_COMPLETE(pB, I2EE_INCONSIST); 366 368 } 367 369 break; 368 370 ··· 371 373 pB->i2eChannelMap[0] = 0x3f; // Six Port 372 374 if (pB->i2ePom.e.porPorts1 != 6) 373 375 { 374 - COMPLETE(pB, I2EE_INCONSIST); 376 + I2_COMPLETE(pB, I2EE_INCONSIST); 375 377 } 376 378 break; 377 379 } ··· 400 402 401 403 if (itemp < 8 || itemp > 15) 402 404 { 403 - COMPLETE(pB, I2EE_INCONSIST); 405 + I2_COMPLETE(pB, I2EE_INCONSIST); 404 406 } 405 407 pB->i2eFifoSize = (1 << itemp); 406 408 ··· 448 450 switch (pB->i2ePom.e.porBus & (POR_BUS_SLOT16 | POR_BUS_DIP16) ) 449 451 { 450 452 case POR_BUS_SLOT16 | POR_BUS_DIP16: 451 - pB->i2eDataWidth16 = YES; 453 + pB->i2eDataWidth16 = true; 452 454 pB->i2eMaxIrq = 15; 453 455 break; 454 456 455 457 case POR_BUS_SLOT16: 456 - pB->i2eDataWidth16 = NO; 458 + pB->i2eDataWidth16 = false; 457 459 pB->i2eMaxIrq = 15; 458 460 break; 459 461 460 462 case 0: 461 463 case POR_BUS_DIP16: // In an 8-bit slot, DIP switch don't care. 462 464 default: 463 - pB->i2eDataWidth16 = NO; 465 + pB->i2eDataWidth16 = false; 464 466 pB->i2eMaxIrq = 7; 465 467 break; 466 468 } 467 469 break; // POR_ID_FIIEX case 468 470 469 471 default: // Unknown type of board 470 - COMPLETE(pB, I2EE_BAD_FAMILY); 472 + I2_COMPLETE(pB, I2EE_BAD_FAMILY); 471 473 break; 472 474 } // End the switch based on family 473 475 ··· 481 483 { 482 484 case POR_BUS_T_ISA: 483 485 case POR_BUS_T_UNK: // If the type of bus is undeclared, assume ok. 484 - pB->i2eChangeIrq = YES; 485 - break; 486 486 case POR_BUS_T_MCA: 487 487 case POR_BUS_T_EISA: 488 - pB->i2eChangeIrq = NO; 489 488 break; 490 489 default: 491 - COMPLETE(pB, I2EE_BADBUS); 490 + I2_COMPLETE(pB, I2EE_BADBUS); 492 491 } 493 492 494 - if (pB->i2eDataWidth16 == YES) 493 + if (pB->i2eDataWidth16) 495 494 { 496 495 pB->i2eWriteBuf = iiWriteBuf16; 497 496 pB->i2eReadBuf = iiReadBuf16; ··· 524 529 break; 525 530 526 531 default: 527 - COMPLETE(pB, I2EE_INCONSIST); 532 + I2_COMPLETE(pB, I2EE_INCONSIST); 528 533 } 529 534 530 535 // Initialize state information. ··· 544 549 // Everything is ok now, return with good status/ 545 550 546 551 pB->i2eValid = I2E_MAGIC; 547 - COMPLETE(pB, I2EE_GOOD); 552 + I2_COMPLETE(pB, I2EE_GOOD); 548 553 } 549 554 550 555 //****************************************************************************** ··· 653 658 while(mseconds--) { 654 659 int i = ii2DelValue; 655 660 while ( i-- ) { 656 - INB ( ii2Safe ); 661 + inb(ii2Safe); 657 662 } 658 663 } 659 664 } ··· 704 709 { 705 710 // Rudimentary sanity checking here. 706 711 if (pB->i2eValid != I2E_MAGIC) 707 - COMPLETE(pB, I2EE_INVALID); 712 + I2_COMPLETE(pB, I2EE_INVALID); 708 713 709 - OUTSW ( pB->i2eData, address, count); 714 + I2_OUTSW(pB->i2eData, address, count); 710 715 711 - COMPLETE(pB, I2EE_GOOD); 716 + I2_COMPLETE(pB, I2EE_GOOD); 712 717 } 713 718 714 719 //****************************************************************************** ··· 733 738 { 734 739 /* Rudimentary sanity checking here */ 735 740 if (pB->i2eValid != I2E_MAGIC) 736 - COMPLETE(pB, I2EE_INVALID); 741 + I2_COMPLETE(pB, I2EE_INVALID); 737 742 738 - OUTSB ( pB->i2eData, address, count ); 743 + I2_OUTSB(pB->i2eData, address, count); 739 744 740 - COMPLETE(pB, I2EE_GOOD); 745 + I2_COMPLETE(pB, I2EE_GOOD); 741 746 } 742 747 743 748 //****************************************************************************** ··· 762 767 { 763 768 // Rudimentary sanity checking here. 764 769 if (pB->i2eValid != I2E_MAGIC) 765 - COMPLETE(pB, I2EE_INVALID); 770 + I2_COMPLETE(pB, I2EE_INVALID); 766 771 767 - INSW ( pB->i2eData, address, count); 772 + I2_INSW(pB->i2eData, address, count); 768 773 769 - COMPLETE(pB, I2EE_GOOD); 774 + I2_COMPLETE(pB, I2EE_GOOD); 770 775 } 771 776 772 777 //****************************************************************************** ··· 791 796 { 792 797 // Rudimentary sanity checking here. 793 798 if (pB->i2eValid != I2E_MAGIC) 794 - COMPLETE(pB, I2EE_INVALID); 799 + I2_COMPLETE(pB, I2EE_INVALID); 795 800 796 - INSB ( pB->i2eData, address, count); 801 + I2_INSB(pB->i2eData, address, count); 797 802 798 - COMPLETE(pB, I2EE_GOOD); 803 + I2_COMPLETE(pB, I2EE_GOOD); 799 804 } 800 805 801 806 //****************************************************************************** ··· 815 820 static unsigned short 816 821 iiReadWord16(i2eBordStrPtr pB) 817 822 { 818 - return (unsigned short)( INW(pB->i2eData) ); 823 + return inw(pB->i2eData); 819 824 } 820 825 821 826 //****************************************************************************** ··· 837 842 { 838 843 unsigned short urs; 839 844 840 - urs = INB ( pB->i2eData ); 845 + urs = inb(pB->i2eData); 841 846 842 - return ( ( INB ( pB->i2eData ) << 8 ) | urs ); 847 + return (inb(pB->i2eData) << 8) | urs; 843 848 } 844 849 845 850 //****************************************************************************** ··· 860 865 static void 861 866 iiWriteWord16(i2eBordStrPtr pB, unsigned short value) 862 867 { 863 - WORD_TO(pB, (int)value); 868 + outw((int)value, pB->i2eData); 864 869 } 865 870 866 871 //****************************************************************************** ··· 881 886 static void 882 887 iiWriteWord8(i2eBordStrPtr pB, unsigned short value) 883 888 { 884 - BYTE_TO(pB, (char)value); 885 - BYTE_TO(pB, (char)(value >> 8) ); 889 + outb((char)value, pB->i2eData); 890 + outb((char)(value >> 8), pB->i2eData); 886 891 } 887 892 888 893 //****************************************************************************** ··· 934 939 // interrupts of any kind. 935 940 936 941 937 - WRITE_LOCK_IRQSAVE(&Dl_spinlock,flags) 938 - OUTB(pB->i2ePointer, SEL_COMMAND); 939 - OUTB(pB->i2ePointer, SEL_CMD_SH); 942 + write_lock_irqsave(&Dl_spinlock, flags); 943 + outb(SEL_COMMAND, pB->i2ePointer); 944 + outb(SEL_CMD_SH, pB->i2ePointer); 940 945 941 - itemp = INB(pB->i2eStatus); 946 + itemp = inb(pB->i2eStatus); 942 947 943 - OUTB(pB->i2ePointer, SEL_COMMAND); 944 - OUTB(pB->i2ePointer, SEL_CMD_UNSH); 948 + outb(SEL_COMMAND, pB->i2ePointer); 949 + outb(SEL_CMD_UNSH, pB->i2ePointer); 945 950 946 951 if (itemp & ST_IN_EMPTY) 947 952 { 948 - UPDATE_FIFO_ROOM(pB); 949 - WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 950 - COMPLETE(pB, I2EE_GOOD); 953 + I2_UPDATE_FIFO_ROOM(pB); 954 + write_unlock_irqrestore(&Dl_spinlock, flags); 955 + I2_COMPLETE(pB, I2EE_GOOD); 951 956 } 952 957 953 - WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 958 + write_unlock_irqrestore(&Dl_spinlock, flags); 954 959 955 960 if (mSdelay-- == 0) 956 961 break; 957 962 958 963 iiDelay(pB, 1); /* 1 mS granularity on checking condition */ 959 964 } 960 - COMPLETE(pB, I2EE_TXE_TIME); 965 + I2_COMPLETE(pB, I2EE_TXE_TIME); 961 966 } 962 967 963 968 //****************************************************************************** ··· 997 1002 // you will generally not want to service interrupts or in any way 998 1003 // disrupt the assumptions implicit in the larger context. 999 1004 1000 - WRITE_LOCK_IRQSAVE(&Dl_spinlock,flags) 1005 + write_lock_irqsave(&Dl_spinlock, flags); 1001 1006 1002 - if (INB(pB->i2eStatus) & STE_OUT_MT) { 1003 - UPDATE_FIFO_ROOM(pB); 1004 - WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 1005 - COMPLETE(pB, I2EE_GOOD); 1007 + if (inb(pB->i2eStatus) & STE_OUT_MT) { 1008 + I2_UPDATE_FIFO_ROOM(pB); 1009 + write_unlock_irqrestore(&Dl_spinlock, flags); 1010 + I2_COMPLETE(pB, I2EE_GOOD); 1006 1011 } 1007 - WRITE_UNLOCK_IRQRESTORE(&Dl_spinlock,flags) 1012 + write_unlock_irqrestore(&Dl_spinlock, flags); 1008 1013 1009 1014 if (mSdelay-- == 0) 1010 1015 break; 1011 1016 1012 1017 iiDelay(pB, 1); // 1 mS granularity on checking condition 1013 1018 } 1014 - COMPLETE(pB, I2EE_TXE_TIME); 1019 + I2_COMPLETE(pB, I2EE_TXE_TIME); 1015 1020 } 1016 1021 1017 1022 //****************************************************************************** ··· 1033 1038 iiTxMailEmptyII(i2eBordStrPtr pB) 1034 1039 { 1035 1040 int port = pB->i2ePointer; 1036 - OUTB ( port, SEL_OUTMAIL ); 1037 - return ( INB(port) == 0 ); 1041 + outb(SEL_OUTMAIL, port); 1042 + return inb(port) == 0; 1038 1043 } 1039 1044 1040 1045 //****************************************************************************** ··· 1055 1060 static int 1056 1061 iiTxMailEmptyIIEX(i2eBordStrPtr pB) 1057 1062 { 1058 - return !(INB(pB->i2eStatus) & STE_OUT_MAIL); 1063 + return !(inb(pB->i2eStatus) & STE_OUT_MAIL); 1059 1064 } 1060 1065 1061 1066 //****************************************************************************** ··· 1079 1084 { 1080 1085 int port = pB->i2ePointer; 1081 1086 1082 - OUTB(port, SEL_OUTMAIL); 1083 - if (INB(port) == 0) { 1084 - OUTB(port, SEL_OUTMAIL); 1085 - OUTB(port, mail); 1087 + outb(SEL_OUTMAIL, port); 1088 + if (inb(port) == 0) { 1089 + outb(SEL_OUTMAIL, port); 1090 + outb(mail, port); 1086 1091 return 1; 1087 1092 } 1088 1093 return 0; ··· 1107 1112 static int 1108 1113 iiTrySendMailIIEX(i2eBordStrPtr pB, unsigned char mail) 1109 1114 { 1110 - if(INB(pB->i2eStatus) & STE_OUT_MAIL) { 1115 + if (inb(pB->i2eStatus) & STE_OUT_MAIL) 1111 1116 return 0; 1112 - } 1113 - OUTB(pB->i2eXMail, mail); 1117 + outb(mail, pB->i2eXMail); 1114 1118 return 1; 1115 1119 } 1116 1120 ··· 1130 1136 static unsigned short 1131 1137 iiGetMailII(i2eBordStrPtr pB) 1132 1138 { 1133 - if (HAS_MAIL(pB)) { 1134 - OUTB(pB->i2ePointer, SEL_INMAIL); 1135 - return INB(pB->i2ePointer); 1139 + if (I2_HAS_MAIL(pB)) { 1140 + outb(SEL_INMAIL, pB->i2ePointer); 1141 + return inb(pB->i2ePointer); 1136 1142 } else { 1137 1143 return NO_MAIL_HERE; 1138 1144 } ··· 1155 1161 static unsigned short 1156 1162 iiGetMailIIEX(i2eBordStrPtr pB) 1157 1163 { 1158 - if (HAS_MAIL(pB)) { 1159 - return INB(pB->i2eXMail); 1160 - } else { 1164 + if (I2_HAS_MAIL(pB)) 1165 + return inb(pB->i2eXMail); 1166 + else 1161 1167 return NO_MAIL_HERE; 1162 - } 1163 1168 } 1164 1169 1165 1170 //****************************************************************************** ··· 1177 1184 static void 1178 1185 iiEnableMailIrqII(i2eBordStrPtr pB) 1179 1186 { 1180 - OUTB(pB->i2ePointer, SEL_MASK); 1181 - OUTB(pB->i2ePointer, ST_IN_MAIL); 1187 + outb(SEL_MASK, pB->i2ePointer); 1188 + outb(ST_IN_MAIL, pB->i2ePointer); 1182 1189 } 1183 1190 1184 1191 //****************************************************************************** ··· 1197 1204 static void 1198 1205 iiEnableMailIrqIIEX(i2eBordStrPtr pB) 1199 1206 { 1200 - OUTB(pB->i2eXMask, MX_IN_MAIL); 1207 + outb(MX_IN_MAIL, pB->i2eXMask); 1201 1208 } 1202 1209 1203 1210 //****************************************************************************** ··· 1216 1223 static void 1217 1224 iiWriteMaskII(i2eBordStrPtr pB, unsigned char value) 1218 1225 { 1219 - OUTB(pB->i2ePointer, SEL_MASK); 1220 - OUTB(pB->i2ePointer, value); 1226 + outb(SEL_MASK, pB->i2ePointer); 1227 + outb(value, pB->i2ePointer); 1221 1228 } 1222 1229 1223 1230 //****************************************************************************** ··· 1236 1243 static void 1237 1244 iiWriteMaskIIEX(i2eBordStrPtr pB, unsigned char value) 1238 1245 { 1239 - OUTB(pB->i2eXMask, value); 1246 + outb(value, pB->i2eXMask); 1240 1247 } 1241 1248 1242 1249 //****************************************************************************** ··· 1347 1354 // immediately and be harmless, though not strictly necessary. 1348 1355 itemp = MAX_DLOAD_ACK_TIME/10; 1349 1356 while (--itemp) { 1350 - if (HAS_INPUT(pB)) { 1351 - switch(BYTE_FROM(pB)) 1352 - { 1357 + if (I2_HAS_INPUT(pB)) { 1358 + switch (inb(pB->i2eData)) { 1353 1359 case LOADWARE_OK: 1354 1360 pB->i2eState = 1355 1361 isStandard ? II_STATE_STDLOADED :II_STATE_LOADED;
+6 -52
drivers/char/ip2/i2ellis.h
··· 185 185 // The highest allowable IRQ, based on the 186 186 // slot size. 187 187 188 - unsigned char i2eChangeIrq; 189 - // Whether tis valid to change IRQ's 190 - // ISA = ok, EISA, MicroChannel, no 191 - 192 188 // Accelerators for various addresses on the board 193 189 int i2eBase; // I/O Address of the Board 194 190 int i2eData; // From here data transfers happen ··· 427 431 // Manifests for i2eBordStr: 428 432 //------------------------------------------- 429 433 430 - #define YES 1 431 - #define NO 0 432 - 433 - #define NULLFUNC (void (*)(void))0 434 - #define NULLPTR (void *)0 435 - 436 434 typedef void (*delayFunc_t)(unsigned int); 437 435 438 436 // i2eValid ··· 484 494 485 495 // i2eUsingIrq 486 496 // 487 - #define IRQ_UNDEFINED 0x1352 // No valid irq (or polling = 0) can ever 488 - // promote to this! 497 + #define I2_IRQ_UNDEFINED 0x1352 /* No valid irq (or polling = 0) can 498 + * ever promote to this! */ 489 499 //------------------------------------------ 490 500 // Handy Macros for i2ellis.c and others 491 501 // Note these are common to -II and -IIEX ··· 494 504 // Given a pointer to the board structure, does the input FIFO have any data or 495 505 // not? 496 506 // 497 - #define HAS_INPUT(pB) !(INB(pB->i2eStatus) & ST_IN_EMPTY) 498 - #define HAS_NO_INPUT(pB) (INB(pB->i2eStatus) & ST_IN_EMPTY) 499 - 500 - // Given a pointer to board structure, read a byte or word from the fifo 501 - // 502 - #define BYTE_FROM(pB) (unsigned char)INB(pB->i2eData) 503 - #define WORD_FROM(pB) (unsigned short)INW(pB->i2eData) 504 - 505 - // Given a pointer to board structure, is there room for any data to be written 506 - // to the data fifo? 507 - // 508 - #define HAS_OUTROOM(pB) !(INB(pB->i2eStatus) & ST_OUT_FULL) 509 - #define HAS_NO_OUTROOM(pB) (INB(pB->i2eStatus) & ST_OUT_FULL) 510 - 511 - // Given a pointer to board structure, write a single byte to the fifo 512 - // structure. Note that for 16-bit interfaces, the high order byte is undefined 513 - // and unknown. 514 - // 515 - #define BYTE_TO(pB, c) OUTB(pB->i2eData,(c)) 516 - 517 - // Write a word to the fifo structure. For 8-bit interfaces, this may have 518 - // unknown results. 519 - // 520 - #define WORD_TO(pB, c) OUTW(pB->i2eData,(c)) 507 + #define I2_HAS_INPUT(pB) !(inb(pB->i2eStatus) & ST_IN_EMPTY) 521 508 522 509 // Given a pointer to the board structure, is there anything in the incoming 523 510 // mailbox? 524 511 // 525 - #define HAS_MAIL(pB) (INB(pB->i2eStatus) & ST_IN_MAIL) 512 + #define I2_HAS_MAIL(pB) (inb(pB->i2eStatus) & ST_IN_MAIL) 526 513 527 - #define UPDATE_FIFO_ROOM(pB) (pB)->i2eFifoRemains=(pB)->i2eFifoSize 528 - 529 - // Handy macro to round up a number (like the buffer write and read routines do) 530 - // 531 - #define ROUNDUP(number) (((number)+1) & (~1)) 514 + #define I2_UPDATE_FIFO_ROOM(pB) ((pB)->i2eFifoRemains = (pB)->i2eFifoSize) 532 515 533 516 //------------------------------------------ 534 517 // Function Declarations for i2ellis.c ··· 556 593 // 557 594 static int iiDownloadAll(i2eBordStrPtr, loadHdrStrPtr, int, int); 558 595 559 - // Called indirectly always. Needed externally so the routine might be 560 - // SPECIFIED as an argument to iiReset() 561 - // 562 - //static void ii2DelayIO(unsigned int); // N-millisecond delay using 563 - //hardware spin 564 - //static void ii2DelayTimer(unsigned int); // N-millisecond delay using Linux 565 - //timer 566 - 567 596 // Many functions defined here return True if good, False otherwise, with an 568 597 // error code in i2eError field. Here is a handy macro for setting the error 569 598 // code and returning. 570 599 // 571 - #define COMPLETE(pB,code) \ 572 - do { \ 600 + #define I2_COMPLETE(pB,code) do { \ 573 601 pB->i2eError = code; \ 574 602 return (code == I2EE_GOOD);\ 575 603 } while (0)
+5 -1
drivers/char/ip2/i2hw.h
··· 129 129 //------------------------------------------------ 130 130 // 131 131 #include "ip2types.h" 132 - #include "i2os.h" /* For any o.s., compiler, or host-related issues */ 133 132 134 133 //------------------------------------------------------------------------- 135 134 // Manifests for the I/O map: ··· 642 643 #define ABS_MAX_BOXES 4 // Absolute most boxes per board 643 644 #define ABS_BIGGEST_BOX 16 // Absolute the most ports per box 644 645 #define ABS_MOST_PORTS (ABS_MAX_BOXES * ABS_BIGGEST_BOX) 646 + 647 + #define I2_OUTSW(port, addr, count) outsw((port), (addr), (((count)+1)/2)) 648 + #define I2_OUTSB(port, addr, count) outsb((port), (addr), (((count)+1))&-2) 649 + #define I2_INSW(port, addr, count) insw((port), (addr), (((count)+1)/2)) 650 + #define I2_INSB(port, addr, count) insb((port), (addr), (((count)+1))&-2) 645 651 646 652 #endif // I2HW_H 647 653
+73 -68
drivers/char/ip2/i2lib.c
··· 227 227 i2ChanStrPtr *ppCh; 228 228 229 229 if (pB->i2eValid != I2E_MAGIC) { 230 - COMPLETE(pB, I2EE_BADMAGIC); 230 + I2_COMPLETE(pB, I2EE_BADMAGIC); 231 231 } 232 232 if (pB->i2eState != II_STATE_STDLOADED) { 233 - COMPLETE(pB, I2EE_BADSTATE); 233 + I2_COMPLETE(pB, I2EE_BADSTATE); 234 234 } 235 235 236 - LOCK_INIT(&pB->read_fifo_spinlock); 237 - LOCK_INIT(&pB->write_fifo_spinlock); 238 - LOCK_INIT(&pB->Dbuf_spinlock); 239 - LOCK_INIT(&pB->Bbuf_spinlock); 240 - LOCK_INIT(&pB->Fbuf_spinlock); 236 + rwlock_init(&pB->read_fifo_spinlock); 237 + rwlock_init(&pB->write_fifo_spinlock); 238 + rwlock_init(&pB->Dbuf_spinlock); 239 + rwlock_init(&pB->Bbuf_spinlock); 240 + rwlock_init(&pB->Fbuf_spinlock); 241 241 242 242 // NO LOCK needed yet - this is init 243 243 ··· 259 259 if ( !(pB->i2eChannelMap[index >> 4] & (1 << (index & 0xf)) ) ) { 260 260 continue; 261 261 } 262 - LOCK_INIT(&pCh->Ibuf_spinlock); 263 - LOCK_INIT(&pCh->Obuf_spinlock); 264 - LOCK_INIT(&pCh->Cbuf_spinlock); 265 - LOCK_INIT(&pCh->Pbuf_spinlock); 262 + rwlock_init(&pCh->Ibuf_spinlock); 263 + rwlock_init(&pCh->Obuf_spinlock); 264 + rwlock_init(&pCh->Cbuf_spinlock); 265 + rwlock_init(&pCh->Pbuf_spinlock); 266 266 // NO LOCK needed yet - this is init 267 267 // Set up validity flag according to support level 268 268 if (pB->i2eGoodMap[index >> 4] & (1 << (index & 0xf)) ) { ··· 347 347 } 348 348 // No need to check for wrap here; this is initialization. 349 349 pB->i2Fbuf_stuff = stuffIndex; 350 - COMPLETE(pB, I2EE_GOOD); 350 + I2_COMPLETE(pB, I2EE_GOOD); 351 351 352 352 } 353 353 ··· 374 374 375 375 case NEED_INLINE: 376 376 377 - WRITE_LOCK_IRQSAVE(&pB->Dbuf_spinlock,flags); 377 + write_lock_irqsave(&pB->Dbuf_spinlock, flags); 378 378 if ( pB->i2Dbuf_stuff != pB->i2Dbuf_strip) 379 379 { 380 380 queueIndex = pB->i2Dbuf_strip; ··· 386 386 pB->i2Dbuf_strip = queueIndex; 387 387 pCh->channelNeeds &= ~NEED_INLINE; 388 388 } 389 - WRITE_UNLOCK_IRQRESTORE(&pB->Dbuf_spinlock,flags); 389 + write_unlock_irqrestore(&pB->Dbuf_spinlock, flags); 390 390 break; 391 391 392 392 case NEED_BYPASS: 393 393 394 - WRITE_LOCK_IRQSAVE(&pB->Bbuf_spinlock,flags); 394 + write_lock_irqsave(&pB->Bbuf_spinlock, flags); 395 395 if (pB->i2Bbuf_stuff != pB->i2Bbuf_strip) 396 396 { 397 397 queueIndex = pB->i2Bbuf_strip; ··· 403 403 pB->i2Bbuf_strip = queueIndex; 404 404 pCh->channelNeeds &= ~NEED_BYPASS; 405 405 } 406 - WRITE_UNLOCK_IRQRESTORE(&pB->Bbuf_spinlock,flags); 406 + write_unlock_irqrestore(&pB->Bbuf_spinlock, flags); 407 407 break; 408 408 409 409 case NEED_FLOW: 410 410 411 - WRITE_LOCK_IRQSAVE(&pB->Fbuf_spinlock,flags); 411 + write_lock_irqsave(&pB->Fbuf_spinlock, flags); 412 412 if (pB->i2Fbuf_stuff != pB->i2Fbuf_strip) 413 413 { 414 414 queueIndex = pB->i2Fbuf_strip; ··· 420 420 pB->i2Fbuf_strip = queueIndex; 421 421 pCh->channelNeeds &= ~NEED_FLOW; 422 422 } 423 - WRITE_UNLOCK_IRQRESTORE(&pB->Fbuf_spinlock,flags); 423 + write_unlock_irqrestore(&pB->Fbuf_spinlock, flags); 424 424 break; 425 425 default: 426 426 printk(KERN_ERR "i2DeQueueNeeds called with bad type:%x\n",type); ··· 453 453 454 454 case NEED_INLINE: 455 455 456 - WRITE_LOCK_IRQSAVE(&pB->Dbuf_spinlock,flags); 456 + write_lock_irqsave(&pB->Dbuf_spinlock, flags); 457 457 if ( !(pCh->channelNeeds & NEED_INLINE) ) 458 458 { 459 459 pCh->channelNeeds |= NEED_INLINE; ··· 463 463 queueIndex = 0; 464 464 pB->i2Dbuf_stuff = queueIndex; 465 465 } 466 - WRITE_UNLOCK_IRQRESTORE(&pB->Dbuf_spinlock,flags); 466 + write_unlock_irqrestore(&pB->Dbuf_spinlock, flags); 467 467 break; 468 468 469 469 case NEED_BYPASS: 470 470 471 - WRITE_LOCK_IRQSAVE(&pB->Bbuf_spinlock,flags); 471 + write_lock_irqsave(&pB->Bbuf_spinlock, flags); 472 472 if ((type & NEED_BYPASS) && !(pCh->channelNeeds & NEED_BYPASS)) 473 473 { 474 474 pCh->channelNeeds |= NEED_BYPASS; ··· 478 478 queueIndex = 0; 479 479 pB->i2Bbuf_stuff = queueIndex; 480 480 } 481 - WRITE_UNLOCK_IRQRESTORE(&pB->Bbuf_spinlock,flags); 481 + write_unlock_irqrestore(&pB->Bbuf_spinlock, flags); 482 482 break; 483 483 484 484 case NEED_FLOW: 485 485 486 - WRITE_LOCK_IRQSAVE(&pB->Fbuf_spinlock,flags); 486 + write_lock_irqsave(&pB->Fbuf_spinlock, flags); 487 487 if ((type & NEED_FLOW) && !(pCh->channelNeeds & NEED_FLOW)) 488 488 { 489 489 pCh->channelNeeds |= NEED_FLOW; ··· 493 493 queueIndex = 0; 494 494 pB->i2Fbuf_stuff = queueIndex; 495 495 } 496 - WRITE_UNLOCK_IRQRESTORE(&pB->Fbuf_spinlock,flags); 496 + write_unlock_irqrestore(&pB->Fbuf_spinlock, flags); 497 497 break; 498 498 499 499 case NEED_CREDIT: ··· 562 562 pB = pCh->pMyBord; 563 563 564 564 // Board must also exist, and THE INTERRUPT COMMAND ALREADY SENT 565 - if (pB->i2eValid != I2E_MAGIC || pB->i2eUsingIrq == IRQ_UNDEFINED) { 565 + if (pB->i2eValid != I2E_MAGIC || pB->i2eUsingIrq == I2_IRQ_UNDEFINED) 566 566 return -2; 567 - } 568 567 // If the board has gone fatal, return bad, and also hit the trap routine if 569 568 // it exists. 570 569 if (pB->i2eFatal) { ··· 619 620 switch(type) { 620 621 case PTYPE_INLINE: 621 622 lock_var_p = &pCh->Obuf_spinlock; 622 - WRITE_LOCK_IRQSAVE(lock_var_p,flags); 623 + write_lock_irqsave(lock_var_p, flags); 623 624 stuffIndex = pCh->Obuf_stuff; 624 625 bufroom = pCh->Obuf_strip - stuffIndex; 625 626 break; 626 627 case PTYPE_BYPASS: 627 628 lock_var_p = &pCh->Cbuf_spinlock; 628 - WRITE_LOCK_IRQSAVE(lock_var_p,flags); 629 + write_lock_irqsave(lock_var_p, flags); 629 630 stuffIndex = pCh->Cbuf_stuff; 630 631 bufroom = pCh->Cbuf_strip - stuffIndex; 631 632 break; ··· 644 645 break; /* from for()- Enough room: goto proceed */ 645 646 } 646 647 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize); 647 - WRITE_UNLOCK_IRQRESTORE(lock_var_p, flags); 648 + write_unlock_irqrestore(lock_var_p, flags); 648 649 } else 649 650 ip2trace(CHANN, ITRC_QUEUE, 3, 1, totalsize); 650 651 ··· 746 747 { 747 748 case PTYPE_INLINE: 748 749 pCh->Obuf_stuff = stuffIndex; // Store buffer pointer 749 - WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 750 + write_unlock_irqrestore(&pCh->Obuf_spinlock, flags); 750 751 751 752 pB->debugInlineQueued++; 752 753 // Add the channel pointer to list of channels needing service (first ··· 756 757 757 758 case PTYPE_BYPASS: 758 759 pCh->Cbuf_stuff = stuffIndex; // Store buffer pointer 759 - WRITE_UNLOCK_IRQRESTORE(&pCh->Cbuf_spinlock,flags); 760 + write_unlock_irqrestore(&pCh->Cbuf_spinlock, flags); 760 761 761 762 pB->debugBypassQueued++; 762 763 // Add the channel pointer to list of channels needing service (first ··· 839 840 count = -1; 840 841 goto i2Input_exit; 841 842 } 842 - WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); 843 + write_lock_irqsave(&pCh->Ibuf_spinlock, flags); 843 844 844 845 // initialize some accelerators and private copies 845 846 stripIndex = pCh->Ibuf_strip; ··· 849 850 // If buffer is empty or requested data count was 0, (trivial case) return 850 851 // without any further thought. 851 852 if ( count == 0 ) { 852 - WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 853 + write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 853 854 goto i2Input_exit; 854 855 } 855 856 // Adjust for buffer wrap ··· 890 891 891 892 if ((pCh->sinceLastFlow += count) >= pCh->whenSendFlow) { 892 893 pCh->sinceLastFlow -= pCh->whenSendFlow; 893 - WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 894 + write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 894 895 i2QueueNeeds(pCh->pMyBord, pCh, NEED_FLOW); 895 896 } else { 896 - WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 897 + write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 897 898 } 898 899 899 900 i2Input_exit: ··· 925 926 926 927 ip2trace (CHANN, ITRC_INPUT, 10, 0); 927 928 928 - WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); 929 + write_lock_irqsave(&pCh->Ibuf_spinlock, flags); 929 930 count = pCh->Ibuf_stuff - pCh->Ibuf_strip; 930 931 931 932 // Adjust for buffer wrap ··· 946 947 if ( (pCh->sinceLastFlow += count) >= pCh->whenSendFlow ) 947 948 { 948 949 pCh->sinceLastFlow -= pCh->whenSendFlow; 949 - WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 950 + write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 950 951 i2QueueNeeds(pCh->pMyBord, pCh, NEED_FLOW); 951 952 } else { 952 - WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 953 + write_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 953 954 } 954 955 955 956 ip2trace (CHANN, ITRC_INPUT, 19, 1, count); ··· 978 979 979 980 980 981 // initialize some accelerators and private copies 981 - READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags); 982 + read_lock_irqsave(&pCh->Ibuf_spinlock, flags); 982 983 count = pCh->Ibuf_stuff - pCh->Ibuf_strip; 983 - READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags); 984 + read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 984 985 985 986 // Adjust for buffer wrap 986 987 if (count < 0) ··· 1044 1045 while ( count > 0 ) { 1045 1046 1046 1047 // How much room in output buffer is there? 1047 - READ_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1048 + read_lock_irqsave(&pCh->Obuf_spinlock, flags); 1048 1049 amountToMove = pCh->Obuf_strip - pCh->Obuf_stuff - 1; 1049 - READ_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1050 + read_unlock_irqrestore(&pCh->Obuf_spinlock, flags); 1050 1051 if (amountToMove < 0) { 1051 1052 amountToMove += OBUF_SIZE; 1052 1053 } ··· 1074 1075 if ( !(pCh->flush_flags && i2RetryFlushOutput(pCh) ) 1075 1076 && amountToMove > 0 ) 1076 1077 { 1077 - WRITE_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1078 + write_lock_irqsave(&pCh->Obuf_spinlock, flags); 1078 1079 stuffIndex = pCh->Obuf_stuff; 1079 1080 1080 1081 // Had room to move some data: don't know whether the block size, ··· 1101 1102 } 1102 1103 pCh->Obuf_stuff = stuffIndex; 1103 1104 1104 - WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1105 + write_unlock_irqrestore(&pCh->Obuf_spinlock, flags); 1105 1106 1106 1107 ip2trace (CHANN, ITRC_OUTPUT, 13, 1, stuffIndex ); 1107 1108 ··· 1351 1352 if ( !i2Validate ( pCh ) ) { 1352 1353 return -1; 1353 1354 } 1354 - READ_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1355 + read_lock_irqsave(&pCh->Obuf_spinlock, flags); 1355 1356 amountToMove = pCh->Obuf_strip - pCh->Obuf_stuff - 1; 1356 - READ_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1357 + read_unlock_irqrestore(&pCh->Obuf_spinlock, flags); 1357 1358 1358 1359 if (amountToMove < 0) { 1359 1360 amountToMove += OBUF_SIZE; ··· 1463 1464 1464 1465 // ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_ENTER, 0 ); 1465 1466 1466 - while (HAS_INPUT(pB)) { 1467 + while (I2_HAS_INPUT(pB)) { 1467 1468 // ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 2, 0 ); 1468 1469 1469 1470 // Process packet from fifo a one atomic unit 1470 - WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock,bflags); 1471 + write_lock_irqsave(&pB->read_fifo_spinlock, bflags); 1471 1472 1472 1473 // The first word (or two bytes) will have channel number and type of 1473 1474 // packet, possibly other information ··· 1489 1490 // sick! 1490 1491 if ( ((unsigned int)count) > IBUF_SIZE ) { 1491 1492 pB->i2eFatal = 2; 1492 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1493 + write_unlock_irqrestore(&pB->read_fifo_spinlock, 1494 + bflags); 1493 1495 return; /* Bail out ASAP */ 1494 1496 } 1495 1497 // Channel is illegally big ? ··· 1498 1498 (NULL==(pCh = ((i2ChanStrPtr*)pB->i2eChannelPtr)[channel]))) 1499 1499 { 1500 1500 iiReadBuf(pB, junkBuffer, count); 1501 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1501 + write_unlock_irqrestore(&pB->read_fifo_spinlock, 1502 + bflags); 1502 1503 break; /* From switch: ready for next packet */ 1503 1504 } 1504 1505 ··· 1513 1512 if(ID_OF(pB->i2eLeadoffWord) == ID_HOT_KEY) 1514 1513 { 1515 1514 pCh->hotKeyIn = iiReadWord(pB) & 0xff; 1516 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1515 + write_unlock_irqrestore(&pB->read_fifo_spinlock, 1516 + bflags); 1517 1517 i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_HOTACK); 1518 1518 break; /* From the switch: ready for next packet */ 1519 1519 } 1520 1520 1521 1521 // Normal data! We crudely assume there is room for the data in our 1522 1522 // buffer because the board wouldn't have exceeded his credit limit. 1523 - WRITE_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,cflags); 1523 + write_lock_irqsave(&pCh->Ibuf_spinlock, cflags); 1524 1524 // We have 2 locks now 1525 1525 stuffIndex = pCh->Ibuf_stuff; 1526 1526 amountToRead = IBUF_SIZE - stuffIndex; ··· 1564 1562 1565 1563 // Update stuff index 1566 1564 pCh->Ibuf_stuff = stuffIndex; 1567 - WRITE_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,cflags); 1568 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1565 + write_unlock_irqrestore(&pCh->Ibuf_spinlock, cflags); 1566 + write_unlock_irqrestore(&pB->read_fifo_spinlock, 1567 + bflags); 1569 1568 1570 1569 #ifdef USE_IQ 1571 1570 schedule_work(&pCh->tqueue_input); ··· 1588 1585 1589 1586 iiReadBuf(pB, cmdBuffer, count); 1590 1587 // We can release early with buffer grab 1591 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock,bflags); 1588 + write_unlock_irqrestore(&pB->read_fifo_spinlock, 1589 + bflags); 1592 1590 1593 1591 pc = cmdBuffer; 1594 1592 pcLimit = &(cmdBuffer[count]); ··· 1834 1830 default: // Neither packet? should be impossible 1835 1831 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, 5, 1, 1836 1832 PTYPE_OF(pB->i2eLeadoffWord) ); 1837 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, 1833 + write_unlock_irqrestore(&pB->read_fifo_spinlock, 1838 1834 bflags); 1839 1835 1840 1836 break; 1841 1837 } // End of switch on type of packets 1842 - } //while(board HAS_INPUT) 1838 + } /*while(board I2_HAS_INPUT)*/ 1843 1839 1844 1840 ip2trace (ITRC_NO_PORT, ITRC_SFIFO, ITRC_RETURN, 0 ); 1845 1841 ··· 1862 1858 { 1863 1859 int rc = 0; 1864 1860 unsigned long flags; 1865 - WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1861 + write_lock_irqsave(&pB->write_fifo_spinlock, flags); 1866 1862 if (!pB->i2eWaitingForEmptyFifo) { 1867 1863 if (pB->i2eFifoRemains > (count+reserve)) { 1868 1864 pB->i2eFifoRemains -= count; ··· 1871 1867 rc = count; 1872 1868 } 1873 1869 } 1874 - WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1870 + write_unlock_irqrestore(&pB->write_fifo_spinlock, flags); 1875 1871 return rc; 1876 1872 } 1877 1873 //****************************************************************************** ··· 1902 1898 while ( --bailout && notClogged && 1903 1899 (NULL != (pCh = i2DeQueueNeeds(pB,NEED_BYPASS)))) 1904 1900 { 1905 - WRITE_LOCK_IRQSAVE(&pCh->Cbuf_spinlock,flags); 1901 + write_lock_irqsave(&pCh->Cbuf_spinlock, flags); 1906 1902 stripIndex = pCh->Cbuf_strip; 1907 1903 1908 1904 // as long as there are packets for this channel... ··· 1910 1906 while (stripIndex != pCh->Cbuf_stuff) { 1911 1907 pRemove = &(pCh->Cbuf[stripIndex]); 1912 1908 packetSize = CMD_COUNT_OF(pRemove) + sizeof(i2CmdHeader); 1913 - paddedSize = ROUNDUP(packetSize); 1909 + paddedSize = roundup(packetSize, 2); 1914 1910 1915 1911 if (paddedSize > 0) { 1916 1912 if ( 0 == i2Write2Fifo(pB, pRemove, paddedSize,0)) { ··· 1934 1930 // Done with this channel. Move to next, removing this one from 1935 1931 // the queue of channels if we cleaned it out (i.e., didn't get clogged. 1936 1932 pCh->Cbuf_strip = stripIndex; 1937 - WRITE_UNLOCK_IRQRESTORE(&pCh->Cbuf_spinlock,flags); 1933 + write_unlock_irqrestore(&pCh->Cbuf_spinlock, flags); 1938 1934 } // Either clogged or finished all the work 1939 1935 1940 1936 #ifdef IP2DEBUG_TRACE ··· 1958 1954 i2StuffFifoFlow(i2eBordStrPtr pB) 1959 1955 { 1960 1956 i2ChanStrPtr pCh; 1961 - unsigned short paddedSize = ROUNDUP(sizeof(flowIn)); 1957 + unsigned short paddedSize = roundup(sizeof(flowIn), 2); 1962 1958 1963 1959 ip2trace (ITRC_NO_PORT, ITRC_SFLOW, ITRC_ENTER, 2, 1964 1960 pB->i2eFifoRemains, paddedSize ); ··· 2014 2010 while ( --bailout && notClogged && 2015 2011 (NULL != (pCh = i2DeQueueNeeds(pB,NEED_INLINE))) ) 2016 2012 { 2017 - WRITE_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 2013 + write_lock_irqsave(&pCh->Obuf_spinlock, flags); 2018 2014 stripIndex = pCh->Obuf_strip; 2019 2015 2020 2016 ip2trace (CHANN, ITRC_SICMD, 3, 2, stripIndex, pCh->Obuf_stuff ); ··· 2035 2031 packetSize = flowsize + sizeof(i2CmdHeader); 2036 2032 } 2037 2033 flowsize = CREDIT_USAGE(flowsize); 2038 - paddedSize = ROUNDUP(packetSize); 2034 + paddedSize = roundup(packetSize, 2); 2039 2035 2040 2036 ip2trace (CHANN, ITRC_SICMD, 4, 2, pB->i2eFifoRemains, paddedSize ); 2041 2037 ··· 2090 2086 // Done with this channel. Move to next, removing this one from the 2091 2087 // queue of channels if we cleaned it out (i.e., didn't get clogged. 2092 2088 pCh->Obuf_strip = stripIndex; 2093 - WRITE_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 2089 + write_unlock_irqrestore(&pCh->Obuf_spinlock, flags); 2094 2090 if ( notClogged ) 2095 2091 { 2096 2092 ··· 2194 2190 2195 2191 if (inmail & MB_OUT_STRIPPED) { 2196 2192 pB->i2eFifoOutInts++; 2197 - WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 2193 + write_lock_irqsave(&pB->write_fifo_spinlock, flags); 2198 2194 pB->i2eFifoRemains = pB->i2eFifoSize; 2199 2195 pB->i2eWaitingForEmptyFifo = 0; 2200 - WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 2196 + write_unlock_irqrestore(&pB->write_fifo_spinlock, 2197 + flags); 2201 2198 2202 2199 ip2trace (ITRC_NO_PORT, ITRC_INTR, 30, 1, pB->i2eFifoRemains ); 2203 2200
-127
drivers/char/ip2/i2os.h
··· 1 - /******************************************************************************* 2 - * 3 - * (c) 1999 by Computone Corporation 4 - * 5 - ******************************************************************************** 6 - * 7 - * 8 - * PACKAGE: Linux tty Device Driver for IntelliPort II family of multiport 9 - * serial I/O controllers. 10 - * 11 - * DESCRIPTION: Defines, definitions and includes which are heavily dependent 12 - * on O/S, host, compiler, etc. This file is tailored for: 13 - * Linux v2.0.0 and later 14 - * Gnu gcc c2.7.2 15 - * 80x86 architecture 16 - * 17 - *******************************************************************************/ 18 - 19 - #ifndef I2OS_H /* To prevent multiple includes */ 20 - #define I2OS_H 1 21 - 22 - //------------------------------------------------- 23 - // Required Includes 24 - //------------------------------------------------- 25 - 26 - #include "ip2types.h" 27 - #include <asm/io.h> /* For inb, etc */ 28 - 29 - //------------------------------------ 30 - // Defines for I/O instructions: 31 - //------------------------------------ 32 - 33 - #define INB(port) inb(port) 34 - #define OUTB(port,value) outb((value),(port)) 35 - #define INW(port) inw(port) 36 - #define OUTW(port,value) outw((value),(port)) 37 - #define OUTSW(port,addr,count) outsw((port),(addr),(((count)+1)/2)) 38 - #define OUTSB(port,addr,count) outsb((port),(addr),(((count)+1))&-2) 39 - #define INSW(port,addr,count) insw((port),(addr),(((count)+1)/2)) 40 - #define INSB(port,addr,count) insb((port),(addr),(((count)+1))&-2) 41 - 42 - //-------------------------------------------- 43 - // Interrupt control 44 - //-------------------------------------------- 45 - 46 - #define LOCK_INIT(a) rwlock_init(a) 47 - 48 - #define SAVE_AND_DISABLE_INTS(a,b) { \ 49 - /* printk("get_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \ 50 - spin_lock_irqsave(a,b); \ 51 - } 52 - 53 - #define RESTORE_INTS(a,b) { \ 54 - /* printk("rel_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \ 55 - spin_unlock_irqrestore(a,b); \ 56 - } 57 - 58 - #define READ_LOCK_IRQSAVE(a,b) { \ 59 - /* printk("get_read_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \ 60 - read_lock_irqsave(a,b); \ 61 - } 62 - 63 - #define READ_UNLOCK_IRQRESTORE(a,b) { \ 64 - /* printk("rel_read_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \ 65 - read_unlock_irqrestore(a,b); \ 66 - } 67 - 68 - #define WRITE_LOCK_IRQSAVE(a,b) { \ 69 - /* printk("get_write_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \ 70 - write_lock_irqsave(a,b); \ 71 - } 72 - 73 - #define WRITE_UNLOCK_IRQRESTORE(a,b) { \ 74 - /* printk("rel_write_lock: 0x%x,%4d,%s\n",(int)a,__LINE__,__FILE__);*/ \ 75 - write_unlock_irqrestore(a,b); \ 76 - } 77 - 78 - 79 - //------------------------------------------------------------------------------ 80 - // Hardware-delay loop 81 - // 82 - // Probably used in only one place (see i2ellis.c) but this helps keep things 83 - // together. Note we have unwound the IN instructions. On machines with a 84 - // reasonable cache, the eight instructions (1 byte each) should fit in cache 85 - // nicely, and on un-cached machines, the code-fetch would tend not to dominate. 86 - // Note that cx is shifted so that "count" still reflects the total number of 87 - // iterations assuming no unwinding. 88 - //------------------------------------------------------------------------------ 89 - 90 - //#define DELAY1MS(port,count,label) 91 - 92 - //------------------------------------------------------------------------------ 93 - // Macros to switch to a new stack, saving stack pointers, and to restore the 94 - // old stack (Used, for example, in i2lib.c) "heap" is the address of some 95 - // buffer which will become the new stack (working down from highest address). 96 - // The two words at the two lowest addresses in this stack are for storing the 97 - // SS and SP. 98 - //------------------------------------------------------------------------------ 99 - 100 - //#define TO_NEW_STACK(heap,size) 101 - //#define TO_OLD_STACK(heap) 102 - 103 - //------------------------------------------------------------------------------ 104 - // Macros to save the original IRQ vectors and masks, and to patch in new ones. 105 - //------------------------------------------------------------------------------ 106 - 107 - //#define SAVE_IRQ_MASKS(dest) 108 - //#define WRITE_IRQ_MASKS(src) 109 - //#define SAVE_IRQ_VECTOR(value,dest) 110 - //#define WRITE_IRQ_VECTOR(value,src) 111 - 112 - //------------------------------------------------------------------------------ 113 - // Macro to copy data from one far pointer to another. 114 - //------------------------------------------------------------------------------ 115 - 116 - #define I2_MOVE_DATA(fpSource,fpDest,count) memmove(fpDest,fpSource,count); 117 - 118 - //------------------------------------------------------------------------------ 119 - // Macros to issue eoi's to host interrupt control (IBM AT 8259-style). 120 - //------------------------------------------------------------------------------ 121 - 122 - //#define MASTER_EOI 123 - //#define SLAVE_EOI 124 - 125 - #endif /* I2OS_H */ 126 - 127 -
+34 -34
drivers/char/ip2/ip2main.c
··· 1052 1052 * Write to FIFO; don't bother to adjust fifo capacity for this, since 1053 1053 * board will respond almost immediately after SendMail hit. 1054 1054 */ 1055 - WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1055 + write_lock_irqsave(&pB->write_fifo_spinlock, flags); 1056 1056 iiWriteBuf(pB, tempCommand, 4); 1057 - WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1057 + write_unlock_irqrestore(&pB->write_fifo_spinlock, flags); 1058 1058 pB->i2eUsingIrq = boardIrq; 1059 1059 pB->i2eOutMailWaiting |= MB_OUT_STUFFED; 1060 1060 ··· 1072 1072 (CMD_OF(tempCommand))[4] = 64; // chars 1073 1073 1074 1074 (CMD_OF(tempCommand))[5] = 87; // HW_TEST 1075 - WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1075 + write_lock_irqsave(&pB->write_fifo_spinlock, flags); 1076 1076 iiWriteBuf(pB, tempCommand, 8); 1077 - WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1077 + write_unlock_irqrestore(&pB->write_fifo_spinlock, flags); 1078 1078 1079 1079 CHANNEL_OF(tempCommand) = 0; 1080 1080 PTYPE_OF(tempCommand) = PTYPE_BYPASS; ··· 1089 1089 CMD_COUNT_OF(tempCommand) = 2; 1090 1090 (CMD_OF(tempCommand))[0] = 44; /* get ping */ 1091 1091 (CMD_OF(tempCommand))[1] = 200; /* 200 ms */ 1092 - WRITE_LOCK_IRQSAVE(&pB->write_fifo_spinlock,flags); 1092 + write_lock_irqsave(&pB->write_fifo_spinlock, flags); 1093 1093 iiWriteBuf(pB, tempCommand, 4); 1094 - WRITE_UNLOCK_IRQRESTORE(&pB->write_fifo_spinlock,flags); 1094 + write_unlock_irqrestore(&pB->write_fifo_spinlock, flags); 1095 1095 #endif 1096 1096 1097 1097 iiEnableMailIrq(pB); ··· 1270 1270 1271 1271 // Data input 1272 1272 if ( pCh->pTTY != NULL ) { 1273 - READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags) 1273 + read_lock_irqsave(&pCh->Ibuf_spinlock, flags); 1274 1274 if (!pCh->throttled && (pCh->Ibuf_stuff != pCh->Ibuf_strip)) { 1275 - READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1275 + read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 1276 1276 i2Input( pCh ); 1277 1277 } else 1278 - READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1278 + read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 1279 1279 } else { 1280 1280 ip2trace(CHANN, ITRC_INPUT, 22, 0 ); 1281 1281 ··· 1719 1719 ip2_flush_chars( tty ); 1720 1720 1721 1721 /* This is the actual move bit. Make sure it does what we need!!!!! */ 1722 - WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1722 + write_lock_irqsave(&pCh->Pbuf_spinlock, flags); 1723 1723 bytesSent = i2Output( pCh, pData, count); 1724 - WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1724 + write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1725 1725 1726 1726 ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); 1727 1727 ··· 1746 1746 1747 1747 // ip2trace (CHANN, ITRC_PUTC, ITRC_ENTER, 1, ch ); 1748 1748 1749 - WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1749 + write_lock_irqsave(&pCh->Pbuf_spinlock, flags); 1750 1750 pCh->Pbuf[pCh->Pbuf_stuff++] = ch; 1751 1751 if ( pCh->Pbuf_stuff == sizeof pCh->Pbuf ) { 1752 - WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1752 + write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1753 1753 ip2_flush_chars( tty ); 1754 1754 } else 1755 - WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1755 + write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1756 1756 1757 1757 // ip2trace (CHANN, ITRC_PUTC, ITRC_RETURN, 1, ch ); 1758 1758 } ··· 1772 1772 i2ChanStrPtr pCh = tty->driver_data; 1773 1773 unsigned long flags; 1774 1774 1775 - WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1775 + write_lock_irqsave(&pCh->Pbuf_spinlock, flags); 1776 1776 if ( pCh->Pbuf_stuff ) { 1777 1777 1778 1778 // ip2trace (CHANN, ITRC_PUTC, 10, 1, strip ); ··· 1786 1786 } 1787 1787 pCh->Pbuf_stuff -= strip; 1788 1788 } 1789 - WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1789 + write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1790 1790 } 1791 1791 1792 1792 /******************************************************************************/ ··· 1804 1804 i2ChanStrPtr pCh = tty->driver_data; 1805 1805 unsigned long flags; 1806 1806 1807 - READ_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1807 + read_lock_irqsave(&pCh->Pbuf_spinlock, flags); 1808 1808 bytesFree = i2OutputFree( pCh ) - pCh->Pbuf_stuff; 1809 - READ_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1809 + read_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1810 1810 1811 1811 ip2trace (CHANN, ITRC_WRITE, 11, 1, bytesFree ); 1812 1812 ··· 1836 1836 pCh->Obuf_char_count + pCh->Pbuf_stuff, 1837 1837 pCh->Obuf_char_count, pCh->Pbuf_stuff ); 1838 1838 #endif 1839 - READ_LOCK_IRQSAVE(&pCh->Obuf_spinlock,flags); 1839 + read_lock_irqsave(&pCh->Obuf_spinlock, flags); 1840 1840 rc = pCh->Obuf_char_count; 1841 - READ_UNLOCK_IRQRESTORE(&pCh->Obuf_spinlock,flags); 1842 - READ_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1841 + read_unlock_irqrestore(&pCh->Obuf_spinlock, flags); 1842 + read_lock_irqsave(&pCh->Pbuf_spinlock, flags); 1843 1843 rc += pCh->Pbuf_stuff; 1844 - READ_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1844 + read_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1845 1845 return rc; 1846 1846 } 1847 1847 ··· 1865 1865 #ifdef IP2DEBUG_WRITE 1866 1866 printk (KERN_DEBUG "IP2: flush buffer\n" ); 1867 1867 #endif 1868 - WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); 1868 + write_lock_irqsave(&pCh->Pbuf_spinlock, flags); 1869 1869 pCh->Pbuf_stuff = 0; 1870 - WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); 1870 + write_unlock_irqrestore(&pCh->Pbuf_spinlock, flags); 1871 1871 i2FlushOutput( pCh ); 1872 1872 ip2_owake(tty); 1873 1873 ··· 1953 1953 pCh->throttled = 0; 1954 1954 i2QueueCommands(PTYPE_BYPASS, pCh, 0, 1, CMD_RESUME); 1955 1955 serviceOutgoingFifo( pCh->pMyBord ); 1956 - READ_LOCK_IRQSAVE(&pCh->Ibuf_spinlock,flags) 1956 + read_lock_irqsave(&pCh->Ibuf_spinlock, flags); 1957 1957 if ( pCh->Ibuf_stuff != pCh->Ibuf_strip ) { 1958 - READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1958 + read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 1959 1959 #ifdef IP2DEBUG_READ 1960 1960 printk (KERN_DEBUG "i2Input called from unthrottle\n" ); 1961 1961 #endif 1962 1962 i2Input( pCh ); 1963 1963 } else 1964 - READ_UNLOCK_IRQRESTORE(&pCh->Ibuf_spinlock,flags) 1964 + read_unlock_irqrestore(&pCh->Ibuf_spinlock, flags); 1965 1965 } 1966 1966 1967 1967 static void ··· 2204 2204 * for masking). Caller should use TIOCGICOUNT to see which one it was 2205 2205 */ 2206 2206 case TIOCMIWAIT: 2207 - WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); 2207 + write_lock_irqsave(&pB->read_fifo_spinlock, flags); 2208 2208 cprev = pCh->icount; /* note the counters on entry */ 2209 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); 2209 + write_unlock_irqrestore(&pB->read_fifo_spinlock, flags); 2210 2210 i2QueueCommands(PTYPE_BYPASS, pCh, 100, 4, 2211 2211 CMD_DCD_REP, CMD_CTS_REP, CMD_DSR_REP, CMD_RI_REP); 2212 2212 init_waitqueue_entry(&wait, current); ··· 2226 2226 rc = -ERESTARTSYS; 2227 2227 break; 2228 2228 } 2229 - WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); 2229 + write_lock_irqsave(&pB->read_fifo_spinlock, flags); 2230 2230 cnow = pCh->icount; /* atomic copy */ 2231 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); 2231 + write_unlock_irqrestore(&pB->read_fifo_spinlock, flags); 2232 2232 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && 2233 2233 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { 2234 2234 rc = -EIO; /* no change => rc */ ··· 2266 2266 case TIOCGICOUNT: 2267 2267 ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc ); 2268 2268 2269 - WRITE_LOCK_IRQSAVE(&pB->read_fifo_spinlock, flags); 2269 + write_lock_irqsave(&pB->read_fifo_spinlock, flags); 2270 2270 cnow = pCh->icount; 2271 - WRITE_UNLOCK_IRQRESTORE(&pB->read_fifo_spinlock, flags); 2271 + write_unlock_irqrestore(&pB->read_fifo_spinlock, flags); 2272 2272 p_cuser = argp; 2273 2273 rc = put_user(cnow.cts, &p_cuser->cts); 2274 2274 rc = put_user(cnow.dsr, &p_cuser->dsr); ··· 2874 2874 case 65: /* Board - ip2stat */ 2875 2875 if ( pB ) { 2876 2876 rc = copy_to_user(argp, pB, sizeof(i2eBordStr)); 2877 - rc = put_user(INB(pB->i2eStatus), 2877 + rc = put_user(inb(pB->i2eStatus), 2878 2878 (ULONG __user *)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) ); 2879 2879 } else { 2880 2880 rc = -ENODEV;