diff options
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 3325660f7248..430d8af35cb1 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -2471,52 +2471,6 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
2471 | } | 2471 | } |
2472 | 2472 | ||
2473 | static | 2473 | static |
2474 | int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi, | ||
2475 | unsigned int cmd, unsigned long arg) | ||
2476 | { | ||
2477 | struct packet_command cgc; | ||
2478 | char buffer[16]; | ||
2479 | int stat; | ||
2480 | |||
2481 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
2482 | |||
2483 | /* These will be moved into the Uniform layer shortly... */ | ||
2484 | switch (cmd) { | ||
2485 | case CDROMSETSPINDOWN: { | ||
2486 | char spindown; | ||
2487 | |||
2488 | if (copy_from_user(&spindown, (void __user *) arg, sizeof(char))) | ||
2489 | return -EFAULT; | ||
2490 | |||
2491 | if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) | ||
2492 | return stat; | ||
2493 | |||
2494 | buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f); | ||
2495 | |||
2496 | return cdrom_mode_select(cdi, &cgc); | ||
2497 | } | ||
2498 | |||
2499 | case CDROMGETSPINDOWN: { | ||
2500 | char spindown; | ||
2501 | |||
2502 | if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0))) | ||
2503 | return stat; | ||
2504 | |||
2505 | spindown = buffer[11] & 0x0f; | ||
2506 | |||
2507 | if (copy_to_user((void __user *) arg, &spindown, sizeof (char))) | ||
2508 | return -EFAULT; | ||
2509 | |||
2510 | return 0; | ||
2511 | } | ||
2512 | |||
2513 | default: | ||
2514 | return -EINVAL; | ||
2515 | } | ||
2516 | |||
2517 | } | ||
2518 | |||
2519 | static | ||
2520 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, | 2474 | int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi, |
2521 | unsigned int cmd, void *arg) | 2475 | unsigned int cmd, void *arg) |
2522 | 2476 | ||
@@ -2852,12 +2806,11 @@ static struct cdrom_device_ops ide_cdrom_dops = { | |||
2852 | .get_mcn = ide_cdrom_get_mcn, | 2806 | .get_mcn = ide_cdrom_get_mcn, |
2853 | .reset = ide_cdrom_reset, | 2807 | .reset = ide_cdrom_reset, |
2854 | .audio_ioctl = ide_cdrom_audio_ioctl, | 2808 | .audio_ioctl = ide_cdrom_audio_ioctl, |
2855 | .dev_ioctl = ide_cdrom_dev_ioctl, | ||
2856 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | | 2809 | .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | |
2857 | CDC_SELECT_SPEED | CDC_SELECT_DISC | | 2810 | CDC_SELECT_SPEED | CDC_SELECT_DISC | |
2858 | CDC_MULTI_SESSION | CDC_MCN | | 2811 | CDC_MULTI_SESSION | CDC_MCN | |
2859 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | | 2812 | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | |
2860 | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R | | 2813 | CDC_DRIVE_STATUS | CDC_CD_R | |
2861 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | | 2814 | CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM | |
2862 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | | 2815 | CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW | |
2863 | CDC_MRW_W | CDC_RAM, | 2816 | CDC_MRW_W | CDC_RAM, |
@@ -3367,6 +3320,45 @@ static int idecd_release(struct inode * inode, struct file * file) | |||
3367 | return 0; | 3320 | return 0; |
3368 | } | 3321 | } |
3369 | 3322 | ||
3323 | static int idecd_set_spindown(struct cdrom_device_info *cdi, unsigned long arg) | ||
3324 | { | ||
3325 | struct packet_command cgc; | ||
3326 | char buffer[16]; | ||
3327 | int stat; | ||
3328 | char spindown; | ||
3329 | |||
3330 | if (copy_from_user(&spindown, (void __user *)arg, sizeof(char))) | ||
3331 | return -EFAULT; | ||
3332 | |||
3333 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
3334 | |||
3335 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0); | ||
3336 | if (stat) | ||
3337 | return stat; | ||
3338 | |||
3339 | buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f); | ||
3340 | return cdrom_mode_select(cdi, &cgc); | ||
3341 | } | ||
3342 | |||
3343 | static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg) | ||
3344 | { | ||
3345 | struct packet_command cgc; | ||
3346 | char buffer[16]; | ||
3347 | int stat; | ||
3348 | char spindown; | ||
3349 | |||
3350 | init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN); | ||
3351 | |||
3352 | stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0); | ||
3353 | if (stat) | ||
3354 | return stat; | ||
3355 | |||
3356 | spindown = buffer[11] & 0x0f; | ||
3357 | if (copy_to_user((void __user *)arg, &spindown, sizeof (char))) | ||
3358 | return -EFAULT; | ||
3359 | return 0; | ||
3360 | } | ||
3361 | |||
3370 | static int idecd_ioctl (struct inode *inode, struct file *file, | 3362 | static int idecd_ioctl (struct inode *inode, struct file *file, |
3371 | unsigned int cmd, unsigned long arg) | 3363 | unsigned int cmd, unsigned long arg) |
3372 | { | 3364 | { |
@@ -3374,7 +3366,16 @@ static int idecd_ioctl (struct inode *inode, struct file *file, | |||
3374 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); | 3366 | struct cdrom_info *info = ide_cd_g(bdev->bd_disk); |
3375 | int err; | 3367 | int err; |
3376 | 3368 | ||
3377 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | 3369 | switch (cmd) { |
3370 | case CDROMSETSPINDOWN: | ||
3371 | return idecd_set_spindown(&info->devinfo, arg); | ||
3372 | case CDROMGETSPINDOWN: | ||
3373 | return idecd_get_spindown(&info->devinfo, arg); | ||
3374 | default: | ||
3375 | break; | ||
3376 | } | ||
3377 | |||
3378 | err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg); | ||
3378 | if (err == -EINVAL) | 3379 | if (err == -EINVAL) |
3379 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); | 3380 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); |
3380 | 3381 | ||