staging: rtl8192e: Add rt_fw_blob

rt_fw_blob contains single firmware blob and its size.
Update firmware loading code accordingly.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Mateusz Kulikowski 2015-10-19 22:00:22 +02:00 committed by Greg Kroah-Hartman
parent c0f6479165
commit 292f4b47ba
2 changed files with 17 additions and 14 deletions

View File

@ -233,7 +233,7 @@ bool rtl92e_init_fw(struct net_device *dev)
for (i = starting_state; i <= FW_INIT_STEP2_DATA; i++) {
if (rst_opt == OPT_SYSTEM_RESET) {
if (pfirmware->firmware_buf_size[i] == 0) {
if (pfirmware->blobs[i].size == 0) {
const char *fw_name[3] = {
RTL8192E_BOOT_IMG_FW,
RTL8192E_MAIN_IMG_FW,
@ -250,8 +250,7 @@ bool rtl92e_init_fw(struct net_device *dev)
"request firmware fail!\n");
goto download_firmware_fail;
}
if (fw_entry->size >
sizeof(pfirmware->firmware_buf[i])) {
if (fw_entry->size > MAX_FW_SIZE) {
RT_TRACE(COMP_FIRMWARE,
"img file size exceed the container struct buffer fail!\n");
release_firmware(fw_entry);
@ -259,17 +258,17 @@ bool rtl92e_init_fw(struct net_device *dev)
}
if (i != FW_INIT_STEP1_MAIN) {
memcpy(pfirmware->firmware_buf[i],
memcpy(pfirmware->blobs[i].data,
fw_entry->data, fw_entry->size);
pfirmware->firmware_buf_size[i] =
pfirmware->blobs[i].size =
fw_entry->size;
} else {
memset(pfirmware->firmware_buf[i],
memset(pfirmware->blobs[i].data,
0, 128);
memcpy(&pfirmware->firmware_buf[i][128],
memcpy(&pfirmware->blobs[i].data[128],
fw_entry->data, fw_entry->size);
pfirmware->firmware_buf_size[i] =
pfirmware->blobs[i].size =
fw_entry->size + 128;
}
@ -278,8 +277,8 @@ bool rtl92e_init_fw(struct net_device *dev)
}
}
mapped_file = pfirmware->firmware_buf[i];
file_length = pfirmware->firmware_buf_size[i];
mapped_file = pfirmware->blobs[i].data;
file_length = pfirmware->blobs[i].size;
rt_status = _rtl92e_fw_download_code(dev, mapped_file,
file_length);

View File

@ -44,12 +44,16 @@ enum firmware_status {
FW_STATUS_5_READY = 5,
};
#define MAX_FW_SIZE 64000
struct rt_fw_blob {
u16 size;
u8 data[MAX_FW_SIZE];
};
#define FW_BLOBS 3
struct rt_firmware {
enum firmware_status firmware_status;
#define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
#define MAX_FW_INIT_STEP 3
u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE];
u16 firmware_buf_size[MAX_FW_INIT_STEP];
struct rt_fw_blob blobs[FW_BLOBS];
};
bool rtl92e_init_fw(struct net_device *dev);