From: Mateusz Kulikowski Date: Mon, 19 Oct 2015 20:00:22 +0000 (+0200) Subject: staging: rtl8192e: Add rt_fw_blob X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=292f4b47baf8e45b4196dab432ee787fd1eeca88;p=linux-beck.git 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c index f88e112847a1..eb1f1bb46ca2 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c @@ -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); diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h index 186c65d6f6d3..4dde93eda4de 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.h @@ -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);