From 75c9be5c1ea4742c863786421e34195570d46b65 Mon Sep 17 00:00:00 2001 From: Luka Perkov Date: Tue, 22 Jan 2013 12:55:01 +0000 Subject: uboot-lantiq: upgrade to 2013.01 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35292 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ...oc-free-probe-functions-dedicated-for-SPL.patch | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch (limited to 'package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch') diff --git a/package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch b/package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch new file mode 100644 index 0000000000..7a1ef3b0be --- /dev/null +++ b/package/boot/uboot-lantiq/patches/0004-sf-add-malloc-free-probe-functions-dedicated-for-SPL.patch @@ -0,0 +1,131 @@ +From f9ab44c271fbd82a5702b6ba067fa90e33a30089 Mon Sep 17 00:00:00 2001 +From: Daniel Schwierzeck +Date: Wed, 7 Nov 2012 15:29:27 +0100 +Subject: sf: add malloc-free probe functions dedicated for SPL + +Signed-off-by: Daniel Schwierzeck + +--- a/drivers/mtd/spi/spi_flash.c ++++ b/drivers/mtd/spi/spi_flash.c +@@ -339,11 +339,11 @@ static struct { + DECLARE_GLOBAL_DATA_PTR; + #endif + +-struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, +- unsigned int max_hz, unsigned int spi_mode) ++int spi_flash_probe_spl(struct spi_flash *flash, unsigned int bus, ++ unsigned int cs, unsigned int max_hz, ++ unsigned int spi_mode) + { + struct spi_slave *spi; +- struct spi_flash *flash; + int ret, i, shift; + u8 idcode[IDCODE_LEN], *idp; + #ifdef CONFIG_NEEDS_MANUAL_RELOC +@@ -359,8 +359,8 @@ struct spi_flash *spi_flash_probe(unsign + + spi = spi_setup_slave(bus, cs, max_hz, spi_mode); + if (!spi) { +- printf("SF: Failed to set up slave\n"); +- return NULL; ++ debug("SF: Failed to set up slave\n"); ++ return -1; + } + + ret = spi_claim_bus(spi); +@@ -379,13 +379,6 @@ struct spi_flash *spi_flash_probe(unsign + print_buffer(0, idcode, 1, sizeof(idcode), 0); + #endif + +- flash = malloc(sizeof(*flash)); +- if (!flash) { +- debug("SF: failed to alloc memory\n"); +- goto err_malloc; +- } +- +- memset(flash, 0, sizeof(*flash)); + flash->spi = spi; + + /* count the number of continuation bytes */ +@@ -404,30 +397,58 @@ struct spi_flash *spi_flash_probe(unsign + } + + if (ret <= 0) { +- printf("SF: Unsupported manufacturer %02x\n", *idp); ++ debug("SF: Unsupported manufacturer %02x\n", *idp); + goto err_manufacturer_probe; + } + +- printf("SF: Detected %s with page size ", flash->name); +- print_size(flash->sector_size, ", total "); +- print_size(flash->size, "\n"); +- + spi_release_bus(spi); + +- return flash; ++ return 0; + + err_manufacturer_probe: +- free(flash); +-err_malloc: + err_read_id: + spi_release_bus(spi); + err_claim_bus: + spi_free_slave(spi); ++ ++ return ret; ++} ++ ++struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, ++ unsigned int max_hz, unsigned int spi_mode) ++{ ++ struct spi_flash *flash; ++ int ret; ++ ++ flash = malloc(sizeof(*flash)); ++ if (!flash) { ++ debug("SF: Failed to malloc spi_flash\n"); ++ return NULL; ++ } ++ memset(flash, 0, sizeof(*flash)); ++ ++ ret = spi_flash_probe_spl(flash, bus, cs, max_hz, spi_mode); ++ if (ret) ++ goto err_probe; ++ ++ printf("SF: %s, page size ", flash->name); ++ print_size(flash->sector_size, ", total "); ++ print_size(flash->size, "\n"); ++ ++ return flash; ++ ++err_probe: ++ free(flash); + return NULL; + } + +-void spi_flash_free(struct spi_flash *flash) ++void spi_flash_free_spl(struct spi_flash *flash) + { + spi_free_slave(flash->spi); ++} ++ ++void spi_flash_free(struct spi_flash *flash) ++{ ++ spi_flash_free_spl(flash); + free(flash); + } +--- a/include/spi_flash.h ++++ b/include/spi_flash.h +@@ -52,6 +52,11 @@ struct spi_flash *spi_flash_probe(unsign + unsigned int max_hz, unsigned int spi_mode); + void spi_flash_free(struct spi_flash *flash); + ++int spi_flash_probe_spl(struct spi_flash *flash, unsigned int bus, ++ unsigned int cs, unsigned int max_hz, ++ unsigned int spi_mode); ++void spi_flash_free_spl(struct spi_flash *flash); ++ + static inline int spi_flash_read(struct spi_flash *flash, u32 offset, + size_t len, void *buf) + { -- cgit v1.2.3