Commit 19e4ff96 authored by Mike Anderson's avatar Mike Anderson Committed by James Bottomley

[PATCH] scsi host sysfs support again [3/4]

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


DESC
Change scsi host to class device model. Change scsi host and scsi device
to release when ref count goes to zero.
EDESC


 drivers/scsi/hosts.c     |   23 +++++------------------
 drivers/scsi/hosts.h     |   20 ++++++++++++++------
 drivers/scsi/scsi_scan.c |    4 +---
 3 files changed, 20 insertions(+), 27 deletions(-)
parent 638e823f
......@@ -193,16 +193,6 @@ static int scsi_host_legacy_release(struct Scsi_Host *shost)
return 0;
}
static int scsi_remove_legacy_host(struct Scsi_Host *shost)
{
int error;
error = scsi_remove_host(shost);
if (!error)
(*shost->hostt->release)(shost);
return 0;
}
static int scsi_check_device_busy(struct scsi_device *sdev)
{
struct Scsi_Host *shost = sdev->host;
......@@ -268,11 +258,8 @@ int scsi_remove_host(struct Scsi_Host *shost)
list_for_each_entry(sdev, &shost->my_devices, siblings)
sdev->online = FALSE;
list_for_each_entry(sdev, &shost->my_devices, siblings)
if (scsi_check_device_busy(sdev))
return 1;
scsi_forget_host(shost);
scsi_sysfs_remove_host(shost);
return 0;
}
......@@ -293,9 +280,9 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
printk(KERN_INFO "scsi%d : %s\n", shost->host_no,
sht->info ? sht->info(shost) : sht->name);
if (dev) {
shost->host_gendev = dev;
}
error = scsi_sysfs_add_host(shost, dev);
if (error)
return error;
scsi_scan_host(shost);
......@@ -531,7 +518,7 @@ int scsi_register_host(Scsi_Host_Template *shost_tp)
**/
int scsi_unregister_host(Scsi_Host_Template *shost_tp)
{
scsi_tp_for_each_host(shost_tp, scsi_remove_legacy_host);
scsi_tp_for_each_host(shost_tp, scsi_remove_host);
return 0;
}
......
......@@ -482,9 +482,10 @@ struct Scsi_Host
unsigned int max_host_blocked;
/*
* Support for driverfs filesystem
* Support for sysfs
*/
struct device *host_gendev;
struct device host_gendev;
struct class_device class_dev;
/*
* We should ensure that this is aligned, both for better performance
......@@ -495,8 +496,11 @@ struct Scsi_Host
__attribute__ ((aligned (sizeof(unsigned long))));
};
#define to_scsi_host(d) d->driver_data /* Major logical breakage, but we compile again... */
#define dev_to_shost(d) \
container_of(d, struct Scsi_Host, host_gendev)
#define class_to_shost(d) \
container_of(d, struct Scsi_Host, class_dev)
/*
* These two functions are used to allocate and free a pseudo device
* which will connect to the host adapter itself rather than any
......@@ -519,12 +523,12 @@ static inline void scsi_assign_lock(struct Scsi_Host *shost, spinlock_t *lock)
static inline void scsi_set_device(struct Scsi_Host *shost,
struct device *dev)
{
shost->host_gendev = dev;
shost->host_gendev.parent = dev;
}
static inline struct device *scsi_get_device(struct Scsi_Host *shost)
{
return shost->host_gendev;
return shost->host_gendev.parent;
}
struct Scsi_Device_Template
......@@ -591,6 +595,10 @@ static inline Scsi_Device *scsi_find_device(struct Scsi_Host *shost,
*/
extern int scsi_upper_driver_register(struct Scsi_Device_Template *);
extern void scsi_upper_driver_unregister(struct Scsi_Device_Template *);
extern int scsi_sysfs_add_host(struct Scsi_Host *, struct device *);
extern void scsi_sysfs_remove_host(struct Scsi_Host *);
extern void scsi_free_sdev(struct scsi_device *);
extern struct class shost_class;
......
......@@ -480,7 +480,7 @@ static struct scsi_device *scsi_alloc_sdev(struct Scsi_Host *shost,
* Undo the actions in scsi_alloc_sdev, including removing @sdev from
* the list, and freeing @sdev.
**/
static void scsi_free_sdev(struct scsi_device *sdev)
void scsi_free_sdev(struct scsi_device *sdev)
{
unsigned long flags;
......@@ -1273,8 +1273,6 @@ int scsi_remove_device(struct scsi_device *sdev)
return -EINVAL;
scsi_device_unregister(sdev);
scsi_free_sdev(sdev);
return 0;
}
......
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