]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/onenand/onenand_spl.c
mtd: cfi: Unlock current sector instead of sector 0 before buffered write
[u-boot] / drivers / mtd / onenand / onenand_spl.c
index 50eaa71882cf19accbb1d60024350879e01b568b..fe6b7d923ccc56bf75d9c07d116e50240f5c98be 100644 (file)
@@ -5,23 +5,7 @@
  *     Copyright (C) 2005-2009 Samsung Electronics
  *     Kyungmin Park <kyungmin.park@samsung.com>
  *
- * 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+
  */
 
 #include <common.h>
@@ -112,7 +96,7 @@ static int onenand_spl_read_page(uint32_t block, uint32_t page, uint32_t *buf,
 void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst)
 {
        uint32_t *addr = (uint32_t *)dst;
-       uint32_t total_pages;
+       uint32_t to_page;
        uint32_t block;
        uint32_t page, rpage;
        enum onenand_spl_pagesize pagesize;
@@ -125,22 +109,20 @@ void onenand_spl_load_image(uint32_t offs, uint32_t size, void *dst)
         * pulling further unwanted functions into the SPL.
         */
        if (pagesize == 2048) {
-               total_pages = DIV_ROUND_UP(size, 2048);
                page = offs / 2048;
+               to_page = page + DIV_ROUND_UP(size, 2048);
        } else {
-               total_pages = DIV_ROUND_UP(size, 4096);
                page = offs / 4096;
+               to_page = page + DIV_ROUND_UP(size, 4096);
        }
 
-       for (; page <= total_pages; page++) {
+       for (; page <= to_page; page++) {
                block = page / ONENAND_PAGES_PER_BLOCK;
                rpage = page & (ONENAND_PAGES_PER_BLOCK - 1);
                ret = onenand_spl_read_page(block, rpage, addr, pagesize);
-               if (ret) {
-                       total_pages += ONENAND_PAGES_PER_BLOCK;
+               if (ret)
                        page += ONENAND_PAGES_PER_BLOCK - 1;
-               } else {
+               else
                        addr += pagesize / 4;
-               }
        }
 }