ar7: add kernel 4.9 support
[openwrt/staging/chunkeey.git] / target / linux / ar7 / patches-4.9 / 003-MIPS-AR7-defer-registration-of-GPIO.patch
1 From 3a8d54573f9d187779d36d6b45e8e0288b82c31a Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jonas.gorski@gmail.com>
3 Date: Thu, 26 Oct 2017 23:25:44 +0200
4 Subject: [PATCH 1/3] MIPS: AR7: defer registration of GPIO
5
6 When called from prom init code, ar7_gpio_init() will fail as it will
7 call gpiochip_add() which relies on a working kmalloc() to alloc
8 the gpio_desc array and kmalloc is not useable yet at prom init time.
9
10 Move ar7_gpio_init() to ar7_register_devices() (a device_initcall)
11 where kmalloc works.
12
13 Fixes: 14e85c0e69d5 ("gpio: remove gpio_descs global array")
14 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
15 ---
16 Text shamelessy stolen from commit 2ec459f2a77b8.
17
18 arch/mips/ar7/platform.c | 4 ++++
19 arch/mips/ar7/prom.c | 2 --
20 2 files changed, 4 insertions(+), 2 deletions(-)
21
22 --- a/arch/mips/ar7/platform.c
23 +++ b/arch/mips/ar7/platform.c
24 @@ -655,6 +655,10 @@ static int __init ar7_register_devices(v
25 u32 val;
26 int res;
27
28 + res = ar7_gpio_init();
29 + if (res)
30 + pr_warn("unable to register gpios: %d\n", res);
31 +
32 res = ar7_register_uarts();
33 if (res)
34 pr_err("unable to setup uart(s): %d\n", res);
35 --- a/arch/mips/ar7/prom.c
36 +++ b/arch/mips/ar7/prom.c
37 @@ -246,8 +246,6 @@ void __init prom_init(void)
38 ar7_init_cmdline(fw_arg0, (char **)fw_arg1);
39 ar7_init_env((struct env_var *)fw_arg2);
40 console_config();
41 -
42 - ar7_gpio_init();
43 }
44
45 #define PORT(offset) (KSEG1ADDR(AR7_REGS_UART0 + (offset * 4)))