aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:45 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-13 15:39:45 -0400
commitf87904898e91923a91b925078ac933f05076c7fd (patch)
treebd4488b5510f8b67d4b2f92bd1d8616472076eee /drivers/ide
parentb9103da463f72d03c513acdb18f1aebd7931ed1e (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/ide')
-rw-r--r--drivers/ide/Makefile3
-rw-r--r--drivers/ide/ide-disk.c48
-rw-r--r--drivers/ide/ide-disk.h25
-rw-r--r--drivers/ide/ide-disk_ioctl.c29
-rw-r--r--drivers/ide/ide.c11
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/
36obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 36obj-$(CONFIG_IDE_GENERIC) += ide-generic.o
37obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o 37obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
38 38
39ide-disk_mod-y += ide-disk.o ide-disk_ioctl.o
39ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o 40ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o
40ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o 41ide-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
44endif 45endif
45 46
46obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o 47obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk_mod.o
47obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o 48obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o
48obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o 49obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o
49obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 50obj-$(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
48struct 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
56static DEFINE_MUTEX(idedisk_ref_mutex); 50static 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
63static void ide_disk_release(struct kref *); 54static void ide_disk_release(struct kref *);
64 55
65static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) 56static 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
725ide_devset_rw(acoustic, acoustic); 716ide_ext_devset_rw(acoustic, acoustic);
726ide_devset_rw(address, addressing); 717ide_ext_devset_rw(address, addressing);
727ide_devset_rw(multcount, multcount); 718ide_ext_devset_rw(multcount, multcount);
728ide_devset_rw(wcache, wcache); 719ide_ext_devset_rw(wcache, wcache);
729 720
730ide_devset_rw_sync(nowerr, nowerr); 721ide_ext_devset_rw_sync(nowerr, nowerr);
731 722
732#ifdef CONFIG_IDE_PROC_FS 723#ifdef CONFIG_IDE_PROC_FS
733ide_devset_rw_field(bios_cyl, bios_cyl); 724ide_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
1028static 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
1037static 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
1052static int idedisk_media_changed(struct gendisk *disk) 1019static 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
1153MODULE_ALIAS("ide:*m-disk*"); 1120MODULE_ALIAS("ide:*m-disk*");
1121MODULE_ALIAS("ide-disk");
1154module_init(idedisk_init); 1122module_init(idedisk_init);
1155module_exit(idedisk_exit); 1123module_exit(idedisk_exit);
1156MODULE_LICENSE("GPL"); 1124MODULE_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
4struct 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 */
16ide_decl_devset(address);
17ide_decl_devset(multcount);
18ide_decl_devset(nowerr);
19ide_decl_devset(wcache);
20ide_decl_devset(acoustic);
21
22/* ide-disk_ioctl.c */
23int 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
7static 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
16int 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) \ 395ide_ext_devset_rw_sync(io_32bit, io_32bit);
396__IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) 396ide_ext_devset_rw_sync(keepsettings, ksettings);
397 397ide_ext_devset_rw_sync(unmaskirq, unmaskirq);
398ide_gen_devset_rw(io_32bit, io_32bit); 398ide_ext_devset_rw_sync(using_dma, using_dma);
399ide_gen_devset_rw(keepsettings, ksettings);
400ide_gen_devset_rw(unmaskirq, unmaskirq);
401ide_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
404static int generic_ide_suspend(struct device *dev, pm_message_t mesg) 401static int generic_ide_suspend(struct device *dev, pm_message_t mesg)