Skip to content

Commit 25458eb

Browse files
Christof SchmittJames Bottomley
authored andcommitted
[SCSI] zfcp: Access ports and units with container_of in sysfs code
When accessing port and unit attributes, use container_of instead of dev_get_drvdata. This eliminates some code checker warnings about aliased access of data structures. Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent b42aece commit 25458eb

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

drivers/s390/scsi/zfcp_aux.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, u64 fcp_lun)
319319
kfree(unit);
320320
goto err_out;
321321
}
322-
dev_set_drvdata(&unit->sysfs_device, unit);
323322
retval = -EINVAL;
324323

325324
/* mark unit unusable as long as sysfs registration is not complete */
@@ -688,7 +687,6 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, u64 wwpn,
688687
kfree(port);
689688
goto err_out;
690689
}
691-
dev_set_drvdata(&port->sysfs_device, port);
692690
retval = -EINVAL;
693691

694692
if (device_register(&port->sysfs_device)) {

drivers/s390/scsi/zfcp_sysfs.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ static ssize_t zfcp_sysfs_##_feat##_##_name##_show(struct device *dev, \
1919
struct device_attribute *at,\
2020
char *buf) \
2121
{ \
22-
struct _feat_def *_feat = dev_get_drvdata(dev); \
22+
struct _feat_def *_feat = container_of(dev, struct _feat_def, \
23+
sysfs_device); \
2324
\
2425
return sprintf(buf, _format, _value); \
2526
} \
@@ -86,7 +87,8 @@ static ssize_t zfcp_sysfs_##_feat##_failed_show(struct device *dev, \
8687
struct device_attribute *attr, \
8788
char *buf) \
8889
{ \
89-
struct _feat_def *_feat = dev_get_drvdata(dev); \
90+
struct _feat_def *_feat = container_of(dev, struct _feat_def, \
91+
sysfs_device); \
9092
\
9193
if (atomic_read(&_feat->status) & ZFCP_STATUS_COMMON_ERP_FAILED) \
9294
return sprintf(buf, "1\n"); \
@@ -97,7 +99,8 @@ static ssize_t zfcp_sysfs_##_feat##_failed_store(struct device *dev, \
9799
struct device_attribute *attr,\
98100
const char *buf, size_t count)\
99101
{ \
100-
struct _feat_def *_feat = dev_get_drvdata(dev); \
102+
struct _feat_def *_feat = container_of(dev, struct _feat_def, \
103+
sysfs_device); \
101104
unsigned long val; \
102105
int retval = 0; \
103106
\
@@ -274,7 +277,8 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
274277
struct device_attribute *attr,
275278
const char *buf, size_t count)
276279
{
277-
struct zfcp_port *port = dev_get_drvdata(dev);
280+
struct zfcp_port *port = container_of(dev, struct zfcp_port,
281+
sysfs_device);
278282
struct zfcp_unit *unit;
279283
u64 fcp_lun;
280284
int retval = -EINVAL;
@@ -305,7 +309,8 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
305309
struct device_attribute *attr,
306310
const char *buf, size_t count)
307311
{
308-
struct zfcp_port *port = dev_get_drvdata(dev);
312+
struct zfcp_port *port = container_of(dev, struct zfcp_port,
313+
sysfs_device);
309314
struct zfcp_unit *unit;
310315
u64 fcp_lun;
311316
int retval = 0;

0 commit comments

Comments
 (0)