aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2006-01-06 06:41:00 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-13 14:26:10 -0500
commit4031bbe4bbec6c0fe50412ef7fb43a270b0f29f1 (patch)
tree1e1449ba492ab04d8c5fbc75f9761be237bcae72
parentbbbe3a41f7ee529f7f4fdcc1bc1157234bac0766 (diff)
[PATCH] Add ide_bus_type probe and remove methods
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/ide/ide-cd.c14
-rw-r--r--drivers/ide/ide-disk.c22
-rw-r--r--drivers/ide/ide-floppy.c14
-rw-r--r--drivers/ide/ide-tape.c18
-rw-r--r--drivers/ide/ide.c31
-rw-r--r--include/linux/ide.h5
6 files changed, 61 insertions, 43 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 9b2ebd219ad0..ef09a7ef2396 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3256,9 +3256,8 @@ sector_t ide_cdrom_capacity (ide_drive_t *drive)
3256} 3256}
3257#endif 3257#endif
3258 3258
3259static int ide_cd_remove(struct device *dev) 3259static void ide_cd_remove(ide_drive_t *drive)
3260{ 3260{
3261 ide_drive_t *drive = to_ide_device(dev);
3262 struct cdrom_info *info = drive->driver_data; 3261 struct cdrom_info *info = drive->driver_data;
3263 3262
3264 ide_unregister_subdriver(drive, info->driver); 3263 ide_unregister_subdriver(drive, info->driver);
@@ -3266,8 +3265,6 @@ static int ide_cd_remove(struct device *dev)
3266 del_gendisk(info->disk); 3265 del_gendisk(info->disk);
3267 3266
3268 ide_cd_put(info); 3267 ide_cd_put(info);
3269
3270 return 0;
3271} 3268}
3272 3269
3273static void ide_cd_release(struct kref *kref) 3270static void ide_cd_release(struct kref *kref)
@@ -3291,7 +3288,7 @@ static void ide_cd_release(struct kref *kref)
3291 kfree(info); 3288 kfree(info);
3292} 3289}
3293 3290
3294static int ide_cd_probe(struct device *); 3291static int ide_cd_probe(ide_drive_t *);
3295 3292
3296#ifdef CONFIG_PROC_FS 3293#ifdef CONFIG_PROC_FS
3297static int proc_idecd_read_capacity 3294static int proc_idecd_read_capacity
@@ -3317,9 +3314,9 @@ static ide_driver_t ide_cdrom_driver = {
3317 .owner = THIS_MODULE, 3314 .owner = THIS_MODULE,
3318 .name = "ide-cdrom", 3315 .name = "ide-cdrom",
3319 .bus = &ide_bus_type, 3316 .bus = &ide_bus_type,
3320 .probe = ide_cd_probe,
3321 .remove = ide_cd_remove,
3322 }, 3317 },
3318 .probe = ide_cd_probe,
3319 .remove = ide_cd_remove,
3323 .version = IDECD_VERSION, 3320 .version = IDECD_VERSION,
3324 .media = ide_cdrom, 3321 .media = ide_cdrom,
3325 .supports_dsc_overlap = 1, 3322 .supports_dsc_overlap = 1,
@@ -3413,9 +3410,8 @@ static char *ignore = NULL;
3413module_param(ignore, charp, 0400); 3410module_param(ignore, charp, 0400);
3414MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 3411MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
3415 3412
3416static int ide_cd_probe(struct device *dev) 3413static int ide_cd_probe(ide_drive_t *drive)
3417{ 3414{
3418 ide_drive_t *drive = to_ide_device(dev);
3419 struct cdrom_info *info; 3415 struct cdrom_info *info;
3420 struct gendisk *g; 3416 struct gendisk *g;
3421 struct request_sense sense; 3417 struct request_sense sense;
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index cab362ea0336..245b508208df 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -997,9 +997,8 @@ static void ide_cacheflush_p(ide_drive_t *drive)
997 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 997 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
998} 998}
999 999
1000static int ide_disk_remove(struct device *dev) 1000static void ide_disk_remove(ide_drive_t *drive)
1001{ 1001{
1002 ide_drive_t *drive = to_ide_device(dev);
1003 struct ide_disk_obj *idkp = drive->driver_data; 1002 struct ide_disk_obj *idkp = drive->driver_data;
1004 struct gendisk *g = idkp->disk; 1003 struct gendisk *g = idkp->disk;
1005 1004
@@ -1010,8 +1009,6 @@ static int ide_disk_remove(struct device *dev)
1010 ide_cacheflush_p(drive); 1009 ide_cacheflush_p(drive);
1011 1010
1012 ide_disk_put(idkp); 1011 ide_disk_put(idkp);
1013
1014 return 0;
1015} 1012}
1016 1013
1017static void ide_disk_release(struct kref *kref) 1014static void ide_disk_release(struct kref *kref)
@@ -1027,12 +1024,10 @@ static void ide_disk_release(struct kref *kref)
1027 kfree(idkp); 1024 kfree(idkp);
1028} 1025}
1029 1026
1030static int ide_disk_probe(struct device *dev); 1027static int ide_disk_probe(ide_drive_t *drive);
1031 1028
1032static void ide_device_shutdown(struct device *dev) 1029static void ide_device_shutdown(ide_drive_t *drive)
1033{ 1030{
1034 ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
1035
1036#ifdef CONFIG_ALPHA 1031#ifdef CONFIG_ALPHA
1037 /* On Alpha, halt(8) doesn't actually turn the machine off, 1032 /* On Alpha, halt(8) doesn't actually turn the machine off,
1038 it puts you into the sort of firmware monitor. Typically, 1033 it puts you into the sort of firmware monitor. Typically,
@@ -1054,7 +1049,7 @@ static void ide_device_shutdown(struct device *dev)
1054 } 1049 }
1055 1050
1056 printk("Shutdown: %s\n", drive->name); 1051 printk("Shutdown: %s\n", drive->name);
1057 dev->bus->suspend(dev, PMSG_SUSPEND); 1052 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
1058} 1053}
1059 1054
1060static ide_driver_t idedisk_driver = { 1055static ide_driver_t idedisk_driver = {
@@ -1062,10 +1057,10 @@ static ide_driver_t idedisk_driver = {
1062 .owner = THIS_MODULE, 1057 .owner = THIS_MODULE,
1063 .name = "ide-disk", 1058 .name = "ide-disk",
1064 .bus = &ide_bus_type, 1059 .bus = &ide_bus_type,
1065 .probe = ide_disk_probe,
1066 .remove = ide_disk_remove,
1067 .shutdown = ide_device_shutdown,
1068 }, 1060 },
1061 .probe = ide_disk_probe,
1062 .remove = ide_disk_remove,
1063 .shutdown = ide_device_shutdown,
1069 .version = IDEDISK_VERSION, 1064 .version = IDEDISK_VERSION,
1070 .media = ide_disk, 1065 .media = ide_disk,
1071 .supports_dsc_overlap = 0, 1066 .supports_dsc_overlap = 0,
@@ -1182,9 +1177,8 @@ static struct block_device_operations idedisk_ops = {
1182 1177
1183MODULE_DESCRIPTION("ATA DISK Driver"); 1178MODULE_DESCRIPTION("ATA DISK Driver");
1184 1179
1185static int ide_disk_probe(struct device *dev) 1180static int ide_disk_probe(ide_drive_t *drive)
1186{ 1181{
1187 ide_drive_t *drive = to_ide_device(dev);
1188 struct ide_disk_obj *idkp; 1182 struct ide_disk_obj *idkp;
1189 struct gendisk *g; 1183 struct gendisk *g;
1190 1184
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 5945f551aaaa..1f8db9ac05d1 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1871,9 +1871,8 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
1871 idefloppy_add_settings(drive); 1871 idefloppy_add_settings(drive);
1872} 1872}
1873 1873
1874static int ide_floppy_remove(struct device *dev) 1874static void ide_floppy_remove(ide_drive_t *drive)
1875{ 1875{
1876 ide_drive_t *drive = to_ide_device(dev);
1877 idefloppy_floppy_t *floppy = drive->driver_data; 1876 idefloppy_floppy_t *floppy = drive->driver_data;
1878 struct gendisk *g = floppy->disk; 1877 struct gendisk *g = floppy->disk;
1879 1878
@@ -1882,8 +1881,6 @@ static int ide_floppy_remove(struct device *dev)
1882 del_gendisk(g); 1881 del_gendisk(g);
1883 1882
1884 ide_floppy_put(floppy); 1883 ide_floppy_put(floppy);
1885
1886 return 0;
1887} 1884}
1888 1885
1889static void ide_floppy_release(struct kref *kref) 1886static void ide_floppy_release(struct kref *kref)
@@ -1922,16 +1919,16 @@ static ide_proc_entry_t idefloppy_proc[] = {
1922 1919
1923#endif /* CONFIG_PROC_FS */ 1920#endif /* CONFIG_PROC_FS */
1924 1921
1925static int ide_floppy_probe(struct device *); 1922static int ide_floppy_probe(ide_drive_t *);
1926 1923
1927static ide_driver_t idefloppy_driver = { 1924static ide_driver_t idefloppy_driver = {
1928 .gen_driver = { 1925 .gen_driver = {
1929 .owner = THIS_MODULE, 1926 .owner = THIS_MODULE,
1930 .name = "ide-floppy", 1927 .name = "ide-floppy",
1931 .bus = &ide_bus_type, 1928 .bus = &ide_bus_type,
1932 .probe = ide_floppy_probe,
1933 .remove = ide_floppy_remove,
1934 }, 1929 },
1930 .probe = ide_floppy_probe,
1931 .remove = ide_floppy_remove,
1935 .version = IDEFLOPPY_VERSION, 1932 .version = IDEFLOPPY_VERSION,
1936 .media = ide_floppy, 1933 .media = ide_floppy,
1937 .supports_dsc_overlap = 0, 1934 .supports_dsc_overlap = 0,
@@ -2136,9 +2133,8 @@ static struct block_device_operations idefloppy_ops = {
2136 .revalidate_disk= idefloppy_revalidate_disk 2133 .revalidate_disk= idefloppy_revalidate_disk
2137}; 2134};
2138 2135
2139static int ide_floppy_probe(struct device *dev) 2136static int ide_floppy_probe(ide_drive_t *drive)
2140{ 2137{
2141 ide_drive_t *drive = to_ide_device(dev);
2142 idefloppy_floppy_t *floppy; 2138 idefloppy_floppy_t *floppy;
2143 struct gendisk *g; 2139 struct gendisk *g;
2144 2140
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index fab9b2b02504..0101d0def7c5 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4682,9 +4682,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
4682 idetape_add_settings(drive); 4682 idetape_add_settings(drive);
4683} 4683}
4684 4684
4685static int ide_tape_remove(struct device *dev) 4685static void ide_tape_remove(ide_drive_t *drive)
4686{ 4686{
4687 ide_drive_t *drive = to_ide_device(dev);
4688 idetape_tape_t *tape = drive->driver_data; 4687 idetape_tape_t *tape = drive->driver_data;
4689 4688
4690 ide_unregister_subdriver(drive, tape->driver); 4689 ide_unregister_subdriver(drive, tape->driver);
@@ -4692,8 +4691,6 @@ static int ide_tape_remove(struct device *dev)
4692 ide_unregister_region(tape->disk); 4691 ide_unregister_region(tape->disk);
4693 4692
4694 ide_tape_put(tape); 4693 ide_tape_put(tape);
4695
4696 return 0;
4697} 4694}
4698 4695
4699static void ide_tape_release(struct kref *kref) 4696static void ide_tape_release(struct kref *kref)
@@ -4745,16 +4742,16 @@ static ide_proc_entry_t idetape_proc[] = {
4745 4742
4746#endif 4743#endif
4747 4744
4748static int ide_tape_probe(struct device *); 4745static int ide_tape_probe(ide_drive_t *);
4749 4746
4750static ide_driver_t idetape_driver = { 4747static ide_driver_t idetape_driver = {
4751 .gen_driver = { 4748 .gen_driver = {
4752 .owner = THIS_MODULE, 4749 .owner = THIS_MODULE,
4753 .name = "ide-tape", 4750 .name = "ide-tape",
4754 .bus = &ide_bus_type, 4751 .bus = &ide_bus_type,
4755 .probe = ide_tape_probe,
4756 .remove = ide_tape_remove,
4757 }, 4752 },
4753 .probe = ide_tape_probe,
4754 .remove = ide_tape_remove,
4758 .version = IDETAPE_VERSION, 4755 .version = IDETAPE_VERSION,
4759 .media = ide_tape, 4756 .media = ide_tape,
4760 .supports_dsc_overlap = 1, 4757 .supports_dsc_overlap = 1,
@@ -4825,9 +4822,8 @@ static struct block_device_operations idetape_block_ops = {
4825 .ioctl = idetape_ioctl, 4822 .ioctl = idetape_ioctl,
4826}; 4823};
4827 4824
4828static int ide_tape_probe(struct device *dev) 4825static int ide_tape_probe(ide_drive_t *drive)
4829{ 4826{
4830 ide_drive_t *drive = to_ide_device(dev);
4831 idetape_tape_t *tape; 4827 idetape_tape_t *tape;
4832 struct gendisk *g; 4828 struct gendisk *g;
4833 int minor; 4829 int minor;
@@ -4883,9 +4879,9 @@ static int ide_tape_probe(struct device *dev)
4883 idetape_setup(drive, tape, minor); 4879 idetape_setup(drive, tape, minor);
4884 4880
4885 class_device_create(idetape_sysfs_class, NULL, 4881 class_device_create(idetape_sysfs_class, NULL,
4886 MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name); 4882 MKDEV(IDETAPE_MAJOR, minor), &drive->gendev, "%s", tape->name);
4887 class_device_create(idetape_sysfs_class, NULL, 4883 class_device_create(idetape_sysfs_class, NULL,
4888 MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name); 4884 MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name);
4889 4885
4890 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), 4886 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
4891 S_IFCHR | S_IRUGO | S_IWUGO, 4887 S_IFCHR | S_IRUGO | S_IWUGO,
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index ec5a4cb173b0..afeb02bbb722 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1949,10 +1949,41 @@ static int ide_uevent(struct device *dev, char **envp, int num_envp,
1949 return 0; 1949 return 0;
1950} 1950}
1951 1951
1952static int generic_ide_probe(struct device *dev)
1953{
1954 ide_drive_t *drive = to_ide_device(dev);
1955 ide_driver_t *drv = to_ide_driver(dev->driver);
1956
1957 return drv->probe ? drv->probe(drive) : -ENODEV;
1958}
1959
1960static int generic_ide_remove(struct device *dev)
1961{
1962 ide_drive_t *drive = to_ide_device(dev);
1963 ide_driver_t *drv = to_ide_driver(dev->driver);
1964
1965 if (drv->remove)
1966 drv->remove(drive);
1967
1968 return 0;
1969}
1970
1971static void generic_ide_shutdown(struct device *dev)
1972{
1973 ide_drive_t *drive = to_ide_device(dev);
1974 ide_driver_t *drv = to_ide_driver(dev->driver);
1975
1976 if (dev->driver && drv->shutdown)
1977 drv->shutdown(drive);
1978}
1979
1952struct bus_type ide_bus_type = { 1980struct bus_type ide_bus_type = {
1953 .name = "ide", 1981 .name = "ide",
1954 .match = ide_bus_match, 1982 .match = ide_bus_match,
1955 .uevent = ide_uevent, 1983 .uevent = ide_uevent,
1984 .probe = generic_ide_probe,
1985 .remove = generic_ide_remove,
1986 .shutdown = generic_ide_shutdown,
1956 .dev_attrs = ide_dev_attrs, 1987 .dev_attrs = ide_dev_attrs,
1957 .suspend = generic_ide_suspend, 1988 .suspend = generic_ide_suspend,
1958 .resume = generic_ide_resume, 1989 .resume = generic_ide_resume,
diff --git a/include/linux/ide.h b/include/linux/ide.h
index f2e1b5b22898..110b3cfac021 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -983,8 +983,13 @@ typedef struct ide_driver_s {
983 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); 983 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
984 ide_proc_entry_t *proc; 984 ide_proc_entry_t *proc;
985 struct device_driver gen_driver; 985 struct device_driver gen_driver;
986 int (*probe)(ide_drive_t *);
987 void (*remove)(ide_drive_t *);
988 void (*shutdown)(ide_drive_t *);
986} ide_driver_t; 989} ide_driver_t;
987 990
991#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
992
988int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 993int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
989 994
990/* 995/*