16 #include <linux/ctype.h>
17 #include <linux/slab.h>
23 static int sprom2hex(
const u16 *sprom,
char *
buf,
size_t buf_len,
24 size_t sprom_size_words)
28 for (i = 0; i < sprom_size_words; i++)
29 pos +=
snprintf(buf + pos, buf_len - pos - 1,
30 "%04X",
swab16(sprom[i]) & 0xFFFF);
31 pos +=
snprintf(buf + pos, buf_len - pos - 1,
"\n");
36 static int hex2sprom(
u16 *sprom,
const char *
dump,
size_t len,
37 size_t sprom_size_words)
39 char c,
tmp[5] = { 0 };
51 if (len != sprom_size_words * 4)
54 while (cnt < sprom_size_words) {
68 int (*sprom_read)(
struct ssb_bus *bus,
u16 *sprom))
85 err = sprom_read(bus, sprom);
89 count = sprom2hex(sprom, buf,
PAGE_SIZE, sprom_size_words);
94 return err ? err :
count;
99 const char *buf,
size_t count,
100 int (*sprom_check_crc)(
const u16 *sprom,
size_t size),
101 int (*sprom_write)(
struct ssb_bus *bus,
const u16 *sprom))
111 err = hex2sprom(sprom, buf, count, sprom_size_words);
116 err = sprom_check_crc(sprom, sprom_size_words);
133 res = sprom_write(bus, sprom);
144 return err ? err :
count;
172 if (get_fallback_sprom)
174 get_fallback_sprom = sprom_callback;
181 if (!get_fallback_sprom)
184 return get_fallback_sprom(bus, out);
196 bus->
chipco.dev->id.revision >= 31)