diff mbox

[U-Boot,v5,03/21] sf: sandbox: Use JEDEC_MFR|ID in id exctract

Message ID 1477849590-11954-4-git-send-email-jagan@openedev.com
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Jagan Teki Oct. 30, 2016, 5:46 p.m. UTC
Instead of extracting id's separately better
to use JEDEC_MFR|ID for code simplicity.

Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jagan@openedev.com>
---
 drivers/mtd/spi/sandbox.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Simon Glass Nov. 5, 2016, 4:07 p.m. UTC | #1
On 30 October 2016 at 11:46, Jagan Teki <jagan@openedev.com> wrote:
> Instead of extracting id's separately better
> to use JEDEC_MFR|ID for code simplicity.
>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Jagan Teki <jagan@openedev.com>
> ---
>  drivers/mtd/spi/sandbox.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox

Patch

diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c
index d68ee4a..09ce783 100644
--- a/drivers/mtd/spi/sandbox.c
+++ b/drivers/mtd/spi/sandbox.c
@@ -359,9 +359,8 @@  static int sandbox_sf_xfer(struct udevice *dev, unsigned int bitlen,
 			debug(" id: off:%u tx:", sbsf->off);
 			if (sbsf->off < IDCODE_LEN) {
 				/* Extract correct byte from ID 0x00aabbcc */
-				id = ((((sbsf->data)->id[0]) << 16) |
-					(((sbsf->data)->id[1]) << 8 |
-					((sbsf->data)->id[2]))) >>
+				id = ((JEDEC_MFR(sbsf->data) << 16) |
+					JEDEC_ID(sbsf->data)) >>
 					(8 * (IDCODE_LEN - 1 - sbsf->off));
 			} else {
 				id = 0;