diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:45 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:45 -0400 |
commit | f87904898e91923a91b925078ac933f05076c7fd (patch) | |
tree | bd4488b5510f8b67d4b2f92bd1d8616472076eee /drivers | |
parent | b9103da463f72d03c513acdb18f1aebd7931ed1e (diff) |
ide-disk: move all ioctl handling to ide-disk_ioctl.c
While at it:
- idedisk_ioctl() -> ide_disk_ioctl()
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/Makefile | 3 | ||||
-rw-r--r-- | drivers/ide/ide-disk.c | 48 | ||||
-rw-r--r-- | drivers/ide/ide-disk.h | 25 | ||||
-rw-r--r-- | drivers/ide/ide-disk_ioctl.c | 29 | ||||
-rw-r--r-- | drivers/ide/ide.c | 11 |
5 files changed, 68 insertions, 48 deletions
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 06e7867052d3..57b252b8e792 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
@@ -36,6 +36,7 @@ obj-$(CONFIG_IDE_H8300) += h8300/ | |||
36 | obj-$(CONFIG_IDE_GENERIC) += ide-generic.o | 36 | obj-$(CONFIG_IDE_GENERIC) += ide-generic.o |
37 | obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o | 37 | obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o |
38 | 38 | ||
39 | ide-disk_mod-y += ide-disk.o ide-disk_ioctl.o | ||
39 | ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o | 40 | ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o |
40 | ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o | 41 | ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o |
41 | 42 | ||
@@ -43,7 +44,7 @@ ifeq ($(CONFIG_IDE_PROC_FS), y) | |||
43 | ide-floppy_mod-y += ide-floppy_proc.o | 44 | ide-floppy_mod-y += ide-floppy_proc.o |
44 | endif | 45 | endif |
45 | 46 | ||
46 | obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o | 47 | obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk_mod.o |
47 | obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o | 48 | obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o |
48 | obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o | 49 | obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o |
49 | obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o | 50 | obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 6eb9fea32a56..995d448109eb 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -45,21 +45,12 @@ | |||
45 | #define IDE_DISK_MINORS 0 | 45 | #define IDE_DISK_MINORS 0 |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | struct ide_disk_obj { | 48 | #include "ide-disk.h" |
49 | ide_drive_t *drive; | ||
50 | ide_driver_t *driver; | ||
51 | struct gendisk *disk; | ||
52 | struct kref kref; | ||
53 | unsigned int openers; /* protected by BKL for now */ | ||
54 | }; | ||
55 | 49 | ||
56 | static DEFINE_MUTEX(idedisk_ref_mutex); | 50 | static DEFINE_MUTEX(idedisk_ref_mutex); |
57 | 51 | ||
58 | #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) | 52 | #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) |
59 | 53 | ||
60 | #define ide_disk_g(disk) \ | ||
61 | container_of((disk)->private_data, struct ide_disk_obj, driver) | ||
62 | |||
63 | static void ide_disk_release(struct kref *); | 54 | static void ide_disk_release(struct kref *); |
64 | 55 | ||
65 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) | 56 | static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) |
@@ -722,12 +713,12 @@ static int set_addressing(ide_drive_t *drive, int arg) | |||
722 | return 0; | 713 | return 0; |
723 | } | 714 | } |
724 | 715 | ||
725 | ide_devset_rw(acoustic, acoustic); | 716 | ide_ext_devset_rw(acoustic, acoustic); |
726 | ide_devset_rw(address, addressing); | 717 | ide_ext_devset_rw(address, addressing); |
727 | ide_devset_rw(multcount, multcount); | 718 | ide_ext_devset_rw(multcount, multcount); |
728 | ide_devset_rw(wcache, wcache); | 719 | ide_ext_devset_rw(wcache, wcache); |
729 | 720 | ||
730 | ide_devset_rw_sync(nowerr, nowerr); | 721 | ide_ext_devset_rw_sync(nowerr, nowerr); |
731 | 722 | ||
732 | #ifdef CONFIG_IDE_PROC_FS | 723 | #ifdef CONFIG_IDE_PROC_FS |
733 | ide_devset_rw_field(bios_cyl, bios_cyl); | 724 | ide_devset_rw_field(bios_cyl, bios_cyl); |
@@ -1025,30 +1016,6 @@ static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
1025 | return 0; | 1016 | return 0; |
1026 | } | 1017 | } |
1027 | 1018 | ||
1028 | static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { | ||
1029 | { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, | ||
1030 | { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, | ||
1031 | { HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr }, | ||
1032 | { HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache }, | ||
1033 | { HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic }, | ||
1034 | { 0 } | ||
1035 | }; | ||
1036 | |||
1037 | static int idedisk_ioctl(struct inode *inode, struct file *file, | ||
1038 | unsigned int cmd, unsigned long arg) | ||
1039 | { | ||
1040 | struct block_device *bdev = inode->i_bdev; | ||
1041 | struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); | ||
1042 | ide_drive_t *drive = idkp->drive; | ||
1043 | int err; | ||
1044 | |||
1045 | err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); | ||
1046 | if (err != -EOPNOTSUPP) | ||
1047 | return err; | ||
1048 | |||
1049 | return generic_ide_ioctl(drive, file, bdev, cmd, arg); | ||
1050 | } | ||
1051 | |||
1052 | static int idedisk_media_changed(struct gendisk *disk) | 1019 | static int idedisk_media_changed(struct gendisk *disk) |
1053 | { | 1020 | { |
1054 | struct ide_disk_obj *idkp = ide_disk_g(disk); | 1021 | struct ide_disk_obj *idkp = ide_disk_g(disk); |
@@ -1075,7 +1042,7 @@ static struct block_device_operations idedisk_ops = { | |||
1075 | .owner = THIS_MODULE, | 1042 | .owner = THIS_MODULE, |
1076 | .open = idedisk_open, | 1043 | .open = idedisk_open, |
1077 | .release = idedisk_release, | 1044 | .release = idedisk_release, |
1078 | .ioctl = idedisk_ioctl, | 1045 | .ioctl = ide_disk_ioctl, |
1079 | .getgeo = idedisk_getgeo, | 1046 | .getgeo = idedisk_getgeo, |
1080 | .media_changed = idedisk_media_changed, | 1047 | .media_changed = idedisk_media_changed, |
1081 | .revalidate_disk = idedisk_revalidate_disk | 1048 | .revalidate_disk = idedisk_revalidate_disk |
@@ -1151,6 +1118,7 @@ static int __init idedisk_init(void) | |||
1151 | } | 1118 | } |
1152 | 1119 | ||
1153 | MODULE_ALIAS("ide:*m-disk*"); | 1120 | MODULE_ALIAS("ide:*m-disk*"); |
1121 | MODULE_ALIAS("ide-disk"); | ||
1154 | module_init(idedisk_init); | 1122 | module_init(idedisk_init); |
1155 | module_exit(idedisk_exit); | 1123 | module_exit(idedisk_exit); |
1156 | MODULE_LICENSE("GPL"); | 1124 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/ide-disk.h b/drivers/ide/ide-disk.h new file mode 100644 index 000000000000..7f007854adac --- /dev/null +++ b/drivers/ide/ide-disk.h | |||
@@ -0,0 +1,25 @@ | |||
1 | #ifndef __IDE_DISK_H | ||
2 | #define __IDE_DISK_H | ||
3 | |||
4 | struct ide_disk_obj { | ||
5 | ide_drive_t *drive; | ||
6 | ide_driver_t *driver; | ||
7 | struct gendisk *disk; | ||
8 | struct kref kref; | ||
9 | unsigned int openers; /* protected by BKL for now */ | ||
10 | }; | ||
11 | |||
12 | #define ide_disk_g(disk) \ | ||
13 | container_of((disk)->private_data, struct ide_disk_obj, driver) | ||
14 | |||
15 | /* ide-disk.c */ | ||
16 | ide_decl_devset(address); | ||
17 | ide_decl_devset(multcount); | ||
18 | ide_decl_devset(nowerr); | ||
19 | ide_decl_devset(wcache); | ||
20 | ide_decl_devset(acoustic); | ||
21 | |||
22 | /* ide-disk_ioctl.c */ | ||
23 | int ide_disk_ioctl(struct inode *, struct file *, unsigned int, unsigned long); | ||
24 | |||
25 | #endif /* __IDE_DISK_H */ | ||
diff --git a/drivers/ide/ide-disk_ioctl.c b/drivers/ide/ide-disk_ioctl.c new file mode 100644 index 000000000000..a6cf1a03a806 --- /dev/null +++ b/drivers/ide/ide-disk_ioctl.c | |||
@@ -0,0 +1,29 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/ide.h> | ||
3 | #include <linux/hdreg.h> | ||
4 | |||
5 | #include "ide-disk.h" | ||
6 | |||
7 | static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { | ||
8 | { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, | ||
9 | { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, | ||
10 | { HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr }, | ||
11 | { HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache }, | ||
12 | { HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic }, | ||
13 | { 0 } | ||
14 | }; | ||
15 | |||
16 | int ide_disk_ioctl(struct inode *inode, struct file *file, | ||
17 | unsigned int cmd, unsigned long arg) | ||
18 | { | ||
19 | struct block_device *bdev = inode->i_bdev; | ||
20 | struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); | ||
21 | ide_drive_t *drive = idkp->drive; | ||
22 | int err; | ||
23 | |||
24 | err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); | ||
25 | if (err != -EOPNOTSUPP) | ||
26 | return err; | ||
27 | |||
28 | return generic_ide_ioctl(drive, file, bdev, cmd, arg); | ||
29 | } | ||
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 73e1cc5839d3..a498245dc213 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
@@ -392,13 +392,10 @@ static int set_unmaskirq(ide_drive_t *drive, int arg) | |||
392 | return 0; | 392 | return 0; |
393 | } | 393 | } |
394 | 394 | ||
395 | #define ide_gen_devset_rw(_name, _func) \ | 395 | ide_ext_devset_rw_sync(io_32bit, io_32bit); |
396 | __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | 396 | ide_ext_devset_rw_sync(keepsettings, ksettings); |
397 | 397 | ide_ext_devset_rw_sync(unmaskirq, unmaskirq); | |
398 | ide_gen_devset_rw(io_32bit, io_32bit); | 398 | ide_ext_devset_rw_sync(using_dma, using_dma); |
399 | ide_gen_devset_rw(keepsettings, ksettings); | ||
400 | ide_gen_devset_rw(unmaskirq, unmaskirq); | ||
401 | ide_gen_devset_rw(using_dma, using_dma); | ||
402 | __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); | 399 | __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); |
403 | 400 | ||
404 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) | 401 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) |