[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>

authored by Russell King and committed by Greg Kroah-Hartman 4031bbe4 bbbe3a41

+61 -43
+5 -9
drivers/ide/ide-cd.c
··· 3256 } 3257 #endif 3258 3259 - static int ide_cd_remove(struct device *dev) 3260 { 3261 - ide_drive_t *drive = to_ide_device(dev); 3262 struct cdrom_info *info = drive->driver_data; 3263 3264 ide_unregister_subdriver(drive, info->driver); ··· 3265 del_gendisk(info->disk); 3266 3267 ide_cd_put(info); 3268 - 3269 - return 0; 3270 } 3271 3272 static void ide_cd_release(struct kref *kref) ··· 3288 kfree(info); 3289 } 3290 3291 - static int ide_cd_probe(struct device *); 3292 3293 #ifdef CONFIG_PROC_FS 3294 static int proc_idecd_read_capacity ··· 3314 .owner = THIS_MODULE, 3315 .name = "ide-cdrom", 3316 .bus = &ide_bus_type, 3317 - .probe = ide_cd_probe, 3318 - .remove = ide_cd_remove, 3319 }, 3320 .version = IDECD_VERSION, 3321 .media = ide_cdrom, 3322 .supports_dsc_overlap = 1, ··· 3410 module_param(ignore, charp, 0400); 3411 MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 3412 3413 - static int ide_cd_probe(struct device *dev) 3414 { 3415 - ide_drive_t *drive = to_ide_device(dev); 3416 struct cdrom_info *info; 3417 struct gendisk *g; 3418 struct request_sense sense;
··· 3256 } 3257 #endif 3258 3259 + static void ide_cd_remove(ide_drive_t *drive) 3260 { 3261 struct cdrom_info *info = drive->driver_data; 3262 3263 ide_unregister_subdriver(drive, info->driver); ··· 3266 del_gendisk(info->disk); 3267 3268 ide_cd_put(info); 3269 } 3270 3271 static void ide_cd_release(struct kref *kref) ··· 3291 kfree(info); 3292 } 3293 3294 + static int ide_cd_probe(ide_drive_t *); 3295 3296 #ifdef CONFIG_PROC_FS 3297 static int proc_idecd_read_capacity ··· 3317 .owner = THIS_MODULE, 3318 .name = "ide-cdrom", 3319 .bus = &ide_bus_type, 3320 }, 3321 + .probe = ide_cd_probe, 3322 + .remove = ide_cd_remove, 3323 .version = IDECD_VERSION, 3324 .media = ide_cdrom, 3325 .supports_dsc_overlap = 1, ··· 3413 module_param(ignore, charp, 0400); 3414 MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 3415 3416 + static int ide_cd_probe(ide_drive_t *drive) 3417 { 3418 struct cdrom_info *info; 3419 struct gendisk *g; 3420 struct request_sense sense;
+8 -14
drivers/ide/ide-disk.c
··· 997 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 998 } 999 1000 - static int ide_disk_remove(struct device *dev) 1001 { 1002 - ide_drive_t *drive = to_ide_device(dev); 1003 struct ide_disk_obj *idkp = drive->driver_data; 1004 struct gendisk *g = idkp->disk; 1005 ··· 1009 ide_cacheflush_p(drive); 1010 1011 ide_disk_put(idkp); 1012 - 1013 - return 0; 1014 } 1015 1016 static void ide_disk_release(struct kref *kref) ··· 1024 kfree(idkp); 1025 } 1026 1027 - static int ide_disk_probe(struct device *dev); 1028 1029 - static void ide_device_shutdown(struct device *dev) 1030 { 1031 - ide_drive_t *drive = container_of(dev, ide_drive_t, gendev); 1032 - 1033 #ifdef CONFIG_ALPHA 1034 /* On Alpha, halt(8) doesn't actually turn the machine off, 1035 it puts you into the sort of firmware monitor. Typically, ··· 1049 } 1050 1051 printk("Shutdown: %s\n", drive->name); 1052 - dev->bus->suspend(dev, PMSG_SUSPEND); 1053 } 1054 1055 static ide_driver_t idedisk_driver = { ··· 1057 .owner = THIS_MODULE, 1058 .name = "ide-disk", 1059 .bus = &ide_bus_type, 1060 - .probe = ide_disk_probe, 1061 - .remove = ide_disk_remove, 1062 - .shutdown = ide_device_shutdown, 1063 }, 1064 .version = IDEDISK_VERSION, 1065 .media = ide_disk, 1066 .supports_dsc_overlap = 0, ··· 1177 1178 MODULE_DESCRIPTION("ATA DISK Driver"); 1179 1180 - static int ide_disk_probe(struct device *dev) 1181 { 1182 - ide_drive_t *drive = to_ide_device(dev); 1183 struct ide_disk_obj *idkp; 1184 struct gendisk *g; 1185
··· 997 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 998 } 999 1000 + static void ide_disk_remove(ide_drive_t *drive) 1001 { 1002 struct ide_disk_obj *idkp = drive->driver_data; 1003 struct gendisk *g = idkp->disk; 1004 ··· 1010 ide_cacheflush_p(drive); 1011 1012 ide_disk_put(idkp); 1013 } 1014 1015 static void ide_disk_release(struct kref *kref) ··· 1027 kfree(idkp); 1028 } 1029 1030 + static int ide_disk_probe(ide_drive_t *drive); 1031 1032 + static void ide_device_shutdown(ide_drive_t *drive) 1033 { 1034 #ifdef CONFIG_ALPHA 1035 /* On Alpha, halt(8) doesn't actually turn the machine off, 1036 it puts you into the sort of firmware monitor. Typically, ··· 1054 } 1055 1056 printk("Shutdown: %s\n", drive->name); 1057 + drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND); 1058 } 1059 1060 static ide_driver_t idedisk_driver = { ··· 1062 .owner = THIS_MODULE, 1063 .name = "ide-disk", 1064 .bus = &ide_bus_type, 1065 }, 1066 + .probe = ide_disk_probe, 1067 + .remove = ide_disk_remove, 1068 + .shutdown = ide_device_shutdown, 1069 .version = IDEDISK_VERSION, 1070 .media = ide_disk, 1071 .supports_dsc_overlap = 0, ··· 1182 1183 MODULE_DESCRIPTION("ATA DISK Driver"); 1184 1185 + static int ide_disk_probe(ide_drive_t *drive) 1186 { 1187 struct ide_disk_obj *idkp; 1188 struct gendisk *g; 1189
+5 -9
drivers/ide/ide-floppy.c
··· 1871 idefloppy_add_settings(drive); 1872 } 1873 1874 - static int ide_floppy_remove(struct device *dev) 1875 { 1876 - ide_drive_t *drive = to_ide_device(dev); 1877 idefloppy_floppy_t *floppy = drive->driver_data; 1878 struct gendisk *g = floppy->disk; 1879 ··· 1881 del_gendisk(g); 1882 1883 ide_floppy_put(floppy); 1884 - 1885 - return 0; 1886 } 1887 1888 static void ide_floppy_release(struct kref *kref) ··· 1919 1920 #endif /* CONFIG_PROC_FS */ 1921 1922 - static int ide_floppy_probe(struct device *); 1923 1924 static ide_driver_t idefloppy_driver = { 1925 .gen_driver = { 1926 .owner = THIS_MODULE, 1927 .name = "ide-floppy", 1928 .bus = &ide_bus_type, 1929 - .probe = ide_floppy_probe, 1930 - .remove = ide_floppy_remove, 1931 }, 1932 .version = IDEFLOPPY_VERSION, 1933 .media = ide_floppy, 1934 .supports_dsc_overlap = 0, ··· 2133 .revalidate_disk= idefloppy_revalidate_disk 2134 }; 2135 2136 - static int ide_floppy_probe(struct device *dev) 2137 { 2138 - ide_drive_t *drive = to_ide_device(dev); 2139 idefloppy_floppy_t *floppy; 2140 struct gendisk *g; 2141
··· 1871 idefloppy_add_settings(drive); 1872 } 1873 1874 + static void ide_floppy_remove(ide_drive_t *drive) 1875 { 1876 idefloppy_floppy_t *floppy = drive->driver_data; 1877 struct gendisk *g = floppy->disk; 1878 ··· 1882 del_gendisk(g); 1883 1884 ide_floppy_put(floppy); 1885 } 1886 1887 static void ide_floppy_release(struct kref *kref) ··· 1922 1923 #endif /* CONFIG_PROC_FS */ 1924 1925 + static int ide_floppy_probe(ide_drive_t *); 1926 1927 static ide_driver_t idefloppy_driver = { 1928 .gen_driver = { 1929 .owner = THIS_MODULE, 1930 .name = "ide-floppy", 1931 .bus = &ide_bus_type, 1932 }, 1933 + .probe = ide_floppy_probe, 1934 + .remove = ide_floppy_remove, 1935 .version = IDEFLOPPY_VERSION, 1936 .media = ide_floppy, 1937 .supports_dsc_overlap = 0, ··· 2136 .revalidate_disk= idefloppy_revalidate_disk 2137 }; 2138 2139 + static int ide_floppy_probe(ide_drive_t *drive) 2140 { 2141 idefloppy_floppy_t *floppy; 2142 struct gendisk *g; 2143
+7 -11
drivers/ide/ide-tape.c
··· 4682 idetape_add_settings(drive); 4683 } 4684 4685 - static int ide_tape_remove(struct device *dev) 4686 { 4687 - ide_drive_t *drive = to_ide_device(dev); 4688 idetape_tape_t *tape = drive->driver_data; 4689 4690 ide_unregister_subdriver(drive, tape->driver); ··· 4691 ide_unregister_region(tape->disk); 4692 4693 ide_tape_put(tape); 4694 - 4695 - return 0; 4696 } 4697 4698 static void ide_tape_release(struct kref *kref) ··· 4742 4743 #endif 4744 4745 - static int ide_tape_probe(struct device *); 4746 4747 static ide_driver_t idetape_driver = { 4748 .gen_driver = { 4749 .owner = THIS_MODULE, 4750 .name = "ide-tape", 4751 .bus = &ide_bus_type, 4752 - .probe = ide_tape_probe, 4753 - .remove = ide_tape_remove, 4754 }, 4755 .version = IDETAPE_VERSION, 4756 .media = ide_tape, 4757 .supports_dsc_overlap = 1, ··· 4822 .ioctl = idetape_ioctl, 4823 }; 4824 4825 - static int ide_tape_probe(struct device *dev) 4826 { 4827 - ide_drive_t *drive = to_ide_device(dev); 4828 idetape_tape_t *tape; 4829 struct gendisk *g; 4830 int minor; ··· 4879 idetape_setup(drive, tape, minor); 4880 4881 class_device_create(idetape_sysfs_class, NULL, 4882 - MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name); 4883 class_device_create(idetape_sysfs_class, NULL, 4884 - MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name); 4885 4886 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), 4887 S_IFCHR | S_IRUGO | S_IWUGO,
··· 4682 idetape_add_settings(drive); 4683 } 4684 4685 + static void ide_tape_remove(ide_drive_t *drive) 4686 { 4687 idetape_tape_t *tape = drive->driver_data; 4688 4689 ide_unregister_subdriver(drive, tape->driver); ··· 4692 ide_unregister_region(tape->disk); 4693 4694 ide_tape_put(tape); 4695 } 4696 4697 static void ide_tape_release(struct kref *kref) ··· 4745 4746 #endif 4747 4748 + static int ide_tape_probe(ide_drive_t *); 4749 4750 static ide_driver_t idetape_driver = { 4751 .gen_driver = { 4752 .owner = THIS_MODULE, 4753 .name = "ide-tape", 4754 .bus = &ide_bus_type, 4755 }, 4756 + .probe = ide_tape_probe, 4757 + .remove = ide_tape_remove, 4758 .version = IDETAPE_VERSION, 4759 .media = ide_tape, 4760 .supports_dsc_overlap = 1, ··· 4825 .ioctl = idetape_ioctl, 4826 }; 4827 4828 + static int ide_tape_probe(ide_drive_t *drive) 4829 { 4830 idetape_tape_t *tape; 4831 struct gendisk *g; 4832 int minor; ··· 4883 idetape_setup(drive, tape, minor); 4884 4885 class_device_create(idetape_sysfs_class, NULL, 4886 + MKDEV(IDETAPE_MAJOR, minor), &drive->gendev, "%s", tape->name); 4887 class_device_create(idetape_sysfs_class, NULL, 4888 + MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name); 4889 4890 devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), 4891 S_IFCHR | S_IRUGO | S_IWUGO,
+31
drivers/ide/ide.c
··· 1949 return 0; 1950 } 1951 1952 struct bus_type ide_bus_type = { 1953 .name = "ide", 1954 .match = ide_bus_match, 1955 .uevent = ide_uevent, 1956 .dev_attrs = ide_dev_attrs, 1957 .suspend = generic_ide_suspend, 1958 .resume = generic_ide_resume,
··· 1949 return 0; 1950 } 1951 1952 + static 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 + 1960 + static 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 + 1971 + static 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 + 1980 struct bus_type ide_bus_type = { 1981 .name = "ide", 1982 .match = ide_bus_match, 1983 .uevent = ide_uevent, 1984 + .probe = generic_ide_probe, 1985 + .remove = generic_ide_remove, 1986 + .shutdown = generic_ide_shutdown, 1987 .dev_attrs = ide_dev_attrs, 1988 .suspend = generic_ide_suspend, 1989 .resume = generic_ide_resume,
+5
include/linux/ide.h
··· 983 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); 984 ide_proc_entry_t *proc; 985 struct device_driver gen_driver; 986 } ide_driver_t; 987 988 int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 989
··· 983 ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); 984 ide_proc_entry_t *proc; 985 struct device_driver gen_driver; 986 + int (*probe)(ide_drive_t *); 987 + void (*remove)(ide_drive_t *); 988 + void (*shutdown)(ide_drive_t *); 989 } ide_driver_t; 990 + 991 + #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 992 993 int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 994