Commit d69e478f authored by Mike Anderson's avatar Mike Anderson Committed by James Bottomley

[PATCH] scsi_host sysfs updates scsi-misc-2.5 [2/2]

Here is an update of the patch with the externs in scsi_priv.h

-andmike
--
Michael Anderson
andmike@us.ibm.com

DESC
scsi shost sysfs cleanups for scsi-misc-2.5
- Add LLDD short name to scsi_host struct device.
- scsi_host_release now calls scsi_free_shost.
- Switched from device_register / device_unregister and class_register
/ class_register to initialize, add, del, put pairs.
- Moved some function from scsi_register and scsi_unregister.
- Filled in scsi_host_put and scsi_host_get.

Rev 2 move externs to scsi_priv.h
EDESC


 drivers/scsi/hosts.c      |   33 ++++++++++++++++++++++++++++-----
 drivers/scsi/scsi_priv.h  |    2 ++
 drivers/scsi/scsi_sysfs.c |   19 +++++++++++--------
 3 files changed, 41 insertions(+), 13 deletions(-)
parent f16c875a
...@@ -212,6 +212,7 @@ int scsi_remove_host(struct Scsi_Host *shost) ...@@ -212,6 +212,7 @@ int scsi_remove_host(struct Scsi_Host *shost)
list_for_each_entry(sdev, &shost->my_devices, siblings) list_for_each_entry(sdev, &shost->my_devices, siblings)
sdev->online = FALSE; sdev->online = FALSE;
scsi_proc_host_rm(shost);
scsi_forget_host(shost); scsi_forget_host(shost);
scsi_sysfs_remove_host(shost); scsi_sysfs_remove_host(shost);
return 0; return 0;
...@@ -238,6 +239,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -238,6 +239,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
if (error) if (error)
return error; return error;
scsi_proc_host_add(shost);
scsi_scan_host(shost); scsi_scan_host(shost);
list_for_each_entry (sdev, &shost->my_devices, siblings) { list_for_each_entry (sdev, &shost->my_devices, siblings) {
...@@ -254,6 +257,15 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -254,6 +257,15 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
* @shost: scsi host to be unregistered * @shost: scsi host to be unregistered
**/ **/
void scsi_unregister(struct Scsi_Host *shost) void scsi_unregister(struct Scsi_Host *shost)
{
scsi_host_put(shost);
}
/**
* scsi_free_sdev - free a scsi hosts resources
* @shost: scsi host to free
**/
void scsi_free_shost(struct Scsi_Host *shost)
{ {
/* Remove shost from scsi_host_list */ /* Remove shost from scsi_host_list */
spin_lock(&scsi_host_list_lock); spin_lock(&scsi_host_list_lock);
...@@ -273,7 +285,6 @@ void scsi_unregister(struct Scsi_Host *shost) ...@@ -273,7 +285,6 @@ void scsi_unregister(struct Scsi_Host *shost)
} }
shost->hostt->present--; shost->hostt->present--;
scsi_proc_host_rm(shost);
scsi_destroy_command_freelist(shost); scsi_destroy_command_freelist(shost);
kfree(shost); kfree(shost);
} }
...@@ -394,7 +405,8 @@ struct Scsi_Host * scsi_register(Scsi_Host_Template *shost_tp, int xtr_bytes) ...@@ -394,7 +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;
scsi_proc_host_add(shost); device_initialize(&shost->host_gendev);
class_device_initialize(&shost->class_dev);
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);
...@@ -522,6 +534,18 @@ struct Scsi_Host *scsi_host_hn_get(unsigned short host_no) ...@@ -522,6 +534,18 @@ struct Scsi_Host *scsi_host_hn_get(unsigned short host_no)
return scsi_find_host_by_num(host_no); return scsi_find_host_by_num(host_no);
} }
/**
* *scsi_host_get - inc a Scsi_Host ref count
* @shost: Pointer to Scsi_Host to inc.
**/
void scsi_host_get(struct Scsi_Host *shost)
{
get_device(&shost->host_gendev);
class_device_get(&shost->class_dev);
return;
}
/** /**
* *scsi_host_put - dec a Scsi_Host ref count * *scsi_host_put - dec a Scsi_Host ref count
* @shost: Pointer to Scsi_Host to dec. * @shost: Pointer to Scsi_Host to dec.
...@@ -529,9 +553,8 @@ struct Scsi_Host *scsi_host_hn_get(unsigned short host_no) ...@@ -529,9 +553,8 @@ struct Scsi_Host *scsi_host_hn_get(unsigned short host_no)
void scsi_host_put(struct Scsi_Host *shost) void scsi_host_put(struct Scsi_Host *shost)
{ {
/* XXX Get list lock */ put_device(&shost->host_gendev);
/* XXX dec ref count */ class_device_put(&shost->class_dev);
/* XXX Release list lock */
return; return;
} }
......
...@@ -109,6 +109,8 @@ extern void scsi_exit_procfs(void); ...@@ -109,6 +109,8 @@ extern void scsi_exit_procfs(void);
extern void scsi_scan_host(struct Scsi_Host *shost); extern void scsi_scan_host(struct Scsi_Host *shost);
extern void scsi_forget_host(struct Scsi_Host *shost); extern void scsi_forget_host(struct Scsi_Host *shost);
extern void scsi_free_sdev(struct scsi_device *); extern void scsi_free_sdev(struct scsi_device *);
extern void scsi_free_shost(struct Scsi_Host *);
extern void scsi_host_get(struct Scsi_Host *);
/* scsi_sysfs.c */ /* scsi_sysfs.c */
extern int scsi_device_register(struct scsi_device *); extern int scsi_device_register(struct scsi_device *);
......
...@@ -317,7 +317,8 @@ static void scsi_host_release(struct device *dev) ...@@ -317,7 +317,8 @@ static void scsi_host_release(struct device *dev)
shost = dev_to_shost(dev); shost = dev_to_shost(dev);
if (!shost) if (!shost)
return; return;
shost->hostt->release(shost);
scsi_free_shost(shost);
} }
/** /**
...@@ -329,13 +330,15 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -329,13 +330,15 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
{ {
int i, error; int i, error;
sprintf(shost->host_gendev.bus_id,"host%d", snprintf(shost->host_gendev.bus_id, BUS_ID_SIZE, "host%d",
shost->host_no); 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; shost->host_gendev.release = scsi_host_release;
error = device_register(&shost->host_gendev); error = device_add(&shost->host_gendev);
if (error) if (error)
return error; return error;
...@@ -343,7 +346,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -343,7 +346,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
shost->class_dev.class = &shost_class; shost->class_dev.class = &shost_class;
snprintf(shost->class_dev.class_id, BUS_ID_SIZE, "host%d", snprintf(shost->class_dev.class_id, BUS_ID_SIZE, "host%d",
shost->host_no); shost->host_no);
error = class_device_register(&shost->class_dev); error = class_device_add(&shost->class_dev);
if (error) if (error)
goto clean_device; goto clean_device;
...@@ -356,9 +359,9 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -356,9 +359,9 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
return error; return error;
clean_class: clean_class:
class_device_unregister(&shost->class_dev); class_device_del(&shost->class_dev);
clean_device: clean_device:
device_unregister(&shost->host_gendev); device_del(&shost->host_gendev);
return error; return error;
} }
...@@ -369,7 +372,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev) ...@@ -369,7 +372,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost, struct device *dev)
**/ **/
void scsi_sysfs_remove_host(struct Scsi_Host *shost) void scsi_sysfs_remove_host(struct Scsi_Host *shost)
{ {
class_device_unregister(&shost->class_dev); class_device_del(&shost->class_dev);
device_unregister(&shost->host_gendev); device_del(&shost->host_gendev);
} }
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