aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Ciarrocchi <paolo.ciarrocchi@gmail.com>2008-04-26 11:36:42 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-26 11:36:42 -0400
commit9ce70fb2b5ab9feb24afd1ea971bfa86bbc5625c (patch)
tree3c635a0f3157231458d6a0a91e35124237755c61
parent175f354b752ca04cad65588dc2c4e648003b8504 (diff)
IDE: Coding Style fixes to drivers/ide/ide-cd.c
Before: total: 43 errors, 66 warnings, 2183 lines checked After: total: 0 errors, 36 warnings, 2192 lines checked I didn't (and I don't plan to) fix the warnings: WARNING: line over 80 characters [bart: minor fixes, md5sum checked (modulo s/"ignore = NULL;"/"ignore;"/ fix)] Signed-off-by: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-cd.c258
1 files changed, 134 insertions, 124 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 5163f6069f8a..49abbb5f3427 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -13,8 +13,8 @@
13 * 13 *
14 * Suggestions are welcome. Patches that work are more welcome though. ;-) 14 * Suggestions are welcome. Patches that work are more welcome though. ;-)
15 * For those wishing to work on this driver, please be sure you download 15 * For those wishing to work on this driver, please be sure you download
16 * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI 16 * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI
17 * (SFF-8020i rev 2.6) standards. These documents can be obtained by 17 * (SFF-8020i rev 2.6) standards. These documents can be obtained by
18 * anonymous ftp from: 18 * anonymous ftp from:
19 * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps 19 * ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps
20 * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf 20 * ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf
@@ -51,7 +51,7 @@
51 51
52static DEFINE_MUTEX(idecd_ref_mutex); 52static DEFINE_MUTEX(idecd_ref_mutex);
53 53
54#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) 54#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)
55 55
56#define ide_cd_g(disk) \ 56#define ide_cd_g(disk) \
57 container_of((disk)->private_data, struct cdrom_info, driver) 57 container_of((disk)->private_data, struct cdrom_info, driver)
@@ -83,7 +83,7 @@ static void ide_cd_put(struct cdrom_info *cd)
83 83
84/* Mark that we've seen a media change, and invalidate our internal 84/* Mark that we've seen a media change, and invalidate our internal
85 buffers. */ 85 buffers. */
86static void cdrom_saw_media_change (ide_drive_t *drive) 86static void cdrom_saw_media_change(ide_drive_t *drive)
87{ 87{
88 struct cdrom_info *cd = drive->driver_data; 88 struct cdrom_info *cd = drive->driver_data;
89 89
@@ -100,38 +100,39 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
100 return 0; 100 return 0;
101 101
102 switch (sense->sense_key) { 102 switch (sense->sense_key) {
103 case NO_SENSE: case RECOVERED_ERROR: 103 case NO_SENSE:
104 break; 104 case RECOVERED_ERROR:
105 case NOT_READY: 105 break;
106 /* 106 case NOT_READY:
107 * don't care about tray state messages for 107 /*
108 * e.g. capacity commands or in-progress or 108 * don't care about tray state messages for
109 * becoming ready 109 * e.g. capacity commands or in-progress or
110 */ 110 * becoming ready
111 if (sense->asc == 0x3a || sense->asc == 0x04) 111 */
112 break; 112 if (sense->asc == 0x3a || sense->asc == 0x04)
113 log = 1;
114 break;
115 case ILLEGAL_REQUEST:
116 /*
117 * don't log START_STOP unit with LoEj set, since
118 * we cannot reliably check if drive can auto-close
119 */
120 if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24)
121 break;
122 log = 1;
123 break;
124 case UNIT_ATTENTION:
125 /*
126 * Make good and sure we've seen this potential media
127 * change. Some drives (i.e. Creative) fail to present
128 * the correct sense key in the error register.
129 */
130 cdrom_saw_media_change(drive);
131 break; 113 break;
132 default: 114 log = 1;
133 log = 1; 115 break;
116 case ILLEGAL_REQUEST:
117 /*
118 * don't log START_STOP unit with LoEj set, since
119 * we cannot reliably check if drive can auto-close
120 */
121 if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24)
134 break; 122 break;
123 log = 1;
124 break;
125 case UNIT_ATTENTION:
126 /*
127 * Make good and sure we've seen this potential media
128 * change. Some drives (i.e. Creative) fail to present
129 * the correct sense key in the error register.
130 */
131 cdrom_saw_media_change(drive);
132 break;
133 default:
134 log = 1;
135 break;
135 } 136 }
136 return log; 137 return log;
137} 138}
@@ -158,8 +159,8 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
158 if (sense->sense_key == 0x05 && sense->asc == 0x24) 159 if (sense->sense_key == 0x05 && sense->asc == 0x24)
159 return; 160 return;
160 161
161 if (sense->error_code == 0x70) { /* Current Error */ 162 if (sense->error_code == 0x70) { /* Current Error */
162 switch(sense->sense_key) { 163 switch (sense->sense_key) {
163 case MEDIUM_ERROR: 164 case MEDIUM_ERROR:
164 case VOLUME_OVERFLOW: 165 case VOLUME_OVERFLOW:
165 case ILLEGAL_REQUEST: 166 case ILLEGAL_REQUEST:
@@ -178,7 +179,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
178 bio_sectors = 4; 179 bio_sectors = 4;
179 if (drive->queue->hardsect_size == 2048) 180 if (drive->queue->hardsect_size == 2048)
180 sector <<= 2; /* Device sector size is 2K */ 181 sector <<= 2; /* Device sector size is 2K */
181 sector &= ~(bio_sectors -1); 182 sector &= ~(bio_sectors - 1);
182 valid = (sector - failed_command->sector) << 9; 183 valid = (sector - failed_command->sector) << 9;
183 184
184 if (valid < 0) 185 if (valid < 0)
@@ -187,8 +188,8 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
187 drive->probed_capacity - sector < 4 * 75) { 188 drive->probed_capacity - sector < 4 * 75) {
188 set_capacity(info->disk, sector); 189 set_capacity(info->disk, sector);
189 } 190 }
190 } 191 }
191 } 192 }
192 193
193 ide_cd_log_error(drive->name, failed_command, sense); 194 ide_cd_log_error(drive->name, failed_command, sense);
194} 195}
@@ -229,7 +230,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
229 (void) ide_do_drive_cmd(drive, rq, ide_preempt); 230 (void) ide_do_drive_cmd(drive, rq, ide_preempt);
230} 231}
231 232
232static void cdrom_end_request (ide_drive_t *drive, int uptodate) 233static void cdrom_end_request(ide_drive_t *drive, int uptodate)
233{ 234{
234 struct request *rq = HWGROUP(drive)->rq; 235 struct request *rq = HWGROUP(drive)->rq;
235 int nsectors = rq->hard_cur_sectors; 236 int nsectors = rq->hard_cur_sectors;
@@ -292,7 +293,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
292{ 293{
293 struct request *rq = HWGROUP(drive)->rq; 294 struct request *rq = HWGROUP(drive)->rq;
294 int stat, err, sense_key; 295 int stat, err, sense_key;
295 296
296 /* Check for errors. */ 297 /* Check for errors. */
297 stat = ide_read_status(drive); 298 stat = ide_read_status(drive);
298 299
@@ -333,26 +334,26 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
333 334
334 /* Check for tray open. */ 335 /* Check for tray open. */
335 if (sense_key == NOT_READY) { 336 if (sense_key == NOT_READY) {
336 cdrom_saw_media_change (drive); 337 cdrom_saw_media_change(drive);
337 } else if (sense_key == UNIT_ATTENTION) { 338 } else if (sense_key == UNIT_ATTENTION) {
338 /* Check for media change. */ 339 /* Check for media change. */
339 cdrom_saw_media_change (drive); 340 cdrom_saw_media_change(drive);
340 /*printk("%s: media changed\n",drive->name);*/ 341 /*printk("%s: media changed\n",drive->name);*/
341 return 0; 342 return 0;
342 } else if ((sense_key == ILLEGAL_REQUEST) && 343 } else if (sense_key == ILLEGAL_REQUEST &&
343 (rq->cmd[0] == GPCMD_START_STOP_UNIT)) { 344 rq->cmd[0] == GPCMD_START_STOP_UNIT) {
344 /* 345 /*
345 * Don't print error message for this condition-- 346 * Don't print error message for this condition--
346 * SFF8090i indicates that 5/24/00 is the correct 347 * SFF8090i indicates that 5/24/00 is the correct
347 * response to a request to close the tray if the 348 * response to a request to close the tray if the
348 * drive doesn't have that capability. 349 * drive doesn't have that capability.
349 * cdrom_log_sense() knows this! 350 * cdrom_log_sense() knows this!
350 */ 351 */
351 } else if (!(rq->cmd_flags & REQ_QUIET)) { 352 } else if (!(rq->cmd_flags & REQ_QUIET)) {
352 /* Otherwise, print an error. */ 353 /* Otherwise, print an error. */
353 ide_dump_status(drive, "packet command error", stat); 354 ide_dump_status(drive, "packet command error", stat);
354 } 355 }
355 356
356 rq->cmd_flags |= REQ_FAILED; 357 rq->cmd_flags |= REQ_FAILED;
357 358
358 /* 359 /*
@@ -373,10 +374,10 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
373 if (sense_key == NOT_READY) { 374 if (sense_key == NOT_READY) {
374 /* Tray open. */ 375 /* Tray open. */
375 if (rq_data_dir(rq) == READ) { 376 if (rq_data_dir(rq) == READ) {
376 cdrom_saw_media_change (drive); 377 cdrom_saw_media_change(drive);
377 378
378 /* Fail the request. */ 379 /* Fail the request. */
379 printk ("%s: tray open\n", drive->name); 380 printk("%s: tray open\n", drive->name);
380 do_end_request = 1; 381 do_end_request = 1;
381 } else { 382 } else {
382 struct cdrom_info *info = drive->driver_data; 383 struct cdrom_info *info = drive->driver_data;
@@ -398,7 +399,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
398 */ 399 */
399 spin_lock_irqsave(&ide_lock, flags); 400 spin_lock_irqsave(&ide_lock, flags);
400 blk_plug_device(drive->queue); 401 blk_plug_device(drive->queue);
401 spin_unlock_irqrestore(&ide_lock,flags); 402 spin_unlock_irqrestore(&ide_lock, flags);
402 return 1; 403 return 1;
403 } 404 }
404 } 405 }
@@ -406,25 +407,31 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
406 /* Media change. */ 407 /* Media change. */
407 cdrom_saw_media_change (drive); 408 cdrom_saw_media_change (drive);
408 409
409 /* Arrange to retry the request. 410 /*
410 But be sure to give up if we've retried 411 * Arrange to retry the request.
411 too many times. */ 412 * But be sure to give up if we've retried
413 * too many times.
414 */
412 if (++rq->errors > ERROR_MAX) 415 if (++rq->errors > ERROR_MAX)
413 do_end_request = 1; 416 do_end_request = 1;
414 } else if (sense_key == ILLEGAL_REQUEST || 417 } else if (sense_key == ILLEGAL_REQUEST ||
415 sense_key == DATA_PROTECT) { 418 sense_key == DATA_PROTECT) {
416 /* No point in retrying after an illegal 419 /*
417 request or data protect error.*/ 420 * No point in retrying after an illegal
418 ide_dump_status_no_sense (drive, "command error", stat); 421 * request or data protect error.
422 */
423 ide_dump_status_no_sense(drive, "command error", stat);
419 do_end_request = 1; 424 do_end_request = 1;
420 } else if (sense_key == MEDIUM_ERROR) { 425 } else if (sense_key == MEDIUM_ERROR) {
421 /* No point in re-trying a zillion times on a bad 426 /*
422 * sector... If we got here the error is not correctable */ 427 * No point in re-trying a zillion times on a bad
423 ide_dump_status_no_sense (drive, "media error (bad sector)", stat); 428 * sector... If we got here the error is not correctable
429 */
430 ide_dump_status_no_sense(drive, "media error (bad sector)", stat);
424 do_end_request = 1; 431 do_end_request = 1;
425 } else if (sense_key == BLANK_CHECK) { 432 } else if (sense_key == BLANK_CHECK) {
426 /* Disk appears blank ?? */ 433 /* Disk appears blank ?? */
427 ide_dump_status_no_sense (drive, "media error (blank)", stat); 434 ide_dump_status_no_sense(drive, "media error (blank)", stat);
428 do_end_request = 1; 435 do_end_request = 1;
429 } else if ((err & ~ABRT_ERR) != 0) { 436 } else if ((err & ~ABRT_ERR) != 0) {
430 /* Go to the default handler 437 /* Go to the default handler
@@ -485,18 +492,18 @@ static int cdrom_timer_expiry(ide_drive_t *drive)
485 * ide_timer_expiry keep polling us for these. 492 * ide_timer_expiry keep polling us for these.
486 */ 493 */
487 switch (rq->cmd[0]) { 494 switch (rq->cmd[0]) {
488 case GPCMD_BLANK: 495 case GPCMD_BLANK:
489 case GPCMD_FORMAT_UNIT: 496 case GPCMD_FORMAT_UNIT:
490 case GPCMD_RESERVE_RZONE_TRACK: 497 case GPCMD_RESERVE_RZONE_TRACK:
491 case GPCMD_CLOSE_TRACK: 498 case GPCMD_CLOSE_TRACK:
492 case GPCMD_FLUSH_CACHE: 499 case GPCMD_FLUSH_CACHE:
493 wait = ATAPI_WAIT_PC; 500 wait = ATAPI_WAIT_PC;
494 break; 501 break;
495 default: 502 default:
496 if (!(rq->cmd_flags & REQ_QUIET)) 503 if (!(rq->cmd_flags & REQ_QUIET))
497 printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); 504 printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]);
498 wait = 0; 505 wait = 0;
499 break; 506 break;
500 } 507 }
501 return wait; 508 return wait;
502} 509}
@@ -556,7 +563,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
556 HANDLER is the interrupt handler to call when the command completes 563 HANDLER is the interrupt handler to call when the command completes
557 or there's data ready. */ 564 or there's data ready. */
558#define ATAPI_MIN_CDB_BYTES 12 565#define ATAPI_MIN_CDB_BYTES 12
559static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive, 566static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
560 struct request *rq, 567 struct request *rq,
561 ide_handler_t *handler) 568 ide_handler_t *handler)
562{ 569{
@@ -748,7 +755,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
748#define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */ 755#define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */
749#define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */ 756#define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */
750 757
751static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive) 758static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
752{ 759{
753 struct cdrom_info *info = drive->driver_data; 760 struct cdrom_info *info = drive->driver_data;
754 int stat; 761 int stat;
@@ -765,14 +772,14 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
765 * this condition is far too common, to bother 772 * this condition is far too common, to bother
766 * users about it 773 * users about it
767 */ 774 */
768 /* printk("%s: disabled DSC seek overlap\n", drive->name);*/ 775 /* printk("%s: disabled DSC seek overlap\n", drive->name);*/
769 drive->dsc_overlap = 0; 776 drive->dsc_overlap = 0;
770 } 777 }
771 } 778 }
772 return ide_stopped; 779 return ide_stopped;
773} 780}
774 781
775static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive) 782static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
776{ 783{
777 struct request *rq = HWGROUP(drive)->rq; 784 struct request *rq = HWGROUP(drive)->rq;
778 sector_t frame = rq->sector; 785 sector_t frame = rq->sector;
@@ -787,7 +794,7 @@ static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
787 return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr); 794 return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
788} 795}
789 796
790static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block) 797static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block)
791{ 798{
792 struct cdrom_info *info = drive->driver_data; 799 struct cdrom_info *info = drive->driver_data;
793 800
@@ -796,9 +803,11 @@ static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
796 return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); 803 return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
797} 804}
798 805
799/* Fix up a possibly partially-processed request so that we can 806/*
800 start it over entirely, or even put it back on the request queue. */ 807 * Fix up a possibly partially-processed request so that we can
801static void restore_request (struct request *rq) 808 * start it over entirely, or even put it back on the request queue.
809 */
810static void restore_request(struct request *rq)
802{ 811{
803 if (rq->buffer != bio_data(rq->bio)) { 812 if (rq->buffer != bio_data(rq->bio)) {
804 sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; 813 sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE;
@@ -849,7 +858,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
849 error = ide_do_drive_cmd(drive, rq, ide_wait); 858 error = ide_do_drive_cmd(drive, rq, ide_wait);
850 time = jiffies - time; 859 time = jiffies - time;
851 860
852 /* FIXME: we should probably abort/retry or something 861 /* FIXME: we should probably abort/retry or something
853 * in case of failure */ 862 * in case of failure */
854 if (rq->cmd_flags & REQ_FAILED) { 863 if (rq->cmd_flags & REQ_FAILED) {
855 /* The request failed. Retry if it was due to a unit 864 /* The request failed. Retry if it was due to a unit
@@ -1210,7 +1219,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1210 * cdrom driver request routine. 1219 * cdrom driver request routine.
1211 */ 1220 */
1212static ide_startstop_t 1221static ide_startstop_t
1213ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) 1222ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block)
1214{ 1223{
1215 ide_startstop_t action; 1224 ide_startstop_t action;
1216 struct cdrom_info *info = drive->driver_data; 1225 struct cdrom_info *info = drive->driver_data;
@@ -1225,13 +1234,13 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
1225 ide_stall_queue(drive, IDECD_SEEK_TIMER); 1234 ide_stall_queue(drive, IDECD_SEEK_TIMER);
1226 return ide_stopped; 1235 return ide_stopped;
1227 } 1236 }
1228 printk (KERN_ERR "%s: DSC timeout\n", drive->name); 1237 printk(KERN_ERR "%s: DSC timeout\n", drive->name);
1229 } 1238 }
1230 info->cd_flags &= ~IDE_CD_FLAG_SEEKING; 1239 info->cd_flags &= ~IDE_CD_FLAG_SEEKING;
1231 } 1240 }
1232 if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) { 1241 if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap)
1233 action = cdrom_start_seek(drive, block); 1242 action = cdrom_start_seek(drive, block);
1234 } else 1243 else
1235 action = cdrom_start_rw(drive, rq); 1244 action = cdrom_start_rw(drive, rq);
1236 info->last_block = block; 1245 info->last_block = block;
1237 return action; 1246 return action;
@@ -1264,7 +1273,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
1264 */ 1273 */
1265 1274
1266static 1275static
1267void msf_from_bcd (struct atapi_msf *msf) 1276void msf_from_bcd(struct atapi_msf *msf)
1268{ 1277{
1269 msf->minute = BCD2BIN(msf->minute); 1278 msf->minute = BCD2BIN(msf->minute);
1270 msf->second = BCD2BIN(msf->second); 1279 msf->second = BCD2BIN(msf->second);
@@ -1364,7 +1373,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1364 /* Try to allocate space. */ 1373 /* Try to allocate space. */
1365 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); 1374 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL);
1366 if (toc == NULL) { 1375 if (toc == NULL) {
1367 printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); 1376 printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name);
1368 return -ENOMEM; 1377 return -ENOMEM;
1369 } 1378 }
1370 info->toc = toc; 1379 info->toc = toc;
@@ -1459,9 +1468,9 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1459 toc->ent[i].track = BCD2BIN(toc->ent[i].track); 1468 toc->ent[i].track = BCD2BIN(toc->ent[i].track);
1460 msf_from_bcd(&toc->ent[i].addr.msf); 1469 msf_from_bcd(&toc->ent[i].addr.msf);
1461 } 1470 }
1462 toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute, 1471 toc->ent[i].addr.lba = msf_to_lba(toc->ent[i].addr.msf.minute,
1463 toc->ent[i].addr.msf.second, 1472 toc->ent[i].addr.msf.second,
1464 toc->ent[i].addr.msf.frame); 1473 toc->ent[i].addr.msf.frame);
1465 } 1474 }
1466 1475
1467 /* Read the multisession information. */ 1476 /* Read the multisession information. */
@@ -1485,9 +1494,9 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1485 if (stat) 1494 if (stat)
1486 return stat; 1495 return stat;
1487 1496
1488 msf_from_bcd (&ms_tmp.ent.addr.msf); 1497 msf_from_bcd(&ms_tmp.ent.addr.msf);
1489 toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute, 1498 toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute,
1490 ms_tmp.ent.addr.msf.second, 1499 ms_tmp.ent.addr.msf.second,
1491 ms_tmp.ent.addr.msf.frame); 1500 ms_tmp.ent.addr.msf.frame);
1492 } 1501 }
1493 1502
@@ -1569,7 +1578,7 @@ static struct cdrom_device_ops ide_cdrom_dops = {
1569 .generic_packet = ide_cdrom_packet, 1578 .generic_packet = ide_cdrom_packet,
1570}; 1579};
1571 1580
1572static int ide_cdrom_register (ide_drive_t *drive, int nslots) 1581static int ide_cdrom_register(ide_drive_t *drive, int nslots)
1573{ 1582{
1574 struct cdrom_info *info = drive->driver_data; 1583 struct cdrom_info *info = drive->driver_data;
1575 struct cdrom_device_info *devinfo = &info->devinfo; 1584 struct cdrom_device_info *devinfo = &info->devinfo;
@@ -1588,7 +1597,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
1588} 1597}
1589 1598
1590static 1599static
1591int ide_cdrom_probe_capabilities (ide_drive_t *drive) 1600int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1592{ 1601{
1593 struct cdrom_info *cd = drive->driver_data; 1602 struct cdrom_info *cd = drive->driver_data;
1594 struct cdrom_device_info *cdi = &cd->devinfo; 1603 struct cdrom_device_info *cdi = &cd->devinfo;
@@ -1760,7 +1769,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
1760 rq->errors = ILLEGAL_REQUEST; 1769 rq->errors = ILLEGAL_REQUEST;
1761 return BLKPREP_KILL; 1770 return BLKPREP_KILL;
1762 } 1771 }
1763 1772
1764 return BLKPREP_OK; 1773 return BLKPREP_OK;
1765} 1774}
1766 1775
@@ -1838,7 +1847,7 @@ static unsigned int ide_cd_flags(struct hd_driveid *id)
1838} 1847}
1839 1848
1840static 1849static
1841int ide_cdrom_setup (ide_drive_t *drive) 1850int ide_cdrom_setup(ide_drive_t *drive)
1842{ 1851{
1843 struct cdrom_info *cd = drive->driver_data; 1852 struct cdrom_info *cd = drive->driver_data;
1844 struct cdrom_device_info *cdi = &cd->devinfo; 1853 struct cdrom_device_info *cdi = &cd->devinfo;
@@ -1869,7 +1878,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
1869 else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) 1878 else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD)
1870 cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ 1879 cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */
1871 1880
1872 nslots = ide_cdrom_probe_capabilities (drive); 1881 nslots = ide_cdrom_probe_capabilities(drive);
1873 1882
1874 /* 1883 /*
1875 * set correct block size 1884 * set correct block size
@@ -1881,7 +1890,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
1881 drive->dsc_overlap = (drive->next != drive); 1890 drive->dsc_overlap = (drive->next != drive);
1882 1891
1883 if (ide_cdrom_register(drive, nslots)) { 1892 if (ide_cdrom_register(drive, nslots)) {
1884 printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); 1893 printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
1885 cd->devinfo.handle = NULL; 1894 cd->devinfo.handle = NULL;
1886 return 1; 1895 return 1;
1887 } 1896 }
@@ -1891,7 +1900,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
1891 1900
1892#ifdef CONFIG_IDE_PROC_FS 1901#ifdef CONFIG_IDE_PROC_FS
1893static 1902static
1894sector_t ide_cdrom_capacity (ide_drive_t *drive) 1903sector_t ide_cdrom_capacity(ide_drive_t *drive)
1895{ 1904{
1896 unsigned long capacity, sectors_per_frame; 1905 unsigned long capacity, sectors_per_frame;
1897 1906
@@ -1940,8 +1949,8 @@ static int proc_idecd_read_capacity
1940 ide_drive_t *drive = data; 1949 ide_drive_t *drive = data;
1941 int len; 1950 int len;
1942 1951
1943 len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive)); 1952 len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive));
1944 PROC_IDE_READ_RETURN(page,start,off,count,eof,len); 1953 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
1945} 1954}
1946 1955
1947static ide_proc_entry_t idecd_proc[] = { 1956static ide_proc_entry_t idecd_proc[] = {
@@ -1970,13 +1979,14 @@ static ide_driver_t ide_cdrom_driver = {
1970#endif 1979#endif
1971}; 1980};
1972 1981
1973static int idecd_open(struct inode * inode, struct file * file) 1982static int idecd_open(struct inode *inode, struct file *file)
1974{ 1983{
1975 struct gendisk *disk = inode->i_bdev->bd_disk; 1984 struct gendisk *disk = inode->i_bdev->bd_disk;
1976 struct cdrom_info *info; 1985 struct cdrom_info *info;
1977 int rc = -ENOMEM; 1986 int rc = -ENOMEM;
1978 1987
1979 if (!(info = ide_cd_get(disk))) 1988 info = ide_cd_get(disk);
1989 if (!info)
1980 return -ENXIO; 1990 return -ENXIO;
1981 1991
1982 rc = cdrom_open(&info->devinfo, inode, file); 1992 rc = cdrom_open(&info->devinfo, inode, file);
@@ -1987,12 +1997,12 @@ static int idecd_open(struct inode * inode, struct file * file)
1987 return rc; 1997 return rc;
1988} 1998}
1989 1999
1990static int idecd_release(struct inode * inode, struct file * file) 2000static int idecd_release(struct inode *inode, struct file *file)
1991{ 2001{
1992 struct gendisk *disk = inode->i_bdev->bd_disk; 2002 struct gendisk *disk = inode->i_bdev->bd_disk;
1993 struct cdrom_info *info = ide_cd_g(disk); 2003 struct cdrom_info *info = ide_cd_g(disk);
1994 2004
1995 cdrom_release (&info->devinfo, file); 2005 cdrom_release(&info->devinfo, file);
1996 2006
1997 ide_cd_put(info); 2007 ide_cd_put(info);
1998 2008
@@ -2024,7 +2034,7 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
2024 struct packet_command cgc; 2034 struct packet_command cgc;
2025 char buffer[16]; 2035 char buffer[16];
2026 int stat; 2036 int stat;
2027 char spindown; 2037 char spindown;
2028 2038
2029 init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); 2039 init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
2030 2040
@@ -2033,12 +2043,12 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
2033 return stat; 2043 return stat;
2034 2044
2035 spindown = buffer[11] & 0x0f; 2045 spindown = buffer[11] & 0x0f;
2036 if (copy_to_user((void __user *)arg, &spindown, sizeof (char))) 2046 if (copy_to_user((void __user *)arg, &spindown, sizeof(char)))
2037 return -EFAULT; 2047 return -EFAULT;
2038 return 0; 2048 return 0;
2039} 2049}
2040 2050
2041static int idecd_ioctl (struct inode *inode, struct file *file, 2051static int idecd_ioctl(struct inode *inode, struct file *file,
2042 unsigned int cmd, unsigned long arg) 2052 unsigned int cmd, unsigned long arg)
2043{ 2053{
2044 struct block_device *bdev = inode->i_bdev; 2054 struct block_device *bdev = inode->i_bdev;
@@ -2046,13 +2056,13 @@ static int idecd_ioctl (struct inode *inode, struct file *file,
2046 int err; 2056 int err;
2047 2057
2048 switch (cmd) { 2058 switch (cmd) {
2049 case CDROMSETSPINDOWN: 2059 case CDROMSETSPINDOWN:
2050 return idecd_set_spindown(&info->devinfo, arg); 2060 return idecd_set_spindown(&info->devinfo, arg);
2051 case CDROMGETSPINDOWN: 2061 case CDROMGETSPINDOWN:
2052 return idecd_get_spindown(&info->devinfo, arg); 2062 return idecd_get_spindown(&info->devinfo, arg);
2053 default: 2063 default:
2054 break; 2064 break;
2055 } 2065 }
2056 2066
2057 err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); 2067 err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg);
2058 if (err == -EINVAL) 2068 if (err == -EINVAL)
@@ -2078,16 +2088,16 @@ static int idecd_revalidate_disk(struct gendisk *disk)
2078} 2088}
2079 2089
2080static struct block_device_operations idecd_ops = { 2090static struct block_device_operations idecd_ops = {
2081 .owner = THIS_MODULE, 2091 .owner = THIS_MODULE,
2082 .open = idecd_open, 2092 .open = idecd_open,
2083 .release = idecd_release, 2093 .release = idecd_release,
2084 .ioctl = idecd_ioctl, 2094 .ioctl = idecd_ioctl,
2085 .media_changed = idecd_media_changed, 2095 .media_changed = idecd_media_changed,
2086 .revalidate_disk= idecd_revalidate_disk 2096 .revalidate_disk = idecd_revalidate_disk
2087}; 2097};
2088 2098
2089/* options */ 2099/* options */
2090static char *ignore = NULL; 2100static char *ignore;
2091 2101
2092module_param(ignore, charp, 0400); 2102module_param(ignore, charp, 0400);
2093MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 2103MODULE_DESCRIPTION("ATAPI CD-ROM Driver");