From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, linux-ide@vger.kernel.org,
albertcc@tw.ibm.com, alan@lxorguk.ukuu.org.uk
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 01/16] libata: implement ata_dev_id_c_string()
Date: Fri, 27 Jan 2006 00:39:11 +0900 [thread overview]
Message-ID: <11382899512709-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <1138289951261-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 | 30 ++++++++++++++++++++++++++++++
include/linux/libata.h | 2 ++
2 files changed, 32 insertions(+), 0 deletions(-)
170e46fb5e18c2bc6c6606f9bf6650bfb2b4f578
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index b1ec4e5..2dfc3e9 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -916,6 +916,35 @@ 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;
+
+ assert(len & 1);
+ s[len - 1] = ' ';
+
+ ata_dev_id_string(id, s, ofs, len - 1);
+
+ p = s + strnlen(s, len) - 1;
+ while (p >= s && *p == ' ')
+ p--;
+ *++p = '\0';
+}
/**
* ata_noop_dev_select - Select device 0/1 on ATA bus
@@ -5531,6 +5560,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 a30aba8..5bcbab0 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -545,6 +545,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.3
next prev parent reply other threads:[~2006-01-26 15:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-26 15:39 [PATCHSET] libata: reorganize configuration and implement revalidation Tejun Heo
2006-01-26 15:39 ` Tejun Heo [this message]
2006-01-26 15:39 ` [PATCH 05/16] libata: make ata_dump_id() take @id instead of @dev Tejun Heo
2006-01-26 15:39 ` [PATCH 12/16] libata: reorganize ata_bus_probe() Tejun Heo
2006-01-26 15:39 ` [PATCH 04/16] libata: separate out ata_id_major_version() Tejun Heo
2006-01-26 15:39 ` [PATCH 09/16] libata: kill ata_dev_reread_id() Tejun Heo
2006-01-26 15:39 ` [PATCH 11/16] libata: fold ata_dev_config() into ata_dev_configure() Tejun Heo
2006-01-26 15:39 ` [PATCH 02/16] libata: use ata_dev_id_c_string() Tejun Heo
2006-01-26 15:39 ` [PATCH 07/16] libata: convert dev->id to pointer Tejun Heo
2006-01-26 15:39 ` [PATCH 16/16] libata: revalidate after transfer mode configuration Tejun Heo
2006-01-26 15:39 ` [PATCH 15/16] libata: implement ata_dev_revalidate() Tejun Heo
2006-01-26 15:39 ` [PATCH 13/16] libata: re-initialize parameters before configuring Tejun Heo
2006-01-26 17:42 ` [PATCHSET] libata: reorganize configuration and implement revalidation Mark Lord
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=11382899512709-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--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).