Commit 5751c8d6 authored by Mike Anderson's avatar Mike Anderson Committed by James Bottomley

[PATCH] scsi_host sysfs updates fix release behaviour

Fix scsi sysfs init so that a scsi_unregister can be called anytime after
a scsi_register.
- Create scsi_sysfs_init_host function and call from
scsi_register.

 drivers/scsi/hosts.c      |    4 ++--
 drivers/scsi/scsi_priv.h  |    1 +
 drivers/scsi/scsi_sysfs.c |   25 ++++++++++++++++---------
 3 files changed, 19 insertions(+), 11 deletions(-)
parent f1bfbf24
...@@ -405,8 +405,8 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template *shost_tp, int xtr_bytes) ...@@ -405,8 +405,8 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template *shost_tp, int xtr_bytes)
rval = scsi_setup_command_freelist(shost); rval = scsi_setup_command_freelist(shost);
if (rval) if (rval)
goto fail; goto fail;
device_initialize(&shost->host_gendev);
class_device_initialize(&shost->class_dev); scsi_sysfs_init_host(shost);
shost->eh_notify = &sem; shost->eh_notify = &sem;
kernel_thread((int (*)(void *)) scsi_error_handler, (void *) shost, 0); kernel_thread((int (*)(void *)) scsi_error_handler, (void *) shost, 0);
......
...@@ -123,6 +123,7 @@ extern int scsi_device_register(struct scsi_device *); ...@@ -123,6 +123,7 @@ extern int scsi_device_register(struct scsi_device *);
extern void scsi_device_unregister(struct scsi_device *); extern void scsi_device_unregister(struct scsi_device *);
extern int scsi_upper_driver_register(struct Scsi_Device_Template *); extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *); extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
extern void scsi_sysfs_init_host(struct Scsi_Host *);
extern int scsi_sysfs_add_host(struct Scsi_Host *, struct device *); extern int scsi_sysfs_add_host(struct Scsi_Host *, struct device *);
extern void scsi_sysfs_remove_host(struct Scsi_Host *); extern void scsi_sysfs_remove_host(struct Scsi_Host *);
extern int scsi_sysfs_register(void); extern int scsi_sysfs_register(void);
......
...@@ -321,6 +321,22 @@ static void scsi_host_release(struct device *dev) ...@@ -321,6 +321,22 @@ static void scsi_host_release(struct device *dev)
scsi_free_shost(shost); scsi_free_shost(shost);
} }
void scsi_sysfs_init_host(struct Scsi_Host *shost)
{
device_initialize(&shost->host_gendev);
snprintf(shost->host_gendev.bus_id, BUS_ID_SIZE, "host%d",
shost->host_no);
snprintf(shost->host_gendev.name, DEVICE_NAME_SIZE, "%s",
shost->hostt->proc_name);
shost->host_gendev.release = scsi_host_release;
class_device_initialize(&shost->class_dev);
shost->class_dev.dev = &shost->host_gendev;
shost->class_dev.class = &shost_class;
snprintf(shost->class_dev.class_id, BUS_ID_SIZE, "host%d",
shost->host_no);
}
/** /**
* scsi_sysfs_add_host - add scsi host to subsystem * scsi_sysfs_add_host - add scsi host to subsystem
* @shost: scsi host struct to add to subsystem * @shost: scsi host struct to add to subsystem
...@@ -330,22 +346,13 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -330,22 +346,13 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
{ {
int i, error; int i, error;
snprintf(shost->host_gendev.bus_id, BUS_ID_SIZE, "host%d",
shost->host_no);
snprintf(shost->host_gendev.name, DEVICE_NAME_SIZE, "%s",
shost->hostt->proc_name);
if (!shost->host_gendev.parent) if (!shost->host_gendev.parent)
shost->host_gendev.parent = (dev) ? dev : &legacy_bus; shost->host_gendev.parent = (dev) ? dev : &legacy_bus;
shost->host_gendev.release = scsi_host_release;
error = device_add(&shost->host_gendev); error = device_add(&shost->host_gendev);
if (error) if (error)
return error; return error;
shost->class_dev.dev = &shost->host_gendev;
shost->class_dev.class = &shost_class;
snprintf(shost->class_dev.class_id, BUS_ID_SIZE, "host%d",
shost->host_no);
error = class_device_add(&shost->class_dev); error = class_device_add(&shost->class_dev);
if (error) if (error)
goto clean_device; goto clean_device;
......
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