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