summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo2006-02-12 14:47:04 +0100
committerJeff Garzik2006-02-12 20:24:41 +0100
commit0e949ff304a7ca07db38c17fbbf3ead1085d7bbf (patch)
treeecc4834d27e221863dc5dbef3c13763dbdf4dd56 /drivers/scsi/libata-core.c
parent[PATCH] ata_piix: kill spurious assignment in piix_sata_probe() (diff)
downloadkernel-qcow2-linux-0e949ff304a7ca07db38c17fbbf3ead1085d7bbf.tar.gz
kernel-qcow2-linux-0e949ff304a7ca07db38c17fbbf3ead1085d7bbf.tar.xz
kernel-qcow2-linux-0e949ff304a7ca07db38c17fbbf3ead1085d7bbf.zip
[PATCH] libata: implement ata_dev_id_c_string()
ata_dev_id_c_string() reads ATA string from the specified offset of the given IDENTIFY PAGE and puts it in the specified buffer in trimmed and NULL-terminated form. The caller must supply a buffer which is one byte larger than the maximum size of the target ID string. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r--drivers/scsi/libata-core.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 9ddb568267e1..7e410299d67a 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -519,6 +519,34 @@ void ata_dev_id_string(const u16 *id, unsigned char *s,
}
}
+/**
+ * ata_dev_id_c_string - Convert IDENTIFY DEVICE page into C string
+ * @id: IDENTIFY DEVICE results we will examine
+ * @s: string into which data is output
+ * @ofs: offset into identify device page
+ * @len: length of string to return. must be an odd number.
+ *
+ * This function is identical to ata_dev_id_string except that it
+ * trims trailing spaces and terminates the resulting string with
+ * null. @len must be actual maximum length (even number) + 1.
+ *
+ * LOCKING:
+ * caller.
+ */
+void ata_dev_id_c_string(const u16 *id, unsigned char *s,
+ unsigned int ofs, unsigned int len)
+{
+ unsigned char *p;
+
+ WARN_ON(!(len & 1));
+
+ ata_dev_id_string(id, s, ofs, len - 1);
+
+ p = s + strnlen(s, len - 1);
+ while (p > s && p[-1] == ' ')
+ p--;
+ *p = '\0';
+}
/**
* ata_noop_dev_select - Select device 0/1 on ATA bus
@@ -4905,6 +4933,7 @@ EXPORT_SYMBOL_GPL(ata_scsi_release);
EXPORT_SYMBOL_GPL(ata_host_intr);
EXPORT_SYMBOL_GPL(ata_dev_classify);
EXPORT_SYMBOL_GPL(ata_dev_id_string);
+EXPORT_SYMBOL_GPL(ata_dev_id_c_string);
EXPORT_SYMBOL_GPL(ata_dev_config);
EXPORT_SYMBOL_GPL(ata_scsi_simulate);
EXPORT_SYMBOL_GPL(ata_eh_qc_complete);