提交 ee959b00 编写于 作者: T Tony Jones 提交者: Greg Kroah-Hartman

SCSI: convert struct class_device to struct device

It's big, but there doesn't seem to be a way to split it up smaller...
Signed-off-by: NTony Jones <tonyj@suse.de>
Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 56d110e8
无相关合并请求
......@@ -758,7 +758,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
mutex_lock(&bsg_mutex);
hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode)));
strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1);
strncpy(bd->name, rq->bsg_dev.class_dev->bus_id, sizeof(bd->name) - 1);
dprintk("bound to <%s>, max queue %d\n",
format_dev_t(buf, inode->i_rdev), bd->max_queue);
......@@ -946,7 +946,7 @@ void bsg_unregister_queue(struct request_queue *q)
mutex_lock(&bsg_mutex);
idr_remove(&bsg_minor_idr, bcd->minor);
sysfs_remove_link(&q->kobj, "bsg");
class_device_unregister(bcd->class_dev);
device_unregister(bcd->class_dev);
put_device(bcd->dev);
bcd->class_dev = NULL;
mutex_unlock(&bsg_mutex);
......@@ -959,7 +959,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
struct bsg_class_device *bcd;
dev_t dev;
int ret, minor;
struct class_device *class_dev = NULL;
struct device *class_dev = NULL;
const char *devname;
if (name)
......@@ -998,8 +998,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
bcd->queue = q;
bcd->dev = get_device(gdev);
dev = MKDEV(bsg_major, bcd->minor);
class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s",
devname);
class_dev = device_create(bsg_class, gdev, dev, "%s", devname);
if (IS_ERR(class_dev)) {
ret = PTR_ERR(class_dev);
goto put_dev;
......@@ -1016,7 +1015,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
return 0;
unregister_class_dev:
class_device_unregister(class_dev);
device_unregister(class_dev);
put_dev:
put_device(gdev);
remove_idr:
......
......@@ -273,8 +273,8 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
static int ahci_pci_device_resume(struct pci_dev *pdev);
#endif
static struct class_device_attribute *ahci_shost_attrs[] = {
&class_device_attr_link_power_management_policy,
static struct device_attribute *ahci_shost_attrs[] = {
&dev_attr_link_power_management_policy,
NULL
};
......
......@@ -131,10 +131,11 @@ static const char *ata_scsi_lpm_get(enum link_pm policy)
return NULL;
}
static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
const char *buf, size_t count)
static ssize_t ata_scsi_lpm_put(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ata_port *ap = ata_shost_to_port(shost);
enum link_pm policy = 0;
int i;
......@@ -162,9 +163,9 @@ static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
}
static ssize_t
ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
ata_scsi_lpm_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ata_port *ap = ata_shost_to_port(shost);
const char *policy =
ata_scsi_lpm_get(ap->pm_policy);
......@@ -174,9 +175,9 @@ ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
return snprintf(buf, 23, "%s\n", policy);
}
CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
ata_scsi_lpm_show, ata_scsi_lpm_put);
EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy);
EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
void (*done)(struct scsi_cmnd *))
......
......@@ -27,21 +27,21 @@
struct internal_container {
struct klist_node node;
struct attribute_container *cont;
struct class_device classdev;
struct device classdev;
};
static void internal_container_klist_get(struct klist_node *n)
{
struct internal_container *ic =
container_of(n, struct internal_container, node);
class_device_get(&ic->classdev);
get_device(&ic->classdev);
}
static void internal_container_klist_put(struct klist_node *n)
{
struct internal_container *ic =
container_of(n, struct internal_container, node);
class_device_put(&ic->classdev);
put_device(&ic->classdev);
}
......@@ -53,7 +53,7 @@ static void internal_container_klist_put(struct klist_node *n)
* Returns the container associated with this classdev.
*/
struct attribute_container *
attribute_container_classdev_to_container(struct class_device *classdev)
attribute_container_classdev_to_container(struct device *classdev)
{
struct internal_container *ic =
container_of(classdev, struct internal_container, classdev);
......@@ -110,11 +110,11 @@ attribute_container_unregister(struct attribute_container *cont)
EXPORT_SYMBOL_GPL(attribute_container_unregister);
/* private function used as class release */
static void attribute_container_release(struct class_device *classdev)
static void attribute_container_release(struct device *classdev)
{
struct internal_container *ic
= container_of(classdev, struct internal_container, classdev);
struct device *dev = classdev->dev;
struct device *dev = classdev->parent;
kfree(ic);
put_device(dev);
......@@ -129,12 +129,12 @@ static void attribute_container_release(struct class_device *classdev)
* This function allocates storage for the class device(s) to be
* attached to dev (one for each matching attribute_container). If no
* fn is provided, the code will simply register the class device via
* class_device_add. If a function is provided, it is expected to add
* device_add. If a function is provided, it is expected to add
* the class device at the appropriate time. One of the things that
* might be necessary is to allocate and initialise the classdev and
* then add it a later time. To do this, call this routine for
* allocation and initialisation and then use
* attribute_container_device_trigger() to call class_device_add() on
* attribute_container_device_trigger() to call device_add() on
* it. Note: after this, the class device contains a reference to dev
* which is not relinquished until the release of the classdev.
*/
......@@ -142,7 +142,7 @@ void
attribute_container_add_device(struct device *dev,
int (*fn)(struct attribute_container *,
struct device *,
struct class_device *))
struct device *))
{
struct attribute_container *cont;
......@@ -163,11 +163,11 @@ attribute_container_add_device(struct device *dev,
}
ic->cont = cont;
class_device_initialize(&ic->classdev);
ic->classdev.dev = get_device(dev);
device_initialize(&ic->classdev);
ic->classdev.parent = get_device(dev);
ic->classdev.class = cont->class;
cont->class->release = attribute_container_release;
strcpy(ic->classdev.class_id, dev->bus_id);
cont->class->dev_release = attribute_container_release;
strcpy(ic->classdev.bus_id, dev->bus_id);
if (fn)
fn(cont, dev, &ic->classdev);
else
......@@ -195,20 +195,19 @@ attribute_container_add_device(struct device *dev,
* @fn: A function to call to remove the device
*
* This routine triggers device removal. If fn is NULL, then it is
* simply done via class_device_unregister (note that if something
* simply done via device_unregister (note that if something
* still has a reference to the classdev, then the memory occupied
* will not be freed until the classdev is released). If you want a
* two phase release: remove from visibility and then delete the
* device, then you should use this routine with a fn that calls
* class_device_del() and then use
* attribute_container_device_trigger() to do the final put on the
* classdev.
* device_del() and then use attribute_container_device_trigger()
* to do the final put on the classdev.
*/
void
attribute_container_remove_device(struct device *dev,
void (*fn)(struct attribute_container *,
struct device *,
struct class_device *))
struct device *))
{
struct attribute_container *cont;
......@@ -224,14 +223,14 @@ attribute_container_remove_device(struct device *dev,
continue;
klist_for_each_entry(ic, &cont->containers, node, &iter) {
if (dev != ic->classdev.dev)
if (dev != ic->classdev.parent)
continue;
klist_del(&ic->node);
if (fn)
fn(cont, dev, &ic->classdev);
else {
attribute_container_remove_attrs(&ic->classdev);
class_device_unregister(&ic->classdev);
device_unregister(&ic->classdev);
}
}
}
......@@ -252,7 +251,7 @@ void
attribute_container_device_trigger(struct device *dev,
int (*fn)(struct attribute_container *,
struct device *,
struct class_device *))
struct device *))
{
struct attribute_container *cont;
......@@ -270,7 +269,7 @@ attribute_container_device_trigger(struct device *dev,
}
klist_for_each_entry(ic, &cont->containers, node, &iter) {
if (dev == ic->classdev.dev)
if (dev == ic->classdev.parent)
fn(cont, dev, &ic->classdev);
}
}
......@@ -313,11 +312,11 @@ attribute_container_trigger(struct device *dev,
* attributes listed in the container
*/
int
attribute_container_add_attrs(struct class_device *classdev)
attribute_container_add_attrs(struct device *classdev)
{
struct attribute_container *cont =
attribute_container_classdev_to_container(classdev);
struct class_device_attribute **attrs = cont->attrs;
struct device_attribute **attrs = cont->attrs;
int i, error;
BUG_ON(attrs && cont->grp);
......@@ -329,7 +328,7 @@ attribute_container_add_attrs(struct class_device *classdev)
return sysfs_create_group(&classdev->kobj, cont->grp);
for (i = 0; attrs[i]; i++) {
error = class_device_create_file(classdev, attrs[i]);
error = device_create_file(classdev, attrs[i]);
if (error)
return error;
}
......@@ -338,18 +337,18 @@ attribute_container_add_attrs(struct class_device *classdev)
}
/**
* attribute_container_add_class_device - same function as class_device_add
* attribute_container_add_class_device - same function as device_add
*
* @classdev: the class device to add
*
* This performs essentially the same function as class_device_add except for
* This performs essentially the same function as device_add except for
* attribute containers, namely add the classdev to the system and then
* create the attribute files
*/
int
attribute_container_add_class_device(struct class_device *classdev)
attribute_container_add_class_device(struct device *classdev)
{
int error = class_device_add(classdev);
int error = device_add(classdev);
if (error)
return error;
return attribute_container_add_attrs(classdev);
......@@ -364,7 +363,7 @@ attribute_container_add_class_device(struct class_device *classdev)
int
attribute_container_add_class_device_adapter(struct attribute_container *cont,
struct device *dev,
struct class_device *classdev)
struct device *classdev)
{
return attribute_container_add_class_device(classdev);
}
......@@ -376,11 +375,11 @@ attribute_container_add_class_device_adapter(struct attribute_container *cont,
*
*/
void
attribute_container_remove_attrs(struct class_device *classdev)
attribute_container_remove_attrs(struct device *classdev)
{
struct attribute_container *cont =
attribute_container_classdev_to_container(classdev);
struct class_device_attribute **attrs = cont->attrs;
struct device_attribute **attrs = cont->attrs;
int i;
if (!attrs && !cont->grp)
......@@ -392,7 +391,7 @@ attribute_container_remove_attrs(struct class_device *classdev)
}
for (i = 0; attrs[i]; i++)
class_device_remove_file(classdev, attrs[i]);
device_remove_file(classdev, attrs[i]);
}
/**
......@@ -401,13 +400,13 @@ attribute_container_remove_attrs(struct class_device *classdev)
* @classdev: the class device
*
* This function simply removes all the attribute files and then calls
* class_device_del.
* device_del.
*/
void
attribute_container_class_device_del(struct class_device *classdev)
attribute_container_class_device_del(struct device *classdev)
{
attribute_container_remove_attrs(classdev);
class_device_del(classdev);
device_del(classdev);
}
/**
......@@ -419,16 +418,16 @@ attribute_container_class_device_del(struct class_device *classdev)
* Looks up the device in the container's list of class devices and returns
* the corresponding class_device.
*/
struct class_device *
struct device *
attribute_container_find_class_device(struct attribute_container *cont,
struct device *dev)
{
struct class_device *cdev = NULL;
struct device *cdev = NULL;
struct internal_container *ic;
struct klist_iter iter;
klist_for_each_entry(ic, &cont->containers, node, &iter) {
if (ic->classdev.dev == dev) {
if (ic->classdev.parent == dev) {
cdev = &ic->classdev;
/* FIXME: must exit iterator then break */
klist_iter_exit(&iter);
......
......@@ -66,7 +66,7 @@ EXPORT_SYMBOL_GPL(transport_class_unregister);
static int anon_transport_dummy_function(struct transport_container *tc,
struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
/* do nothing */
return 0;
......@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(anon_transport_class_unregister);
static int transport_setup_classdev(struct attribute_container *cont,
struct device *dev,
struct class_device *classdev)
struct device *classdev)
{
struct transport_class *tclass = class_to_transport_class(cont->class);
struct transport_container *tcont = attribute_container_to_transport_container(cont);
......@@ -149,7 +149,7 @@ EXPORT_SYMBOL_GPL(transport_setup_device);
static int transport_add_class_device(struct attribute_container *cont,
struct device *dev,
struct class_device *classdev)
struct device *classdev)
{
int error = attribute_container_add_class_device(classdev);
struct transport_container *tcont =
......@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(transport_add_device);
static int transport_configure(struct attribute_container *cont,
struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
struct transport_class *tclass = class_to_transport_class(cont->class);
struct transport_container *tcont = attribute_container_to_transport_container(cont);
......@@ -212,7 +212,7 @@ EXPORT_SYMBOL_GPL(transport_configure_device);
static int transport_remove_classdev(struct attribute_container *cont,
struct device *dev,
struct class_device *classdev)
struct device *classdev)
{
struct transport_container *tcont =
attribute_container_to_transport_container(cont);
......@@ -251,12 +251,12 @@ EXPORT_SYMBOL_GPL(transport_remove_device);
static void transport_destroy_classdev(struct attribute_container *cont,
struct device *dev,
struct class_device *classdev)
struct device *classdev)
{
struct transport_class *tclass = class_to_transport_class(cont->class);
if (tclass->remove != anon_transport_dummy_function)
class_device_put(classdev);
put_device(classdev);
}
......
......@@ -1458,9 +1458,10 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
return ret;
}
static ssize_t show_id_ext(struct class_device *cdev, char *buf)
static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1470,9 +1471,10 @@ static ssize_t show_id_ext(struct class_device *cdev, char *buf)
(unsigned long long) be64_to_cpu(target->id_ext));
}
static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1482,9 +1484,10 @@ static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
(unsigned long long) be64_to_cpu(target->ioc_guid));
}
static ssize_t show_service_id(struct class_device *cdev, char *buf)
static ssize_t show_service_id(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1494,9 +1497,10 @@ static ssize_t show_service_id(struct class_device *cdev, char *buf)
(unsigned long long) be64_to_cpu(target->service_id));
}
static ssize_t show_pkey(struct class_device *cdev, char *buf)
static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1505,9 +1509,10 @@ static ssize_t show_pkey(struct class_device *cdev, char *buf)
return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
}
static ssize_t show_dgid(struct class_device *cdev, char *buf)
static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1524,9 +1529,10 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf)
be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
}
static ssize_t show_orig_dgid(struct class_device *cdev, char *buf)
static ssize_t show_orig_dgid(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1543,9 +1549,10 @@ static ssize_t show_orig_dgid(struct class_device *cdev, char *buf)
be16_to_cpu(target->orig_dgid[7]));
}
static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
static ssize_t show_zero_req_lim(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
if (target->state == SRP_TARGET_DEAD ||
target->state == SRP_TARGET_REMOVED)
......@@ -1554,40 +1561,42 @@ static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
return sprintf(buf, "%d\n", target->zero_req_lim);
}
static ssize_t show_local_ib_port(struct class_device *cdev, char *buf)
static ssize_t show_local_ib_port(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
return sprintf(buf, "%d\n", target->srp_host->port);
}
static ssize_t show_local_ib_device(struct class_device *cdev, char *buf)
static ssize_t show_local_ib_device(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct srp_target_port *target = host_to_target(class_to_shost(cdev));
struct srp_target_port *target = host_to_target(class_to_shost(dev));
return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name);
}
static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
static struct class_device_attribute *srp_host_attrs[] = {
&class_device_attr_id_ext,
&class_device_attr_ioc_guid,
&class_device_attr_service_id,
&class_device_attr_pkey,
&class_device_attr_dgid,
&class_device_attr_orig_dgid,
&class_device_attr_zero_req_lim,
&class_device_attr_local_ib_port,
&class_device_attr_local_ib_device,
static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
static struct device_attribute *srp_host_attrs[] = {
&dev_attr_id_ext,
&dev_attr_ioc_guid,
&dev_attr_service_id,
&dev_attr_pkey,
&dev_attr_dgid,
&dev_attr_orig_dgid,
&dev_attr_zero_req_lim,
&dev_attr_local_ib_port,
&dev_attr_local_ib_device,
NULL
};
......@@ -1639,17 +1648,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
return 0;
}
static void srp_release_class_dev(struct class_device *class_dev)
static void srp_release_dev(struct device *dev)
{
struct srp_host *host =
container_of(class_dev, struct srp_host, class_dev);
container_of(dev, struct srp_host, dev);
complete(&host->released);
}
static struct class srp_class = {
.name = "infiniband_srp",
.release = srp_release_class_dev
.dev_release = srp_release_dev
};
/*
......@@ -1837,11 +1846,12 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target)
return ret;
}
static ssize_t srp_create_target(struct class_device *class_dev,
static ssize_t srp_create_target(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct srp_host *host =
container_of(class_dev, struct srp_host, class_dev);
container_of(dev, struct srp_host, dev);
struct Scsi_Host *target_host;
struct srp_target_port *target;
int ret;
......@@ -1929,27 +1939,27 @@ static ssize_t srp_create_target(struct class_device *class_dev,
return ret;
}
static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target);
static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target);
static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_host *host =
container_of(class_dev, struct srp_host, class_dev);
struct srp_host *host = container_of(dev, struct srp_host, dev);
return sprintf(buf, "%s\n", host->srp_dev->dev->name);
}
static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
static ssize_t show_port(struct class_device *class_dev, char *buf)
static ssize_t show_port(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_host *host =
container_of(class_dev, struct srp_host, class_dev);
struct srp_host *host = container_of(dev, struct srp_host, dev);
return sprintf(buf, "%d\n", host->port);
}
static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
{
......@@ -1965,24 +1975,24 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
host->srp_dev = device;
host->port = port;
host->class_dev.class = &srp_class;
host->class_dev.dev = device->dev->dma_device;
snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d",
host->dev.class = &srp_class;
host->dev.parent = device->dev->dma_device;
snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d",
device->dev->name, port);
if (class_device_register(&host->class_dev))
if (device_register(&host->dev))
goto free_host;
if (class_device_create_file(&host->class_dev, &class_device_attr_add_target))
if (device_create_file(&host->dev, &dev_attr_add_target))
goto err_class;
if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev))
if (device_create_file(&host->dev, &dev_attr_ibdev))
goto err_class;
if (class_device_create_file(&host->class_dev, &class_device_attr_port))
if (device_create_file(&host->dev, &dev_attr_port))
goto err_class;
return host;
err_class:
class_device_unregister(&host->class_dev);
device_unregister(&host->dev);
free_host:
kfree(host);
......@@ -2087,7 +2097,7 @@ static void srp_remove_one(struct ib_device *device)
srp_dev = ib_get_client_data(device, &srp_client);
list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
class_device_unregister(&host->class_dev);
device_unregister(&host->dev);
/*
* Wait for the sysfs entry to go away, so that no new
* target ports can be created.
......
......@@ -99,7 +99,7 @@ struct srp_device {
struct srp_host {
struct srp_device *srp_dev;
u8 port;
struct class_device class_dev;
struct device dev;
struct list_head target_list;
spinlock_t target_lock;
struct completion released;
......
......@@ -3300,9 +3300,10 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
}
static ssize_t
mptscsih_version_fw_show(struct class_device *cdev, char *buf)
mptscsih_version_fw_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
......@@ -3312,12 +3313,13 @@ mptscsih_version_fw_show(struct class_device *cdev, char *buf)
(ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
ioc->facts.FWVersion.Word & 0x000000FF);
}
static CLASS_DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL);
static DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL);
static ssize_t
mptscsih_version_bios_show(struct class_device *cdev, char *buf)
mptscsih_version_bios_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
......@@ -3327,129 +3329,141 @@ mptscsih_version_bios_show(struct class_device *cdev, char *buf)
(ioc->biosVersion & 0x0000FF00) >> 8,
ioc->biosVersion & 0x000000FF);
}
static CLASS_DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL);
static DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL);
static ssize_t
mptscsih_version_mpi_show(struct class_device *cdev, char *buf)
mptscsih_version_mpi_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion);
}
static CLASS_DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL);
static DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL);
static ssize_t
mptscsih_version_product_show(struct class_device *cdev, char *buf)
mptscsih_version_product_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name);
}
static CLASS_DEVICE_ATTR(version_product, S_IRUGO,
static DEVICE_ATTR(version_product, S_IRUGO,
mptscsih_version_product_show, NULL);
static ssize_t
mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf)
mptscsih_version_nvdata_persistent_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02xh\n",
ioc->nvdata_version_persistent);
}
static CLASS_DEVICE_ATTR(version_nvdata_persistent, S_IRUGO,
static DEVICE_ATTR(version_nvdata_persistent, S_IRUGO,
mptscsih_version_nvdata_persistent_show, NULL);
static ssize_t
mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf)
mptscsih_version_nvdata_default_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default);
}
static CLASS_DEVICE_ATTR(version_nvdata_default, S_IRUGO,
static DEVICE_ATTR(version_nvdata_default, S_IRUGO,
mptscsih_version_nvdata_default_show, NULL);
static ssize_t
mptscsih_board_name_show(struct class_device *cdev, char *buf)
mptscsih_board_name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name);
}
static CLASS_DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL);
static DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL);
static ssize_t
mptscsih_board_assembly_show(struct class_device *cdev, char *buf)
mptscsih_board_assembly_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly);
}
static CLASS_DEVICE_ATTR(board_assembly, S_IRUGO,
static DEVICE_ATTR(board_assembly, S_IRUGO,
mptscsih_board_assembly_show, NULL);
static ssize_t
mptscsih_board_tracer_show(struct class_device *cdev, char *buf)
mptscsih_board_tracer_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer);
}
static CLASS_DEVICE_ATTR(board_tracer, S_IRUGO,
static DEVICE_ATTR(board_tracer, S_IRUGO,
mptscsih_board_tracer_show, NULL);
static ssize_t
mptscsih_io_delay_show(struct class_device *cdev, char *buf)
mptscsih_io_delay_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
}
static CLASS_DEVICE_ATTR(io_delay, S_IRUGO,
static DEVICE_ATTR(io_delay, S_IRUGO,
mptscsih_io_delay_show, NULL);
static ssize_t
mptscsih_device_delay_show(struct class_device *cdev, char *buf)
mptscsih_device_delay_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
}
static CLASS_DEVICE_ATTR(device_delay, S_IRUGO,
static DEVICE_ATTR(device_delay, S_IRUGO,
mptscsih_device_delay_show, NULL);
static ssize_t
mptscsih_debug_level_show(struct class_device *cdev, char *buf)
mptscsih_debug_level_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
return snprintf(buf, PAGE_SIZE, "%08xh\n", ioc->debug_level);
}
static ssize_t
mptscsih_debug_level_store(struct class_device *cdev, const char *buf,
size_t count)
mptscsih_debug_level_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *host = class_to_shost(cdev);
struct Scsi_Host *host = class_to_shost(dev);
MPT_SCSI_HOST *hd = shost_priv(host);
MPT_ADAPTER *ioc = hd->ioc;
int val = 0;
......@@ -3462,22 +3476,22 @@ mptscsih_debug_level_store(struct class_device *cdev, const char *buf,
ioc->name, ioc->debug_level);
return strlen(buf);
}
static CLASS_DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
mptscsih_debug_level_show, mptscsih_debug_level_store);
struct class_device_attribute *mptscsih_host_attrs[] = {
&class_device_attr_version_fw,
&class_device_attr_version_bios,
&class_device_attr_version_mpi,
&class_device_attr_version_product,
&class_device_attr_version_nvdata_persistent,
&class_device_attr_version_nvdata_default,
&class_device_attr_board_name,
&class_device_attr_board_assembly,
&class_device_attr_board_tracer,
&class_device_attr_io_delay,
&class_device_attr_device_delay,
&class_device_attr_debug_level,
static DEVICE_ATTR(debug_level, S_IRUGO | S_IWUSR,
mptscsih_debug_level_show, mptscsih_debug_level_store);
struct device_attribute *mptscsih_host_attrs[] = {
&dev_attr_version_fw,
&dev_attr_version_bios,
&dev_attr_version_mpi,
&dev_attr_version_product,
&dev_attr_version_nvdata_persistent,
&dev_attr_version_nvdata_default,
&dev_attr_board_name,
&dev_attr_board_assembly,
&dev_attr_board_tracer,
&dev_attr_io_delay,
&dev_attr_device_delay,
&dev_attr_debug_level,
NULL,
};
EXPORT_SYMBOL(mptscsih_host_attrs);
......
......@@ -129,4 +129,4 @@ extern void mptscsih_timer_expired(unsigned long data);
extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id);
extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id);
extern struct class_device_attribute *mptscsih_host_attrs[];
extern struct device_attribute *mptscsih_host_attrs[];
......@@ -40,16 +40,16 @@ static struct class enclosure_component_class;
* Looks through the list of registered enclosures to see
* if it can find a match for a device. Returns NULL if no
* enclosure is found. Obtains a reference to the enclosure class
* device which must be released with class_device_put().
* device which must be released with device_put().
*/
struct enclosure_device *enclosure_find(struct device *dev)
{
struct enclosure_device *edev = NULL;
struct enclosure_device *edev;
mutex_lock(&container_list_lock);
list_for_each_entry(edev, &container_list, node) {
if (edev->cdev.dev == dev) {
class_device_get(&edev->cdev);
if (edev->edev.parent == dev) {
get_device(&edev->edev);
mutex_unlock(&container_list_lock);
return edev;
}
......@@ -117,11 +117,11 @@ enclosure_register(struct device *dev, const char *name, int components,
edev->components = components;
edev->cdev.class = &enclosure_class;
edev->cdev.dev = get_device(dev);
edev->edev.class = &enclosure_class;
edev->edev.parent = get_device(dev);
edev->cb = cb;
snprintf(edev->cdev.class_id, BUS_ID_SIZE, "%s", name);
err = class_device_register(&edev->cdev);
snprintf(edev->edev.bus_id, BUS_ID_SIZE, "%s", name);
err = device_register(&edev->edev);
if (err)
goto err;
......@@ -135,7 +135,7 @@ enclosure_register(struct device *dev, const char *name, int components,
return edev;
err:
put_device(edev->cdev.dev);
put_device(edev->edev.parent);
kfree(edev);
return ERR_PTR(err);
}
......@@ -158,27 +158,28 @@ void enclosure_unregister(struct enclosure_device *edev)
for (i = 0; i < edev->components; i++)
if (edev->component[i].number != -1)
class_device_unregister(&edev->component[i].cdev);
device_unregister(&edev->component[i].cdev);
/* prevent any callbacks into service user */
edev->cb = &enclosure_null_callbacks;
class_device_unregister(&edev->cdev);
device_unregister(&edev->edev);
}
EXPORT_SYMBOL_GPL(enclosure_unregister);
static void enclosure_release(struct class_device *cdev)
static void enclosure_release(struct device *cdev)
{
struct enclosure_device *edev = to_enclosure_device(cdev);
put_device(cdev->dev);
put_device(cdev->parent);
kfree(edev);
}
static void enclosure_component_release(struct class_device *cdev)
static void enclosure_component_release(struct device *dev)
{
if (cdev->dev)
put_device(cdev->dev);
class_device_put(cdev->parent);
struct enclosure_component *cdev = to_enclosure_component(dev);
put_device(cdev->dev);
put_device(dev->parent);
}
/**
......@@ -201,7 +202,7 @@ enclosure_component_register(struct enclosure_device *edev,
const char *name)
{
struct enclosure_component *ecomp;
struct class_device *cdev;
struct device *cdev;
int err;
if (number >= edev->components)
......@@ -215,14 +216,14 @@ enclosure_component_register(struct enclosure_device *edev,
ecomp->type = type;
ecomp->number = number;
cdev = &ecomp->cdev;
cdev->parent = class_device_get(&edev->cdev);
cdev->parent = get_device(&edev->edev);
cdev->class = &enclosure_component_class;
if (name)
snprintf(cdev->class_id, BUS_ID_SIZE, "%s", name);
snprintf(cdev->bus_id, BUS_ID_SIZE, "%s", name);
else
snprintf(cdev->class_id, BUS_ID_SIZE, "%u", number);
snprintf(cdev->bus_id, BUS_ID_SIZE, "%u", number);
err = class_device_register(cdev);
err = device_register(cdev);
if (err)
ERR_PTR(err);
......@@ -247,18 +248,17 @@ EXPORT_SYMBOL_GPL(enclosure_component_register);
int enclosure_add_device(struct enclosure_device *edev, int component,
struct device *dev)
{
struct class_device *cdev;
struct enclosure_component *cdev;
if (!edev || component >= edev->components)
return -EINVAL;
cdev = &edev->component[component].cdev;
cdev = &edev->component[component];
class_device_del(cdev);
if (cdev->dev)
put_device(cdev->dev);
device_del(&cdev->cdev);
put_device(cdev->dev);
cdev->dev = get_device(dev);
return class_device_add(cdev);
return device_add(&cdev->cdev);
}
EXPORT_SYMBOL_GPL(enclosure_add_device);
......@@ -272,18 +272,17 @@ EXPORT_SYMBOL_GPL(enclosure_add_device);
*/
int enclosure_remove_device(struct enclosure_device *edev, int component)
{
struct class_device *cdev;
struct enclosure_component *cdev;
if (!edev || component >= edev->components)
return -EINVAL;
cdev = &edev->component[component].cdev;
cdev = &edev->component[component];
class_device_del(cdev);
if (cdev->dev)
put_device(cdev->dev);
device_del(&cdev->cdev);
put_device(cdev->dev);
cdev->dev = NULL;
return class_device_add(cdev);
return device_add(&cdev->cdev);
}
EXPORT_SYMBOL_GPL(enclosure_remove_device);
......@@ -291,14 +290,16 @@ EXPORT_SYMBOL_GPL(enclosure_remove_device);
* sysfs pieces below
*/
static ssize_t enclosure_show_components(struct class_device *cdev, char *buf)
static ssize_t enclosure_show_components(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
struct enclosure_device *edev = to_enclosure_device(cdev);
return snprintf(buf, 40, "%d\n", edev->components);
}
static struct class_device_attribute enclosure_attrs[] = {
static struct device_attribute enclosure_attrs[] = {
__ATTR(components, S_IRUGO, enclosure_show_components, NULL),
__ATTR_NULL
};
......@@ -306,8 +307,8 @@ static struct class_device_attribute enclosure_attrs[] = {
static struct class enclosure_class = {
.name = "enclosure",
.owner = THIS_MODULE,
.release = enclosure_release,
.class_dev_attrs = enclosure_attrs,
.dev_release = enclosure_release,
.dev_attrs = enclosure_attrs,
};
static const char *const enclosure_status [] = {
......@@ -326,7 +327,8 @@ static const char *const enclosure_type [] = {
[ENCLOSURE_COMPONENT_ARRAY_DEVICE] = "array device",
};
static ssize_t get_component_fault(struct class_device *cdev, char *buf)
static ssize_t get_component_fault(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -336,8 +338,9 @@ static ssize_t get_component_fault(struct class_device *cdev, char *buf)
return snprintf(buf, 40, "%d\n", ecomp->fault);
}
static ssize_t set_component_fault(struct class_device *cdev, const char *buf,
size_t count)
static ssize_t set_component_fault(struct device *cdev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -348,7 +351,8 @@ static ssize_t set_component_fault(struct class_device *cdev, const char *buf,
return count;
}
static ssize_t get_component_status(struct class_device *cdev, char *buf)
static ssize_t get_component_status(struct device *cdev,
struct device_attribute *attr,char *buf)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -358,8 +362,9 @@ static ssize_t get_component_status(struct class_device *cdev, char *buf)
return snprintf(buf, 40, "%s\n", enclosure_status[ecomp->status]);
}
static ssize_t set_component_status(struct class_device *cdev, const char *buf,
size_t count)
static ssize_t set_component_status(struct device *cdev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -380,7 +385,8 @@ static ssize_t set_component_status(struct class_device *cdev, const char *buf,
return -EINVAL;
}
static ssize_t get_component_active(struct class_device *cdev, char *buf)
static ssize_t get_component_active(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -390,8 +396,9 @@ static ssize_t get_component_active(struct class_device *cdev, char *buf)
return snprintf(buf, 40, "%d\n", ecomp->active);
}
static ssize_t set_component_active(struct class_device *cdev, const char *buf,
size_t count)
static ssize_t set_component_active(struct device *cdev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -402,7 +409,8 @@ static ssize_t set_component_active(struct class_device *cdev, const char *buf,
return count;
}
static ssize_t get_component_locate(struct class_device *cdev, char *buf)
static ssize_t get_component_locate(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -412,8 +420,9 @@ static ssize_t get_component_locate(struct class_device *cdev, char *buf)
return snprintf(buf, 40, "%d\n", ecomp->locate);
}
static ssize_t set_component_locate(struct class_device *cdev, const char *buf,
size_t count)
static ssize_t set_component_locate(struct device *cdev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct enclosure_device *edev = to_enclosure_device(cdev->parent);
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -424,7 +433,8 @@ static ssize_t set_component_locate(struct class_device *cdev, const char *buf,
return count;
}
static ssize_t get_component_type(struct class_device *cdev, char *buf)
static ssize_t get_component_type(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct enclosure_component *ecomp = to_enclosure_component(cdev);
......@@ -432,7 +442,7 @@ static ssize_t get_component_type(struct class_device *cdev, char *buf)
}
static struct class_device_attribute enclosure_component_attrs[] = {
static struct device_attribute enclosure_component_attrs[] = {
__ATTR(fault, S_IRUGO | S_IWUSR, get_component_fault,
set_component_fault),
__ATTR(status, S_IRUGO | S_IWUSR, get_component_status,
......@@ -448,8 +458,8 @@ static struct class_device_attribute enclosure_component_attrs[] = {
static struct class enclosure_component_class = {
.name = "enclosure_component",
.owner = THIS_MODULE,
.class_dev_attrs = enclosure_component_attrs,
.release = enclosure_component_release,
.dev_attrs = enclosure_component_attrs,
.dev_release = enclosure_component_release,
};
static int __init enclosure_init(void)
......
......@@ -140,9 +140,10 @@ static void twa_unmap_scsi_data(TW_Device_Extension *tw_dev, int request_id);
/* Functions */
/* Show some statistics about the card */
static ssize_t twa_show_stats(struct class_device *class_dev, char *buf)
static ssize_t twa_show_stats(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(class_dev);
struct Scsi_Host *host = class_to_shost(dev);
TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
unsigned long flags = 0;
ssize_t len;
......@@ -184,7 +185,7 @@ static int twa_change_queue_depth(struct scsi_device *sdev, int queue_depth)
} /* End twa_change_queue_depth() */
/* Create sysfs 'stats' entry */
static struct class_device_attribute twa_host_stats_attr = {
static struct device_attribute twa_host_stats_attr = {
.attr = {
.name = "stats",
.mode = S_IRUGO,
......@@ -193,7 +194,7 @@ static struct class_device_attribute twa_host_stats_attr = {
};
/* Host attributes initializer */
static struct class_device_attribute *twa_host_attrs[] = {
static struct device_attribute *twa_host_attrs[] = {
&twa_host_stats_attr,
NULL,
};
......
......@@ -484,9 +484,10 @@ static void tw_state_request_start(TW_Device_Extension *tw_dev, int *request_id)
} /* End tw_state_request_start() */
/* Show some statistics about the card */
static ssize_t tw_show_stats(struct class_device *class_dev, char *buf)
static ssize_t tw_show_stats(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(class_dev);
struct Scsi_Host *host = class_to_shost(dev);
TW_Device_Extension *tw_dev = (TW_Device_Extension *)host->hostdata;
unsigned long flags = 0;
ssize_t len;
......@@ -528,7 +529,7 @@ static int tw_change_queue_depth(struct scsi_device *sdev, int queue_depth)
} /* End tw_change_queue_depth() */
/* Create sysfs 'stats' entry */
static struct class_device_attribute tw_host_stats_attr = {
static struct device_attribute tw_host_stats_attr = {
.attr = {
.name = "stats",
.mode = S_IRUGO,
......@@ -537,7 +538,7 @@ static struct class_device_attribute tw_host_stats_attr = {
};
/* Host attributes initializer */
static struct class_device_attribute *tw_host_attrs[] = {
static struct device_attribute *tw_host_attrs[] = {
&tw_host_stats_attr,
NULL,
};
......
......@@ -1316,7 +1316,7 @@ int aac_get_adapter_info(struct aac_dev* dev)
tmp>>24,(tmp>>16)&0xff,tmp&0xff,
le32_to_cpu(dev->adapter_info.biosbuild));
buffer[0] = '\0';
if (aac_show_serial_number(
if (aac_get_serial_number(
shost_to_class(dev->scsi_host_ptr), buffer))
printk(KERN_INFO "%s%d: serial %s",
dev->name, dev->id, buffer);
......
......@@ -1850,9 +1850,9 @@ int aac_get_containers(struct aac_dev *dev);
int aac_scsi_cmd(struct scsi_cmnd *cmd);
int aac_dev_ioctl(struct aac_dev *dev, int cmd, void __user *arg);
#ifndef shost_to_class
#define shost_to_class(shost) &shost->shost_classdev
#define shost_to_class(shost) &shost->shost_dev
#endif
ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf);
ssize_t aac_get_serial_number(struct device *dev, char *buf);
int aac_do_ioctl(struct aac_dev * dev, int cmd, void __user *arg);
int aac_rx_init(struct aac_dev *dev);
int aac_rkt_init(struct aac_dev *dev);
......
......@@ -755,10 +755,10 @@ static long aac_compat_cfg_ioctl(struct file *file, unsigned cmd, unsigned long
}
#endif
static ssize_t aac_show_model(struct class_device *class_dev,
char *buf)
static ssize_t aac_show_model(struct device *device,
struct device_attribute *attr, char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len;
if (dev->supplement_adapter_info.AdapterTypeText[0]) {
......@@ -774,10 +774,10 @@ static ssize_t aac_show_model(struct class_device *class_dev,
return len;
}
static ssize_t aac_show_vendor(struct class_device *class_dev,
char *buf)
static ssize_t aac_show_vendor(struct device *device,
struct device_attribute *attr, char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len;
if (dev->supplement_adapter_info.AdapterTypeText[0]) {
......@@ -793,10 +793,11 @@ static ssize_t aac_show_vendor(struct class_device *class_dev,
return len;
}
static ssize_t aac_show_flags(struct class_device *class_dev, char *buf)
static ssize_t aac_show_flags(struct device *cdev,
struct device_attribute *attr, char *buf)
{
int len = 0;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(cdev)->hostdata;
if (nblank(dprintk(x)))
len = snprintf(buf, PAGE_SIZE, "dprintk\n");
......@@ -812,10 +813,11 @@ static ssize_t aac_show_flags(struct class_device *class_dev, char *buf)
return len;
}
static ssize_t aac_show_kernel_version(struct class_device *class_dev,
char *buf)
static ssize_t aac_show_kernel_version(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len, tmp;
tmp = le32_to_cpu(dev->adapter_info.kernelrev);
......@@ -825,10 +827,11 @@ static ssize_t aac_show_kernel_version(struct class_device *class_dev,
return len;
}
static ssize_t aac_show_monitor_version(struct class_device *class_dev,
char *buf)
static ssize_t aac_show_monitor_version(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len, tmp;
tmp = le32_to_cpu(dev->adapter_info.monitorrev);
......@@ -838,10 +841,11 @@ static ssize_t aac_show_monitor_version(struct class_device *class_dev,
return len;
}
static ssize_t aac_show_bios_version(struct class_device *class_dev,
char *buf)
static ssize_t aac_show_bios_version(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len, tmp;
tmp = le32_to_cpu(dev->adapter_info.biosrev);
......@@ -851,9 +855,10 @@ static ssize_t aac_show_bios_version(struct class_device *class_dev,
return len;
}
ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf)
ssize_t aac_show_serial_number(struct device *device,
struct device_attribute *attr, char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len = 0;
if (le32_to_cpu(dev->adapter_info.serial[0]) != 0xBAD0)
......@@ -869,35 +874,39 @@ ssize_t aac_show_serial_number(struct class_device *class_dev, char *buf)
return len;
}
static ssize_t aac_show_max_channel(struct class_device *class_dev, char *buf)
static ssize_t aac_show_max_channel(struct device *device,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n",
class_to_shost(class_dev)->max_channel);
class_to_shost(device)->max_channel);
}
static ssize_t aac_show_max_id(struct class_device *class_dev, char *buf)
static ssize_t aac_show_max_id(struct device *device,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n",
class_to_shost(class_dev)->max_id);
class_to_shost(device)->max_id);
}
static ssize_t aac_store_reset_adapter(struct class_device *class_dev,
const char *buf, size_t count)
static ssize_t aac_store_reset_adapter(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
int retval = -EACCES;
if (!capable(CAP_SYS_ADMIN))
return retval;
retval = aac_reset_adapter((struct aac_dev*)class_to_shost(class_dev)->hostdata, buf[0] == '!');
retval = aac_reset_adapter((struct aac_dev*)class_to_shost(device)->hostdata, buf[0] == '!');
if (retval >= 0)
retval = count;
return retval;
}
static ssize_t aac_show_reset_adapter(struct class_device *class_dev,
char *buf)
static ssize_t aac_show_reset_adapter(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct aac_dev *dev = (struct aac_dev*)class_to_shost(class_dev)->hostdata;
struct aac_dev *dev = (struct aac_dev*)class_to_shost(device)->hostdata;
int len, tmp;
tmp = aac_adapter_check_health(dev);
......@@ -907,70 +916,70 @@ static ssize_t aac_show_reset_adapter(struct class_device *class_dev,
return len;
}
static struct class_device_attribute aac_model = {
static struct device_attribute aac_model = {
.attr = {
.name = "model",
.mode = S_IRUGO,
},
.show = aac_show_model,
};
static struct class_device_attribute aac_vendor = {
static struct device_attribute aac_vendor = {
.attr = {
.name = "vendor",
.mode = S_IRUGO,
},
.show = aac_show_vendor,
};
static struct class_device_attribute aac_flags = {
static struct device_attribute aac_flags = {
.attr = {
.name = "flags",
.mode = S_IRUGO,
},
.show = aac_show_flags,
};
static struct class_device_attribute aac_kernel_version = {
static struct device_attribute aac_kernel_version = {
.attr = {
.name = "hba_kernel_version",
.mode = S_IRUGO,
},
.show = aac_show_kernel_version,
};
static struct class_device_attribute aac_monitor_version = {
static struct device_attribute aac_monitor_version = {
.attr = {
.name = "hba_monitor_version",
.mode = S_IRUGO,
},
.show = aac_show_monitor_version,
};
static struct class_device_attribute aac_bios_version = {
static struct device_attribute aac_bios_version = {
.attr = {
.name = "hba_bios_version",
.mode = S_IRUGO,
},
.show = aac_show_bios_version,
};
static struct class_device_attribute aac_serial_number = {
static struct device_attribute aac_serial_number = {
.attr = {
.name = "serial_number",
.mode = S_IRUGO,
},
.show = aac_show_serial_number,
};
static struct class_device_attribute aac_max_channel = {
static struct device_attribute aac_max_channel = {
.attr = {
.name = "max_channel",
.mode = S_IRUGO,
},
.show = aac_show_max_channel,
};
static struct class_device_attribute aac_max_id = {
static struct device_attribute aac_max_id = {
.attr = {
.name = "max_id",
.mode = S_IRUGO,
},
.show = aac_show_max_id,
};
static struct class_device_attribute aac_reset = {
static struct device_attribute aac_reset = {
.attr = {
.name = "reset_host",
.mode = S_IWUSR|S_IRUGO,
......@@ -979,7 +988,7 @@ static struct class_device_attribute aac_reset = {
.show = aac_show_reset_adapter,
};
static struct class_device_attribute *aac_attrs[] = {
static struct device_attribute *aac_attrs[] = {
&aac_model,
&aac_vendor,
&aac_flags,
......@@ -993,6 +1002,10 @@ static struct class_device_attribute *aac_attrs[] = {
NULL
};
ssize_t aac_get_serial_number(struct device *device, char *buf)
{
return aac_show_serial_number(device, &aac_serial_number, buf);
}
static const struct file_operations aac_cfg_fops = {
.owner = THIS_MODULE,
......
......@@ -44,7 +44,7 @@
*/
#include <linux/interrupt.h>
struct class_device_attribute;
struct device_attribute;
/*The limit of outstanding scsi command that firmware can handle*/
#define ARCMSR_MAX_OUTSTANDING_CMD 256
#define ARCMSR_MAX_FREECCB_NUM 320
......@@ -556,6 +556,6 @@ struct SENSE_DATA
extern void arcmsr_post_ioctldata2iop(struct AdapterControlBlock *);
extern void arcmsr_iop_message_read(struct AdapterControlBlock *);
extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
extern struct class_device_attribute *arcmsr_host_attrs[];
extern struct device_attribute *arcmsr_host_attrs[];
extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);
......@@ -57,15 +57,15 @@
#include <scsi/scsi_transport.h>
#include "arcmsr.h"
struct class_device_attribute *arcmsr_host_attrs[];
struct device_attribute *arcmsr_host_attrs[];
static ssize_t arcmsr_sysfs_iop_message_read(struct kobject *kobj,
struct bin_attribute *bin,
char *buf, loff_t off,
size_t count)
{
struct class_device *cdev = container_of(kobj,struct class_device,kobj);
struct Scsi_Host *host = class_to_shost(cdev);
struct device *dev = container_of(kobj,struct device,kobj);
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
uint8_t *pQbuffer,*ptmpQbuffer;
int32_t allxfer_len = 0;
......@@ -110,8 +110,8 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct kobject *kobj,
char *buf, loff_t off,
size_t count)
{
struct class_device *cdev = container_of(kobj,struct class_device,kobj);
struct Scsi_Host *host = class_to_shost(cdev);
struct device *dev = container_of(kobj,struct device,kobj);
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
uint8_t *pQbuffer, *ptmpuserbuffer;
......@@ -158,8 +158,8 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct kobject *kobj,
char *buf, loff_t off,
size_t count)
{
struct class_device *cdev = container_of(kobj,struct class_device,kobj);
struct Scsi_Host *host = class_to_shost(cdev);
struct device *dev = container_of(kobj,struct device,kobj);
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
uint8_t *pQbuffer;
......@@ -220,87 +220,104 @@ int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb)
struct Scsi_Host *host = acb->host;
int error;
error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr);
error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
if (error) {
printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n");
goto error_bin_file_message_read;
}
error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr);
error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
if (error) {
printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n");
goto error_bin_file_message_write;
}
error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr);
error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr);
if (error) {
printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n");
goto error_bin_file_message_clear;
}
return 0;
error_bin_file_message_clear:
sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr);
sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
error_bin_file_message_write:
sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr);
sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
error_bin_file_message_read:
return error;
}
void
arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb) {
void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb)
{
struct Scsi_Host *host = acb->host;
sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr);
sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr);
sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr);
sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr);
sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
}
static ssize_t
arcmsr_attr_host_driver_version(struct class_device *cdev, char *buf) {
arcmsr_attr_host_driver_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE,
"%s\n",
ARCMSR_DRIVER_VERSION);
}
static ssize_t
arcmsr_attr_host_driver_posted_cmd(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_driver_posted_cmd(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
atomic_read(&acb->ccboutstandingcount));
}
static ssize_t
arcmsr_attr_host_driver_reset(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_driver_reset(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
acb->num_resets);
}
static ssize_t
arcmsr_attr_host_driver_abort(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_driver_abort(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
acb->num_aborts);
}
static ssize_t
arcmsr_attr_host_fw_model(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_fw_model(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%s\n",
acb->firm_model);
}
static ssize_t
arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_fw_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%s\n",
......@@ -308,9 +325,12 @@ arcmsr_attr_host_fw_version(struct class_device *cdev, char *buf) {
}
static ssize_t
arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_fw_request_len(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
......@@ -318,9 +338,12 @@ arcmsr_attr_host_fw_request_len(struct class_device *cdev, char *buf) {
}
static ssize_t
arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_fw_numbers_queue(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
......@@ -328,9 +351,12 @@ arcmsr_attr_host_fw_numbers_queue(struct class_device *cdev, char *buf) {
}
static ssize_t
arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_fw_sdram_size(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
......@@ -338,36 +364,39 @@ arcmsr_attr_host_fw_sdram_size(struct class_device *cdev, char *buf) {
}
static ssize_t
arcmsr_attr_host_fw_hd_channels(struct class_device *cdev, char *buf) {
struct Scsi_Host *host = class_to_shost(cdev);
struct AdapterControlBlock *acb = (struct AdapterControlBlock *) host->hostdata;
arcmsr_attr_host_fw_hd_channels(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct AdapterControlBlock *acb =
(struct AdapterControlBlock *) host->hostdata;
return snprintf(buf, PAGE_SIZE,
"%4d\n",
acb->firm_hd_channels);
}
static CLASS_DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL);
static CLASS_DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL);
static CLASS_DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL);
static CLASS_DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL);
static CLASS_DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL);
static CLASS_DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL);
static CLASS_DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL);
static CLASS_DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL);
static CLASS_DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL);
static CLASS_DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL);
struct class_device_attribute *arcmsr_host_attrs[] = {
&class_device_attr_host_driver_version,
&class_device_attr_host_driver_posted_cmd,
&class_device_attr_host_driver_reset,
&class_device_attr_host_driver_abort,
&class_device_attr_host_fw_model,
&class_device_attr_host_fw_version,
&class_device_attr_host_fw_request_len,
&class_device_attr_host_fw_numbers_queue,
&class_device_attr_host_fw_sdram_size,
&class_device_attr_host_fw_hd_channels,
static DEVICE_ATTR(host_driver_version, S_IRUGO, arcmsr_attr_host_driver_version, NULL);
static DEVICE_ATTR(host_driver_posted_cmd, S_IRUGO, arcmsr_attr_host_driver_posted_cmd, NULL);
static DEVICE_ATTR(host_driver_reset, S_IRUGO, arcmsr_attr_host_driver_reset, NULL);
static DEVICE_ATTR(host_driver_abort, S_IRUGO, arcmsr_attr_host_driver_abort, NULL);
static DEVICE_ATTR(host_fw_model, S_IRUGO, arcmsr_attr_host_fw_model, NULL);
static DEVICE_ATTR(host_fw_version, S_IRUGO, arcmsr_attr_host_fw_version, NULL);
static DEVICE_ATTR(host_fw_request_len, S_IRUGO, arcmsr_attr_host_fw_request_len, NULL);
static DEVICE_ATTR(host_fw_numbers_queue, S_IRUGO, arcmsr_attr_host_fw_numbers_queue, NULL);
static DEVICE_ATTR(host_fw_sdram_size, S_IRUGO, arcmsr_attr_host_fw_sdram_size, NULL);
static DEVICE_ATTR(host_fw_hd_channels, S_IRUGO, arcmsr_attr_host_fw_hd_channels, NULL);
struct device_attribute *arcmsr_host_attrs[] = {
&dev_attr_host_driver_version,
&dev_attr_host_driver_posted_cmd,
&dev_attr_host_driver_reset,
&dev_attr_host_driver_abort,
&dev_attr_host_fw_model,
&dev_attr_host_fw_version,
&dev_attr_host_fw_request_len,
&dev_attr_host_fw_numbers_queue,
&dev_attr_host_fw_sdram_size,
&dev_attr_host_fw_hd_channels,
NULL,
};
......@@ -881,7 +881,7 @@ static long ch_ioctl_compat(struct file * file,
static int ch_probe(struct device *dev)
{
struct scsi_device *sd = to_scsi_device(dev);
struct class_device *class_dev;
struct device *class_dev;
int minor, ret = -ENOMEM;
scsi_changer *ch;
......@@ -910,11 +910,11 @@ static int ch_probe(struct device *dev)
ch->minor = minor;
sprintf(ch->name,"ch%d",ch->minor);
class_dev = class_device_create(ch_sysfs_class, NULL,
MKDEV(SCSI_CHANGER_MAJOR, ch->minor),
dev, "s%s", ch->name);
class_dev = device_create(ch_sysfs_class, dev,
MKDEV(SCSI_CHANGER_MAJOR,ch->minor),
"s%s", ch->name);
if (IS_ERR(class_dev)) {
printk(KERN_WARNING "ch%d: class_device_create failed\n",
printk(KERN_WARNING "ch%d: device_create failed\n",
ch->minor);
ret = PTR_ERR(class_dev);
goto remove_idr;
......@@ -945,8 +945,7 @@ static int ch_remove(struct device *dev)
idr_remove(&ch_index_idr, ch->minor);
spin_unlock(&ch_index_lock);
class_device_destroy(ch_sysfs_class,
MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
device_destroy(ch_sysfs_class, MKDEV(SCSI_CHANGER_MAJOR,ch->minor));
kfree(ch->dt);
kfree(ch);
return 0;
......
......@@ -43,14 +43,14 @@
static int scsi_host_next_hn; /* host_no for next new host */
static void scsi_host_cls_release(struct class_device *class_dev)
static void scsi_host_cls_release(struct device *dev)
{
put_device(&class_to_shost(class_dev)->shost_gendev);
put_device(&class_to_shost(dev)->shost_gendev);
}
static struct class shost_class = {
.name = "scsi_host",
.release = scsi_host_cls_release,
.dev_release = scsi_host_cls_release,
};
/**
......@@ -174,7 +174,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
spin_unlock_irqrestore(shost->host_lock, flags);
transport_unregister_device(&shost->shost_gendev);
class_device_unregister(&shost->shost_classdev);
device_unregister(&shost->shost_dev);
device_del(&shost->shost_gendev);
scsi_proc_hostdir_rm(shost->hostt);
}
......@@ -212,7 +212,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
scsi_host_set_state(shost, SHOST_RUNNING);
get_device(shost->shost_gendev.parent);
error = class_device_add(&shost->shost_classdev);
error = device_add(&shost->shost_dev);
if (error)
goto out_del_gendev;
......@@ -223,7 +223,7 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
GFP_KERNEL);
if (shost->shost_data == NULL) {
error = -ENOMEM;
goto out_del_classdev;
goto out_del_dev;
}
}
......@@ -250,8 +250,8 @@ int scsi_add_host(struct Scsi_Host *shost, struct device *dev)
destroy_workqueue(shost->work_q);
out_free_shost_data:
kfree(shost->shost_data);
out_del_classdev:
class_device_del(&shost->shost_classdev);
out_del_dev:
device_del(&shost->shost_dev);
out_del_gendev:
device_del(&shost->shost_gendev);
out:
......@@ -385,11 +385,11 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
shost->host_no);
shost->shost_gendev.release = scsi_host_dev_release;
class_device_initialize(&shost->shost_classdev);
shost->shost_classdev.dev = &shost->shost_gendev;
shost->shost_classdev.class = &shost_class;
snprintf(shost->shost_classdev.class_id, BUS_ID_SIZE, "host%d",
shost->host_no);
device_initialize(&shost->shost_dev);
shost->shost_dev.parent = &shost->shost_gendev;
shost->shost_dev.class = &shost_class;
snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d",
shost->host_no);
shost->ehandler = kthread_run(scsi_error_handler, shost,
"scsi_eh_%d", shost->host_no);
......@@ -432,12 +432,12 @@ void scsi_unregister(struct Scsi_Host *shost)
}
EXPORT_SYMBOL(scsi_unregister);
static int __scsi_host_match(struct class_device *cdev, void *data)
static int __scsi_host_match(struct device *dev, void *data)
{
struct Scsi_Host *p;
unsigned short *hostnum = (unsigned short *)data;
p = class_to_shost(cdev);
p = class_to_shost(dev);
return p->host_no == *hostnum;
}
......@@ -450,10 +450,10 @@ static int __scsi_host_match(struct class_device *cdev, void *data)
**/
struct Scsi_Host *scsi_host_lookup(unsigned short hostnum)
{
struct class_device *cdev;
struct device *cdev;
struct Scsi_Host *shost = ERR_PTR(-ENXIO);
cdev = class_find_child(&shost_class, &hostnum, __scsi_host_match);
cdev = class_find_device(&shost_class, &hostnum, __scsi_host_match);
if (cdev)
shost = scsi_host_get(class_to_shost(cdev));
......
......@@ -859,14 +859,16 @@ static int hptiop_adjust_disk_queue_depth(struct scsi_device *sdev,
return queue_depth;
}
static ssize_t hptiop_show_version(struct class_device *class_dev, char *buf)
static ssize_t hptiop_show_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s\n", driver_ver);
}
static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf)
static ssize_t hptiop_show_fw_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(class_dev);
struct Scsi_Host *host = class_to_shost(dev);
struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n",
......@@ -876,7 +878,7 @@ static ssize_t hptiop_show_fw_version(struct class_device *class_dev, char *buf)
hba->firmware_version & 0xff);
}
static struct class_device_attribute hptiop_attr_version = {
static struct device_attribute hptiop_attr_version = {
.attr = {
.name = "driver-version",
.mode = S_IRUGO,
......@@ -884,7 +886,7 @@ static struct class_device_attribute hptiop_attr_version = {
.show = hptiop_show_version,
};
static struct class_device_attribute hptiop_attr_fw_version = {
static struct device_attribute hptiop_attr_fw_version = {
.attr = {
.name = "firmware-version",
.mode = S_IRUGO,
......@@ -892,7 +894,7 @@ static struct class_device_attribute hptiop_attr_fw_version = {
.show = hptiop_show_fw_version,
};
static struct class_device_attribute *hptiop_attrs[] = {
static struct device_attribute *hptiop_attrs[] = {
&hptiop_attr_version,
&hptiop_attr_fw_version,
NULL
......
......@@ -1456,9 +1456,10 @@ static int ibmvscsi_change_queue_depth(struct scsi_device *sdev, int qdepth)
/* ------------------------------------------------------------
* sysfs attributes
*/
static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf)
static ssize_t show_host_srp_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvscsi_host_data *hostdata = shost_priv(shost);
int len;
......@@ -1467,7 +1468,7 @@ static ssize_t show_host_srp_version(struct class_device *class_dev, char *buf)
return len;
}
static struct class_device_attribute ibmvscsi_host_srp_version = {
static struct device_attribute ibmvscsi_host_srp_version = {
.attr = {
.name = "srp_version",
.mode = S_IRUGO,
......@@ -1475,10 +1476,11 @@ static struct class_device_attribute ibmvscsi_host_srp_version = {
.show = show_host_srp_version,
};
static ssize_t show_host_partition_name(struct class_device *class_dev,
static ssize_t show_host_partition_name(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvscsi_host_data *hostdata = shost_priv(shost);
int len;
......@@ -1487,7 +1489,7 @@ static ssize_t show_host_partition_name(struct class_device *class_dev,
return len;
}
static struct class_device_attribute ibmvscsi_host_partition_name = {
static struct device_attribute ibmvscsi_host_partition_name = {
.attr = {
.name = "partition_name",
.mode = S_IRUGO,
......@@ -1495,10 +1497,11 @@ static struct class_device_attribute ibmvscsi_host_partition_name = {
.show = show_host_partition_name,
};
static ssize_t show_host_partition_number(struct class_device *class_dev,
static ssize_t show_host_partition_number(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvscsi_host_data *hostdata = shost_priv(shost);
int len;
......@@ -1507,7 +1510,7 @@ static ssize_t show_host_partition_number(struct class_device *class_dev,
return len;
}
static struct class_device_attribute ibmvscsi_host_partition_number = {
static struct device_attribute ibmvscsi_host_partition_number = {
.attr = {
.name = "partition_number",
.mode = S_IRUGO,
......@@ -1515,9 +1518,10 @@ static struct class_device_attribute ibmvscsi_host_partition_number = {
.show = show_host_partition_number,
};
static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf)
static ssize_t show_host_mad_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvscsi_host_data *hostdata = shost_priv(shost);
int len;
......@@ -1526,7 +1530,7 @@ static ssize_t show_host_mad_version(struct class_device *class_dev, char *buf)
return len;
}
static struct class_device_attribute ibmvscsi_host_mad_version = {
static struct device_attribute ibmvscsi_host_mad_version = {
.attr = {
.name = "mad_version",
.mode = S_IRUGO,
......@@ -1534,9 +1538,10 @@ static struct class_device_attribute ibmvscsi_host_mad_version = {
.show = show_host_mad_version,
};
static ssize_t show_host_os_type(struct class_device *class_dev, char *buf)
static ssize_t show_host_os_type(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvscsi_host_data *hostdata = shost_priv(shost);
int len;
......@@ -1544,7 +1549,7 @@ static ssize_t show_host_os_type(struct class_device *class_dev, char *buf)
return len;
}
static struct class_device_attribute ibmvscsi_host_os_type = {
static struct device_attribute ibmvscsi_host_os_type = {
.attr = {
.name = "os_type",
.mode = S_IRUGO,
......@@ -1552,9 +1557,10 @@ static struct class_device_attribute ibmvscsi_host_os_type = {
.show = show_host_os_type,
};
static ssize_t show_host_config(struct class_device *class_dev, char *buf)
static ssize_t show_host_config(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvscsi_host_data *hostdata = shost_priv(shost);
/* returns null-terminated host config data */
......@@ -1564,7 +1570,7 @@ static ssize_t show_host_config(struct class_device *class_dev, char *buf)
return 0;
}
static struct class_device_attribute ibmvscsi_host_config = {
static struct device_attribute ibmvscsi_host_config = {
.attr = {
.name = "config",
.mode = S_IRUGO,
......@@ -1572,7 +1578,7 @@ static struct class_device_attribute ibmvscsi_host_config = {
.show = show_host_config,
};
static struct class_device_attribute *ibmvscsi_attrs[] = {
static struct device_attribute *ibmvscsi_attrs[] = {
&ibmvscsi_host_srp_version,
&ibmvscsi_host_partition_name,
&ibmvscsi_host_partition_number,
......
......@@ -780,32 +780,35 @@ static int ibmvstgt_it_nexus_response(struct Scsi_Host *shost, u64 itn_id,
return 0;
}
static ssize_t system_id_show(struct class_device *cdev, char *buf)
static ssize_t system_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s\n", system_id);
}
static ssize_t partition_number_show(struct class_device *cdev, char *buf)
static ssize_t partition_number_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%x\n", partition_number);
}
static ssize_t unit_address_show(struct class_device *cdev, char *buf)
static ssize_t unit_address_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(cdev);
struct Scsi_Host *shost = class_to_shost(dev);
struct srp_target *target = host_to_srp_target(shost);
struct vio_port *vport = target_to_port(target);
return snprintf(buf, PAGE_SIZE, "%x\n", vport->dma_dev->unit_address);
}
static CLASS_DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
static CLASS_DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
static CLASS_DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
static DEVICE_ATTR(system_id, S_IRUGO, system_id_show, NULL);
static DEVICE_ATTR(partition_number, S_IRUGO, partition_number_show, NULL);
static DEVICE_ATTR(unit_address, S_IRUGO, unit_address_show, NULL);
static struct class_device_attribute *ibmvstgt_attrs[] = {
&class_device_attr_system_id,
&class_device_attr_partition_number,
&class_device_attr_unit_address,
static struct device_attribute *ibmvstgt_attrs[] = {
&dev_attr_system_id,
&dev_attr_partition_number,
&dev_attr_unit_address,
NULL,
};
......
......@@ -2431,7 +2431,7 @@ static void ipr_worker_thread(struct work_struct *work)
}
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE);
kobject_uevent(&ioa_cfg->host->shost_dev.kobj, KOBJ_CHANGE);
LEAVE;
}
......@@ -2451,8 +2451,8 @@ static ssize_t ipr_read_trace(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct class_device *cdev = container_of(kobj,struct class_device,kobj);
struct Scsi_Host *shost = class_to_shost(cdev);
struct device *dev = container_of(kobj, struct device, kobj);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
int size = IPR_TRACE_SIZE;
......@@ -2492,15 +2492,16 @@ static const struct {
/**
* ipr_show_write_caching - Show the write caching attribute
* @class_dev: class device struct
* @buf: buffer
* @dev: device struct
* @buf: buffer
*
* Return value:
* number of bytes printed to buffer
**/
static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf)
static ssize_t ipr_show_write_caching(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
int i, len = 0;
......@@ -2519,19 +2520,20 @@ static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf)
/**
* ipr_store_write_caching - Enable/disable adapter write cache
* @class_dev: class_device struct
* @buf: buffer
* @count: buffer size
* @dev: device struct
* @buf: buffer
* @count: buffer size
*
* This function will enable/disable adapter write cache.
*
* Return value:
* count on success / other on failure
**/
static ssize_t ipr_store_write_caching(struct class_device *class_dev,
const char *buf, size_t count)
static ssize_t ipr_store_write_caching(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
enum ipr_cache_state new_state = CACHE_INVALID;
......@@ -2569,7 +2571,7 @@ static ssize_t ipr_store_write_caching(struct class_device *class_dev,
return count;
}
static struct class_device_attribute ipr_ioa_cache_attr = {
static struct device_attribute ipr_ioa_cache_attr = {
.attr = {
.name = "write_cache",
.mode = S_IRUGO | S_IWUSR,
......@@ -2580,15 +2582,16 @@ static struct class_device_attribute ipr_ioa_cache_attr = {
/**
* ipr_show_fw_version - Show the firmware version
* @class_dev: class device struct
* @buf: buffer
* @dev: class device struct
* @buf: buffer
*
* Return value:
* number of bytes printed to buffer
**/
static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf)
static ssize_t ipr_show_fw_version(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
struct ipr_inquiry_page3 *ucode_vpd = &ioa_cfg->vpd_cbs->page3_data;
unsigned long lock_flags = 0;
......@@ -2603,7 +2606,7 @@ static ssize_t ipr_show_fw_version(struct class_device *class_dev, char *buf)
return len;
}
static struct class_device_attribute ipr_fw_version_attr = {
static struct device_attribute ipr_fw_version_attr = {
.attr = {
.name = "fw_version",
.mode = S_IRUGO,
......@@ -2613,15 +2616,16 @@ static struct class_device_attribute ipr_fw_version_attr = {
/**
* ipr_show_log_level - Show the adapter's error logging level
* @class_dev: class device struct
* @buf: buffer
* @dev: class device struct
* @buf: buffer
*
* Return value:
* number of bytes printed to buffer
**/
static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf)
static ssize_t ipr_show_log_level(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
int len;
......@@ -2634,16 +2638,17 @@ static ssize_t ipr_show_log_level(struct class_device *class_dev, char *buf)
/**
* ipr_store_log_level - Change the adapter's error logging level
* @class_dev: class device struct
* @buf: buffer
* @dev: class device struct
* @buf: buffer
*
* Return value:
* number of bytes printed to buffer
**/
static ssize_t ipr_store_log_level(struct class_device *class_dev,
static ssize_t ipr_store_log_level(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
......@@ -2653,7 +2658,7 @@ static ssize_t ipr_store_log_level(struct class_device *class_dev,
return strlen(buf);
}
static struct class_device_attribute ipr_log_level_attr = {
static struct device_attribute ipr_log_level_attr = {
.attr = {
.name = "log_level",
.mode = S_IRUGO | S_IWUSR,
......@@ -2664,9 +2669,9 @@ static struct class_device_attribute ipr_log_level_attr = {
/**
* ipr_store_diagnostics - IOA Diagnostics interface
* @class_dev: class_device struct
* @buf: buffer
* @count: buffer size
* @dev: device struct
* @buf: buffer
* @count: buffer size
*
* This function will reset the adapter and wait a reasonable
* amount of time for any errors that the adapter might log.
......@@ -2674,10 +2679,11 @@ static struct class_device_attribute ipr_log_level_attr = {
* Return value:
* count on success / other on failure
**/
static ssize_t ipr_store_diagnostics(struct class_device *class_dev,
static ssize_t ipr_store_diagnostics(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
int rc = count;
......@@ -2714,7 +2720,7 @@ static ssize_t ipr_store_diagnostics(struct class_device *class_dev,
return rc;
}
static struct class_device_attribute ipr_diagnostics_attr = {
static struct device_attribute ipr_diagnostics_attr = {
.attr = {
.name = "run_diagnostics",
.mode = S_IWUSR,
......@@ -2724,15 +2730,16 @@ static struct class_device_attribute ipr_diagnostics_attr = {
/**
* ipr_show_adapter_state - Show the adapter's state
* @class_dev: class device struct
* @buf: buffer
* @class_dev: device struct
* @buf: buffer
*
* Return value:
* number of bytes printed to buffer
**/
static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf)
static ssize_t ipr_show_adapter_state(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags = 0;
int len;
......@@ -2748,19 +2755,20 @@ static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf)
/**
* ipr_store_adapter_state - Change adapter state
* @class_dev: class_device struct
* @buf: buffer
* @count: buffer size
* @dev: device struct
* @buf: buffer
* @count: buffer size
*
* This function will change the adapter's state.
*
* Return value:
* count on success / other on failure
**/
static ssize_t ipr_store_adapter_state(struct class_device *class_dev,
static ssize_t ipr_store_adapter_state(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags;
int result = count;
......@@ -2781,7 +2789,7 @@ static ssize_t ipr_store_adapter_state(struct class_device *class_dev,
return result;
}
static struct class_device_attribute ipr_ioa_state_attr = {
static struct device_attribute ipr_ioa_state_attr = {
.attr = {
.name = "state",
.mode = S_IRUGO | S_IWUSR,
......@@ -2792,19 +2800,20 @@ static struct class_device_attribute ipr_ioa_state_attr = {
/**
* ipr_store_reset_adapter - Reset the adapter
* @class_dev: class_device struct
* @buf: buffer
* @count: buffer size
* @dev: device struct
* @buf: buffer
* @count: buffer size
*
* This function will reset the adapter.
*
* Return value:
* count on success / other on failure
**/
static ssize_t ipr_store_reset_adapter(struct class_device *class_dev,
static ssize_t ipr_store_reset_adapter(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
unsigned long lock_flags;
int result = count;
......@@ -2821,7 +2830,7 @@ static ssize_t ipr_store_reset_adapter(struct class_device *class_dev,
return result;
}
static struct class_device_attribute ipr_ioa_reset_attr = {
static struct device_attribute ipr_ioa_reset_attr = {
.attr = {
.name = "reset_host",
.mode = S_IWUSR,
......@@ -3054,19 +3063,20 @@ static int ipr_update_ioa_ucode(struct ipr_ioa_cfg *ioa_cfg,
/**
* ipr_store_update_fw - Update the firmware on the adapter
* @class_dev: class_device struct
* @buf: buffer
* @count: buffer size
* @class_dev: device struct
* @buf: buffer
* @count: buffer size
*
* This function will update the firmware on the adapter.
*
* Return value:
* count on success / other on failure
**/
static ssize_t ipr_store_update_fw(struct class_device *class_dev,
const char *buf, size_t count)
static ssize_t ipr_store_update_fw(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
struct ipr_ucode_image_header *image_hdr;
const struct firmware *fw_entry;
......@@ -3124,7 +3134,7 @@ static ssize_t ipr_store_update_fw(struct class_device *class_dev,
return result;
}
static struct class_device_attribute ipr_update_fw_attr = {
static struct device_attribute ipr_update_fw_attr = {
.attr = {
.name = "update_fw",
.mode = S_IWUSR,
......@@ -3132,7 +3142,7 @@ static struct class_device_attribute ipr_update_fw_attr = {
.store = ipr_store_update_fw
};
static struct class_device_attribute *ipr_ioa_attrs[] = {
static struct device_attribute *ipr_ioa_attrs[] = {
&ipr_fw_version_attr,
&ipr_log_level_attr,
&ipr_diagnostics_attr,
......@@ -3159,7 +3169,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct class_device *cdev = container_of(kobj,struct class_device,kobj);
struct device *cdev = container_of(kobj, struct device, kobj);
struct Scsi_Host *shost = class_to_shost(cdev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
struct ipr_dump *dump;
......@@ -3322,7 +3332,7 @@ static ssize_t ipr_write_dump(struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct class_device *cdev = container_of(kobj,struct class_device,kobj);
struct device *cdev = container_of(kobj, struct device, kobj);
struct Scsi_Host *shost = class_to_shost(cdev);
struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
int rc;
......@@ -7671,9 +7681,9 @@ static void ipr_remove(struct pci_dev *pdev)
ENTER;
ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj,
ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj,
&ipr_trace_attr);
ipr_remove_dump_file(&ioa_cfg->host->shost_classdev.kobj,
ipr_remove_dump_file(&ioa_cfg->host->shost_dev.kobj,
&ipr_dump_attr);
scsi_remove_host(ioa_cfg->host);
......@@ -7714,7 +7724,7 @@ static int __devinit ipr_probe(struct pci_dev *pdev,
return rc;
}
rc = ipr_create_trace_file(&ioa_cfg->host->shost_classdev.kobj,
rc = ipr_create_trace_file(&ioa_cfg->host->shost_dev.kobj,
&ipr_trace_attr);
if (rc) {
......@@ -7723,11 +7733,11 @@ static int __devinit ipr_probe(struct pci_dev *pdev,
return rc;
}
rc = ipr_create_dump_file(&ioa_cfg->host->shost_classdev.kobj,
rc = ipr_create_dump_file(&ioa_cfg->host->shost_dev.kobj,
&ipr_dump_attr);
if (rc) {
ipr_remove_trace_file(&ioa_cfg->host->shost_classdev.kobj,
ipr_remove_trace_file(&ioa_cfg->host->shost_dev.kobj,
&ipr_trace_attr);
scsi_remove_host(ioa_cfg->host);
__ipr_remove(pdev);
......
此差异已折叠。
......@@ -253,8 +253,8 @@ void lpfc_get_cfgparam(struct lpfc_hba *);
void lpfc_get_vport_cfgparam(struct lpfc_vport *);
int lpfc_alloc_sysfs_attr(struct lpfc_vport *);
void lpfc_free_sysfs_attr(struct lpfc_vport *);
extern struct class_device_attribute *lpfc_hba_attrs[];
extern struct class_device_attribute *lpfc_vport_attrs[];
extern struct device_attribute *lpfc_hba_attrs[];
extern struct device_attribute *lpfc_vport_attrs[];
extern struct scsi_host_template lpfc_template;
extern struct scsi_host_template lpfc_vport_template;
extern struct fc_function_template lpfc_transport_functions;
......
......@@ -125,7 +125,7 @@ static irqreturn_t megaraid_isr(int, void *);
static void megaraid_mbox_dpc(unsigned long);
static ssize_t megaraid_sysfs_show_app_hndl(struct class_device *, char *);
static ssize_t megaraid_sysfs_show_app_hndl(struct device *, struct device_attribute *attr, char *);
static ssize_t megaraid_sysfs_show_ldnum(struct device *, struct device_attribute *attr, char *);
static int megaraid_cmm_register(adapter_t *);
......@@ -313,12 +313,12 @@ static struct pci_driver megaraid_pci_driver = {
// definitions for the device attributes for exporting logical drive number
// for a scsi address (Host, Channel, Id, Lun)
CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl,
DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl,
NULL);
// Host template initializer for megaraid mbox sysfs device attributes
static struct class_device_attribute *megaraid_shost_attrs[] = {
&class_device_attr_megaraid_mbox_app_hndl,
static struct device_attribute *megaraid_shost_attrs[] = {
&dev_attr_megaraid_mbox_app_hndl,
NULL,
};
......@@ -4063,9 +4063,10 @@ megaraid_sysfs_get_ldmap(adapter_t *adapter)
* handle, since we do not interface with applications directly.
*/
static ssize_t
megaraid_sysfs_show_app_hndl(struct class_device *cdev, char *buf)
megaraid_sysfs_show_app_hndl(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *shost = class_to_shost(cdev);
struct Scsi_Host *shost = class_to_shost(dev);
adapter_t *adapter = (adapter_t *)SCSIHOST2ADAP(shost);
uint32_t app_hndl;
......
......@@ -8243,7 +8243,8 @@ static void process_waiting_list(struct ncb *np, int sts)
#undef next_wcmd
static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf)
static ssize_t show_ncr53c8xx_revision(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *host = class_to_shost(dev);
struct host_data *host_data = (struct host_data *)host->hostdata;
......@@ -8251,12 +8252,12 @@ static ssize_t show_ncr53c8xx_revision(struct class_device *dev, char *buf)
return snprintf(buf, 20, "0x%x\n", host_data->ncb->revision_id);
}
static struct class_device_attribute ncr53c8xx_revision_attr = {
static struct device_attribute ncr53c8xx_revision_attr = {
.attr = { .name = "revision", .mode = S_IRUGO, },
.show = show_ncr53c8xx_revision,
};
static struct class_device_attribute *ncr53c8xx_host_attrs[] = {
static struct device_attribute *ncr53c8xx_host_attrs[] = {
&ncr53c8xx_revision_attr,
NULL
};
......
......@@ -5591,9 +5591,10 @@ static void osst_remove_sysfs_files(struct device_driver *sysfs)
* sysfs support for accessing ADR header information
*/
static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf)
static ssize_t osst_adr_rev_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
ssize_t l = 0;
if (STp && STp->header_ok && STp->linux_media)
......@@ -5601,11 +5602,13 @@ static ssize_t osst_adr_rev_show(struct class_device *class_dev, char *buf)
return l;
}
CLASS_DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL);
DEVICE_ATTR(ADR_rev, S_IRUGO, osst_adr_rev_show, NULL);
static ssize_t osst_linux_media_version_show(struct class_device *class_dev, char *buf)
static ssize_t osst_linux_media_version_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
ssize_t l = 0;
if (STp && STp->header_ok && STp->linux_media)
......@@ -5613,11 +5616,12 @@ static ssize_t osst_linux_media_version_show(struct class_device *class_dev, cha
return l;
}
CLASS_DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL);
DEVICE_ATTR(media_version, S_IRUGO, osst_linux_media_version_show, NULL);
static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf)
static ssize_t osst_capacity_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
ssize_t l = 0;
if (STp && STp->header_ok && STp->linux_media)
......@@ -5625,11 +5629,13 @@ static ssize_t osst_capacity_show(struct class_device *class_dev, char *buf)
return l;
}
CLASS_DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL);
DEVICE_ATTR(capacity, S_IRUGO, osst_capacity_show, NULL);
static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *buf)
static ssize_t osst_first_data_ppos_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
ssize_t l = 0;
if (STp && STp->header_ok && STp->linux_media)
......@@ -5637,11 +5643,13 @@ static ssize_t osst_first_data_ppos_show(struct class_device *class_dev, char *b
return l;
}
CLASS_DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL);
DEVICE_ATTR(BOT_frame, S_IRUGO, osst_first_data_ppos_show, NULL);
static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *buf)
static ssize_t osst_eod_frame_ppos_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
ssize_t l = 0;
if (STp && STp->header_ok && STp->linux_media)
......@@ -5649,11 +5657,12 @@ static ssize_t osst_eod_frame_ppos_show(struct class_device *class_dev, char *bu
return l;
}
CLASS_DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL);
DEVICE_ATTR(EOD_frame, S_IRUGO, osst_eod_frame_ppos_show, NULL);
static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf)
static ssize_t osst_filemark_cnt_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct osst_tape * STp = (struct osst_tape *) class_get_devdata (class_dev);
struct osst_tape * STp = (struct osst_tape *) dev_get_drvdata (dev);
ssize_t l = 0;
if (STp && STp->header_ok && STp->linux_media)
......@@ -5661,7 +5670,7 @@ static ssize_t osst_filemark_cnt_show(struct class_device *class_dev, char *buf)
return l;
}
CLASS_DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL);
DEVICE_ATTR(file_count, S_IRUGO, osst_filemark_cnt_show, NULL);
static struct class *osst_sysfs_class;
......@@ -5678,44 +5687,37 @@ static int osst_sysfs_init(void)
static void osst_sysfs_destroy(dev_t dev)
{
class_device_destroy(osst_sysfs_class, dev);
device_destroy(osst_sysfs_class, dev);
}
static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * STp, char * name)
{
struct class_device *osst_class_member;
struct device *osst_member;
int err;
osst_class_member = class_device_create(osst_sysfs_class, NULL, dev,
device, "%s", name);
if (IS_ERR(osst_class_member)) {
osst_member = device_create(osst_sysfs_class, device, dev, "%s", name);
if (IS_ERR(osst_member)) {
printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name);
return PTR_ERR(osst_class_member);
return PTR_ERR(osst_member);
}
class_set_devdata(osst_class_member, STp);
err = class_device_create_file(osst_class_member,
&class_device_attr_ADR_rev);
dev_set_drvdata(osst_member, STp);
err = device_create_file(osst_member, &dev_attr_ADR_rev);
if (err)
goto err_out;
err = class_device_create_file(osst_class_member,
&class_device_attr_media_version);
err = device_create_file(osst_member, &dev_attr_media_version);
if (err)
goto err_out;
err = class_device_create_file(osst_class_member,
&class_device_attr_capacity);
err = device_create_file(osst_member, &dev_attr_capacity);
if (err)
goto err_out;
err = class_device_create_file(osst_class_member,
&class_device_attr_BOT_frame);
err = device_create_file(osst_member, &dev_attr_BOT_frame);
if (err)
goto err_out;
err = class_device_create_file(osst_class_member,
&class_device_attr_EOD_frame);
err = device_create_file(osst_member, &dev_attr_EOD_frame);
if (err)
goto err_out;
err = class_device_create_file(osst_class_member,
&class_device_attr_file_count);
err = device_create_file(osst_member, &dev_attr_file_count);
if (err)
goto err_out;
......
......@@ -632,9 +632,10 @@ SYM53C500_biosparm(struct scsi_device *disk,
}
static ssize_t
SYM53C500_show_pio(struct class_device *cdev, char *buf)
SYM53C500_show_pio(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *SHp = class_to_shost(cdev);
struct Scsi_Host *SHp = class_to_shost(dev);
struct sym53c500_data *data =
(struct sym53c500_data *)SHp->hostdata;
......@@ -642,10 +643,11 @@ SYM53C500_show_pio(struct class_device *cdev, char *buf)
}
static ssize_t
SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count)
SYM53C500_store_pio(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int pio;
struct Scsi_Host *SHp = class_to_shost(cdev);
struct Scsi_Host *SHp = class_to_shost(dev);
struct sym53c500_data *data =
(struct sym53c500_data *)SHp->hostdata;
......@@ -662,7 +664,7 @@ SYM53C500_store_pio(struct class_device *cdev, const char *buf, size_t count)
* SCSI HBA device attributes we want to
* make available via sysfs.
*/
static struct class_device_attribute SYM53C500_pio_attr = {
static struct device_attribute SYM53C500_pio_attr = {
.attr = {
.name = "fast_pio",
.mode = (S_IRUGO | S_IWUSR),
......@@ -671,7 +673,7 @@ static struct class_device_attribute SYM53C500_pio_attr = {
.store = SYM53C500_store_pio,
};
static struct class_device_attribute *SYM53C500_shost_attrs[] = {
static struct device_attribute *SYM53C500_shost_attrs[] = {
&SYM53C500_pio_attr,
NULL,
};
......
......@@ -530,15 +530,17 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
/* Scsi_Host attributes. */
static ssize_t
qla2x00_drvr_version_show(struct class_device *cdev, char *buf)
qla2x00_drvr_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
}
static ssize_t
qla2x00_fw_version_show(struct class_device *cdev, char *buf)
qla2x00_fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
char fw_str[30];
return snprintf(buf, PAGE_SIZE, "%s\n",
......@@ -546,9 +548,10 @@ qla2x00_fw_version_show(struct class_device *cdev, char *buf)
}
static ssize_t
qla2x00_serial_num_show(struct class_device *cdev, char *buf)
qla2x00_serial_num_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
uint32_t sn;
if (IS_FWI2_CAPABLE(ha))
......@@ -560,40 +563,45 @@ qla2x00_serial_num_show(struct class_device *cdev, char *buf)
}
static ssize_t
qla2x00_isp_name_show(struct class_device *cdev, char *buf)
qla2x00_isp_name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device);
}
static ssize_t
qla2x00_isp_id_show(struct class_device *cdev, char *buf)
qla2x00_isp_id_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
ha->product_id[0], ha->product_id[1], ha->product_id[2],
ha->product_id[3]);
}
static ssize_t
qla2x00_model_name_show(struct class_device *cdev, char *buf)
qla2x00_model_name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number);
}
static ssize_t
qla2x00_model_desc_show(struct class_device *cdev, char *buf)
qla2x00_model_desc_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%s\n",
ha->model_desc ? ha->model_desc: "");
}
static ssize_t
qla2x00_pci_info_show(struct class_device *cdev, char *buf)
qla2x00_pci_info_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
char pci_info[30];
return snprintf(buf, PAGE_SIZE, "%s\n",
......@@ -601,9 +609,10 @@ qla2x00_pci_info_show(struct class_device *cdev, char *buf)
}
static ssize_t
qla2x00_state_show(struct class_device *cdev, char *buf)
qla2x00_state_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
int len = 0;
if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
......@@ -639,9 +648,10 @@ qla2x00_state_show(struct class_device *cdev, char *buf)
}
static ssize_t
qla2x00_zio_show(struct class_device *cdev, char *buf)
qla2x00_zio_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
int len = 0;
switch (ha->zio_mode) {
......@@ -656,9 +666,10 @@ qla2x00_zio_show(struct class_device *cdev, char *buf)
}
static ssize_t
qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count)
qla2x00_zio_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
int val = 0;
uint16_t zio_mode;
......@@ -682,18 +693,19 @@ qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count)
}
static ssize_t
qla2x00_zio_timer_show(struct class_device *cdev, char *buf)
qla2x00_zio_timer_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100);
}
static ssize_t
qla2x00_zio_timer_store(struct class_device *cdev, const char *buf,
size_t count)
qla2x00_zio_timer_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
int val = 0;
uint16_t zio_timer;
......@@ -709,9 +721,10 @@ qla2x00_zio_timer_store(struct class_device *cdev, const char *buf,
}
static ssize_t
qla2x00_beacon_show(struct class_device *cdev, char *buf)
qla2x00_beacon_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
int len = 0;
if (ha->beacon_blink_led)
......@@ -722,10 +735,10 @@ qla2x00_beacon_show(struct class_device *cdev, char *buf)
}
static ssize_t
qla2x00_beacon_store(struct class_device *cdev, const char *buf,
size_t count)
qla2x00_beacon_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
int val = 0;
int rval;
......@@ -753,84 +766,86 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf,
}
static ssize_t
qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf)
qla2x00_optrom_bios_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
ha->bios_revision[0]);
}
static ssize_t
qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf)
qla2x00_optrom_efi_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
ha->efi_revision[0]);
}
static ssize_t
qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf)
qla2x00_optrom_fcode_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
ha->fcode_revision[0]);
}
static ssize_t
qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf)
qla2x00_optrom_fw_version_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
scsi_qla_host_t *ha = shost_priv(class_to_shost(dev));
return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
ha->fw_revision[3]);
}
static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show,
NULL);
static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL);
static CLASS_DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show,
qla2x00_zio_store);
static CLASS_DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
qla2x00_zio_timer_store);
static CLASS_DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
qla2x00_beacon_store);
static CLASS_DEVICE_ATTR(optrom_bios_version, S_IRUGO,
qla2x00_optrom_bios_version_show, NULL);
static CLASS_DEVICE_ATTR(optrom_efi_version, S_IRUGO,
qla2x00_optrom_efi_version_show, NULL);
static CLASS_DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
qla2x00_optrom_fcode_version_show, NULL);
static CLASS_DEVICE_ATTR(optrom_fw_version, S_IRUGO,
qla2x00_optrom_fw_version_show, NULL);
struct class_device_attribute *qla2x00_host_attrs[] = {
&class_device_attr_driver_version,
&class_device_attr_fw_version,
&class_device_attr_serial_num,
&class_device_attr_isp_name,
&class_device_attr_isp_id,
&class_device_attr_model_name,
&class_device_attr_model_desc,
&class_device_attr_pci_info,
&class_device_attr_state,
&class_device_attr_zio,
&class_device_attr_zio_timer,
&class_device_attr_beacon,
&class_device_attr_optrom_bios_version,
&class_device_attr_optrom_efi_version,
&class_device_attr_optrom_fcode_version,
&class_device_attr_optrom_fw_version,
static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
static DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
static DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
static DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
static DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
static DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
static DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL);
static DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show, qla2x00_zio_store);
static DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
qla2x00_zio_timer_store);
static DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
qla2x00_beacon_store);
static DEVICE_ATTR(optrom_bios_version, S_IRUGO,
qla2x00_optrom_bios_version_show, NULL);
static DEVICE_ATTR(optrom_efi_version, S_IRUGO,
qla2x00_optrom_efi_version_show, NULL);
static DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
qla2x00_optrom_fcode_version_show, NULL);
static DEVICE_ATTR(optrom_fw_version, S_IRUGO, qla2x00_optrom_fw_version_show,
NULL);
struct device_attribute *qla2x00_host_attrs[] = {
&dev_attr_driver_version,
&dev_attr_fw_version,
&dev_attr_serial_num,
&dev_attr_isp_name,
&dev_attr_isp_id,
&dev_attr_model_name,
&dev_attr_model_desc,
&dev_attr_pci_info,
&dev_attr_state,
&dev_attr_zio,
&dev_attr_zio_timer,
&dev_attr_beacon,
&dev_attr_optrom_bios_version,
&dev_attr_optrom_efi_version,
&dev_attr_optrom_fcode_version,
&dev_attr_optrom_fw_version,
NULL,
};
......
......@@ -347,8 +347,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
/*
* Global Function Prototypes in qla_attr.c source file.
*/
struct class_device_attribute;
extern struct class_device_attribute *qla2x00_host_attrs[];
struct device_attribute;
extern struct device_attribute *qla2x00_host_attrs[];
struct fc_function_template;
extern struct fc_function_template qla2xxx_transport_functions;
extern struct fc_function_template qla2xxx_transport_vport_functions;
......
......@@ -24,15 +24,15 @@ struct raid_internal {
struct raid_template r;
struct raid_function_template *f;
/* The actual attributes */
struct class_device_attribute private_attrs[RAID_NUM_ATTRS];
struct device_attribute private_attrs[RAID_NUM_ATTRS];
/* The array of null terminated pointers to attributes
* needed by scsi_sysfs.c */
struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1];
struct device_attribute *attrs[RAID_NUM_ATTRS + 1];
};
struct raid_component {
struct list_head node;
struct class_device cdev;
struct device dev;
int num;
};
......@@ -50,9 +50,9 @@ struct raid_component {
tc_to_raid_internal(tc); \
})
#define class_device_to_raid_internal(cdev) ({ \
#define device_to_raid_internal(dev) ({ \
struct attribute_container *ac = \
attribute_container_classdev_to_container(cdev); \
attribute_container_classdev_to_container(dev); \
ac_to_raid_internal(ac); \
})
......@@ -76,33 +76,33 @@ static int raid_match(struct attribute_container *cont, struct device *dev)
}
static int raid_setup(struct transport_container *tc, struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
struct raid_data *rd;
BUG_ON(class_get_devdata(cdev));
BUG_ON(dev_get_drvdata(cdev));
rd = kzalloc(sizeof(*rd), GFP_KERNEL);
if (!rd)
return -ENOMEM;
INIT_LIST_HEAD(&rd->component_list);
class_set_devdata(cdev, rd);
dev_set_drvdata(cdev, rd);
return 0;
}
static int raid_remove(struct transport_container *tc, struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
struct raid_data *rd = class_get_devdata(cdev);
struct raid_data *rd = dev_get_drvdata(cdev);
struct raid_component *rc, *next;
dev_printk(KERN_ERR, dev, "RAID REMOVE\n");
class_set_devdata(cdev, NULL);
dev_set_drvdata(cdev, NULL);
list_for_each_entry_safe(rc, next, &rd->component_list, node) {
list_del(&rc->node);
dev_printk(KERN_ERR, rc->cdev.dev, "RAID COMPONENT REMOVE\n");
class_device_unregister(&rc->cdev);
dev_printk(KERN_ERR, rc->dev.parent, "RAID COMPONENT REMOVE\n");
device_unregister(&rc->dev);
}
dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n");
kfree(rd);
......@@ -171,9 +171,11 @@ static const char *raid_level_name(enum raid_level level)
}
#define raid_attr_show_internal(attr, fmt, var, code) \
static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \
static ssize_t raid_show_##attr(struct device *dev, \
struct device_attribute *attr, \
char *buf) \
{ \
struct raid_data *rd = class_get_devdata(cdev); \
struct raid_data *rd = dev_get_drvdata(dev); \
code \
return snprintf(buf, 20, #fmt "\n", var); \
}
......@@ -184,17 +186,17 @@ raid_attr_show_internal(attr, %s, name, \
code \
name = raid_##states##_name(rd->attr); \
) \
static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
#define raid_attr_ro_internal(attr, code) \
raid_attr_show_internal(attr, %d, rd->attr, code) \
static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
#define ATTR_CODE(attr) \
struct raid_internal *i = class_device_to_raid_internal(cdev); \
struct raid_internal *i = device_to_raid_internal(dev); \
if (i->f->get_##attr) \
i->f->get_##attr(cdev->dev);
i->f->get_##attr(dev->parent);
#define raid_attr_ro(attr) raid_attr_ro_internal(attr, )
#define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr))
......@@ -206,23 +208,23 @@ raid_attr_ro_state(level);
raid_attr_ro_fn(resync);
raid_attr_ro_state_fn(state);
static void raid_component_release(struct class_device *cdev)
static void raid_component_release(struct device *dev)
{
struct raid_component *rc = container_of(cdev, struct raid_component,
cdev);
dev_printk(KERN_ERR, rc->cdev.dev, "COMPONENT RELEASE\n");
put_device(rc->cdev.dev);
struct raid_component *rc =
container_of(dev, struct raid_component, dev);
dev_printk(KERN_ERR, rc->dev.parent, "COMPONENT RELEASE\n");
put_device(rc->dev.parent);
kfree(rc);
}
int raid_component_add(struct raid_template *r,struct device *raid_dev,
struct device *component_dev)
{
struct class_device *cdev =
struct device *cdev =
attribute_container_find_class_device(&r->raid_attrs.ac,
raid_dev);
struct raid_component *rc;
struct raid_data *rd = class_get_devdata(cdev);
struct raid_data *rd = dev_get_drvdata(cdev);
int err;
rc = kzalloc(sizeof(*rc), GFP_KERNEL);
......@@ -230,17 +232,16 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev,
return -ENOMEM;
INIT_LIST_HEAD(&rc->node);
class_device_initialize(&rc->cdev);
rc->cdev.release = raid_component_release;
rc->cdev.dev = get_device(component_dev);
device_initialize(&rc->dev);
rc->dev.release = raid_component_release;
rc->dev.parent = get_device(component_dev);
rc->num = rd->component_count++;
snprintf(rc->cdev.class_id, sizeof(rc->cdev.class_id),
snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id),
"component-%d", rc->num);
list_add_tail(&rc->node, &rd->component_list);
rc->cdev.parent = cdev;
rc->cdev.class = &raid_class.class;
err = class_device_add(&rc->cdev);
rc->dev.class = &raid_class.class;
err = device_add(&rc->dev);
if (err)
goto err_out;
......@@ -273,9 +274,9 @@ raid_class_attach(struct raid_function_template *ft)
attribute_container_register(&i->r.raid_attrs.ac);
i->attrs[count++] = &class_device_attr_level;
i->attrs[count++] = &class_device_attr_resync;
i->attrs[count++] = &class_device_attr_state;
i->attrs[count++] = &dev_attr_level;
i->attrs[count++] = &dev_attr_resync;
i->attrs[count++] = &dev_attr_state;
i->attrs[count] = NULL;
BUG_ON(count > RAID_NUM_ATTRS);
......
......@@ -13,12 +13,12 @@ struct sas_internal {
struct sas_function_template *f;
struct sas_domain_function_template *dft;
struct class_device_attribute private_host_attrs[SAS_HOST_ATTRS];
struct class_device_attribute private_phy_attrs[SAS_PHY_ATTRS];
struct class_device_attribute private_port_attrs[SAS_PORT_ATTRS];
struct class_device_attribute private_rphy_attrs[SAS_RPORT_ATTRS];
struct class_device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS];
struct class_device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS];
struct device_attribute private_host_attrs[SAS_HOST_ATTRS];
struct device_attribute private_phy_attrs[SAS_PHY_ATTRS];
struct device_attribute private_port_attrs[SAS_PORT_ATTRS];
struct device_attribute private_rphy_attrs[SAS_RPORT_ATTRS];
struct device_attribute private_end_dev_attrs[SAS_END_DEV_ATTRS];
struct device_attribute private_expander_attrs[SAS_EXPANDER_ATTRS];
struct transport_container phy_attr_cont;
struct transport_container port_attr_cont;
......@@ -30,12 +30,12 @@ struct sas_internal {
* The array of null terminated pointers to attributes
* needed by scsi_sysfs.c
*/
struct class_device_attribute *host_attrs[SAS_HOST_ATTRS + 1];
struct class_device_attribute *phy_attrs[SAS_PHY_ATTRS + 1];
struct class_device_attribute *port_attrs[SAS_PORT_ATTRS + 1];
struct class_device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1];
struct class_device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1];
struct class_device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1];
struct device_attribute *host_attrs[SAS_HOST_ATTRS + 1];
struct device_attribute *phy_attrs[SAS_PHY_ATTRS + 1];
struct device_attribute *port_attrs[SAS_PORT_ATTRS + 1];
struct device_attribute *rphy_attrs[SAS_RPORT_ATTRS + 1];
struct device_attribute *end_dev_attrs[SAS_END_DEV_ATTRS + 1];
struct device_attribute *expander_attrs[SAS_EXPANDER_ATTRS + 1];
};
#define to_sas_internal(tmpl) container_of(tmpl, struct sas_internal, t)
......
......@@ -119,9 +119,10 @@ static int scsi_scan(struct Scsi_Host *shost, const char *str)
*/
#define shost_show_function(name, field, format_string) \
static ssize_t \
show_##name (struct class_device *class_dev, char *buf) \
show_##name (struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
struct Scsi_Host *shost = class_to_shost(class_dev); \
struct Scsi_Host *shost = class_to_shost(dev); \
return snprintf (buf, 20, format_string, shost->field); \
}
......@@ -131,7 +132,7 @@ show_##name (struct class_device *class_dev, char *buf) \
*/
#define shost_rd_attr2(name, field, format_string) \
shost_show_function(name, field, format_string) \
static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
#define shost_rd_attr(field, format_string) \
shost_rd_attr2(field, field, format_string)
......@@ -140,10 +141,11 @@ shost_rd_attr2(field, field, format_string)
* Create the actual show/store functions and data structures.
*/
static ssize_t store_scan(struct class_device *class_dev, const char *buf,
size_t count)
static ssize_t
store_scan(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
int res;
res = scsi_scan(shost, buf);
......@@ -151,13 +153,14 @@ static ssize_t store_scan(struct class_device *class_dev, const char *buf,
res = count;
return res;
};
static CLASS_DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
static DEVICE_ATTR(scan, S_IWUSR, NULL, store_scan);
static ssize_t
store_shost_state(struct class_device *class_dev, const char *buf, size_t count)
store_shost_state(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int i;
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
enum scsi_host_state state = 0;
for (i = 0; i < ARRAY_SIZE(shost_states); i++) {
......@@ -177,9 +180,9 @@ store_shost_state(struct class_device *class_dev, const char *buf, size_t count)
}
static ssize_t
show_shost_state(struct class_device *class_dev, char *buf)
show_shost_state(struct device *dev, struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
const char *name = scsi_host_state_name(shost->shost_state);
if (!name)
......@@ -188,7 +191,9 @@ show_shost_state(struct class_device *class_dev, char *buf)
return snprintf(buf, 20, "%s\n", name);
}
static CLASS_DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
/* DEVICE_ATTR(state) clashes with dev_attr_state for sdev */
struct device_attribute dev_attr_hstate =
__ATTR(state, S_IRUGO | S_IWUSR, show_shost_state, store_shost_state);
static ssize_t
show_shost_mode(unsigned int mode, char *buf)
......@@ -206,9 +211,11 @@ show_shost_mode(unsigned int mode, char *buf)
return len;
}
static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *buf)
static ssize_t
show_shost_supported_mode(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
unsigned int supported_mode = shost->hostt->supported_mode;
if (supported_mode == MODE_UNKNOWN)
......@@ -218,11 +225,13 @@ static ssize_t show_shost_supported_mode(struct class_device *class_dev, char *b
return show_shost_mode(supported_mode, buf);
}
static CLASS_DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
static DEVICE_ATTR(supported_mode, S_IRUGO | S_IWUSR, show_shost_supported_mode, NULL);
static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf)
static ssize_t
show_shost_active_mode(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct Scsi_Host *shost = class_to_shost(class_dev);
struct Scsi_Host *shost = class_to_shost(dev);
if (shost->active_mode == MODE_UNKNOWN)
return snprintf(buf, 20, "unknown\n");
......@@ -230,7 +239,7 @@ static ssize_t show_shost_active_mode(struct class_device *class_dev, char *buf)
return show_shost_mode(shost->active_mode, buf);
}
static CLASS_DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL);
shost_rd_attr(unique_id, "%u\n");
shost_rd_attr(host_busy, "%hu\n");
......@@ -240,22 +249,22 @@ shost_rd_attr(sg_tablesize, "%hu\n");
shost_rd_attr(unchecked_isa_dma, "%d\n");
shost_rd_attr2(proc_name, hostt->proc_name, "%s\n");
static struct class_device_attribute *scsi_sysfs_shost_attrs[] = {
&class_device_attr_unique_id,
&class_device_attr_host_busy,
&class_device_attr_cmd_per_lun,
&class_device_attr_can_queue,
&class_device_attr_sg_tablesize,
&class_device_attr_unchecked_isa_dma,
&class_device_attr_proc_name,
&class_device_attr_scan,
&class_device_attr_state,
&class_device_attr_supported_mode,
&class_device_attr_active_mode,
static struct device_attribute *scsi_sysfs_shost_attrs[] = {
&dev_attr_unique_id,
&dev_attr_host_busy,
&dev_attr_cmd_per_lun,
&dev_attr_can_queue,
&dev_attr_sg_tablesize,
&dev_attr_unchecked_isa_dma,
&dev_attr_proc_name,
&dev_attr_scan,
&dev_attr_hstate,
&dev_attr_supported_mode,
&dev_attr_active_mode,
NULL
};
static void scsi_device_cls_release(struct class_device *class_dev)
static void scsi_device_cls_release(struct device *class_dev)
{
struct scsi_device *sdev;
......@@ -320,7 +329,7 @@ static void scsi_device_dev_release(struct device *dev)
static struct class sdev_class = {
.name = "scsi_device",
.release = scsi_device_cls_release,
.dev_release = scsi_device_cls_release,
};
/* all probing is done in the individual ->probe routines */
......@@ -424,7 +433,8 @@ void scsi_sysfs_unregister(void)
*/
#define sdev_show_function(field, format_string) \
static ssize_t \
sdev_show_##field (struct device *dev, struct device_attribute *attr, char *buf) \
sdev_show_##field (struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
struct scsi_device *sdev; \
sdev = to_scsi_device(dev); \
......@@ -448,7 +458,8 @@ static DEVICE_ATTR(field, S_IRUGO, sdev_show_##field, NULL);
sdev_show_function(field, format_string) \
\
static ssize_t \
sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
sdev_store_##field (struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
struct scsi_device *sdev; \
sdev = to_scsi_device(dev); \
......@@ -468,7 +479,8 @@ static DEVICE_ATTR(field, S_IRUGO | S_IWUSR, sdev_show_##field, sdev_store_##fie
sdev_show_function(field, "%d\n") \
\
static ssize_t \
sdev_store_##field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \
sdev_store_##field (struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
int ret; \
struct scsi_device *sdev; \
......@@ -519,7 +531,8 @@ sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf)
}
static ssize_t
sdev_store_timeout (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
sdev_store_timeout (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct scsi_device *sdev;
int timeout;
......@@ -531,7 +544,8 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr, const cha
static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
static ssize_t
store_rescan_field (struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
store_rescan_field (struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
scsi_rescan_device(dev);
return count;
......@@ -543,8 +557,9 @@ static void sdev_store_delete_callback(struct device *dev)
scsi_remove_device(to_scsi_device(dev));
}
static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *attr, const char *buf,
size_t count)
static ssize_t
sdev_store_delete(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int rc;
......@@ -559,7 +574,8 @@ static ssize_t sdev_store_delete(struct device *dev, struct device_attribute *at
static DEVICE_ATTR(delete, S_IWUSR, NULL, sdev_store_delete);
static ssize_t
store_state_field(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
store_state_field(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int i;
struct scsi_device *sdev = to_scsi_device(dev);
......@@ -596,7 +612,8 @@ show_state_field(struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field, store_state_field);
static ssize_t
show_queue_type_field(struct device *dev, struct device_attribute *attr, char *buf)
show_queue_type_field(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct scsi_device *sdev = to_scsi_device(dev);
const char *name = "none";
......@@ -612,7 +629,7 @@ show_queue_type_field(struct device *dev, struct device_attribute *attr, char *b
static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);
static ssize_t
show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf)
show_iostat_counterbits(struct device *dev, struct device_attribute *attr, char *buf)
{
return snprintf(buf, 20, "%d\n", (int)sizeof(atomic_t) * 8);
}
......@@ -621,7 +638,8 @@ static DEVICE_ATTR(iocounterbits, S_IRUGO, show_iostat_counterbits, NULL);
#define show_sdev_iostat(field) \
static ssize_t \
show_iostat_##field(struct device *dev, struct device_attribute *attr, char *buf) \
show_iostat_##field(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
struct scsi_device *sdev = to_scsi_device(dev); \
unsigned long long count = atomic_read(&sdev->field); \
......@@ -645,7 +663,7 @@ static DEVICE_ATTR(modalias, S_IRUGO, sdev_show_modalias, NULL);
#define DECLARE_EVT_SHOW(name, Cap_name) \
static ssize_t \
sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \
char *buf) \
char *buf) \
{ \
struct scsi_device *sdev = to_scsi_device(dev); \
int val = test_bit(SDEV_EVT_##Cap_name, sdev->supported_events);\
......@@ -654,7 +672,7 @@ sdev_show_evt_##name(struct device *dev, struct device_attribute *attr, \
#define DECLARE_EVT_STORE(name, Cap_name) \
static ssize_t \
sdev_store_evt_##name(struct device *dev, struct device_attribute *attr, \
sdev_store_evt_##name(struct device *dev, struct device_attribute *attr,\
const char *buf, size_t count) \
{ \
struct scsi_device *sdev = to_scsi_device(dev); \
......@@ -707,8 +725,9 @@ static struct attribute_group *scsi_sdev_attr_groups[] = {
NULL
};
static ssize_t sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr, const char *buf,
size_t count)
static ssize_t
sdev_store_queue_depth_rw(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int depth, retval;
struct scsi_device *sdev = to_scsi_device(dev);
......@@ -733,8 +752,9 @@ static struct device_attribute sdev_attr_queue_depth_rw =
__ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth,
sdev_store_queue_depth_rw);
static ssize_t sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr, const char *buf,
size_t count)
static ssize_t
sdev_store_queue_type_rw(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct scsi_device *sdev = to_scsi_device(dev);
struct scsi_host_template *sht = sdev->host->hostt;
......@@ -786,13 +806,13 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
printk(KERN_INFO "error 1\n");
return error;
}
error = class_device_add(&sdev->sdev_classdev);
error = device_add(&sdev->sdev_dev);
if (error) {
printk(KERN_INFO "error 2\n");
goto clean_device;
}
/* take a reference for the sdev_classdev; this is
/* take a reference for the sdev_dev; this is
* released by the sdev_class .release */
get_device(&sdev->sdev_gendev);
......@@ -858,7 +878,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
return;
bsg_unregister_queue(sdev->request_queue);
class_device_unregister(&sdev->sdev_classdev);
device_unregister(&sdev->sdev_dev);
transport_remove_device(dev);
device_del(dev);
scsi_device_set_state(sdev, SDEV_DEL);
......@@ -952,9 +972,9 @@ int scsi_register_interface(struct class_interface *intf)
EXPORT_SYMBOL(scsi_register_interface);
static struct class_device_attribute *class_attr_overridden(
struct class_device_attribute **attrs,
struct class_device_attribute *attr)
static struct device_attribute *class_attr_overridden(
struct device_attribute **attrs,
struct device_attribute *attr)
{
int i;
......@@ -966,10 +986,10 @@ static struct class_device_attribute *class_attr_overridden(
return NULL;
}
static int class_attr_add(struct class_device *classdev,
struct class_device_attribute *attr)
static int class_attr_add(struct device *classdev,
struct device_attribute *attr)
{
struct class_device_attribute *base_attr;
struct device_attribute *base_attr;
/*
* Spare the caller from having to copy things it's not interested in.
......@@ -986,7 +1006,7 @@ static int class_attr_add(struct class_device *classdev,
attr->store = base_attr->store;
}
return class_device_create_file(classdev, attr);
return device_create_file(classdev, attr);
}
/**
......@@ -1000,7 +1020,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
if (shost->hostt->shost_attrs) {
for (i = 0; shost->hostt->shost_attrs[i]; i++) {
error = class_attr_add(&shost->shost_classdev,
error = class_attr_add(&shost->shost_dev,
shost->hostt->shost_attrs[i]);
if (error)
return error;
......@@ -1010,7 +1030,7 @@ int scsi_sysfs_add_host(struct Scsi_Host *shost)
for (i = 0; scsi_sysfs_shost_attrs[i]; i++) {
if (!class_attr_overridden(shost->hostt->shost_attrs,
scsi_sysfs_shost_attrs[i])) {
error = class_device_create_file(&shost->shost_classdev,
error = device_create_file(&shost->shost_dev,
scsi_sysfs_shost_attrs[i]);
if (error)
return error;
......@@ -1041,10 +1061,10 @@ void scsi_sysfs_device_initialize(struct scsi_device *sdev)
sdev->host->host_no, sdev->channel, sdev->id,
sdev->lun);
class_device_initialize(&sdev->sdev_classdev);
sdev->sdev_classdev.dev = &sdev->sdev_gendev;
sdev->sdev_classdev.class = &sdev_class;
snprintf(sdev->sdev_classdev.class_id, BUS_ID_SIZE,
device_initialize(&sdev->sdev_dev);
sdev->sdev_dev.parent = &sdev->sdev_gendev;
sdev->sdev_dev.class = &sdev_class;
snprintf(sdev->sdev_dev.bus_id, BUS_ID_SIZE,
"%d:%d:%d:%d", sdev->host->host_no,
sdev->channel, sdev->id, sdev->lun);
sdev->scsi_level = starget->scsi_level;
......
此差异已折叠。
......@@ -40,13 +40,13 @@ struct iscsi_internal {
struct scsi_transport_template t;
struct iscsi_transport *iscsi_transport;
struct list_head list;
struct class_device cdev;
struct device dev;
struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1];
struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1];
struct transport_container conn_cont;
struct class_device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1];
struct device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1];
struct transport_container session_cont;
struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
struct device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
};
static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
......@@ -63,12 +63,12 @@ static DEFINE_SPINLOCK(iscsi_transport_lock);
#define to_iscsi_internal(tmpl) \
container_of(tmpl, struct iscsi_internal, t)
#define cdev_to_iscsi_internal(_cdev) \
container_of(_cdev, struct iscsi_internal, cdev)
#define dev_to_iscsi_internal(_dev) \
container_of(_dev, struct iscsi_internal, dev)
static void iscsi_transport_release(struct class_device *cdev)
static void iscsi_transport_release(struct device *dev)
{
struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev);
struct iscsi_internal *priv = dev_to_iscsi_internal(dev);
kfree(priv);
}
......@@ -78,25 +78,27 @@ static void iscsi_transport_release(struct class_device *cdev)
*/
static struct class iscsi_transport_class = {
.name = "iscsi_transport",
.release = iscsi_transport_release,
.dev_release = iscsi_transport_release,
};
static ssize_t
show_transport_handle(struct class_device *cdev, char *buf)
show_transport_handle(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev);
struct iscsi_internal *priv = dev_to_iscsi_internal(dev);
return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport));
}
static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL);
static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL);
#define show_transport_attr(name, format) \
static ssize_t \
show_transport_##name(struct class_device *cdev, char *buf) \
show_transport_##name(struct device *dev, \
struct device_attribute *attr,char *buf) \
{ \
struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); \
struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \
return sprintf(buf, format"\n", priv->iscsi_transport->name); \
} \
static CLASS_DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);
static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);
show_transport_attr(caps, "0x%x");
show_transport_attr(max_lun, "%d");
......@@ -104,11 +106,11 @@ show_transport_attr(max_conn, "%d");
show_transport_attr(max_cmd_len, "%d");
static struct attribute *iscsi_transport_attrs[] = {
&class_device_attr_handle.attr,
&class_device_attr_caps.attr,
&class_device_attr_max_lun.attr,
&class_device_attr_max_conn.attr,
&class_device_attr_max_cmd_len.attr,
&dev_attr_handle.attr,
&dev_attr_caps.attr,
&dev_attr_max_lun.attr,
&dev_attr_max_conn.attr,
&dev_attr_max_cmd_len.attr,
NULL,
};
......@@ -119,7 +121,7 @@ static struct attribute_group iscsi_transport_group = {
static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
struct Scsi_Host *shost = dev_to_shost(dev);
struct iscsi_host *ihost = shost->shost_data;
......@@ -139,7 +141,7 @@ static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
}
static int iscsi_remove_host(struct transport_container *tc, struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
struct Scsi_Host *shost = dev_to_shost(dev);
struct iscsi_host *ihost = shost->shost_data;
......@@ -1337,11 +1339,8 @@ iscsi_if_rx(struct sk_buff *skb)
mutex_unlock(&rx_queue_mutex);
}
#define iscsi_cdev_to_conn(_cdev) \
iscsi_dev_to_conn(_cdev->dev)
#define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \
struct class_device_attribute class_device_attr_##_prefix##_##_name = \
struct device_attribute dev_attr_##_prefix##_##_name = \
__ATTR(_name,_mode,_show,_store)
/*
......@@ -1349,9 +1348,10 @@ struct class_device_attribute class_device_attr_##_prefix##_##_name = \
*/
#define iscsi_conn_attr_show(param) \
static ssize_t \
show_conn_param_##param(struct class_device *cdev, char *buf) \
show_conn_param_##param(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \
struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \
struct iscsi_transport *t = conn->transport; \
return t->get_conn_param(conn, param, buf); \
}
......@@ -1375,17 +1375,16 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
#define iscsi_cdev_to_session(_cdev) \
iscsi_dev_to_session(_cdev->dev)
/*
* iSCSI session attrs
*/
#define iscsi_session_attr_show(param, perm) \
static ssize_t \
show_session_param_##param(struct class_device *cdev, char *buf) \
show_session_param_##param(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \
struct iscsi_cls_session *session = \
iscsi_dev_to_session(dev->parent); \
struct iscsi_transport *t = session->transport; \
\
if (perm && !capable(CAP_SYS_ADMIN)) \
......@@ -1417,9 +1416,10 @@ iscsi_session_attr(abort_tmo, ISCSI_PARAM_ABORT_TMO, 0);
iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0);
static ssize_t
show_priv_session_state(struct class_device *cdev, char *buf)
show_priv_session_state(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);
struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent);
return sprintf(buf, "%s\n", iscsi_session_state_name(session->state));
}
static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state,
......@@ -1427,9 +1427,11 @@ static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state,
#define iscsi_priv_session_attr_show(field, format) \
static ssize_t \
show_priv_session_##field(struct class_device *cdev, char *buf) \
show_priv_session_##field(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\
struct iscsi_cls_session *session = \
iscsi_dev_to_session(dev->parent); \
return sprintf(buf, format"\n", session->field); \
}
......@@ -1444,9 +1446,10 @@ iscsi_priv_session_attr(recovery_tmo, "%d");
*/
#define iscsi_host_attr_show(param) \
static ssize_t \
show_host_param_##param(struct class_device *cdev, char *buf) \
show_host_param_##param(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct Scsi_Host *shost = transport_class_to_shost(cdev); \
struct Scsi_Host *shost = transport_class_to_shost(dev); \
struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \
return priv->iscsi_transport->get_host_param(shost, param, buf); \
}
......@@ -1463,7 +1466,7 @@ iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME);
#define SETUP_PRIV_SESSION_RD_ATTR(field) \
do { \
priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \
priv->session_attrs[count] = &dev_attr_priv_sess_##field; \
count++; \
} while (0)
......@@ -1471,7 +1474,7 @@ do { \
#define SETUP_SESSION_RD_ATTR(field, param_flag) \
do { \
if (tt->param_mask & param_flag) { \
priv->session_attrs[count] = &class_device_attr_sess_##field; \
priv->session_attrs[count] = &dev_attr_sess_##field; \
count++; \
} \
} while (0)
......@@ -1479,7 +1482,7 @@ do { \
#define SETUP_CONN_RD_ATTR(field, param_flag) \
do { \
if (tt->param_mask & param_flag) { \
priv->conn_attrs[count] = &class_device_attr_conn_##field; \
priv->conn_attrs[count] = &dev_attr_conn_##field; \
count++; \
} \
} while (0)
......@@ -1487,7 +1490,7 @@ do { \
#define SETUP_HOST_RD_ATTR(field, param_flag) \
do { \
if (tt->host_param_mask & param_flag) { \
priv->host_attrs[count] = &class_device_attr_host_##field; \
priv->host_attrs[count] = &dev_attr_host_##field; \
count++; \
} \
} while (0)
......@@ -1578,15 +1581,15 @@ iscsi_register_transport(struct iscsi_transport *tt)
priv->iscsi_transport = tt;
priv->t.user_scan = iscsi_user_scan;
priv->cdev.class = &iscsi_transport_class;
snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name);
err = class_device_register(&priv->cdev);
priv->dev.class = &iscsi_transport_class;
snprintf(priv->dev.bus_id, BUS_ID_SIZE, "%s", tt->name);
err = device_register(&priv->dev);
if (err)
goto free_priv;
err = sysfs_create_group(&priv->cdev.kobj, &iscsi_transport_group);
err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
if (err)
goto unregister_cdev;
goto unregister_dev;
/* host parameters */
priv->t.host_attrs.ac.attrs = &priv->host_attrs[0];
......@@ -1663,8 +1666,8 @@ iscsi_register_transport(struct iscsi_transport *tt)
printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name);
return &priv->t;
unregister_cdev:
class_device_unregister(&priv->cdev);
unregister_dev:
device_unregister(&priv->dev);
free_priv:
kfree(priv);
return NULL;
......@@ -1691,8 +1694,8 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
transport_container_unregister(&priv->session_cont);
transport_container_unregister(&priv->t.host_attrs);
sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group);
class_device_unregister(&priv->cdev);
sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group);
device_unregister(&priv->dev);
mutex_unlock(&rx_queue_mutex);
return 0;
......
此差异已折叠。
此差异已折叠。
......@@ -44,20 +44,20 @@ struct srp_internal {
struct scsi_transport_template t;
struct srp_function_template *f;
struct class_device_attribute *host_attrs[SRP_HOST_ATTRS + 1];
struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1];
struct class_device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1];
struct class_device_attribute private_rport_attrs[SRP_RPORT_ATTRS];
struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1];
struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS];
struct transport_container rport_attr_cont;
};
#define to_srp_internal(tmpl) container_of(tmpl, struct srp_internal, t)
#define dev_to_rport(d) container_of(d, struct srp_rport, dev)
#define transport_class_to_srp_rport(cdev) dev_to_rport((cdev)->dev)
#define transport_class_to_srp_rport(dev) dev_to_rport((dev)->parent)
static int srp_host_setup(struct transport_container *tc, struct device *dev,
struct class_device *cdev)
struct device *cdev)
{
struct Scsi_Host *shost = dev_to_shost(dev);
struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
......@@ -73,7 +73,7 @@ static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
NULL, NULL, NULL);
#define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm) \
i->private_##attrb[count] = class_device_attr_##field; \
i->private_##attrb[count] = dev_attr_##field; \
i->private_##attrb[count].attr.mode = perm; \
if (ro_test) { \
i->private_##attrb[count].attr.mode = ro_perm; \
......@@ -100,13 +100,14 @@ static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
static ssize_t
show_srp_rport_id(struct class_device *cdev, char *buf)
show_srp_rport_id(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_rport *rport = transport_class_to_srp_rport(cdev);
struct srp_rport *rport = transport_class_to_srp_rport(dev);
return sprintf(buf, SRP_PID_FMT "\n", SRP_PID(rport));
}
static CLASS_DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
static DEVICE_ATTR(port_id, S_IRUGO, show_srp_rport_id, NULL);
static const struct {
u32 value;
......@@ -117,9 +118,10 @@ static const struct {
};
static ssize_t
show_srp_rport_roles(struct class_device *cdev, char *buf)
show_srp_rport_roles(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct srp_rport *rport = transport_class_to_srp_rport(cdev);
struct srp_rport *rport = transport_class_to_srp_rport(dev);
int i;
char *name = NULL;
......@@ -131,7 +133,7 @@ show_srp_rport_roles(struct class_device *cdev, char *buf)
return sprintf(buf, "%s\n", name ? : "unknown");
}
static CLASS_DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL);
static DEVICE_ATTR(roles, S_IRUGO, show_srp_rport_roles, NULL);
static void srp_rport_release(struct device *dev)
{
......
此差异已折叠。
......@@ -107,7 +107,7 @@ static int ses_set_page2_descriptor(struct enclosure_device *edev,
unsigned char *desc)
{
int i, j, count = 0, descriptor = ecomp->number;
struct scsi_device *sdev = to_scsi_device(edev->cdev.dev);
struct scsi_device *sdev = to_scsi_device(edev->edev.parent);
struct ses_device *ses_dev = edev->scratch;
unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11];
unsigned char *desc_ptr = ses_dev->page2 + 8;
......@@ -137,7 +137,7 @@ static unsigned char *ses_get_page2_descriptor(struct enclosure_device *edev,
struct enclosure_component *ecomp)
{
int i, j, count = 0, descriptor = ecomp->number;
struct scsi_device *sdev = to_scsi_device(edev->cdev.dev);
struct scsi_device *sdev = to_scsi_device(edev->edev.parent);
struct ses_device *ses_dev = edev->scratch;
unsigned char *type_ptr = ses_dev->page1 + 12 + ses_dev->page1[11];
unsigned char *desc_ptr = ses_dev->page2 + 8;
......@@ -269,10 +269,10 @@ int ses_match_host(struct enclosure_device *edev, void *data)
struct ses_host_edev *sed = data;
struct scsi_device *sdev;
if (!scsi_is_sdev_device(edev->cdev.dev))
if (!scsi_is_sdev_device(edev->edev.parent))
return 0;
sdev = to_scsi_device(edev->cdev.dev);
sdev = to_scsi_device(edev->edev.parent);
if (sdev->host != sed->shost)
return 0;
......@@ -407,10 +407,10 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
#define INIT_ALLOC_SIZE 32
static int ses_intf_add(struct class_device *cdev,
static int ses_intf_add(struct device *cdev,
struct class_interface *intf)
{
struct scsi_device *sdev = to_scsi_device(cdev->dev);
struct scsi_device *sdev = to_scsi_device(cdev->parent);
struct scsi_device *tmp_sdev;
unsigned char *buf = NULL, *hdr_buf, *type_ptr, *desc_ptr = NULL,
*addl_desc_ptr = NULL;
......@@ -426,7 +426,7 @@ static int ses_intf_add(struct class_device *cdev,
edev = enclosure_find(&sdev->host->shost_gendev);
if (edev) {
ses_match_to_enclosure(edev, sdev);
class_device_put(&edev->cdev);
put_device(&edev->edev);
}
return -ENODEV;
}
......@@ -515,7 +515,7 @@ static int ses_intf_add(struct class_device *cdev,
if (!scomp)
goto err_free;
edev = enclosure_register(cdev->dev, sdev->sdev_gendev.bus_id,
edev = enclosure_register(cdev->parent, sdev->sdev_gendev.bus_id,
components, &ses_enclosure_callbacks);
if (IS_ERR(edev)) {
err = PTR_ERR(edev);
......@@ -625,17 +625,17 @@ static int ses_remove(struct device *dev)
return 0;
}
static void ses_intf_remove(struct class_device *cdev,
static void ses_intf_remove(struct device *cdev,
struct class_interface *intf)
{
struct scsi_device *sdev = to_scsi_device(cdev->dev);
struct scsi_device *sdev = to_scsi_device(cdev->parent);
struct enclosure_device *edev;
struct ses_device *ses_dev;
if (!scsi_device_enclosure(sdev))
return;
edev = enclosure_find(cdev->dev);
edev = enclosure_find(cdev->parent);
if (!edev)
return;
......@@ -649,13 +649,13 @@ static void ses_intf_remove(struct class_device *cdev,
kfree(edev->component[0].scratch);
class_device_put(&edev->cdev);
put_device(&edev->edev);
enclosure_unregister(edev);
}
static struct class_interface ses_interface = {
.add = ses_intf_add,
.remove = ses_intf_remove,
.add_dev = ses_intf_add,
.remove_dev = ses_intf_remove,
};
static struct scsi_driver ses_template = {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -55,7 +55,7 @@ struct sg_io_v4 {
#if defined(CONFIG_BLK_DEV_BSG)
struct bsg_class_device {
struct class_device *class_dev;
struct device *class_dev;
struct device *dev;
int minor;
struct request_queue *queue;
......
此差异已折叠。
......@@ -443,7 +443,7 @@ enum link_pm {
MAX_PERFORMANCE,
MEDIUM_POWER,
};
extern struct class_device_attribute class_device_attr_link_power_management_policy;
extern struct device_attribute dev_attr_link_power_management_policy;
#ifdef CONFIG_ATA_SFF
struct ata_ioports {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -80,7 +80,7 @@ struct scsi_transport_template {
};
#define transport_class_to_shost(tc) \
dev_to_shost((tc)->dev)
dev_to_shost((tc)->parent)
/* Private area maintenance. The driver requested allocations come
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部