4e5793bc8686841af9962b2f2e52a1b95edc322a
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-4.3 / 800-bcma-use-two-different-initcalls-if-built-in.patch
1 From 666bdfc027cde41a171862dc698987a378c8b66a Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Mon, 9 Feb 2015 18:00:42 +0100
4 Subject: [PATCH RFC] bcma: use two different initcalls if built-in
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This is needed as we can't initialize bus during fs_initcall.
10 Initialization requires SPROM which depends on NVRAM which depends on
11 mtd. Since mtd, spi, nand, spi-nor use standard module_init, we have to
12 do the same in bcma.
13 Without this we'll try to initialize SPROM without having a ready SPROM
14 proviver registered using bcma_arch_register_fallback_sprom.
15
16 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
17 ---
18 While this patch seems to work and I can compile bcma as built-in and
19 module, I'm not too proud of it. I don't really like these #if(n)def
20 tricks and I'm afraid bcma_modinit may be called even if
21 bcma_modinit_early failed.
22
23 Do you see any better idea of solving this?
24 ---
25 drivers/bcma/main.c | 16 ++++++++++++++--
26 1 file changed, 14 insertions(+), 2 deletions(-)
27
28 --- a/drivers/bcma/main.c
29 +++ b/drivers/bcma/main.c
30 @@ -673,13 +673,25 @@ static int bcma_device_uevent(struct dev
31 core->id.rev, core->id.class);
32 }
33
34 +/* Bus has to be registered early, before any bcma driver */
35 +static int __init bcma_modinit_early(void)
36 +{
37 + return bus_register(&bcma_bus_type);
38 +}
39 +#ifndef MODULE
40 +fs_initcall(bcma_modinit_early);
41 +#endif
42 +
43 +/* Initialization has to be done later with SPI/mtd/NAND/SPROM available */
44 static int __init bcma_modinit(void)
45 {
46 int err;
47
48 - err = bus_register(&bcma_bus_type);
49 +#ifdef MODULE
50 + err = bcma_modinit_early();
51 if (err)
52 return err;
53 +#endif
54
55 err = bcma_host_soc_register_driver();
56 if (err) {
57 @@ -696,7 +708,7 @@ static int __init bcma_modinit(void)
58
59 return err;
60 }
61 -fs_initcall(bcma_modinit);
62 +module_init(bcma_modinit);
63
64 static void __exit bcma_modexit(void)
65 {