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

macintosh/via-macii, macintosh/adb-iop: Clean up whitespace

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Finn Thain and committed by
Michael Ellerman
47fd2060 351e5ad3

+179 -165
+28 -20
drivers/macintosh/adb-iop.c
··· 20 20 #include <linux/init.h> 21 21 #include <linux/proc_fs.h> 22 22 23 - #include <asm/macintosh.h> 24 - #include <asm/macints.h> 23 + #include <asm/macintosh.h> 24 + #include <asm/macints.h> 25 25 #include <asm/mac_iop.h> 26 26 #include <asm/mac_oss.h> 27 27 #include <asm/adb_iop.h> 28 28 29 - #include <linux/adb.h> 29 + #include <linux/adb.h> 30 30 31 31 /*#define DEBUG_ADB_IOP*/ 32 32 ··· 38 38 #endif 39 39 40 40 static enum adb_iop_state { 41 - idle, 42 - sending, 43 - awaiting_reply 41 + idle, 42 + sending, 43 + awaiting_reply 44 44 } adb_iop_state; 45 45 46 46 static void adb_iop_start(void); ··· 66 66 { 67 67 req->complete = 1; 68 68 current_req = req->next; 69 - if (req->done) (*req->done)(req); 69 + if (req->done) 70 + (*req->done)(req); 70 71 adb_iop_state = state; 71 72 } 72 73 ··· 101 100 102 101 static void adb_iop_listen(struct iop_msg *msg) 103 102 { 104 - struct adb_iopmsg *amsg = (struct adb_iopmsg *) msg->message; 103 + struct adb_iopmsg *amsg = (struct adb_iopmsg *)msg->message; 105 104 struct adb_request *req; 106 105 unsigned long flags; 107 106 #ifdef DEBUG_ADB_IOP ··· 114 113 115 114 #ifdef DEBUG_ADB_IOP 116 115 printk("adb_iop_listen %p: rcvd packet, %d bytes: %02X %02X", req, 117 - (uint) amsg->count + 2, (uint) amsg->flags, (uint) amsg->cmd); 116 + (uint)amsg->count + 2, (uint)amsg->flags, (uint)amsg->cmd); 118 117 for (i = 0; i < amsg->count; i++) 119 - printk(" %02X", (uint) amsg->data[i]); 118 + printk(" %02X", (uint)amsg->data[i]); 120 119 printk("\n"); 121 120 #endif 122 121 ··· 169 168 170 169 /* get the packet to send */ 171 170 req = current_req; 172 - if (!req) return; 171 + if (!req) 172 + return; 173 173 174 174 local_irq_save(flags); 175 175 176 176 #ifdef DEBUG_ADB_IOP 177 177 printk("adb_iop_start %p: sending packet, %d bytes:", req, req->nbytes); 178 - for (i = 0 ; i < req->nbytes ; i++) 179 - printk(" %02X", (uint) req->data[i]); 178 + for (i = 0; i < req->nbytes; i++) 179 + printk(" %02X", (uint)req->data[i]); 180 180 printk("\n"); 181 181 #endif 182 182 ··· 198 196 /* Now send it. The IOP manager will call adb_iop_complete */ 199 197 /* when the packet has been sent. */ 200 198 201 - iop_send_message(ADB_IOP, ADB_CHAN, req, 202 - sizeof(amsg), (__u8 *) &amsg, adb_iop_complete); 199 + iop_send_message(ADB_IOP, ADB_CHAN, req, sizeof(amsg), (__u8 *)&amsg, 200 + adb_iop_complete); 203 201 } 204 202 205 203 int adb_iop_probe(void) 206 204 { 207 - if (!iop_ism_present) return -ENODEV; 205 + if (!iop_ism_present) 206 + return -ENODEV; 208 207 return 0; 209 208 } 210 209 ··· 221 218 int err; 222 219 223 220 err = adb_iop_write(req); 224 - if (err) return err; 221 + if (err) 222 + return err; 225 223 226 224 if (sync) { 227 - while (!req->complete) adb_iop_poll(); 225 + while (!req->complete) 226 + adb_iop_poll(); 228 227 } 229 228 return 0; 230 229 } ··· 256 251 } 257 252 258 253 local_irq_restore(flags); 259 - if (adb_iop_state == idle) adb_iop_start(); 254 + 255 + if (adb_iop_state == idle) 256 + adb_iop_start(); 260 257 return 0; 261 258 } 262 259 ··· 270 263 271 264 void adb_iop_poll(void) 272 265 { 273 - if (adb_iop_state == idle) adb_iop_start(); 266 + if (adb_iop_state == idle) 267 + adb_iop_start(); 274 268 iop_ism_irq_poll(ADB_IOP); 275 269 } 276 270
+151 -145
drivers/macintosh/via-macii.c
··· 12 12 * 13 13 * 1999-08-02 (jmt) - Initial rewrite for Unified ADB. 14 14 * 2000-03-29 Tony Mantler <tonym@mac.linux-m68k.org> 15 - * - Big overhaul, should actually work now. 15 + * - Big overhaul, should actually work now. 16 16 * 2006-12-31 Finn Thain - Another overhaul. 17 17 * 18 18 * Suggested reading: ··· 23 23 * Apple's "ADB Analyzer" bus sniffer is invaluable: 24 24 * ftp://ftp.apple.com/developer/Tool_Chest/Devices_-_Hardware/Apple_Desktop_Bus/ 25 25 */ 26 - 26 + 27 27 #include <stdarg.h> 28 28 #include <linux/types.h> 29 29 #include <linux/errno.h> ··· 77 77 #define ST_ODD 0x20 /* ADB state: odd data byte */ 78 78 #define ST_IDLE 0x30 /* ADB state: idle, nothing to send */ 79 79 80 - static int macii_init_via(void); 80 + static int macii_init_via(void); 81 81 static void macii_start(void); 82 82 static irqreturn_t macii_interrupt(int irq, void *arg); 83 83 static void macii_queue_poll(void); ··· 123 123 /* Check for MacII style ADB */ 124 124 static int macii_probe(void) 125 125 { 126 - if (macintosh_config->adb_type != MAC_ADB_II) return -ENODEV; 126 + if (macintosh_config->adb_type != MAC_ADB_II) 127 + return -ENODEV; 127 128 128 129 via = via1; 129 130 ··· 137 136 { 138 137 unsigned long flags; 139 138 int err; 140 - 139 + 141 140 local_irq_save(flags); 142 - 141 + 143 142 err = macii_init_via(); 144 - if (err) goto out; 143 + if (err) 144 + goto out; 145 145 146 146 err = request_irq(IRQ_MAC_ADB, macii_interrupt, 0, "ADB", 147 147 macii_interrupt); 148 - if (err) goto out; 148 + if (err) 149 + goto out; 149 150 150 151 macii_state = idle; 151 152 out: ··· 155 152 return err; 156 153 } 157 154 158 - /* initialize the hardware */ 155 + /* initialize the hardware */ 159 156 static int macii_init_via(void) 160 157 { 161 158 unsigned char x; ··· 165 162 166 163 /* Set up state: idle */ 167 164 via[B] |= ST_IDLE; 168 - last_status = via[B] & (ST_MASK|CTLR_IRQ); 165 + last_status = via[B] & (ST_MASK | CTLR_IRQ); 169 166 170 167 /* Shift register on input */ 171 168 via[ACR] = (via[ACR] & ~SR_CTRL) | SR_EXT; ··· 191 188 int next_device; 192 189 static struct adb_request req; 193 190 194 - if (!autopoll_devs) return; 191 + if (!autopoll_devs) 192 + return; 195 193 196 194 device_mask = (1 << (((command_byte & 0xF0) >> 4) + 1)) - 1; 197 195 if (autopoll_devs & ~device_mask) ··· 200 196 else 201 197 next_device = ffs(autopoll_devs) - 1; 202 198 203 - adb_request(&req, NULL, ADBREQ_NOSEND, 1, 204 - ADB_READREG(next_device, 0)); 199 + adb_request(&req, NULL, ADBREQ_NOSEND, 1, ADB_READREG(next_device, 0)); 205 200 206 201 req.sent = 0; 207 202 req.complete = 0; ··· 240 237 req->complete = 1; 241 238 return -EINVAL; 242 239 } 243 - 240 + 244 241 req->next = NULL; 245 242 req->sent = 0; 246 243 req->complete = 0; ··· 254 251 } else { 255 252 current_req = req; 256 253 last_req = req; 257 - if (macii_state == idle) macii_start(); 254 + if (macii_state == idle) 255 + macii_start(); 258 256 } 259 257 260 258 local_irq_restore(flags); ··· 273 269 /* bit 1 == device 1, and so on. */ 274 270 autopoll_devs = devs & 0xFFFE; 275 271 276 - if (!autopoll_devs) return 0; 272 + if (!autopoll_devs) 273 + return 0; 277 274 278 275 local_irq_save(flags); 279 276 ··· 291 286 return err; 292 287 } 293 288 294 - static inline int need_autopoll(void) { 289 + static inline int need_autopoll(void) 290 + { 295 291 /* Was the last command Talk Reg 0 296 292 * and is the target on the autopoll list? 297 293 */ ··· 312 306 static int macii_reset_bus(void) 313 307 { 314 308 static struct adb_request req; 315 - 309 + 316 310 /* Command = 0, Address = ignored */ 317 311 adb_request(&req, NULL, ADBREQ_NOSEND, 1, ADB_BUSRESET); 318 312 macii_send_request(&req, 1); ··· 355 349 * to be activity on the ADB bus. The chip will poll to achieve this. 356 350 * 357 351 * The basic ADB state machine was left unchanged from the original MacII code 358 - * by Alan Cox, which was based on the CUDA driver for PowerMac. 352 + * by Alan Cox, which was based on the CUDA driver for PowerMac. 359 353 * The syntax of the ADB status lines is totally different on MacII, 360 354 * though. MacII uses the states Command -> Even -> Odd -> Even ->...-> Idle 361 355 * for sending and Idle -> Even -> Odd -> Even ->...-> Idle for receiving. ··· 383 377 } 384 378 385 379 last_status = status; 386 - status = via[B] & (ST_MASK|CTLR_IRQ); 380 + status = via[B] & (ST_MASK | CTLR_IRQ); 387 381 388 382 switch (macii_state) { 389 - case idle: 390 - if (reading_reply) { 391 - reply_ptr = current_req->reply; 392 - } else { 393 - WARN_ON(current_req); 394 - reply_ptr = reply_buf; 395 - } 383 + case idle: 384 + if (reading_reply) { 385 + reply_ptr = current_req->reply; 386 + } else { 387 + WARN_ON(current_req); 388 + reply_ptr = reply_buf; 389 + } 396 390 397 - x = via[SR]; 391 + x = via[SR]; 398 392 399 - if ((status & CTLR_IRQ) && (x == 0xFF)) { 400 - /* Bus timeout without SRQ sequence: 401 - * data is "FF" while CTLR_IRQ is "H" 402 - */ 403 - reply_len = 0; 404 - srq_asserted = 0; 405 - macii_state = read_done; 406 - } else { 407 - macii_state = reading; 408 - *reply_ptr = x; 409 - reply_len = 1; 410 - } 411 - 412 - /* set ADB state = even for first data byte */ 413 - via[B] = (via[B] & ~ST_MASK) | ST_EVEN; 414 - break; 415 - 416 - case sending: 417 - req = current_req; 418 - if (data_index >= req->nbytes) { 419 - req->sent = 1; 420 - macii_state = idle; 421 - 422 - if (req->reply_expected) { 423 - reading_reply = 1; 424 - } else { 425 - req->complete = 1; 426 - current_req = req->next; 427 - if (req->done) (*req->done)(req); 428 - 429 - if (current_req) 430 - macii_start(); 431 - else 432 - if (need_autopoll()) 433 - macii_autopoll(autopoll_devs); 434 - } 435 - 436 - if (macii_state == idle) { 437 - /* reset to shift in */ 438 - via[ACR] &= ~SR_OUT; 439 - x = via[SR]; 440 - /* set ADB state idle - might get SRQ */ 441 - via[B] = (via[B] & ~ST_MASK) | ST_IDLE; 442 - } 443 - } else { 444 - via[SR] = req->data[data_index++]; 445 - 446 - if ( (via[B] & ST_MASK) == ST_CMD ) { 447 - /* just sent the command byte, set to EVEN */ 448 - via[B] = (via[B] & ~ST_MASK) | ST_EVEN; 449 - } else { 450 - /* invert state bits, toggle ODD/EVEN */ 451 - via[B] ^= ST_MASK; 452 - } 453 - } 454 - break; 455 - 456 - case reading: 457 - x = via[SR]; 458 - WARN_ON((status & ST_MASK) == ST_CMD || 459 - (status & ST_MASK) == ST_IDLE); 460 - 461 - /* Bus timeout with SRQ sequence: 462 - * data is "XX FF" while CTLR_IRQ is "L L" 463 - * End of packet without SRQ sequence: 464 - * data is "XX...YY 00" while CTLR_IRQ is "L...H L" 465 - * End of packet SRQ sequence: 466 - * data is "XX...YY 00" while CTLR_IRQ is "L...L L" 467 - * (where XX is the first response byte and 468 - * YY is the last byte of valid response data.) 393 + if ((status & CTLR_IRQ) && (x == 0xFF)) { 394 + /* Bus timeout without SRQ sequence: 395 + * data is "FF" while CTLR_IRQ is "H" 469 396 */ 470 - 397 + reply_len = 0; 471 398 srq_asserted = 0; 472 - if (!(status & CTLR_IRQ)) { 473 - if (x == 0xFF) { 474 - if (!(last_status & CTLR_IRQ)) { 475 - macii_state = read_done; 476 - reply_len = 0; 477 - srq_asserted = 1; 478 - } 479 - } else if (x == 0x00) { 480 - macii_state = read_done; 481 - if (!(last_status & CTLR_IRQ)) 482 - srq_asserted = 1; 483 - } 484 - } 399 + macii_state = read_done; 400 + } else { 401 + macii_state = reading; 402 + *reply_ptr = x; 403 + reply_len = 1; 404 + } 485 405 486 - if (macii_state == reading && 487 - reply_len < ARRAY_SIZE(reply_buf)) { 488 - reply_ptr++; 489 - *reply_ptr = x; 490 - reply_len++; 491 - } 406 + /* set ADB state = even for first data byte */ 407 + via[B] = (via[B] & ~ST_MASK) | ST_EVEN; 408 + break; 492 409 493 - /* invert state bits, toggle ODD/EVEN */ 494 - via[B] ^= ST_MASK; 495 - break; 496 - 497 - case read_done: 498 - x = via[SR]; 499 - 500 - if (reading_reply) { 501 - reading_reply = 0; 502 - req = current_req; 503 - req->reply_len = reply_len; 504 - req->complete = 1; 505 - current_req = req->next; 506 - if (req->done) (*req->done)(req); 507 - } else if (reply_len && autopoll_devs) 508 - adb_input(reply_buf, reply_len, 0); 509 - 410 + case sending: 411 + req = current_req; 412 + if (data_index >= req->nbytes) { 413 + req->sent = 1; 510 414 macii_state = idle; 511 415 512 - /* SRQ seen before, initiate poll now */ 513 - if (srq_asserted) 514 - macii_queue_poll(); 416 + if (req->reply_expected) { 417 + reading_reply = 1; 418 + } else { 419 + req->complete = 1; 420 + current_req = req->next; 421 + if (req->done) 422 + (*req->done)(req); 515 423 516 - if (current_req) 517 - macii_start(); 518 - else 519 - if (need_autopoll()) 424 + if (current_req) 425 + macii_start(); 426 + else if (need_autopoll()) 520 427 macii_autopoll(autopoll_devs); 428 + } 521 429 522 - if (macii_state == idle) 430 + if (macii_state == idle) { 431 + /* reset to shift in */ 432 + via[ACR] &= ~SR_OUT; 433 + x = via[SR]; 434 + /* set ADB state idle - might get SRQ */ 523 435 via[B] = (via[B] & ~ST_MASK) | ST_IDLE; 524 - break; 436 + } 437 + } else { 438 + via[SR] = req->data[data_index++]; 525 439 526 - default: 440 + if ((via[B] & ST_MASK) == ST_CMD) { 441 + /* just sent the command byte, set to EVEN */ 442 + via[B] = (via[B] & ~ST_MASK) | ST_EVEN; 443 + } else { 444 + /* invert state bits, toggle ODD/EVEN */ 445 + via[B] ^= ST_MASK; 446 + } 447 + } 448 + break; 449 + 450 + case reading: 451 + x = via[SR]; 452 + WARN_ON((status & ST_MASK) == ST_CMD || 453 + (status & ST_MASK) == ST_IDLE); 454 + 455 + /* Bus timeout with SRQ sequence: 456 + * data is "XX FF" while CTLR_IRQ is "L L" 457 + * End of packet without SRQ sequence: 458 + * data is "XX...YY 00" while CTLR_IRQ is "L...H L" 459 + * End of packet SRQ sequence: 460 + * data is "XX...YY 00" while CTLR_IRQ is "L...L L" 461 + * (where XX is the first response byte and 462 + * YY is the last byte of valid response data.) 463 + */ 464 + 465 + srq_asserted = 0; 466 + if (!(status & CTLR_IRQ)) { 467 + if (x == 0xFF) { 468 + if (!(last_status & CTLR_IRQ)) { 469 + macii_state = read_done; 470 + reply_len = 0; 471 + srq_asserted = 1; 472 + } 473 + } else if (x == 0x00) { 474 + macii_state = read_done; 475 + if (!(last_status & CTLR_IRQ)) 476 + srq_asserted = 1; 477 + } 478 + } 479 + 480 + if (macii_state == reading && 481 + reply_len < ARRAY_SIZE(reply_buf)) { 482 + reply_ptr++; 483 + *reply_ptr = x; 484 + reply_len++; 485 + } 486 + 487 + /* invert state bits, toggle ODD/EVEN */ 488 + via[B] ^= ST_MASK; 489 + break; 490 + 491 + case read_done: 492 + x = via[SR]; 493 + 494 + if (reading_reply) { 495 + reading_reply = 0; 496 + req = current_req; 497 + req->reply_len = reply_len; 498 + req->complete = 1; 499 + current_req = req->next; 500 + if (req->done) 501 + (*req->done)(req); 502 + } else if (reply_len && autopoll_devs) 503 + adb_input(reply_buf, reply_len, 0); 504 + 505 + macii_state = idle; 506 + 507 + /* SRQ seen before, initiate poll now */ 508 + if (srq_asserted) 509 + macii_queue_poll(); 510 + 511 + if (current_req) 512 + macii_start(); 513 + else if (need_autopoll()) 514 + macii_autopoll(autopoll_devs); 515 + 516 + if (macii_state == idle) 517 + via[B] = (via[B] & ~ST_MASK) | ST_IDLE; 518 + break; 519 + 520 + default: 527 521 break; 528 522 } 529 523