[PATCH 10/10] gpio: allocate gpio_desc table dynamically
Sascha Hauer
s.hauer at pengutronix.de
Sat Mar 9 05:53:11 EST 2013
Some systems are runnignfrom a very limited SRAM, but have a huge
malloc space in SDRAM. The bss normally is in SRAM, so we should
avoid having big structures there. The gpio_desc table is 3072 bytes
big, so allocate it dynamically instead.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/gpio/gpio.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
index d37f5a0..9d081c2 100644
--- a/drivers/gpio/gpio.c
+++ b/drivers/gpio/gpio.c
@@ -1,3 +1,4 @@
+#include <init.h>
#include <common.h>
#include <command.h>
#include <complete.h>
@@ -13,7 +14,15 @@ struct gpio_info {
char *label;
};
-static struct gpio_info gpio_desc[ARCH_NR_GPIOS];
+static struct gpio_info *gpio_desc;
+
+static int gpio_desc_alloc(void)
+{
+ gpio_desc = xzalloc(sizeof(struct gpio_info) * ARCH_NR_GPIOS);
+
+ return 0;
+}
+pure_initcall(gpio_desc_alloc);
static int gpio_ensure_requested(struct gpio_info *gi, int gpio)
{
--
1.8.2.rc2
More information about the barebox
mailing list