[PATCH] drivers/cdrom/cm206.c: cleanups

This patch contains the following cleanups:
- make needlessly global functions static
- remove the following unused global function:
- cm206_delay

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Cc: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Adrian Bunk and committed by Linus Torvalds 8b3d4a2a 995c6ed2

+50 -63
+50 -63
drivers/cdrom/cm206.c
··· 307 /* First, we define some polling functions. These are actually 308 only being used in the initialization. */ 309 310 - void send_command_polled(int command) 311 { 312 int loop = POLLOOP; 313 while (!(inw(r_line_status) & ls_transmitter_buffer_empty) ··· 318 outw(command, r_uart_transmit); 319 } 320 321 - uch receive_echo_polled(void) 322 { 323 int loop = POLLOOP; 324 while (!(inw(r_line_status) & ls_receive_buffer_full) && loop > 0) { ··· 328 return ((uch) inw(r_uart_receive)); 329 } 330 331 - uch send_receive_polled(int command) 332 { 333 send_command_polled(command); 334 return receive_echo_polled(); 335 } 336 337 - inline void clear_ur(void) 338 { 339 if (cd->ur_r != cd->ur_w) { 340 debug(("Deleting bytes from fifo:")); ··· 439 } 440 441 /* we have put the address of the wait queue in who */ 442 - void cm206_timeout(unsigned long who) 443 { 444 cd->timed_out = 1; 445 debug(("Timing out\n")); ··· 448 449 /* This function returns 1 if a timeout occurred, 0 if an interrupt 450 happened */ 451 - int sleep_or_timeout(wait_queue_head_t * wait, int timeout) 452 { 453 cd->timed_out = 0; 454 init_timer(&cd->timer); ··· 465 return 0; 466 } 467 468 - void cm206_delay(int nr_jiffies) 469 - { 470 - DECLARE_WAIT_QUEUE_HEAD(wait); 471 - sleep_or_timeout(&wait, nr_jiffies); 472 - } 473 - 474 - void send_command(int command) 475 { 476 debug(("Sending 0x%x\n", command)); 477 if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) { ··· 484 outw(command, r_uart_transmit); 485 } 486 487 - uch receive_byte(int timeout) 488 { 489 uch ret; 490 cli(); ··· 515 return ret; 516 } 517 518 - inline uch receive_echo(void) 519 { 520 return receive_byte(UART_TIMEOUT); 521 } 522 523 - inline uch send_receive(int command) 524 { 525 send_command(command); 526 return receive_echo(); 527 } 528 529 - inline uch wait_dsb(void) 530 { 531 return receive_byte(DSB_TIMEOUT); 532 } 533 534 - int type_0_command(int command, int expect_dsb) 535 { 536 int e; 537 clear_ur(); ··· 546 return 0; 547 } 548 549 - int type_1_command(int command, int bytes, uch * status) 550 { /* returns info */ 551 int i; 552 if (type_0_command(command, 0)) ··· 558 559 /* This function resets the adapter card. We'd better not do this too 560 * often, because it tends to generate `lost interrupts.' */ 561 - void reset_cm260(void) 562 { 563 outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control); 564 udelay(10); /* 3.3 mu sec minimum */ ··· 566 } 567 568 /* fsm: frame-sec-min from linear address; one of many */ 569 - void fsm(int lba, uch * fsm) 570 { 571 fsm[0] = lba % 75; 572 lba /= 75; ··· 575 fsm[2] = lba / 60; 576 } 577 578 - inline int fsm2lba(uch * fsm) 579 { 580 return fsm[0] + 75 * (fsm[1] - 2 + 60 * fsm[2]); 581 } 582 583 - inline int f_s_m2lba(uch f, uch s, uch m) 584 { 585 return f + 75 * (s - 2 + 60 * m); 586 } 587 588 - int start_read(int start) 589 { 590 uch read_sector[4] = { c_read_data, }; 591 int i, e; ··· 607 return 0; 608 } 609 610 - int stop_read(void) 611 { 612 int e; 613 type_0_command(c_stop, 0); ··· 624 routine takes care of this. Set a flag `background' in the cd 625 struct to indicate the process. */ 626 627 - int read_background(int start, int reading) 628 { 629 if (cd->background) 630 return -1; /* can't do twice */ ··· 652 653 654 #define MAX_TRIES 100 655 - int read_sector(int start) 656 { 657 int tries = 0; 658 if (cd->background) { ··· 747 /* This command clears the dsb_possible_media_change flag, so we must 748 * retain it. 749 */ 750 - void get_drive_status(void) 751 { 752 uch status[2]; 753 type_1_command(c_drive_status, 2, status); /* this might be done faster */ ··· 758 dsb_drive_not_ready | dsb_tray_not_closed)); 759 } 760 761 - void get_disc_status(void) 762 { 763 if (type_1_command(c_disc_status, 7, cd->disc_status)) { 764 debug(("get_disc_status: error\n")); ··· 795 796 /* Empty buffer empties $sectors$ sectors of the adapter card buffer, 797 * and then reads a sector in kernel memory. */ 798 - void empty_buffer(int sectors) 799 { 800 while (sectors >= 0) { 801 transport_data(r_fifo_output_buffer, ··· 813 /* try_adapter. This function determines if the requested sector is 814 in adapter memory, or will appear there soon. Returns 0 upon 815 success */ 816 - int try_adapter(int sector) 817 { 818 if (cd->adapter_first <= sector && sector < cd->adapter_last) { 819 /* sector is in adapter memory */ ··· 904 */ 905 906 /* seek seeks to address lba. It does wait to arrive there. */ 907 - void seek(int lba) 908 { 909 int i; 910 uch seek_command[4] = { c_seek, }; ··· 920 return (bcd >> 4) * 10 + (bcd & 0xf); 921 } 922 923 - inline uch normalize_track(uch track) 924 { 925 if (track < 1) 926 return 1; ··· 933 * tracks seen in the process. Input $track$ must be between 1 and 934 * #-of-tracks+1. Note that the start of the disc must be in toc[1].fsm. 935 */ 936 - int get_toc_lba(uch track) 937 { 938 int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm); 939 int i, lba, l, old_lba = 0; ··· 985 return lba; 986 } 987 988 - void update_toc_entry(uch track) 989 { 990 track = normalize_track(track); 991 if (!cd->toc[track].track) ··· 993 } 994 995 /* return 0 upon success */ 996 - int read_toc_header(struct cdrom_tochdr *hp) 997 { 998 if (!FIRST_TRACK) 999 get_disc_status(); ··· 1010 return -1; 1011 } 1012 1013 - void play_from_to_msf(struct cdrom_msf *msfp) 1014 { 1015 uch play_command[] = { c_play, 1016 msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0, ··· 1026 cd->dsb = wait_dsb(); 1027 } 1028 1029 - void play_from_to_track(int from, int to) 1030 { 1031 uch play_command[8] = { c_play, }; 1032 int i; ··· 1053 cd->dsb = wait_dsb(); 1054 } 1055 1056 - int get_current_q(struct cdrom_subchnl *qp) 1057 { 1058 int i; 1059 uch *q = cd->q; ··· 1087 return 0; 1088 } 1089 1090 - void invalidate_toc(void) 1091 { 1092 memset(cd->toc, 0, sizeof(cd->toc)); 1093 memset(cd->disc_status, 0, sizeof(cd->disc_status)); 1094 } 1095 1096 /* cdrom.c guarantees that cdte_format == CDROM_MSF */ 1097 - void get_toc_entry(struct cdrom_tocentry *ep) 1098 { 1099 uch track = normalize_track(ep->cdte_track); 1100 update_toc_entry(track); ··· 1111 * upon success. Memory checking has been done by cdrom_ioctl(), the 1112 * calling function, as well as LBA/MSF sanitization. 1113 */ 1114 - int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, 1115 - void *arg) 1116 { 1117 switch (cmd) { 1118 case CDROMREADTOCHDR: ··· 1183 } 1184 } 1185 1186 - int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) 1187 { 1188 if (cd != NULL) { 1189 int r; ··· 1198 /* The new generic cdrom support. Routines should be concise, most of 1199 the logic should be in cdrom.c */ 1200 1201 - /* returns number of times device is in use */ 1202 - int cm206_open_files(struct cdrom_device_info *cdi) 1203 - { 1204 - if (cd) 1205 - return cd->openfiles; 1206 - return -1; 1207 - } 1208 1209 /* controls tray movement */ 1210 - int cm206_tray_move(struct cdrom_device_info *cdi, int position) 1211 { 1212 if (position) { /* 1: eject */ 1213 type_0_command(c_open_tray, 1); ··· 1211 } 1212 1213 /* gives current state of the drive */ 1214 - int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr) 1215 { 1216 get_drive_status(); 1217 if (cd->dsb & dsb_tray_not_closed) ··· 1224 } 1225 1226 /* locks or unlocks door lock==1: lock; return 0 upon success */ 1227 - int cm206_lock_door(struct cdrom_device_info *cdi, int lock) 1228 { 1229 uch command = (lock) ? c_lock_tray : c_unlock_tray; 1230 type_0_command(command, 1); /* wait and get dsb */ ··· 1235 /* Although a session start should be in LBA format, we return it in 1236 MSF format because it is slightly easier, and the new generic ioctl 1237 will take care of the necessary conversion. */ 1238 - int cm206_get_last_session(struct cdrom_device_info *cdi, 1239 - struct cdrom_multisession *mssp) 1240 { 1241 if (!FIRST_TRACK) 1242 get_disc_status(); ··· 1255 return 0; 1256 } 1257 1258 - int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) 1259 { 1260 uch upc[10]; 1261 char *ret = mcn->medium_catalog_number; ··· 1274 return 0; 1275 } 1276 1277 - int cm206_reset(struct cdrom_device_info *cdi) 1278 { 1279 stop_read(); 1280 reset_cm260(); ··· 1287 return 0; 1288 } 1289 1290 - int cm206_select_speed(struct cdrom_device_info *cdi, int speed) 1291 { 1292 int r; 1293 switch (speed) { ··· 1379 request_region, 15 bits of one port and 6 of another make things 1380 likely enough to accept the region on the first hit... 1381 */ 1382 - int __init probe_base_port(int base) 1383 { 1384 int b = 0x300, e = 0x370; /* this is the range of start addresses */ 1385 volatile int fool, i; ··· 1403 1404 #if !defined(MODULE) || defined(AUTO_PROBE_MODULE) 1405 /* Probe for irq# nr. If nr==0, probe for all possible irq's. */ 1406 - int __init probe_irq(int nr) 1407 { 1408 int irqs, irq; 1409 outw(dc_normal | READ_AHEAD, r_data_control); /* disable irq-generation */ ··· 1545 } 1546 } 1547 1548 - int __cm206_init(void) 1549 { 1550 parse_options(); 1551 #if !defined(AUTO_PROBE_MODULE) ··· 1554 return cm206_init(); 1555 } 1556 1557 - void __exit cm206_exit(void) 1558 { 1559 del_gendisk(cm206_gendisk); 1560 put_disk(cm206_gendisk);
··· 307 /* First, we define some polling functions. These are actually 308 only being used in the initialization. */ 309 310 + static void send_command_polled(int command) 311 { 312 int loop = POLLOOP; 313 while (!(inw(r_line_status) & ls_transmitter_buffer_empty) ··· 318 outw(command, r_uart_transmit); 319 } 320 321 + static uch receive_echo_polled(void) 322 { 323 int loop = POLLOOP; 324 while (!(inw(r_line_status) & ls_receive_buffer_full) && loop > 0) { ··· 328 return ((uch) inw(r_uart_receive)); 329 } 330 331 + static uch send_receive_polled(int command) 332 { 333 send_command_polled(command); 334 return receive_echo_polled(); 335 } 336 337 + static inline void clear_ur(void) 338 { 339 if (cd->ur_r != cd->ur_w) { 340 debug(("Deleting bytes from fifo:")); ··· 439 } 440 441 /* we have put the address of the wait queue in who */ 442 + static void cm206_timeout(unsigned long who) 443 { 444 cd->timed_out = 1; 445 debug(("Timing out\n")); ··· 448 449 /* This function returns 1 if a timeout occurred, 0 if an interrupt 450 happened */ 451 + static int sleep_or_timeout(wait_queue_head_t * wait, int timeout) 452 { 453 cd->timed_out = 0; 454 init_timer(&cd->timer); ··· 465 return 0; 466 } 467 468 + static void send_command(int command) 469 { 470 debug(("Sending 0x%x\n", command)); 471 if (!(inw(r_line_status) & ls_transmitter_buffer_empty)) { ··· 490 outw(command, r_uart_transmit); 491 } 492 493 + static uch receive_byte(int timeout) 494 { 495 uch ret; 496 cli(); ··· 521 return ret; 522 } 523 524 + static inline uch receive_echo(void) 525 { 526 return receive_byte(UART_TIMEOUT); 527 } 528 529 + static inline uch send_receive(int command) 530 { 531 send_command(command); 532 return receive_echo(); 533 } 534 535 + static inline uch wait_dsb(void) 536 { 537 return receive_byte(DSB_TIMEOUT); 538 } 539 540 + static int type_0_command(int command, int expect_dsb) 541 { 542 int e; 543 clear_ur(); ··· 552 return 0; 553 } 554 555 + static int type_1_command(int command, int bytes, uch * status) 556 { /* returns info */ 557 int i; 558 if (type_0_command(command, 0)) ··· 564 565 /* This function resets the adapter card. We'd better not do this too 566 * often, because it tends to generate `lost interrupts.' */ 567 + static void reset_cm260(void) 568 { 569 outw(dc_normal | dc_initialize | READ_AHEAD, r_data_control); 570 udelay(10); /* 3.3 mu sec minimum */ ··· 572 } 573 574 /* fsm: frame-sec-min from linear address; one of many */ 575 + static void fsm(int lba, uch * fsm) 576 { 577 fsm[0] = lba % 75; 578 lba /= 75; ··· 581 fsm[2] = lba / 60; 582 } 583 584 + static inline int fsm2lba(uch * fsm) 585 { 586 return fsm[0] + 75 * (fsm[1] - 2 + 60 * fsm[2]); 587 } 588 589 + static inline int f_s_m2lba(uch f, uch s, uch m) 590 { 591 return f + 75 * (s - 2 + 60 * m); 592 } 593 594 + static int start_read(int start) 595 { 596 uch read_sector[4] = { c_read_data, }; 597 int i, e; ··· 613 return 0; 614 } 615 616 + static int stop_read(void) 617 { 618 int e; 619 type_0_command(c_stop, 0); ··· 630 routine takes care of this. Set a flag `background' in the cd 631 struct to indicate the process. */ 632 633 + static int read_background(int start, int reading) 634 { 635 if (cd->background) 636 return -1; /* can't do twice */ ··· 658 659 660 #define MAX_TRIES 100 661 + static int read_sector(int start) 662 { 663 int tries = 0; 664 if (cd->background) { ··· 753 /* This command clears the dsb_possible_media_change flag, so we must 754 * retain it. 755 */ 756 + static void get_drive_status(void) 757 { 758 uch status[2]; 759 type_1_command(c_drive_status, 2, status); /* this might be done faster */ ··· 764 dsb_drive_not_ready | dsb_tray_not_closed)); 765 } 766 767 + static void get_disc_status(void) 768 { 769 if (type_1_command(c_disc_status, 7, cd->disc_status)) { 770 debug(("get_disc_status: error\n")); ··· 801 802 /* Empty buffer empties $sectors$ sectors of the adapter card buffer, 803 * and then reads a sector in kernel memory. */ 804 + static void empty_buffer(int sectors) 805 { 806 while (sectors >= 0) { 807 transport_data(r_fifo_output_buffer, ··· 819 /* try_adapter. This function determines if the requested sector is 820 in adapter memory, or will appear there soon. Returns 0 upon 821 success */ 822 + static int try_adapter(int sector) 823 { 824 if (cd->adapter_first <= sector && sector < cd->adapter_last) { 825 /* sector is in adapter memory */ ··· 910 */ 911 912 /* seek seeks to address lba. It does wait to arrive there. */ 913 + static void seek(int lba) 914 { 915 int i; 916 uch seek_command[4] = { c_seek, }; ··· 926 return (bcd >> 4) * 10 + (bcd & 0xf); 927 } 928 929 + static inline uch normalize_track(uch track) 930 { 931 if (track < 1) 932 return 1; ··· 939 * tracks seen in the process. Input $track$ must be between 1 and 940 * #-of-tracks+1. Note that the start of the disc must be in toc[1].fsm. 941 */ 942 + static int get_toc_lba(uch track) 943 { 944 int max = 74 * 60 * 75 - 150, min = fsm2lba(cd->toc[1].fsm); 945 int i, lba, l, old_lba = 0; ··· 991 return lba; 992 } 993 994 + static void update_toc_entry(uch track) 995 { 996 track = normalize_track(track); 997 if (!cd->toc[track].track) ··· 999 } 1000 1001 /* return 0 upon success */ 1002 + static int read_toc_header(struct cdrom_tochdr *hp) 1003 { 1004 if (!FIRST_TRACK) 1005 get_disc_status(); ··· 1016 return -1; 1017 } 1018 1019 + static void play_from_to_msf(struct cdrom_msf *msfp) 1020 { 1021 uch play_command[] = { c_play, 1022 msfp->cdmsf_frame0, msfp->cdmsf_sec0, msfp->cdmsf_min0, ··· 1032 cd->dsb = wait_dsb(); 1033 } 1034 1035 + static void play_from_to_track(int from, int to) 1036 { 1037 uch play_command[8] = { c_play, }; 1038 int i; ··· 1059 cd->dsb = wait_dsb(); 1060 } 1061 1062 + static int get_current_q(struct cdrom_subchnl *qp) 1063 { 1064 int i; 1065 uch *q = cd->q; ··· 1093 return 0; 1094 } 1095 1096 + static void invalidate_toc(void) 1097 { 1098 memset(cd->toc, 0, sizeof(cd->toc)); 1099 memset(cd->disc_status, 0, sizeof(cd->disc_status)); 1100 } 1101 1102 /* cdrom.c guarantees that cdte_format == CDROM_MSF */ 1103 + static void get_toc_entry(struct cdrom_tocentry *ep) 1104 { 1105 uch track = normalize_track(ep->cdte_track); 1106 update_toc_entry(track); ··· 1117 * upon success. Memory checking has been done by cdrom_ioctl(), the 1118 * calling function, as well as LBA/MSF sanitization. 1119 */ 1120 + static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd, 1121 + void *arg) 1122 { 1123 switch (cmd) { 1124 case CDROMREADTOCHDR: ··· 1189 } 1190 } 1191 1192 + static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr) 1193 { 1194 if (cd != NULL) { 1195 int r; ··· 1204 /* The new generic cdrom support. Routines should be concise, most of 1205 the logic should be in cdrom.c */ 1206 1207 1208 /* controls tray movement */ 1209 + static int cm206_tray_move(struct cdrom_device_info *cdi, int position) 1210 { 1211 if (position) { /* 1: eject */ 1212 type_0_command(c_open_tray, 1); ··· 1224 } 1225 1226 /* gives current state of the drive */ 1227 + static int cm206_drive_status(struct cdrom_device_info *cdi, int slot_nr) 1228 { 1229 get_drive_status(); 1230 if (cd->dsb & dsb_tray_not_closed) ··· 1237 } 1238 1239 /* locks or unlocks door lock==1: lock; return 0 upon success */ 1240 + static int cm206_lock_door(struct cdrom_device_info *cdi, int lock) 1241 { 1242 uch command = (lock) ? c_lock_tray : c_unlock_tray; 1243 type_0_command(command, 1); /* wait and get dsb */ ··· 1248 /* Although a session start should be in LBA format, we return it in 1249 MSF format because it is slightly easier, and the new generic ioctl 1250 will take care of the necessary conversion. */ 1251 + static int cm206_get_last_session(struct cdrom_device_info *cdi, 1252 + struct cdrom_multisession *mssp) 1253 { 1254 if (!FIRST_TRACK) 1255 get_disc_status(); ··· 1268 return 0; 1269 } 1270 1271 + static int cm206_get_upc(struct cdrom_device_info *cdi, struct cdrom_mcn *mcn) 1272 { 1273 uch upc[10]; 1274 char *ret = mcn->medium_catalog_number; ··· 1287 return 0; 1288 } 1289 1290 + static int cm206_reset(struct cdrom_device_info *cdi) 1291 { 1292 stop_read(); 1293 reset_cm260(); ··· 1300 return 0; 1301 } 1302 1303 + static int cm206_select_speed(struct cdrom_device_info *cdi, int speed) 1304 { 1305 int r; 1306 switch (speed) { ··· 1392 request_region, 15 bits of one port and 6 of another make things 1393 likely enough to accept the region on the first hit... 1394 */ 1395 + static int __init probe_base_port(int base) 1396 { 1397 int b = 0x300, e = 0x370; /* this is the range of start addresses */ 1398 volatile int fool, i; ··· 1416 1417 #if !defined(MODULE) || defined(AUTO_PROBE_MODULE) 1418 /* Probe for irq# nr. If nr==0, probe for all possible irq's. */ 1419 + static int __init probe_irq(int nr) 1420 { 1421 int irqs, irq; 1422 outw(dc_normal | READ_AHEAD, r_data_control); /* disable irq-generation */ ··· 1558 } 1559 } 1560 1561 + static int __cm206_init(void) 1562 { 1563 parse_options(); 1564 #if !defined(AUTO_PROBE_MODULE) ··· 1567 return cm206_init(); 1568 } 1569 1570 + static void __exit cm206_exit(void) 1571 { 1572 del_gendisk(cm206_gendisk); 1573 put_disk(cm206_gendisk);