aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/libata-core.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-02-12 08:47:04 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-12 14:24:41 -0500
commit0e949ff304a7ca07db38c17fbbf3ead1085d7bbf (patch)
treeecc4834d27e221863dc5dbef3c13763dbdf4dd56 /drivers/scsi/libata-core.c
parent48f80e12abbc1e9034e54614c30e7c304209ce99 (diff)
[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,
519 } 519 }
520} 520}
521 521
522/**
523 * ata_dev_id_c_string - Convert IDENTIFY DEVICE page into C string
524 * @id: IDENTIFY DEVICE results we will examine
525 * @s: string into which data is output
526 * @ofs: offset into identify device page
527 * @len: length of string to return. must be an odd number.
528 *
529 * This function is identical to ata_dev_id_string except that it
530 * trims trailing spaces and terminates the resulting string with
531 * null. @len must be actual maximum length (even number) + 1.
532 *
533 * LOCKING:
534 * caller.
535 */
536void ata_dev_id_c_string(const u16 *id, unsigned char *s,
537 unsigned int ofs, unsigned int len)
538{
539 unsigned char *p;
540
541 WARN_ON(!(len & 1));
542
543 ata_dev_id_string(id, s, ofs, len - 1);
544
545 p = s + strnlen(s, len - 1);
546 while (p > s && p[-1] == ' ')
547 p--;
548 *p = '\0';
549}
522 550
523/** 551/**
524 * ata_noop_dev_select - Select device 0/1 on ATA bus 552 * ata_noop_dev_select - Select device 0/1 on ATA bus
@@ -4905,6 +4933,7 @@ EXPORT_SYMBOL_GPL(ata_scsi_release);
4905EXPORT_SYMBOL_GPL(ata_host_intr); 4933EXPORT_SYMBOL_GPL(ata_host_intr);
4906EXPORT_SYMBOL_GPL(ata_dev_classify); 4934EXPORT_SYMBOL_GPL(ata_dev_classify);
4907EXPORT_SYMBOL_GPL(ata_dev_id_string); 4935EXPORT_SYMBOL_GPL(ata_dev_id_string);
4936EXPORT_SYMBOL_GPL(ata_dev_id_c_string);
4908EXPORT_SYMBOL_GPL(ata_dev_config); 4937EXPORT_SYMBOL_GPL(ata_dev_config);
4909EXPORT_SYMBOL_GPL(ata_scsi_simulate); 4938EXPORT_SYMBOL_GPL(ata_scsi_simulate);
4910EXPORT_SYMBOL_GPL(ata_eh_qc_complete); 4939EXPORT_SYMBOL_GPL(ata_eh_qc_complete);