1 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
2 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
3 @@ -643,6 +643,17 @@ static struct ssb_sprom bcm63xx_sprom =
4 .boardflags_lo = 0x2848,
5 .boardflags_hi = 0x0000,
8 +int bcm63xx_get_fallback_sprom(struct ssb_bus *bus, struct ssb_sprom *out)
10 + if (bus->bustype == SSB_BUSTYPE_PCI) {
11 + memcpy(out, &bcm63xx_sprom, sizeof(struct ssb_sprom));
14 + printk(KERN_ERR PFX "unable to fill SPROM for given bustype.\n");
21 @@ -793,8 +804,9 @@ void __init board_prom_init(void)
22 if (!board_get_mac_address(bcm63xx_sprom.il0mac)) {
23 memcpy(bcm63xx_sprom.et0mac, bcm63xx_sprom.il0mac, ETH_ALEN);
24 memcpy(bcm63xx_sprom.et1mac, bcm63xx_sprom.il0mac, ETH_ALEN);
25 - if (ssb_arch_set_fallback_sprom(&bcm63xx_sprom) < 0)
26 - printk(KERN_ERR "failed to register fallback SPROM\n");
27 + if (ssb_arch_register_fallback_sprom(
28 + &bcm63xx_get_fallback_sprom) < 0)
29 + printk(KERN_ERR PFX "failed to register fallback SPROM\n");
33 --- a/drivers/ssb/pci.c
34 +++ b/drivers/ssb/pci.c
35 @@ -662,7 +662,6 @@ static int sprom_extract(struct ssb_bus
36 static int ssb_pci_sprom_get(struct ssb_bus *bus,
37 struct ssb_sprom *sprom)
39 - const struct ssb_sprom *fallback;
43 @@ -707,10 +706,14 @@ static int ssb_pci_sprom_get(struct ssb_
45 /* All CRC attempts failed.
46 * Maybe there is no SPROM on the device?
47 - * If we have a fallback, use that. */
48 - fallback = ssb_get_fallback_sprom();
50 - memcpy(sprom, fallback, sizeof(*sprom));
51 + * Now we ask the arch code if there is some sprom
52 + * avaliable for this device in some other storage */
53 + err = ssb_fill_sprom_with_fallback(bus, sprom);
55 + ssb_printk(KERN_WARNING PFX "WARNING: Using"
56 + " fallback SPROM failed (err %d)\n",
62 --- a/drivers/ssb/sprom.c
63 +++ b/drivers/ssb/sprom.c
65 #include <linux/slab.h>
68 -static const struct ssb_sprom *fallback_sprom;
69 +static int(*get_fallback_sprom)(struct ssb_bus *dev, struct ssb_sprom *out);
72 static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
73 @@ -145,13 +145,14 @@ out:
77 - * ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found.
78 + * ssb_arch_register_fallback_sprom - Registers a method providing a fallback
79 + * SPROM if no SPROM is found.
81 - * @sprom: The SPROM data structure to register.
82 + * @sprom_callback: The callbcak function.
84 - * With this function the architecture implementation may register a fallback
85 - * SPROM data structure. The fallback is only used for PCI based SSB devices,
86 - * where no valid SPROM can be found in the shadow registers.
87 + * With this function the architecture implementation may register a callback
88 + * handler which wills the SPROM data structure. The fallback is only used for
89 + * PCI based SSB devices, where no valid SPROM can be found in the shadow registers.
91 * This function is useful for weird architectures that have a half-assed SSB device
92 * hardwired to their PCI bus.
93 @@ -163,18 +164,21 @@ out:
95 * This function is available for architecture code, only. So it is not exported.
97 -int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom)
98 +int ssb_arch_register_fallback_sprom(int (*sprom_callback)(struct ssb_bus *bus, struct ssb_sprom *out))
100 - if (fallback_sprom)
101 + if (get_fallback_sprom)
103 - fallback_sprom = sprom;
104 + get_fallback_sprom = sprom_callback;
109 -const struct ssb_sprom *ssb_get_fallback_sprom(void)
110 +int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out)
112 - return fallback_sprom;
113 + if (!get_fallback_sprom)
116 + return get_fallback_sprom(bus, out);
119 /* http://bcm-v4.sipsolutions.net/802.11/IsSpromAvailable */
120 --- a/drivers/ssb/ssb_private.h
121 +++ b/drivers/ssb/ssb_private.h
122 @@ -171,7 +171,7 @@ ssize_t ssb_attr_sprom_store(struct ssb_
123 const char *buf, size_t count,
124 int (*sprom_check_crc)(const u16 *sprom, size_t size),
125 int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
126 -extern const struct ssb_sprom *ssb_get_fallback_sprom(void);
127 +extern int ssb_fill_sprom_with_fallback(struct ssb_bus *bus, struct ssb_sprom *out);
131 --- a/include/linux/ssb/ssb.h
132 +++ b/include/linux/ssb/ssb.h
133 @@ -404,7 +404,9 @@ extern bool ssb_is_sprom_available(struc
135 /* Set a fallback SPROM.
136 * See kdoc at the function definition for complete documentation. */
137 -extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom);
138 +extern int ssb_arch_register_fallback_sprom(
139 + int (*sprom_callback)(struct ssb_bus *bus,
140 + struct ssb_sprom *out));
142 /* Suspend a SSB bus.
143 * Call this from the parent bus suspend routine. */