From patchwork Thu Dec 6 14:44:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roese X-Patchwork-Id: 204253 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E0A8C2C030F for ; Fri, 7 Dec 2012 01:44:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3790F4A254; Thu, 6 Dec 2012 15:44:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l69Ugz0cOQaQ; Thu, 6 Dec 2012 15:44:22 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 34E2B4A24B; Thu, 6 Dec 2012 15:44:22 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B53544A24B for ; Thu, 6 Dec 2012 15:44:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8DR+n3CcsCqJ for ; Thu, 6 Dec 2012 15:44:18 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mo-p05-ob.rzone.de (mo-p05-ob.rzone.de [81.169.146.180]) by theia.denx.de (Postfix) with ESMTPS id C575D4A24A for ; Thu, 6 Dec 2012 15:44:17 +0100 (CET) X-RZG-AUTH: :IW0NeWC7b/q2i6W/qstXb1SBUuFnrGohdvpEkce+Ub4+ReKfHD+mCZCG5UI/9A== X-RZG-CLASS-ID: mo05 Received: from ubuntu-2012.fritz.box (p57B942D7.dip.t-dialin.net [87.185.66.215]) by smtp.strato.de (jored mo25) (RZmta 31.7 DYNA|AUTH) with ESMTPA id 20750eoB6DfZxK for ; Thu, 6 Dec 2012 15:44:15 +0100 (CET) From: Stefan Roese To: u-boot@lists.denx.de Date: Thu, 6 Dec 2012 15:44:09 +0100 Message-Id: <1354805052-32347-1-git-send-email-sr@denx.de> X-Mailer: git-send-email 1.8.0.1 Subject: [U-Boot] [PATCH 1/4] cfi_flash: Add manufact_match helper function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Consolidate manufacturer matching into the function manufact_match() and use it. Signed-off-by: Stefan Roese --- 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 */