blob: da36f729ff3273b99e8700670047299ad3cfeab3 [file] [log] [blame]
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +02001#include <linux/kernel.h>
2#include <linux/ide.h>
3#include <linux/hdreg.h>
Arnd Bergmann2a48fc02010-06-02 14:28:52 +02004#include <linux/mutex.h>
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +02005
6#include "ide-disk.h"
7
Arnd Bergmann2a48fc02010-06-02 14:28:52 +02008static DEFINE_MUTEX(ide_disk_ioctl_mutex);
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +02009static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
10{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address },
11{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount },
12{ HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr },
13{ HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache },
14{ HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic },
15{ 0 }
16};
17
Al Virobadf8082008-10-16 10:23:20 -040018int ide_disk_ioctl(ide_drive_t *drive, struct block_device *bdev, fmode_t mode,
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +020019 unsigned int cmd, unsigned long arg)
20{
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +020021 int err;
22
Arnd Bergmann2a48fc02010-06-02 14:28:52 +020023 mutex_lock(&ide_disk_ioctl_mutex);
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +020024 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
25 if (err != -EOPNOTSUPP)
Arnd Bergmann8a6cfeb2010-07-08 10:18:46 +020026 goto out;
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +020027
Arnd Bergmann8a6cfeb2010-07-08 10:18:46 +020028 err = generic_ide_ioctl(drive, bdev, cmd, arg);
29out:
Arnd Bergmann2a48fc02010-06-02 14:28:52 +020030 mutex_unlock(&ide_disk_ioctl_mutex);
Arnd Bergmann8a6cfeb2010-07-08 10:18:46 +020031 return err;
Bartlomiej Zolnierkiewiczf8790482008-10-13 21:39:45 +020032}