All of lore.kernel.org
 help / color / mirror / Atom feed
From: unsik Kim <donari75@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-BOOT][PATCH 3/4] mflash : Use common libata function
Date: Wed, 18 Feb 2009 19:51:50 +0900	[thread overview]
Message-ID: <499BE846.1040707@gmail.com> (raw)


replace mg_ident_cpy to ata_id_c_string

Signed-off-by: unsik Kim <donari75@gmail.com>
---
  doc/README.mflash       |    1 +
  drivers/block/mg_disk.c |   67 ++++++++--------------------------------------
  2 files changed, 13 insertions(+), 55 deletions(-)

diff --git a/doc/README.mflash b/doc/README.mflash
index d0d0f7b..50133b4 100644
--- a/doc/README.mflash
+++ b/doc/README.mflash
@@ -17,6 +17,7 @@ So the rest mflash repersents mflash and gflash altogether.
  2-1. Board configuration
  * Mflash driver support
  #define CONFIG_CMD_MG_DISK
+#define CONFIG_LIBATA

  * Environment variable support (optional)
  #define CONFIG_ENV_IS_IN_MG_DISK
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index 1f9debe..113aa79 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -85,37 +85,6 @@ static void mg_dump_status (const char *msg, unsigned int stat, unsigned err)
  	}
  }

-/*
- * copy src to dest, skipping leading and trailing blanks and null
- * terminate the string
- * "len" is the size of available memory including the terminating '\0'
- */
-static void mg_ident_cpy (unsigned char *dst, unsigned char *src,
-		unsigned int len)
-{
-	unsigned char *end, *last;
-
-	last = dst;
-	end  = src + len - 1;
-
-	/* reserve space for '\0' */
-	if (len < 2)
-		goto OUT;
-
-	/* skip leading white space */
-	while ((*src) && (src < end) && (*src == ' '))
-		++src;
-
-	/* copy string, omitting trailing white space */
-	while ((*src) && (src < end)) {
-		*dst++ = *src;
-		if (*src++ != ' ')
-			last = dst;
-	}
-OUT:
-	*last = '\0';
-}
-
  static unsigned int mg_wait (u32 expect, u32 msec)
  {
  	u8 status;
@@ -158,46 +127,34 @@ static unsigned int mg_wait (u32 expect, u32 msec)

  static int mg_get_disk_id (void)
  {
-	u32 iobuf[(MG_SECTOR_SIZE / sizeof(u32))];
-	hd_driveid_t *iop = (hd_driveid_t *)iobuf;
+	u16 id[(MG_SECTOR_SIZE / sizeof(u16))];
+	hd_driveid_t *iop = (hd_driveid_t *)id;
  	u32 i, err, res;
-	u16 *buff = (u16 *)iobuf;

  	writeb(MG_CMD_ID, mg_base() + MG_REG_COMMAND);
  	err = mg_wait(MG_REG_STATUS_BIT_DATA_REQ, 3000);
  	if (err)
  		return err;

-	for(i = 0; i < (MG_SECTOR_SIZE / sizeof(u32)) >> 1; i++)
-		buff[i] = readw(mg_base() + MG_BUFF_OFFSET + i * 2);
+	for(i = 0; i < (MG_SECTOR_SIZE / sizeof(u16)); i++)
+		id[i] = readw(mg_base() + MG_BUFF_OFFSET + i * 2);

  	writeb(MG_CMD_RD_CONF, mg_base() + MG_REG_COMMAND);
  	err = mg_wait(MG_STAT_READY, 3000);
  	if (err)
  		return err;

+	ata_swap_buf_le16(id, MG_SECTOR_SIZE / sizeof(u16));
+
  	if((iop->field_valid & 1) == 0)
  		return MG_ERR_TRANSLATION;

-	mg_ident_cpy((unsigned char*)mg_disk_dev.revision, iop->fw_rev,
-			sizeof(mg_disk_dev.revision));
-	mg_ident_cpy((unsigned char*)mg_disk_dev.vendor, iop->model,
-			sizeof(mg_disk_dev.vendor));
-	mg_ident_cpy((unsigned char*)mg_disk_dev.product, iop->serial_no,
-			sizeof(mg_disk_dev.product));
-#ifdef __LITTLE_ENDIAN
-	/*
-	 * firmware revision, model, and serial number have Big Endian Byte
-	 * order in Word. Convert all three to little endian.
-	 *
-	 * See CF+ and CompactFlash Specification Revision 2.0:
-	 * 6.2.1.6: Identify Drive, Table 39 for more details
-	 */
-
-	strswab(mg_disk_dev.revision);
-	strswab(mg_disk_dev.vendor);
-	strswab(mg_disk_dev.product);
-#endif /* __LITTLE_ENDIAN */
+	ata_id_c_string(id, (unsigned char *)mg_disk_dev.revision,
+			ATA_ID_FW_REV, sizeof(mg_disk_dev.revision));
+	ata_id_c_string(id, (unsigned char *)mg_disk_dev.vendor,
+			ATA_ID_PROD, sizeof(mg_disk_dev.vendor));
+	ata_id_c_string(id, (unsigned char *)mg_disk_dev.product,
+			ATA_ID_SERNO, sizeof(mg_disk_dev.product));

  #ifdef __BIG_ENDIAN
  	iop->lba_capacity = (iop->lba_capacity << 16) |
-- 
1.5.6.6

                 reply	other threads:[~2009-02-18 10:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=499BE846.1040707@gmail.com \
    --to=donari75@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.