Re: [PATCH 3/5] ses: add enclosure logical id

2015-01-10 Thread Hannes Reinecke
On 12/30/2014 11:46 PM, Song Liu wrote:
 From: Dan Williams dan.j.willi...@intel.com
 
 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: Dan Williams dan.j.willi...@intel.com
 Signed-off-by: Song Liu songliubrav...@fb.com
 Reviewed-by: Jens Axboe ax...@fb.com
 Cc: Hannes Reinecke h...@suse.de
Reviewed-by: Hannes Reinecke h...@suse.de

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] ses: add enclosure logical id

2014-12-30 Thread Song Liu
From: Dan Williams dan.j.willi...@intel.com

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: Dan Williams dan.j.willi...@intel.com
Signed-off-by: Song Liu songliubrav...@fb.com
Reviewed-by: Jens Axboe ax...@fb.com
Cc: Hannes Reinecke h...@suse.de
---
 drivers/misc/enclosure.c  | 13 +
 drivers/scsi/ses.c|  9 +
 include/linux/enclosure.h |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index d566f0f..ab4de85 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -432,8 +432,21 @@ static ssize_t components_show(struct device *cdev,
 }
 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[] = {
dev_attr_components.attr,
+   dev_attr_id.attr,
NULL,
 };
 ATTRIBUTE_GROUPS(enclosure_class);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 6662b0c..1041556 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -258,6 +258,14 @@ static int ses_set_active(struct enclosure_device *edev,
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 = {
.get_fault  = ses_get_fault,
.set_fault  = ses_set_fault,
@@ -265,6 +273,7 @@ static struct enclosure_component_callbacks 
ses_enclosure_callbacks = {
.get_locate = ses_get_locate,
.set_locate = ses_set_locate,
.set_active = ses_set_active,
+   .show_id= ses_show_id,
 };
 
 struct ses_host_edev {
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h
index a835d33..807622b 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -79,6 +79,7 @@ struct enclosure_component_callbacks {
int (*set_locate)(struct enclosure_device *,
  struct enclosure_component *,
  enum enclosure_component_setting);
+   int (*show_id)(struct enclosure_device *, char *buf);
 };
 
 
-- 
1.8.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 3/5] SES: add enclosure logical id

2014-09-12 Thread Song Liu
From 849dd255bdd2158cb621697e41448cf6b230d2f4 Mon Sep 17 00:00:00 2001
From: Dan Williams dan.j.willi...@intel.com
Date: Thu, 21 Aug 2014 11:43:24 -0700
Subject: [PATCH 3/5] 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: Dan Williams dan.j.willi...@intel.com
Signed-off-by: Song Liu songliubrav...@fb.com
Reviewed-by: Jens Axboe ax...@fb.com
Cc: Hannes Reinecke h...@suse.de
---
 drivers/misc/enclosure.c  | 13 +
 drivers/scsi/ses.c|  9 +
 include/linux/enclosure.h |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 15faf61..18b87de 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -395,8 +395,21 @@ static ssize_t components_show(struct device *cdev,
 }
 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[] = {
dev_attr_components.attr,
+   dev_attr_id.attr,
NULL,
 };
 ATTRIBUTE_GROUPS(enclosure_class);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index 87cf970b..696d5d8 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -258,6 +258,14 @@ static int ses_set_active(struct enclosure_device *edev,
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 = {
.get_fault  = ses_get_fault,
.set_fault  = ses_set_fault,
@@ -265,6 +273,7 @@ static struct enclosure_component_callbacks 
ses_enclosure_callbacks = {
.get_locate = ses_get_locate,
.set_locate = ses_set_locate,
.set_active = ses_set_active,
+   .show_id= ses_show_id,
 };
 
 struct ses_host_edev {
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h
index a835d33..807622b 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -79,6 +79,7 @@ struct enclosure_component_callbacks {
int (*set_locate)(struct enclosure_device *,
  struct enclosure_component *,
  enum enclosure_component_setting);
+   int (*show_id)(struct enclosure_device *, char *buf);
 };
 
 
-- 
1.8.1


 -Original Message-
 From: Hannes Reinecke [mailto:h...@suse.de]
 Sent: Thursday, September 4, 2014 12:55 AM
 To: Song Liu; linux-scsi@vger.kernel.org
 Cc: Dan Williams; Jens Axboe
 Subject: Re: [PATCH 3/5] SES: add enclosure logical id
 
 On 08/25/2014 07:34 PM, Song Liu wrote:
  From: Song Liu [mailto:songliubrav...@fb.com]
  Sent: Monday, August 25, 2014 10:26 AM
  To: Song Liu
  Cc: Dan Williams; Hannes Reinecke
  Subject: [PATCH 3/5] SES: add enclosure logical id
 
  From: Dan Williams dan.j.willi...@intel.com
 
  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: Dan Williams dan.j.willi...@intel.com
  Signed-off-by: Song Liu songliubrav...@fb.com
  Reviewed-by: Jens Axboe ax...@fb.com
  Cc: Hannes Reinecke h...@suse.de
  ---
   drivers/misc/enclosure.c  | 13 +
   drivers/scsi/ses.c|  9 +
   include/linux/enclosure.h |  1 +
   3 files changed, 23 insertions(+)
 
  diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index
  15faf61..646068a 100644
  --- a/drivers/misc/enclosure.c
  +++ b/drivers/misc/enclosure.c
  @@ -395,8 +395,21 @@ static ssize_t components_show(struct device
  *cdev,  }  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 0;
  +}
  +static DEVICE_ATTR_RO(id);
  +
   static struct attribute *enclosure_class_attrs[] = {
  dev_attr_components.attr,
  +   dev_attr_id.attr,
  NULL,
   };
   ATTRIBUTE_GROUPS(enclosure_class);
 
 Maybe you should return -EINVAL or something here; '0' would mean an
 enclosure id of length '0', which is a different meaning from 'enclosure id 
 not
 available'.
 
  diff --git

Re: [PATCH 3/5] SES: add enclosure logical id

2014-09-04 Thread Hannes Reinecke
On 08/25/2014 07:34 PM, Song Liu wrote:
 From: Song Liu [mailto:songliubrav...@fb.com] 
 Sent: Monday, August 25, 2014 10:26 AM
 To: Song Liu
 Cc: Dan Williams; Hannes Reinecke
 Subject: [PATCH 3/5] SES: add enclosure logical id
 
 From: Dan Williams dan.j.willi...@intel.com
 
 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: Dan Williams dan.j.willi...@intel.com
 Signed-off-by: Song Liu songliubrav...@fb.com
 Reviewed-by: Jens Axboe ax...@fb.com
 Cc: Hannes Reinecke h...@suse.de
 ---
  drivers/misc/enclosure.c  | 13 +
  drivers/scsi/ses.c|  9 +
  include/linux/enclosure.h |  1 +
  3 files changed, 23 insertions(+)
 
 diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 
 15faf61..646068a 100644
 --- a/drivers/misc/enclosure.c
 +++ b/drivers/misc/enclosure.c
 @@ -395,8 +395,21 @@ static ssize_t components_show(struct device *cdev,  }  
 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 0;
 +}
 +static DEVICE_ATTR_RO(id);
 +
  static struct attribute *enclosure_class_attrs[] = {
   dev_attr_components.attr,
 + dev_attr_id.attr,
   NULL,
  };
  ATTRIBUTE_GROUPS(enclosure_class);

Maybe you should return -EINVAL or something here; '0' would mean an
enclosure id of length '0', which is a different meaning from
'enclosure id not available'.

 diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 8f0a62a..61deb4e 
 100644
 --- a/drivers/scsi/ses.c
 +++ b/drivers/scsi/ses.c
 @@ -258,6 +258,14 @@ static int ses_set_active(struct enclosure_device *edev,
   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 = {
   .get_fault  = ses_get_fault,
   .set_fault  = ses_set_fault,
 @@ -265,6 +273,7 @@ static struct enclosure_component_callbacks 
 ses_enclosure_callbacks = {
   .get_locate = ses_get_locate,
   .set_locate = ses_set_locate,
   .set_active = ses_set_active,
 + .show_id= ses_show_id,
  };
  
  struct ses_host_edev {
 diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index 
 a835d33..807622b 100644
 --- a/include/linux/enclosure.h
 +++ b/include/linux/enclosure.h
 @@ -79,6 +79,7 @@ struct enclosure_component_callbacks {
   int (*set_locate)(struct enclosure_device *,
 struct enclosure_component *,
 enum enclosure_component_setting);
 + int (*show_id)(struct enclosure_device *, char *buf);
  };
  
  
 --
 1.8.1
 
Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries  Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/5] SES: add enclosure logical id

2014-08-25 Thread Song Liu
From: Song Liu [mailto:songliubrav...@fb.com] 
Sent: Monday, August 25, 2014 10:26 AM
To: Song Liu
Cc: Dan Williams; Hannes Reinecke
Subject: [PATCH 3/5] SES: add enclosure logical id

From: Dan Williams dan.j.willi...@intel.com

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: Dan Williams dan.j.willi...@intel.com
Signed-off-by: Song Liu songliubrav...@fb.com
Reviewed-by: Jens Axboe ax...@fb.com
Cc: Hannes Reinecke h...@suse.de
---
 drivers/misc/enclosure.c  | 13 +
 drivers/scsi/ses.c|  9 +
 include/linux/enclosure.h |  1 +
 3 files changed, 23 insertions(+)

diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c index 
15faf61..646068a 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -395,8 +395,21 @@ static ssize_t components_show(struct device *cdev,  }  
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 0;
+}
+static DEVICE_ATTR_RO(id);
+
 static struct attribute *enclosure_class_attrs[] = {
dev_attr_components.attr,
+   dev_attr_id.attr,
NULL,
 };
 ATTRIBUTE_GROUPS(enclosure_class);
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 8f0a62a..61deb4e 
100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -258,6 +258,14 @@ static int ses_set_active(struct enclosure_device *edev,
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 = {
.get_fault  = ses_get_fault,
.set_fault  = ses_set_fault,
@@ -265,6 +273,7 @@ static struct enclosure_component_callbacks 
ses_enclosure_callbacks = {
.get_locate = ses_get_locate,
.set_locate = ses_set_locate,
.set_active = ses_set_active,
+   .show_id= ses_show_id,
 };
 
 struct ses_host_edev {
diff --git a/include/linux/enclosure.h b/include/linux/enclosure.h index 
a835d33..807622b 100644
--- a/include/linux/enclosure.h
+++ b/include/linux/enclosure.h
@@ -79,6 +79,7 @@ struct enclosure_component_callbacks {
int (*set_locate)(struct enclosure_device *,
  struct enclosure_component *,
  enum enclosure_component_setting);
+   int (*show_id)(struct enclosure_device *, char *buf);
 };
 
 
--
1.8.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html