-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel Drake
authored and
John W. Linville
committed
Apr 17, 2012
1 parent
9d8209b
commit 807699d
Showing
9 changed files
with
95 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: be03d4a45c09ee5100d3aaaedd087f19bc20d01f | ||
refs/heads/master: 370803c25dd77332ee4ca97884c3a5e1e1eafbca |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Firmware loading and handling functions. | ||
*/ | ||
|
||
#include <linux/firmware.h> | ||
#include <linux/module.h> | ||
|
||
#include "decl.h" | ||
|
||
/** | ||
* lbs_get_firmware - Retrieves two-stage firmware | ||
* | ||
* @dev: A pointer to &device structure | ||
* @card_model: Bus-specific card model ID used to filter firmware table | ||
* elements | ||
* @fw_table: Table of firmware file names and device model numbers | ||
* terminated by an entry with a NULL helper name | ||
* @helper: On success, the helper firmware; caller must free | ||
* @mainfw: On success, the main firmware; caller must free | ||
* | ||
* returns: 0 on success, non-zero on failure | ||
*/ | ||
int lbs_get_firmware(struct device *dev, u32 card_model, | ||
const struct lbs_fw_table *fw_table, | ||
const struct firmware **helper, | ||
const struct firmware **mainfw) | ||
{ | ||
const struct lbs_fw_table *iter; | ||
int ret; | ||
|
||
BUG_ON(helper == NULL); | ||
BUG_ON(mainfw == NULL); | ||
|
||
/* Search for firmware to use from the table. */ | ||
iter = fw_table; | ||
while (iter && iter->helper) { | ||
if (iter->model != card_model) | ||
goto next; | ||
|
||
if (*helper == NULL) { | ||
ret = request_firmware(helper, iter->helper, dev); | ||
if (ret) | ||
goto next; | ||
|
||
/* If the device has one-stage firmware (ie cf8305) and | ||
* we've got it then we don't need to bother with the | ||
* main firmware. | ||
*/ | ||
if (iter->fwname == NULL) | ||
return 0; | ||
} | ||
|
||
if (*mainfw == NULL) { | ||
ret = request_firmware(mainfw, iter->fwname, dev); | ||
if (ret) { | ||
/* Clear the helper to ensure we don't have | ||
* mismatched firmware pairs. | ||
*/ | ||
release_firmware(*helper); | ||
*helper = NULL; | ||
} | ||
} | ||
|
||
if (*helper && *mainfw) | ||
return 0; | ||
|
||
next: | ||
iter++; | ||
} | ||
|
||
/* Failed */ | ||
release_firmware(*helper); | ||
*helper = NULL; | ||
release_firmware(*mainfw); | ||
*mainfw = NULL; | ||
|
||
return -ENOENT; | ||
} | ||
EXPORT_SYMBOL_GPL(lbs_get_firmware); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.