Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 135068
b: refs/heads/master
c: e79c1ba
h: refs/heads/master
v: v3
  • Loading branch information
Michael Buesch authored and John W. Linville committed Mar 5, 2009
1 parent 546eecf commit 08e8de8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e31ae0508315ebf5d8b1b8a1fca8550737fb3996
refs/heads/master: e79c1ba84c68de9161d541bd2bcc8ea65c89955c
14 changes: 13 additions & 1 deletion trunk/drivers/ssb/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
static int ssb_pci_sprom_get(struct ssb_bus *bus,
struct ssb_sprom *sprom)
{
const struct ssb_sprom *fallback;
int err = -ENOMEM;
u16 *buf;

Expand All @@ -583,12 +584,23 @@ static int ssb_pci_sprom_get(struct ssb_bus *bus,
bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
sprom_do_read(bus, buf);
err = sprom_check_crc(buf, bus->sprom_size);
if (err)
if (err) {
/* All CRC attempts failed.
* Maybe there is no SPROM on the device?
* If we have a fallback, use that. */
fallback = ssb_get_fallback_sprom();
if (fallback) {
memcpy(sprom, fallback, sizeof(*sprom));
err = 0;
goto out_free;
}
ssb_printk(KERN_WARNING PFX "WARNING: Invalid"
" SPROM CRC (corrupt SPROM)\n");
}
}
err = sprom_extract(bus, sprom, buf, bus->sprom_size);

out_free:
kfree(buf);
out:
return err;
Expand Down
36 changes: 36 additions & 0 deletions trunk/drivers/ssb/sprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include "ssb_private.h"


static const struct ssb_sprom *fallback_sprom;


static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
size_t sprom_size_words)
{
Expand Down Expand Up @@ -131,3 +134,36 @@ ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
return res;
return err ? err : count;
}

/**
* ssb_arch_set_fallback_sprom - Set a fallback SPROM for use if no SPROM is found.
*
* @sprom: The SPROM data structure to register.
*
* With this function the architecture implementation may register a fallback
* SPROM data structure. The fallback is only used for PCI based SSB devices,
* where no valid SPROM can be found in the shadow registers.
*
* This function is useful for weird architectures that have a half-assed SSB device
* hardwired to their PCI bus.
*
* Note that it does only work with PCI attached SSB devices. PCMCIA devices currently
* don't use this fallback.
* Architectures must provide the SPROM for native SSB devices anyway,
* so the fallback also isn't used for native devices.
*
* This function is available for architecture code, only. So it is not exported.
*/
int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom)
{
if (fallback_sprom)
return -EEXIST;
fallback_sprom = sprom;

return 0;
}

const struct ssb_sprom *ssb_get_fallback_sprom(void)
{
return fallback_sprom;
}
1 change: 1 addition & 0 deletions trunk/drivers/ssb/ssb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ ssize_t ssb_attr_sprom_store(struct ssb_bus *bus,
const char *buf, size_t count,
int (*sprom_check_crc)(const u16 *sprom, size_t size),
int (*sprom_write)(struct ssb_bus *bus, const u16 *sprom));
extern const struct ssb_sprom *ssb_get_fallback_sprom(void);


/* core.c */
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/linux/ssb/ssb.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,

extern void ssb_bus_unregister(struct ssb_bus *bus);

/* Set a fallback SPROM.
* See kdoc at the function definition for complete documentation. */
extern int ssb_arch_set_fallback_sprom(const struct ssb_sprom *sprom);

/* Suspend a SSB bus.
* Call this from the parent bus suspend routine. */
extern int ssb_bus_suspend(struct ssb_bus *bus);
Expand Down

0 comments on commit 08e8de8

Please sign in to comment.