From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, albertcc@tw.ibm.com, linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 1/5] libata: implement ata_dev_id_c_string()
Date: Sun, 12 Feb 2006 22:47:04 +0900 [thread overview]
Message-ID: <11397520242535-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11397520242602-git-send-email-htejun@gmail.com>
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>
---
drivers/scsi/libata-core.c | 29 +++++++++++++++++++++++++++++
include/linux/libata.h | 2 ++
2 files changed, 31 insertions(+), 0 deletions(-)
fecf9b72f3395e5c73d303cdd098d39418554a82
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index cef85e5..ea993eb 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, un
}
}
+/**
+ * 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
@@ -4902,6 +4930,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);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 83a1f2e..0853032 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -540,6 +540,8 @@ extern void ata_sg_init(struct ata_queue
extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
extern void ata_dev_id_string(const u16 *id, unsigned char *s,
unsigned int ofs, unsigned int len);
+extern void ata_dev_id_c_string(const u16 *id, unsigned char *s,
+ unsigned int ofs, unsigned int len);
extern void ata_dev_config(struct ata_port *ap, unsigned int i);
extern void ata_bmdma_setup (struct ata_queued_cmd *qc);
extern void ata_bmdma_start (struct ata_queued_cmd *qc);
--
1.1.5
next prev parent reply other threads:[~2006-02-12 13:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-12 13:47 [PATCHSET] libata: misc preps for configuration reorganization Tejun Heo
2006-02-12 13:47 ` Tejun Heo [this message]
2006-02-12 19:25 ` [PATCH 1/5] libata: implement ata_dev_id_c_string() Jeff Garzik
2006-02-13 1:02 ` [PATCH] libata: rename ata_dev_id_[c_]string() Tejun Heo
2006-02-15 2:00 ` Tejun Heo
2006-02-20 9:54 ` Jeff Garzik
2006-02-12 13:47 ` [PATCH 4/5] libata: separate out ata_id_major_version() Tejun Heo
2006-02-12 13:47 ` [PATCH 2/5] libata: use ata_dev_id_c_string() Tejun Heo
2006-02-12 13:47 ` [PATCH 5/5] libata: make ata_dump_id() take @id instead of @dev Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11397520242535-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=albertcc@tw.ibm.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).