Commit 967f7bab authored by Dan Williams's avatar Dan Williams Committed by Christoph Hellwig

ses: add enclosure logical id

Export the NAA logical id for the enclosure.  This is optionally
available from the sas_transport_class, but it is really a property of
the enclosure.
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Reviewed-by: default avatarJens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 15a0fbbc
...@@ -432,8 +432,21 @@ static ssize_t components_show(struct device *cdev, ...@@ -432,8 +432,21 @@ static ssize_t components_show(struct device *cdev,
} }
static DEVICE_ATTR_RO(components); static DEVICE_ATTR_RO(components);
static ssize_t id_show(struct device *cdev,
struct device_attribute *attr,
char *buf)
{
struct enclosure_device *edev = to_enclosure_device(cdev);
if (edev->cb->show_id)
return edev->cb->show_id(edev, buf);
return -EINVAL;
}
static DEVICE_ATTR_RO(id);
static struct attribute *enclosure_class_attrs[] = { static struct attribute *enclosure_class_attrs[] = {
&dev_attr_components.attr, &dev_attr_components.attr,
&dev_attr_id.attr,
NULL, NULL,
}; };
ATTRIBUTE_GROUPS(enclosure_class); ATTRIBUTE_GROUPS(enclosure_class);
......
...@@ -258,6 +258,14 @@ static int ses_set_active(struct enclosure_device *edev, ...@@ -258,6 +258,14 @@ static int ses_set_active(struct enclosure_device *edev,
return ses_set_page2_descriptor(edev, ecomp, desc); return ses_set_page2_descriptor(edev, ecomp, desc);
} }
static int ses_show_id(struct enclosure_device *edev, char *buf)
{
struct ses_device *ses_dev = edev->scratch;
unsigned long long id = get_unaligned_be64(ses_dev->page1+8+4);
return sprintf(buf, "%#llx\n", id);
}
static struct enclosure_component_callbacks ses_enclosure_callbacks = { static struct enclosure_component_callbacks ses_enclosure_callbacks = {
.get_fault = ses_get_fault, .get_fault = ses_get_fault,
.set_fault = ses_set_fault, .set_fault = ses_set_fault,
...@@ -265,6 +273,7 @@ static struct enclosure_component_callbacks ses_enclosure_callbacks = { ...@@ -265,6 +273,7 @@ static struct enclosure_component_callbacks ses_enclosure_callbacks = {
.get_locate = ses_get_locate, .get_locate = ses_get_locate,
.set_locate = ses_set_locate, .set_locate = ses_set_locate,
.set_active = ses_set_active, .set_active = ses_set_active,
.show_id = ses_show_id,
}; };
struct ses_host_edev { struct ses_host_edev {
......
...@@ -79,6 +79,7 @@ struct enclosure_component_callbacks { ...@@ -79,6 +79,7 @@ struct enclosure_component_callbacks {
int (*set_locate)(struct enclosure_device *, int (*set_locate)(struct enclosure_device *,
struct enclosure_component *, struct enclosure_component *,
enum enclosure_component_setting); enum enclosure_component_setting);
int (*show_id)(struct enclosure_device *, char *buf);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment