Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 342112
b: refs/heads/master
c: ab5c4f7
h: refs/heads/master
v: v3
  • Loading branch information
Gabor Juhos authored and John W. Linville committed Dec 10, 2012
1 parent daff62b commit 4a712bc
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 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: 0e4b9f2f12e94686855605eda64ea534a95d77f2
refs/heads/master: ab5c4f71d8c7add173a2d32e5beefdaaf1b7cbbc
19 changes: 18 additions & 1 deletion trunk/drivers/net/wireless/ath/ath9k/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,29 @@ void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
}
}

static bool ath9k_hw_nvram_read_blob(struct ath_hw *ah, u32 off,
u16 *data)
{
u16 *blob_data;

if (off * sizeof(u16) > ah->eeprom_blob->size)
return false;

blob_data = (u16 *)ah->eeprom_blob->data;
*data = blob_data[off];
return true;
}

bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data)
{
struct ath_common *common = ath9k_hw_common(ah);
bool ret;

ret = common->bus_ops->eeprom_read(common, off, data);
if (ah->eeprom_blob)
ret = ath9k_hw_nvram_read_blob(ah, off, data);
else
ret = common->bus_ops->eeprom_read(common, off, data);

if (!ret)
ath_dbg(common, EEPROM,
"unable to read eeprom region at offset %u\n", off);
Expand Down
3 changes: 3 additions & 0 deletions trunk/drivers/net/wireless/ath/ath9k/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/if_ether.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/firmware.h>

#include "mac.h"
#include "ani.h"
Expand Down Expand Up @@ -921,6 +922,8 @@ struct ath_hw {
bool is_clk_25mhz;
int (*get_mac_revision)(void);
int (*external_reset)(void);

const struct firmware *eeprom_blob;
};

struct ath_bus_ops {
Expand Down
60 changes: 59 additions & 1 deletion trunk/drivers/net/wireless/ath/ath9k/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

#include "ath9k.h"

struct ath9k_eeprom_ctx {
struct completion complete;
struct ath_hw *ah;
};

static char *dev_info = "ath9k";

MODULE_AUTHOR("Atheros Communications");
Expand Down Expand Up @@ -506,6 +511,51 @@ static void ath9k_init_misc(struct ath_softc *sc)
sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT;
}

static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob,
void *ctx)
{
struct ath9k_eeprom_ctx *ec = ctx;

if (eeprom_blob)
ec->ah->eeprom_blob = eeprom_blob;

complete(&ec->complete);
}

static int ath9k_eeprom_request(struct ath_softc *sc, const char *name)
{
struct ath9k_eeprom_ctx ec;
struct ath_hw *ah = ah = sc->sc_ah;
int err;

/* try to load the EEPROM content asynchronously */
init_completion(&ec.complete);
ec.ah = sc->sc_ah;

err = request_firmware_nowait(THIS_MODULE, 1, name, sc->dev, GFP_KERNEL,
&ec, ath9k_eeprom_request_cb);
if (err < 0) {
ath_err(ath9k_hw_common(ah),
"EEPROM request failed\n");
return err;
}

wait_for_completion(&ec.complete);

if (!ah->eeprom_blob) {
ath_err(ath9k_hw_common(ah),
"Unable to load EEPROM file %s\n", name);
return -EINVAL;
}

return 0;
}

static void ath9k_eeprom_release(struct ath_softc *sc)
{
release_firmware(sc->sc_ah->eeprom_blob);
}

static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
const struct ath_bus_ops *bus_ops)
{
Expand Down Expand Up @@ -583,6 +633,12 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
ath_read_cachesize(common, &csz);
common->cachelsz = csz << 2; /* convert to bytes */

if (pdata->eeprom_name) {
ret = ath9k_eeprom_request(sc, pdata->eeprom_name);
if (ret)
goto err_eeprom;
}

/* Initializes the hardware for all supported chipsets */
ret = ath9k_hw_init(ah);
if (ret)
Expand Down Expand Up @@ -619,7 +675,8 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
err_queues:
ath9k_hw_deinit(ah);
err_hw:

ath9k_eeprom_release(sc);
err_eeprom:
kfree(ah);
sc->sc_ah = NULL;

Expand Down Expand Up @@ -882,6 +939,7 @@ static void ath9k_deinit_softc(struct ath_softc *sc)
if (sc->dfs_detector != NULL)
sc->dfs_detector->exit(sc->dfs_detector);

ath9k_eeprom_release(sc);
kfree(sc->sc_ah);
sc->sc_ah = NULL;
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/ath9k_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#define ATH9K_PLAT_EEP_MAX_WORDS 2048

struct ath9k_platform_data {
const char *eeprom_name;

u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
u8 *macaddr;

Expand Down

0 comments on commit 4a712bc

Please sign in to comment.