public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/4] cfi_flash: Add manufact_match helper function
@ 2012-12-06 14:44 Stefan Roese
  2012-12-06 14:44 ` [U-Boot] [PATCH 2/4 v2] cfi_flash: Read PPB sector protection from device for AMD/Spansion chips Stefan Roese
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Stefan Roese @ 2012-12-06 14:44 UTC (permalink / raw)
  To: u-boot

Consolidate manufacturer matching into the function manufact_match()
and use it.

Signed-off-by: Stefan Roese <sr@denx.de>
---
 drivers/mtd/cfi_flash.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index b2dfc53..d865c40 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1425,13 +1425,18 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
 	return flash_write_cfiword (info, wp, cword);
 }
 
+static inline int manufact_match(flash_info_t *info, u32 manu)
+{
+	return info->manufacturer_id == ((manu & FLASH_VENDMASK) >> 16);
+}
+
 /*-----------------------------------------------------------------------
  */
 #ifdef CONFIG_SYS_FLASH_PROTECTION
 
 static int cfi_protect_bugfix(flash_info_t *info, long sector, int prot)
 {
-	if (info->manufacturer_id == ((INTEL_MANUFACT & FLASH_VENDMASK) >> 16)
+	if (manufact_match(info, INTEL_MANUFACT)
 	    && info->device_id == NUMONYX_256MBIT) {
 		/*
 		 * see errata called
@@ -1488,8 +1493,7 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 		case CFI_CMDSET_AMD_EXTENDED:
 		case CFI_CMDSET_AMD_STANDARD:
 			/* U-Boot only checks the first byte */
-			if (info->manufacturer_id ==
-			    ((ATM_MANUFACT & FLASH_VENDMASK) >> 16)) {
+			if (manufact_match(info, ATM_MANUFACT)) {
 				if (prot) {
 					flash_unlock_seq (info, 0);
 					flash_write_cmd (info, 0,
@@ -1507,8 +1511,7 @@ int flash_real_protect (flash_info_t * info, long sector, int prot)
 							0, ATM_CMD_UNLOCK_SECT);
 				}
 			}
-			if (info->manufacturer_id ==
-			    ((AMD_MANUFACT & FLASH_VENDMASK) >> 16)) {
+			if (manufact_match(info, AMD_MANUFACT)) {
 				int flag = disable_interrupts();
 				int lock_flag;
 
@@ -1738,8 +1741,7 @@ static int cmdset_amd_init(flash_info_t *info, struct cfi_qry *qry)
 	flash_write_cmd(info, 0, info->cfi_offset, FLASH_CMD_CFI);
 
 #ifdef CONFIG_SYS_FLASH_PROTECTION
-	if (info->ext_addr && info->manufacturer_id ==
-	    ((AMD_MANUFACT & FLASH_VENDMASK) >> 16)) {
+	if (info->ext_addr && manufact_match(info, AMD_MANUFACT)) {
 		ushort spus;
 
 		/* read sector protect/unprotect scheme */
-- 
1.8.0.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-01-10 14:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-06 14:44 [U-Boot] [PATCH 1/4] cfi_flash: Add manufact_match helper function Stefan Roese
2012-12-06 14:44 ` [U-Boot] [PATCH 2/4 v2] cfi_flash: Read PPB sector protection from device for AMD/Spansion chips Stefan Roese
2012-12-07  9:19   ` Holger Brunck
2012-12-06 14:44 ` [U-Boot] [PATCH 3/4] cfi_flash: Enable PPB protection for all AMD cmdset flash chips Stefan Roese
2012-12-07  9:19   ` Holger Brunck
2012-12-06 14:44 ` [U-Boot] [PATCH 4/4] cfi_flash: Report Advanced Sector Protection (PPB) with flinfo cmd Stefan Roese
2012-12-07  9:20   ` Holger Brunck
2013-01-10 14:33 ` [U-Boot] [PATCH 1/4] cfi_flash: Add manufact_match helper function Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox