diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:21 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:21 -0500 |
commit | 455d80a9553915251b6392e31c39aeb8f8a94d68 (patch) | |
tree | 3b9452a3ee0d3a3de67f316f13bb6e3db00531fa /drivers/ide/ide-cd.c | |
parent | 0ba11211f9ac583333aac44daec5af4f7eeba217 (diff) |
ide-cd: remove struct atapi_capabilities_page (take 2)
* Remove struct atapi_capabilities_page.
* Add ATAPI_CAPABILITIES_PAGE[_PAD]_SIZE define.
v2:
* The buf[] array access indexes were swapped between 'curspeed'/'maxspeed'.
(Noticed by Borislav Petkov).
Cc: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 59981a043182..ab1cdce806ec 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -2394,13 +2394,12 @@ int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock) | |||
2394 | return cdrom_lockdoor(drive, lock, NULL); | 2394 | return cdrom_lockdoor(drive, lock, NULL); |
2395 | } | 2395 | } |
2396 | 2396 | ||
2397 | static | 2397 | static int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf) |
2398 | int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_page *cap) | ||
2399 | { | 2398 | { |
2400 | struct cdrom_info *info = drive->driver_data; | 2399 | struct cdrom_info *info = drive->driver_data; |
2401 | struct cdrom_device_info *cdi = &info->devinfo; | 2400 | struct cdrom_device_info *cdi = &info->devinfo; |
2402 | struct packet_command cgc; | 2401 | struct packet_command cgc; |
2403 | int stat, attempts = 3, size = sizeof(*cap); | 2402 | int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; |
2404 | 2403 | ||
2405 | /* | 2404 | /* |
2406 | * ACER50 (and others?) require the full spec length mode sense | 2405 | * ACER50 (and others?) require the full spec length mode sense |
@@ -2408,9 +2407,9 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_pag | |||
2408 | */ | 2407 | */ |
2409 | if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") || | 2408 | if (!(!strcmp(drive->id->model, "ATAPI CD ROM DRIVE 50X MAX") || |
2410 | !strcmp(drive->id->model, "WPI CDS-32X"))) | 2409 | !strcmp(drive->id->model, "WPI CDS-32X"))) |
2411 | size -= sizeof(cap->pad); | 2410 | size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; |
2412 | 2411 | ||
2413 | init_cdrom_command(&cgc, cap, size, CGC_DATA_UNKNOWN); | 2412 | init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); |
2414 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ | 2413 | do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ |
2415 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); | 2414 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); |
2416 | if (!stat) | 2415 | if (!stat) |
@@ -2419,20 +2418,22 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, struct atapi_capabilities_pag | |||
2419 | return stat; | 2418 | return stat; |
2420 | } | 2419 | } |
2421 | 2420 | ||
2422 | static | 2421 | static void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf) |
2423 | void ide_cdrom_update_speed (ide_drive_t *drive, struct atapi_capabilities_page *cap) | ||
2424 | { | 2422 | { |
2425 | struct cdrom_info *cd = drive->driver_data; | 2423 | struct cdrom_info *cd = drive->driver_data; |
2426 | u16 curspeed, maxspeed; | 2424 | u16 curspeed, maxspeed; |
2427 | 2425 | ||
2426 | curspeed = *(u16 *)&buf[8 + 14]; | ||
2427 | maxspeed = *(u16 *)&buf[8 + 8]; | ||
2428 | |||
2428 | /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */ | 2429 | /* The ACER/AOpen 24X cdrom has the speed fields byte-swapped */ |
2429 | if (!drive->id->model[0] && | 2430 | if (!drive->id->model[0] && |
2430 | !strncmp(drive->id->fw_rev, "241N", 4)) { | 2431 | !strncmp(drive->id->fw_rev, "241N", 4)) { |
2431 | curspeed = le16_to_cpu(cap->curspeed); | 2432 | curspeed = le16_to_cpu(curspeed); |
2432 | maxspeed = le16_to_cpu(cap->maxspeed); | 2433 | maxspeed = le16_to_cpu(maxspeed); |
2433 | } else { | 2434 | } else { |
2434 | curspeed = be16_to_cpu(cap->curspeed); | 2435 | curspeed = be16_to_cpu(curspeed); |
2435 | maxspeed = be16_to_cpu(cap->maxspeed); | 2436 | maxspeed = be16_to_cpu(maxspeed); |
2436 | } | 2437 | } |
2437 | 2438 | ||
2438 | cd->state_flags.current_speed = (curspeed + (176/2)) / 176; | 2439 | cd->state_flags.current_speed = (curspeed + (176/2)) / 176; |
@@ -2445,14 +2446,14 @@ int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed) | |||
2445 | ide_drive_t *drive = cdi->handle; | 2446 | ide_drive_t *drive = cdi->handle; |
2446 | struct cdrom_info *cd = drive->driver_data; | 2447 | struct cdrom_info *cd = drive->driver_data; |
2447 | struct request_sense sense; | 2448 | struct request_sense sense; |
2448 | struct atapi_capabilities_page cap; | 2449 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
2449 | int stat; | 2450 | int stat; |
2450 | 2451 | ||
2451 | if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0) | 2452 | if ((stat = cdrom_select_speed(drive, speed, &sense)) < 0) |
2452 | return stat; | 2453 | return stat; |
2453 | 2454 | ||
2454 | if (!ide_cdrom_get_capabilities(drive, &cap)) { | 2455 | if (!ide_cdrom_get_capabilities(drive, buf)) { |
2455 | ide_cdrom_update_speed(drive, &cap); | 2456 | ide_cdrom_update_speed(drive, buf); |
2456 | cdi->speed = cd->state_flags.current_speed; | 2457 | cdi->speed = cd->state_flags.current_speed; |
2457 | } | 2458 | } |
2458 | return 0; | 2459 | return 0; |
@@ -2636,7 +2637,8 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
2636 | { | 2637 | { |
2637 | struct cdrom_info *cd = drive->driver_data; | 2638 | struct cdrom_info *cd = drive->driver_data; |
2638 | struct cdrom_device_info *cdi = &cd->devinfo; | 2639 | struct cdrom_device_info *cdi = &cd->devinfo; |
2639 | struct atapi_capabilities_page cap; | 2640 | u8 buf[ATAPI_CAPABILITIES_PAGE_SIZE]; |
2641 | mechtype_t mechtype; | ||
2640 | int nslots = 1; | 2642 | int nslots = 1; |
2641 | 2643 | ||
2642 | cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | | 2644 | cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | |
@@ -2666,26 +2668,28 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
2666 | cdi->handle = drive; | 2668 | cdi->handle = drive; |
2667 | cdi->ops = &ide_cdrom_dops; | 2669 | cdi->ops = &ide_cdrom_dops; |
2668 | 2670 | ||
2669 | if (ide_cdrom_get_capabilities(drive, &cap)) | 2671 | if (ide_cdrom_get_capabilities(drive, buf)) |
2670 | return 0; | 2672 | return 0; |
2671 | 2673 | ||
2672 | if (cap.lock == 0) | 2674 | if ((buf[8 + 6] & 0x01) == 0) |
2673 | cd->config_flags.no_doorlock = 1; | 2675 | cd->config_flags.no_doorlock = 1; |
2674 | if (cap.eject) | 2676 | if (buf[8 + 6] & 0x08) |
2675 | cd->config_flags.no_eject = 0; | 2677 | cd->config_flags.no_eject = 0; |
2676 | if (cap.cd_r_write) | 2678 | if (buf[8 + 3] & 0x01) |
2677 | cdi->mask &= ~CDC_CD_R; | 2679 | cdi->mask &= ~CDC_CD_R; |
2678 | if (cap.cd_rw_write) | 2680 | if (buf[8 + 3] & 0x02) |
2679 | cdi->mask &= ~(CDC_CD_RW | CDC_RAM); | 2681 | cdi->mask &= ~(CDC_CD_RW | CDC_RAM); |
2680 | if (cap.dvd_ram_read || cap.dvd_r_read || cap.dvd_rom) | 2682 | if (buf[8 + 2] & 0x38) |
2681 | cdi->mask &= ~CDC_DVD; | 2683 | cdi->mask &= ~CDC_DVD; |
2682 | if (cap.dvd_ram_write) | 2684 | if (buf[8 + 3] & 0x20) |
2683 | cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM); | 2685 | cdi->mask &= ~(CDC_DVD_RAM | CDC_RAM); |
2684 | if (cap.dvd_r_write) | 2686 | if (buf[8 + 3] & 0x10) |
2685 | cdi->mask &= ~CDC_DVD_R; | 2687 | cdi->mask &= ~CDC_DVD_R; |
2686 | if (cap.audio_play) | 2688 | if (buf[8 + 4] & 0x01) |
2687 | cdi->mask &= ~CDC_PLAY_AUDIO; | 2689 | cdi->mask &= ~CDC_PLAY_AUDIO; |
2688 | if (cap.mechtype == mechtype_caddy || cap.mechtype == mechtype_popup) | 2690 | |
2691 | mechtype = buf[8 + 6] >> 5; | ||
2692 | if (mechtype == mechtype_caddy || mechtype == mechtype_popup) | ||
2689 | cdi->mask |= CDC_CLOSE_TRAY; | 2693 | cdi->mask |= CDC_CLOSE_TRAY; |
2690 | 2694 | ||
2691 | /* Some drives used by Apple don't advertise audio play | 2695 | /* Some drives used by Apple don't advertise audio play |
@@ -2705,14 +2709,14 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
2705 | 2709 | ||
2706 | else | 2710 | else |
2707 | #endif /* not STANDARD_ATAPI */ | 2711 | #endif /* not STANDARD_ATAPI */ |
2708 | if (cap.mechtype == mechtype_individual_changer || | 2712 | if (mechtype == mechtype_individual_changer || |
2709 | cap.mechtype == mechtype_cartridge_changer) { | 2713 | mechtype == mechtype_cartridge_changer) { |
2710 | nslots = cdrom_number_of_slots(cdi); | 2714 | nslots = cdrom_number_of_slots(cdi); |
2711 | if (nslots > 1) | 2715 | if (nslots > 1) |
2712 | cdi->mask &= ~CDC_SELECT_DISC; | 2716 | cdi->mask &= ~CDC_SELECT_DISC; |
2713 | } | 2717 | } |
2714 | 2718 | ||
2715 | ide_cdrom_update_speed(drive, &cap); | 2719 | ide_cdrom_update_speed(drive, buf); |
2716 | 2720 | ||
2717 | printk(KERN_INFO "%s: ATAPI", drive->name); | 2721 | printk(KERN_INFO "%s: ATAPI", drive->name); |
2718 | 2722 | ||
@@ -2737,7 +2741,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive) | |||
2737 | else | 2741 | else |
2738 | printk(KERN_CONT " drive"); | 2742 | printk(KERN_CONT " drive"); |
2739 | 2743 | ||
2740 | printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(cap.buffer_size)); | 2744 | printk(KERN_CONT ", %dkB Cache\n", be16_to_cpu(*(u16 *)&buf[8 + 12])); |
2741 | 2745 | ||
2742 | return nslots; | 2746 | return nslots; |
2743 | } | 2747 | } |