aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-cd.c
diff options
context:
space:
mode:
authorJesper Juhl <jesper.juhl@gmail.com>2005-10-30 18:02:45 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:23 -0500
commit2a91f3e54ff27c6002597f689ba51c5fa657ddbd (patch)
treefdf7632886716b66f2c335b2a6169a192d329c46 /drivers/ide/ide-cd.c
parent20e1129ab831486c811d50d3905343ad48c4275f (diff)
[PATCH] ide-cd mini cleanup of casts
Remove some unneeded casts. Avoid an assignment in the case of kmalloc failure. Break a few instances of if (foo) whatever; into two lines. Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> Acked-by: Jens Axboe <axboe@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r--drivers/ide/ide-cd.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 7130939c7f91..8b9d85526596 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -2211,13 +2211,12 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
2211 2211
2212 if (toc == NULL) { 2212 if (toc == NULL) {
2213 /* Try to allocate space. */ 2213 /* Try to allocate space. */
2214 toc = (struct atapi_toc *) kmalloc (sizeof (struct atapi_toc), 2214 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL);
2215 GFP_KERNEL);
2216 info->toc = toc;
2217 if (toc == NULL) { 2215 if (toc == NULL) {
2218 printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); 2216 printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name);
2219 return -ENOMEM; 2217 return -ENOMEM;
2220 } 2218 }
2219 info->toc = toc;
2221 } 2220 }
2222 2221
2223 /* Check to see if the existing data is still valid. 2222 /* Check to see if the existing data is still valid.
@@ -2240,7 +2239,8 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
2240 /* First read just the header, so we know how long the TOC is. */ 2239 /* First read just the header, so we know how long the TOC is. */
2241 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, 2240 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
2242 sizeof(struct atapi_toc_header), sense); 2241 sizeof(struct atapi_toc_header), sense);
2243 if (stat) return stat; 2242 if (stat)
2243 return stat;
2244 2244
2245#if ! STANDARD_ATAPI 2245#if ! STANDARD_ATAPI
2246 if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) { 2246 if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {
@@ -2324,7 +2324,8 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
2324 /* Read the multisession information. */ 2324 /* Read the multisession information. */
2325 stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, 2325 stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp,
2326 sizeof(ms_tmp), sense); 2326 sizeof(ms_tmp), sense);
2327 if (stat) return stat; 2327 if (stat)
2328 return stat;
2328 2329
2329 toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba); 2330 toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba);
2330 } else { 2331 } else {
@@ -2460,7 +2461,7 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
2460 struct packet_command *cgc) 2461 struct packet_command *cgc)
2461{ 2462{
2462 struct request req; 2463 struct request req;
2463 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2464 ide_drive_t *drive = cdi->handle;
2464 2465
2465 if (cgc->timeout <= 0) 2466 if (cgc->timeout <= 0)
2466 cgc->timeout = ATAPI_WAIT_PC; 2467 cgc->timeout = ATAPI_WAIT_PC;
@@ -2537,7 +2538,7 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
2537 unsigned int cmd, void *arg) 2538 unsigned int cmd, void *arg)
2538 2539
2539{ 2540{
2540 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2541 ide_drive_t *drive = cdi->handle;
2541 struct cdrom_info *info = drive->driver_data; 2542 struct cdrom_info *info = drive->driver_data;
2542 int stat; 2543 int stat;
2543 2544
@@ -2548,7 +2549,7 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
2548 */ 2549 */
2549 case CDROMPLAYTRKIND: { 2550 case CDROMPLAYTRKIND: {
2550 unsigned long lba_start, lba_end; 2551 unsigned long lba_start, lba_end;
2551 struct cdrom_ti *ti = (struct cdrom_ti *)arg; 2552 struct cdrom_ti *ti = arg;
2552 struct atapi_toc_entry *first_toc, *last_toc; 2553 struct atapi_toc_entry *first_toc, *last_toc;
2553 2554
2554 stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc); 2555 stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc);
@@ -2571,12 +2572,13 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
2571 } 2572 }
2572 2573
2573 case CDROMREADTOCHDR: { 2574 case CDROMREADTOCHDR: {
2574 struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg; 2575 struct cdrom_tochdr *tochdr = arg;
2575 struct atapi_toc *toc; 2576 struct atapi_toc *toc;
2576 2577
2577 /* Make sure our saved TOC is valid. */ 2578 /* Make sure our saved TOC is valid. */
2578 stat = cdrom_read_toc(drive, NULL); 2579 stat = cdrom_read_toc(drive, NULL);
2579 if (stat) return stat; 2580 if (stat)
2581 return stat;
2580 2582
2581 toc = info->toc; 2583 toc = info->toc;
2582 tochdr->cdth_trk0 = toc->hdr.first_track; 2584 tochdr->cdth_trk0 = toc->hdr.first_track;
@@ -2586,11 +2588,12 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
2586 } 2588 }
2587 2589
2588 case CDROMREADTOCENTRY: { 2590 case CDROMREADTOCENTRY: {
2589 struct cdrom_tocentry *tocentry = (struct cdrom_tocentry*) arg; 2591 struct cdrom_tocentry *tocentry = arg;
2590 struct atapi_toc_entry *toce; 2592 struct atapi_toc_entry *toce;
2591 2593
2592 stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce); 2594 stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce);
2593 if (stat) return stat; 2595 if (stat)
2596 return stat;
2594 2597
2595 tocentry->cdte_ctrl = toce->control; 2598 tocentry->cdte_ctrl = toce->control;
2596 tocentry->cdte_adr = toce->adr; 2599 tocentry->cdte_adr = toce->adr;
@@ -2613,7 +2616,7 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
2613static 2616static
2614int ide_cdrom_reset (struct cdrom_device_info *cdi) 2617int ide_cdrom_reset (struct cdrom_device_info *cdi)
2615{ 2618{
2616 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2619 ide_drive_t *drive = cdi->handle;
2617 struct request_sense sense; 2620 struct request_sense sense;
2618 struct request req; 2621 struct request req;
2619 int ret; 2622 int ret;
@@ -2636,12 +2639,13 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi)
2636static 2639static
2637int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position) 2640int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
2638{ 2641{
2639 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2642 ide_drive_t *drive = cdi->handle;
2640 struct request_sense sense; 2643 struct request_sense sense;
2641 2644
2642 if (position) { 2645 if (position) {
2643 int stat = cdrom_lockdoor(drive, 0, &sense); 2646 int stat = cdrom_lockdoor(drive, 0, &sense);
2644 if (stat) return stat; 2647 if (stat)
2648 return stat;
2645 } 2649 }
2646 2650
2647 return cdrom_eject(drive, !position, &sense); 2651 return cdrom_eject(drive, !position, &sense);
@@ -2650,7 +2654,7 @@ int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
2650static 2654static
2651int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock) 2655int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock)
2652{ 2656{
2653 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2657 ide_drive_t *drive = cdi->handle;
2654 return cdrom_lockdoor(drive, lock, NULL); 2658 return cdrom_lockdoor(drive, lock, NULL);
2655} 2659}
2656 2660
@@ -2700,7 +2704,7 @@ void ide_cdrom_update_speed (ide_drive_t *drive, struct atapi_capabilities_page
2700static 2704static
2701int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed) 2705int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
2702{ 2706{
2703 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2707 ide_drive_t *drive = cdi->handle;
2704 struct request_sense sense; 2708 struct request_sense sense;
2705 struct atapi_capabilities_page cap; 2709 struct atapi_capabilities_page cap;
2706 int stat; 2710 int stat;
@@ -2723,7 +2727,7 @@ int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
2723static 2727static
2724int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr) 2728int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr)
2725{ 2729{
2726 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2730 ide_drive_t *drive = cdi->handle;
2727 struct media_event_desc med; 2731 struct media_event_desc med;
2728 struct request_sense sense; 2732 struct request_sense sense;
2729 int stat; 2733 int stat;
@@ -2769,7 +2773,7 @@ int ide_cdrom_get_last_session (struct cdrom_device_info *cdi,
2769 struct cdrom_multisession *ms_info) 2773 struct cdrom_multisession *ms_info)
2770{ 2774{
2771 struct atapi_toc *toc; 2775 struct atapi_toc *toc;
2772 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2776 ide_drive_t *drive = cdi->handle;
2773 struct cdrom_info *info = drive->driver_data; 2777 struct cdrom_info *info = drive->driver_data;
2774 struct request_sense sense; 2778 struct request_sense sense;
2775 int ret; 2779 int ret;
@@ -2791,7 +2795,7 @@ int ide_cdrom_get_mcn (struct cdrom_device_info *cdi,
2791{ 2795{
2792 int stat; 2796 int stat;
2793 char mcnbuf[24]; 2797 char mcnbuf[24];
2794 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2798 ide_drive_t *drive = cdi->handle;
2795 2799
2796/* get MCN */ 2800/* get MCN */
2797 if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL))) 2801 if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL)))
@@ -2815,7 +2819,7 @@ static
2815int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi, 2819int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi,
2816 int slot_nr) 2820 int slot_nr)
2817{ 2821{
2818 ide_drive_t *drive = (ide_drive_t*) cdi->handle; 2822 ide_drive_t *drive = cdi->handle;
2819 int retval; 2823 int retval;
2820 2824
2821 if (slot_nr == CDSL_CURRENT) { 2825 if (slot_nr == CDSL_CURRENT) {
@@ -2886,7 +2890,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
2886 devinfo->mask = 0; 2890 devinfo->mask = 0;
2887 devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed; 2891 devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed;
2888 devinfo->capacity = nslots; 2892 devinfo->capacity = nslots;
2889 devinfo->handle = (void *) drive; 2893 devinfo->handle = drive;
2890 strcpy(devinfo->name, drive->name); 2894 strcpy(devinfo->name, drive->name);
2891 2895
2892 /* set capability mask to match the probe. */ 2896 /* set capability mask to match the probe. */
@@ -2942,7 +2946,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
2942 * registered with the Uniform layer yet, it can't do this. 2946 * registered with the Uniform layer yet, it can't do this.
2943 * Same goes for cdi->ops. 2947 * Same goes for cdi->ops.
2944 */ 2948 */
2945 cdi->handle = (ide_drive_t *) drive; 2949 cdi->handle = drive;
2946 cdi->ops = &ide_cdrom_dops; 2950 cdi->ops = &ide_cdrom_dops;
2947 2951
2948 if (ide_cdrom_get_capabilities(drive, &cap)) 2952 if (ide_cdrom_get_capabilities(drive, &cap))
@@ -3311,7 +3315,7 @@ static int ide_cd_probe(struct device *);
3311static int proc_idecd_read_capacity 3315static int proc_idecd_read_capacity
3312 (char *page, char **start, off_t off, int count, int *eof, void *data) 3316 (char *page, char **start, off_t off, int count, int *eof, void *data)
3313{ 3317{
3314 ide_drive_t*drive = (ide_drive_t *)data; 3318 ide_drive_t *drive = data;
3315 int len; 3319 int len;
3316 3320
3317 len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive)); 3321 len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive));
@@ -3451,7 +3455,7 @@ static int ide_cd_probe(struct device *dev)
3451 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); 3455 printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
3452 goto failed; 3456 goto failed;
3453 } 3457 }
3454 info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL); 3458 info = kmalloc(sizeof(struct cdrom_info), GFP_KERNEL);
3455 if (info == NULL) { 3459 if (info == NULL) {
3456 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); 3460 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
3457 goto failed; 3461 goto failed;