Skip to content

Commit

Permalink
[SCSI] zfcp: cleanup unit sysfs attribute usage
Browse files Browse the repository at this point in the history
Let the driver core handle device attribute creation and removal. This
will simplify the code and eliminates races between attribute
availability and userspace notification via uevents.

Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Sebastian Ott authored and James Bottomley committed May 31, 2013
1 parent 83d4e1c commit 86bdf21
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion drivers/s390/scsi/zfcp_ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void zfcp_ccw_remove(struct ccw_device *cdev)
zfcp_ccw_adapter_put(adapter); /* put from zfcp_ccw_adapter_by_cdev */

list_for_each_entry_safe(unit, u, &unit_remove_lh, list)
zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs);
device_unregister(&unit->dev);

list_for_each_entry_safe(port, p, &port_remove_lh, list)
device_unregister(&port->dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/s390/scsi/zfcp_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extern void zfcp_scsi_set_prot(struct zfcp_adapter *);
extern void zfcp_scsi_dif_sense_error(struct scsi_cmnd *, int);

/* zfcp_sysfs.c */
extern struct attribute_group zfcp_sysfs_unit_attrs;
extern const struct attribute_group *zfcp_unit_attr_groups[];
extern struct attribute_group zfcp_sysfs_adapter_attrs;
extern const struct attribute_group *zfcp_port_attr_groups[];
extern struct mutex zfcp_sysfs_port_units_mutex;
Expand Down
7 changes: 5 additions & 2 deletions drivers/s390/scsi/zfcp_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,13 @@ static struct attribute *zfcp_unit_attrs[] = {
&dev_attr_unit_access_readonly.attr,
NULL
};

struct attribute_group zfcp_sysfs_unit_attrs = {
static struct attribute_group zfcp_unit_attr_group = {
.attrs = zfcp_unit_attrs,
};
const struct attribute_group *zfcp_unit_attr_groups[] = {
&zfcp_unit_attr_group,
NULL,
};

#define ZFCP_DEFINE_LATENCY_ATTR(_name) \
static ssize_t \
Expand Down
9 changes: 2 additions & 7 deletions drivers/s390/scsi/zfcp_unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
unit->fcp_lun = fcp_lun;
unit->dev.parent = &port->dev;
unit->dev.release = zfcp_unit_release;
unit->dev.groups = zfcp_unit_attr_groups;
INIT_WORK(&unit->scsi_work, zfcp_unit_scsi_scan_work);

if (dev_set_name(&unit->dev, "0x%016llx",
Expand All @@ -160,12 +161,6 @@ int zfcp_unit_add(struct zfcp_port *port, u64 fcp_lun)
goto out;
}

if (sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs)) {
device_unregister(&unit->dev);
retval = -EINVAL;
goto out;
}

atomic_inc(&port->units); /* under zfcp_sysfs_port_units_mutex ! */

write_lock_irq(&port->unit_list_lock);
Expand Down Expand Up @@ -254,7 +249,7 @@ int zfcp_unit_remove(struct zfcp_port *port, u64 fcp_lun)

put_device(&unit->dev);

zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs);
device_unregister(&unit->dev);

return 0;
}

0 comments on commit 86bdf21

Please sign in to comment.