]> err.no Git - linux-2.6/commitdiff
[SCSI] libsas: Provide a transport-level facility to request SAS addrs
authorDarrick J. Wong <djwong@us.ibm.com>
Tue, 19 Feb 2008 18:49:40 +0000 (10:49 -0800)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Mon, 7 Apr 2008 17:15:38 +0000 (12:15 -0500)
Provide a facility to use the request_firmware() interface to get a SAS
address from userspace.  This can be used by SAS LLDDs that cannot
obtain the address from the host adapter.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/libsas/sas_scsi_host.c
include/scsi/libsas.h

index 1f8241563c6ccea625640eb69c22554d931f3d87..601ec5b6a7f6ab1a240ff130b0dbc6f989b3ec4e 100644 (file)
@@ -24,6 +24,8 @@
  */
 
 #include <linux/kthread.h>
+#include <linux/firmware.h>
+#include <linux/ctype.h>
 
 #include "sas_internal.h"
 
@@ -1064,6 +1066,45 @@ void sas_target_destroy(struct scsi_target *starget)
        return;
 }
 
+static void sas_parse_addr(u8 *sas_addr, const char *p)
+{
+       int i;
+       for (i = 0; i < SAS_ADDR_SIZE; i++) {
+               u8 h, l;
+               if (!*p)
+                       break;
+               h = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
+               p++;
+               l = isdigit(*p) ? *p-'0' : toupper(*p)-'A'+10;
+               p++;
+               sas_addr[i] = (h<<4) | l;
+       }
+}
+
+#define SAS_STRING_ADDR_SIZE   16
+
+int sas_request_addr(struct Scsi_Host *shost, u8 *addr)
+{
+       int res;
+       const struct firmware *fw;
+
+       res = request_firmware(&fw, "sas_addr", &shost->shost_gendev);
+       if (res)
+               return res;
+
+       if (fw->size < SAS_STRING_ADDR_SIZE) {
+               res = -ENODEV;
+               goto out;
+       }
+
+       sas_parse_addr(addr, fw->data);
+
+out:
+       release_firmware(fw);
+       return res;
+}
+EXPORT_SYMBOL_GPL(sas_request_addr);
+
 EXPORT_SYMBOL_GPL(sas_queuecommand);
 EXPORT_SYMBOL_GPL(sas_target_alloc);
 EXPORT_SYMBOL_GPL(sas_slave_configure);
index 39e1cac24bb751503fdef353a764292326b32037..98724ba65a79751d483e4aeb3ec4cd449b17bb2d 100644 (file)
@@ -677,4 +677,6 @@ extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
                                  struct ssp_response_iu *iu);
 struct sas_phy *sas_find_local_phy(struct domain_device *dev);
 
+int sas_request_addr(struct Scsi_Host *shost, u8 *addr);
+
 #endif /* _SASLIB_H_ */