Commit 4031bbe4 authored by Russell King's avatar Russell King Committed by Greg Kroah-Hartman

[PATCH] Add ide_bus_type probe and remove methods

Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent bbbe3a41
...@@ -3256,9 +3256,8 @@ sector_t ide_cdrom_capacity (ide_drive_t *drive) ...@@ -3256,9 +3256,8 @@ sector_t ide_cdrom_capacity (ide_drive_t *drive)
} }
#endif #endif
static int ide_cd_remove(struct device *dev) static void ide_cd_remove(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
struct cdrom_info *info = drive->driver_data; struct cdrom_info *info = drive->driver_data;
ide_unregister_subdriver(drive, info->driver); ide_unregister_subdriver(drive, info->driver);
...@@ -3266,8 +3265,6 @@ static int ide_cd_remove(struct device *dev) ...@@ -3266,8 +3265,6 @@ static int ide_cd_remove(struct device *dev)
del_gendisk(info->disk); del_gendisk(info->disk);
ide_cd_put(info); ide_cd_put(info);
return 0;
} }
static void ide_cd_release(struct kref *kref) static void ide_cd_release(struct kref *kref)
...@@ -3291,7 +3288,7 @@ static void ide_cd_release(struct kref *kref) ...@@ -3291,7 +3288,7 @@ static void ide_cd_release(struct kref *kref)
kfree(info); kfree(info);
} }
static int ide_cd_probe(struct device *); static int ide_cd_probe(ide_drive_t *);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int proc_idecd_read_capacity static int proc_idecd_read_capacity
...@@ -3317,9 +3314,9 @@ static ide_driver_t ide_cdrom_driver = { ...@@ -3317,9 +3314,9 @@ static ide_driver_t ide_cdrom_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ide-cdrom", .name = "ide-cdrom",
.bus = &ide_bus_type, .bus = &ide_bus_type,
},
.probe = ide_cd_probe, .probe = ide_cd_probe,
.remove = ide_cd_remove, .remove = ide_cd_remove,
},
.version = IDECD_VERSION, .version = IDECD_VERSION,
.media = ide_cdrom, .media = ide_cdrom,
.supports_dsc_overlap = 1, .supports_dsc_overlap = 1,
...@@ -3413,9 +3410,8 @@ static char *ignore = NULL; ...@@ -3413,9 +3410,8 @@ static char *ignore = NULL;
module_param(ignore, charp, 0400); module_param(ignore, charp, 0400);
MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
static int ide_cd_probe(struct device *dev) static int ide_cd_probe(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
struct cdrom_info *info; struct cdrom_info *info;
struct gendisk *g; struct gendisk *g;
struct request_sense sense; struct request_sense sense;
......
...@@ -997,9 +997,8 @@ static void ide_cacheflush_p(ide_drive_t *drive) ...@@ -997,9 +997,8 @@ static void ide_cacheflush_p(ide_drive_t *drive)
printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
} }
static int ide_disk_remove(struct device *dev) static void ide_disk_remove(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
struct ide_disk_obj *idkp = drive->driver_data; struct ide_disk_obj *idkp = drive->driver_data;
struct gendisk *g = idkp->disk; struct gendisk *g = idkp->disk;
...@@ -1010,8 +1009,6 @@ static int ide_disk_remove(struct device *dev) ...@@ -1010,8 +1009,6 @@ static int ide_disk_remove(struct device *dev)
ide_cacheflush_p(drive); ide_cacheflush_p(drive);
ide_disk_put(idkp); ide_disk_put(idkp);
return 0;
} }
static void ide_disk_release(struct kref *kref) static void ide_disk_release(struct kref *kref)
...@@ -1027,12 +1024,10 @@ static void ide_disk_release(struct kref *kref) ...@@ -1027,12 +1024,10 @@ static void ide_disk_release(struct kref *kref)
kfree(idkp); kfree(idkp);
} }
static int ide_disk_probe(struct device *dev); static int ide_disk_probe(ide_drive_t *drive);
static void ide_device_shutdown(struct device *dev) static void ide_device_shutdown(ide_drive_t *drive)
{ {
ide_drive_t *drive = container_of(dev, ide_drive_t, gendev);
#ifdef CONFIG_ALPHA #ifdef CONFIG_ALPHA
/* On Alpha, halt(8) doesn't actually turn the machine off, /* On Alpha, halt(8) doesn't actually turn the machine off,
it puts you into the sort of firmware monitor. Typically, it puts you into the sort of firmware monitor. Typically,
...@@ -1054,7 +1049,7 @@ static void ide_device_shutdown(struct device *dev) ...@@ -1054,7 +1049,7 @@ static void ide_device_shutdown(struct device *dev)
} }
printk("Shutdown: %s\n", drive->name); printk("Shutdown: %s\n", drive->name);
dev->bus->suspend(dev, PMSG_SUSPEND); drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
} }
static ide_driver_t idedisk_driver = { static ide_driver_t idedisk_driver = {
...@@ -1062,10 +1057,10 @@ static ide_driver_t idedisk_driver = { ...@@ -1062,10 +1057,10 @@ static ide_driver_t idedisk_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ide-disk", .name = "ide-disk",
.bus = &ide_bus_type, .bus = &ide_bus_type,
},
.probe = ide_disk_probe, .probe = ide_disk_probe,
.remove = ide_disk_remove, .remove = ide_disk_remove,
.shutdown = ide_device_shutdown, .shutdown = ide_device_shutdown,
},
.version = IDEDISK_VERSION, .version = IDEDISK_VERSION,
.media = ide_disk, .media = ide_disk,
.supports_dsc_overlap = 0, .supports_dsc_overlap = 0,
...@@ -1182,9 +1177,8 @@ static struct block_device_operations idedisk_ops = { ...@@ -1182,9 +1177,8 @@ static struct block_device_operations idedisk_ops = {
MODULE_DESCRIPTION("ATA DISK Driver"); MODULE_DESCRIPTION("ATA DISK Driver");
static int ide_disk_probe(struct device *dev) static int ide_disk_probe(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
struct ide_disk_obj *idkp; struct ide_disk_obj *idkp;
struct gendisk *g; struct gendisk *g;
......
...@@ -1871,9 +1871,8 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) ...@@ -1871,9 +1871,8 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy)
idefloppy_add_settings(drive); idefloppy_add_settings(drive);
} }
static int ide_floppy_remove(struct device *dev) static void ide_floppy_remove(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
struct gendisk *g = floppy->disk; struct gendisk *g = floppy->disk;
...@@ -1882,8 +1881,6 @@ static int ide_floppy_remove(struct device *dev) ...@@ -1882,8 +1881,6 @@ static int ide_floppy_remove(struct device *dev)
del_gendisk(g); del_gendisk(g);
ide_floppy_put(floppy); ide_floppy_put(floppy);
return 0;
} }
static void ide_floppy_release(struct kref *kref) static void ide_floppy_release(struct kref *kref)
...@@ -1922,16 +1919,16 @@ static ide_proc_entry_t idefloppy_proc[] = { ...@@ -1922,16 +1919,16 @@ static ide_proc_entry_t idefloppy_proc[] = {
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
static int ide_floppy_probe(struct device *); static int ide_floppy_probe(ide_drive_t *);
static ide_driver_t idefloppy_driver = { static ide_driver_t idefloppy_driver = {
.gen_driver = { .gen_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ide-floppy", .name = "ide-floppy",
.bus = &ide_bus_type, .bus = &ide_bus_type,
},
.probe = ide_floppy_probe, .probe = ide_floppy_probe,
.remove = ide_floppy_remove, .remove = ide_floppy_remove,
},
.version = IDEFLOPPY_VERSION, .version = IDEFLOPPY_VERSION,
.media = ide_floppy, .media = ide_floppy,
.supports_dsc_overlap = 0, .supports_dsc_overlap = 0,
...@@ -2136,9 +2133,8 @@ static struct block_device_operations idefloppy_ops = { ...@@ -2136,9 +2133,8 @@ static struct block_device_operations idefloppy_ops = {
.revalidate_disk= idefloppy_revalidate_disk .revalidate_disk= idefloppy_revalidate_disk
}; };
static int ide_floppy_probe(struct device *dev) static int ide_floppy_probe(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
idefloppy_floppy_t *floppy; idefloppy_floppy_t *floppy;
struct gendisk *g; struct gendisk *g;
......
...@@ -4682,9 +4682,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) ...@@ -4682,9 +4682,8 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor)
idetape_add_settings(drive); idetape_add_settings(drive);
} }
static int ide_tape_remove(struct device *dev) static void ide_tape_remove(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
idetape_tape_t *tape = drive->driver_data; idetape_tape_t *tape = drive->driver_data;
ide_unregister_subdriver(drive, tape->driver); ide_unregister_subdriver(drive, tape->driver);
...@@ -4692,8 +4691,6 @@ static int ide_tape_remove(struct device *dev) ...@@ -4692,8 +4691,6 @@ static int ide_tape_remove(struct device *dev)
ide_unregister_region(tape->disk); ide_unregister_region(tape->disk);
ide_tape_put(tape); ide_tape_put(tape);
return 0;
} }
static void ide_tape_release(struct kref *kref) static void ide_tape_release(struct kref *kref)
...@@ -4745,16 +4742,16 @@ static ide_proc_entry_t idetape_proc[] = { ...@@ -4745,16 +4742,16 @@ static ide_proc_entry_t idetape_proc[] = {
#endif #endif
static int ide_tape_probe(struct device *); static int ide_tape_probe(ide_drive_t *);
static ide_driver_t idetape_driver = { static ide_driver_t idetape_driver = {
.gen_driver = { .gen_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ide-tape", .name = "ide-tape",
.bus = &ide_bus_type, .bus = &ide_bus_type,
},
.probe = ide_tape_probe, .probe = ide_tape_probe,
.remove = ide_tape_remove, .remove = ide_tape_remove,
},
.version = IDETAPE_VERSION, .version = IDETAPE_VERSION,
.media = ide_tape, .media = ide_tape,
.supports_dsc_overlap = 1, .supports_dsc_overlap = 1,
...@@ -4825,9 +4822,8 @@ static struct block_device_operations idetape_block_ops = { ...@@ -4825,9 +4822,8 @@ static struct block_device_operations idetape_block_ops = {
.ioctl = idetape_ioctl, .ioctl = idetape_ioctl,
}; };
static int ide_tape_probe(struct device *dev) static int ide_tape_probe(ide_drive_t *drive)
{ {
ide_drive_t *drive = to_ide_device(dev);
idetape_tape_t *tape; idetape_tape_t *tape;
struct gendisk *g; struct gendisk *g;
int minor; int minor;
...@@ -4883,9 +4879,9 @@ static int ide_tape_probe(struct device *dev) ...@@ -4883,9 +4879,9 @@ static int ide_tape_probe(struct device *dev)
idetape_setup(drive, tape, minor); idetape_setup(drive, tape, minor);
class_device_create(idetape_sysfs_class, NULL, class_device_create(idetape_sysfs_class, NULL,
MKDEV(IDETAPE_MAJOR, minor), dev, "%s", tape->name); MKDEV(IDETAPE_MAJOR, minor), &drive->gendev, "%s", tape->name);
class_device_create(idetape_sysfs_class, NULL, class_device_create(idetape_sysfs_class, NULL,
MKDEV(IDETAPE_MAJOR, minor + 128), dev, "n%s", tape->name); MKDEV(IDETAPE_MAJOR, minor + 128), &drive->gendev, "n%s", tape->name);
devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor), devfs_mk_cdev(MKDEV(HWIF(drive)->major, minor),
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
......
...@@ -1949,10 +1949,41 @@ static int ide_uevent(struct device *dev, char **envp, int num_envp, ...@@ -1949,10 +1949,41 @@ static int ide_uevent(struct device *dev, char **envp, int num_envp,
return 0; return 0;
} }
static int generic_ide_probe(struct device *dev)
{
ide_drive_t *drive = to_ide_device(dev);
ide_driver_t *drv = to_ide_driver(dev->driver);
return drv->probe ? drv->probe(drive) : -ENODEV;
}
static int generic_ide_remove(struct device *dev)
{
ide_drive_t *drive = to_ide_device(dev);
ide_driver_t *drv = to_ide_driver(dev->driver);
if (drv->remove)
drv->remove(drive);
return 0;
}
static void generic_ide_shutdown(struct device *dev)
{
ide_drive_t *drive = to_ide_device(dev);
ide_driver_t *drv = to_ide_driver(dev->driver);
if (dev->driver && drv->shutdown)
drv->shutdown(drive);
}
struct bus_type ide_bus_type = { struct bus_type ide_bus_type = {
.name = "ide", .name = "ide",
.match = ide_bus_match, .match = ide_bus_match,
.uevent = ide_uevent, .uevent = ide_uevent,
.probe = generic_ide_probe,
.remove = generic_ide_remove,
.shutdown = generic_ide_shutdown,
.dev_attrs = ide_dev_attrs, .dev_attrs = ide_dev_attrs,
.suspend = generic_ide_suspend, .suspend = generic_ide_suspend,
.resume = generic_ide_resume, .resume = generic_ide_resume,
......
...@@ -983,8 +983,13 @@ typedef struct ide_driver_s { ...@@ -983,8 +983,13 @@ typedef struct ide_driver_s {
ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
ide_proc_entry_t *proc; ide_proc_entry_t *proc;
struct device_driver gen_driver; struct device_driver gen_driver;
int (*probe)(ide_drive_t *);
void (*remove)(ide_drive_t *);
void (*shutdown)(ide_drive_t *);
} ide_driver_t; } ide_driver_t;
#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment