Merge branch 'master' of git://www.denx.de/git/u-boot-cfi-flash
[oweals/u-boot.git] / drivers / mtd / cfi_flash.c
index 25f875202c337deafbda8f30b530325f21c5d88c..a389cd101c2f55e62ca8ab90efaf395234d98713 100644 (file)
  * Copyright (C) 2006
  * Tolunay Orkun <listmember@orkun.us>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /* The DEBUG define must be before common to enable debugging */
@@ -1797,7 +1780,7 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
                        };
                        int i;
 
-                       for (i = 0; i < sizeof(modes) / sizeof(modes[0]); i++) {
+                       for (i = 0; i < ARRAY_SIZE(modes); i++) {
                                info->vendor = modes[i];
                                info->start[0] =
                                        (ulong)map_physmem(base,
@@ -1820,7 +1803,7 @@ static int flash_detect_legacy(phys_addr_t base, int banknum)
                                        break;
                                else
                                        unmap_physmem((void *)info->start[0],
-                                                     MAP_NOCACHE);
+                                                     info->portwidth);
                        }
                }
 
@@ -1883,8 +1866,7 @@ static int __flash_detect_cfi (flash_info_t * info, struct cfi_qry *qry)
        /* Issue FLASH reset command */
        flash_cmd_reset(info);
 
-       for (cfi_offset=0;
-            cfi_offset < sizeof(flash_offset_cfi) / sizeof(uint);
+       for (cfi_offset = 0; cfi_offset < ARRAY_SIZE(flash_offset_cfi);
             cfi_offset++) {
                flash_write_cmd (info, 0, flash_offset_cfi[cfi_offset],
                                 FLASH_CMD_CFI);
@@ -2336,7 +2318,7 @@ void flash_protect_default(void)
 #endif
 
 #if defined(CONFIG_SYS_FLASH_AUTOPROTECT_LIST)
-       for (i = 0; i < (sizeof(apl) / sizeof(struct apl_s)); i++) {
+       for (i = 0; i < ARRAY_SIZE(apl); i++) {
                debug("autoprotecting from %08lx to %08lx\n",
                      apl[i].start, apl[i].start + apl[i].size - 1);
                flash_protect(FLAG_PROTECT_SET,