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