Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wlcore: create private static_data area and add operation to parse it

The wl18xx firmware has more information in the static_data than
wl12xx. To be able to parse that in an abstracted way, this patch
adds a priv area to the static data struct and an operation that
allows the lower driver to parse it if necessary.

Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Arik Nemtsov <arik@wizery.com>

+47 -24
+31 -24
drivers/net/wireless/ti/wlcore/boot.c
··· 45 45 wlcore_write_reg(wl, REG_ECPU_CONTROL, cpu_ctrl); 46 46 } 47 47 48 - static int wlcore_parse_fw_ver(struct wl1271 *wl) 48 + static int wlcore_boot_parse_fw_ver(struct wl1271 *wl, 49 + struct wl1271_static_data *static_data) 49 50 { 50 51 int ret; 52 + 53 + strncpy(wl->chip.fw_ver_str, static_data->fw_version, 54 + sizeof(wl->chip.fw_ver_str)); 55 + 56 + /* make sure the string is NULL-terminated */ 57 + wl->chip.fw_ver_str[sizeof(wl->chip.fw_ver_str) - 1] = '\0'; 51 58 52 59 ret = sscanf(wl->chip.fw_ver_str + 4, "%u.%u.%u.%u.%u", 53 60 &wl->chip.fw_ver[0], &wl->chip.fw_ver[1], ··· 64 57 if (ret != 5) { 65 58 wl1271_warning("fw version incorrect value"); 66 59 memset(wl->chip.fw_ver, 0, sizeof(wl->chip.fw_ver)); 67 - return -EINVAL; 60 + ret = -EINVAL; 61 + goto out; 68 62 } 69 63 70 64 ret = wlcore_identify_fw(wl); 71 65 if (ret < 0) 72 - return ret; 73 - 74 - return 0; 66 + goto out; 67 + out: 68 + return ret; 75 69 } 76 70 77 - static int wlcore_boot_fw_version(struct wl1271 *wl) 71 + static int wlcore_boot_static_data(struct wl1271 *wl) 78 72 { 79 73 struct wl1271_static_data *static_data; 74 + size_t len = sizeof(*static_data) + wl->static_data_priv_len; 80 75 int ret; 81 76 82 - static_data = kmalloc(sizeof(*static_data), GFP_KERNEL | GFP_DMA); 77 + static_data = kmalloc(len, GFP_KERNEL); 83 78 if (!static_data) { 84 - wl1271_error("Couldn't allocate memory for static data!"); 85 - return -ENOMEM; 79 + ret = -ENOMEM; 80 + goto out; 86 81 } 87 82 88 - wl1271_read(wl, wl->cmd_box_addr, static_data, sizeof(*static_data), 89 - false); 83 + wl1271_read(wl, wl->cmd_box_addr, static_data, len, false); 90 84 91 - strncpy(wl->chip.fw_ver_str, static_data->fw_version, 92 - sizeof(wl->chip.fw_ver_str)); 93 - 94 - kfree(static_data); 95 - 96 - /* make sure the string is NULL-terminated */ 97 - wl->chip.fw_ver_str[sizeof(wl->chip.fw_ver_str) - 1] = '\0'; 98 - 99 - ret = wlcore_parse_fw_ver(wl); 85 + ret = wlcore_boot_parse_fw_ver(wl, static_data); 100 86 if (ret < 0) 101 - return ret; 87 + goto out_free; 102 88 103 - return 0; 89 + ret = wlcore_handle_static_data(wl, static_data); 90 + if (ret < 0) 91 + goto out_free; 92 + 93 + out_free: 94 + kfree(static_data); 95 + out: 96 + return ret; 104 97 } 105 98 106 99 static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf, ··· 407 400 wl1271_debug(DEBUG_MAILBOX, "MBOX ptrs: 0x%x 0x%x", 408 401 wl->mbox_ptr[0], wl->mbox_ptr[1]); 409 402 410 - ret = wlcore_boot_fw_version(wl); 403 + ret = wlcore_boot_static_data(wl); 411 404 if (ret < 0) { 412 - wl1271_error("couldn't boot firmware"); 405 + wl1271_error("error getting static data"); 413 406 return ret; 414 407 } 415 408
+1
drivers/net/wireless/ti/wlcore/boot.h
··· 40 40 u8 fw_version[WL1271_FW_VERSION_MAX_LEN]; 41 41 u32 hw_version; 42 42 u8 tx_power_table[WL1271_NO_SUBBANDS][WL1271_NO_POWER_LEVELS]; 43 + u8 priv[0]; 43 44 }; 44 45 45 46 /* number of times we try to read the INIT interrupt */
+9
drivers/net/wireless/ti/wlcore/hw_ops.h
··· 158 158 return 0; 159 159 } 160 160 161 + static inline int 162 + wlcore_handle_static_data(struct wl1271 *wl, void *static_data) 163 + { 164 + if (wl->ops->handle_static_data) 165 + return wl->ops->handle_static_data(wl, static_data); 166 + 167 + return 0; 168 + } 169 + 161 170 #endif
+6
drivers/net/wireless/ti/wlcore/wlcore.h
··· 26 26 27 27 #include "wlcore_i.h" 28 28 #include "event.h" 29 + #include "boot.h" 29 30 30 31 /* The maximum number of Tx descriptors in all chip families */ 31 32 #define WLCORE_MAX_TX_DESCRIPTORS 32 ··· 73 72 u32 (*ap_get_mimo_wide_rate_mask)(struct wl1271 *wl, 74 73 struct wl12xx_vif *wlvif); 75 74 int (*debugfs_init)(struct wl1271 *wl, struct dentry *rootdir); 75 + int (*handle_static_data)(struct wl1271 *wl, 76 + struct wl1271_static_data *static_data); 76 77 }; 77 78 78 79 enum wlcore_partitions { ··· 375 372 376 373 /* RX Data filter rule state - enabled/disabled */ 377 374 bool rx_filter_enabled[WL1271_MAX_RX_FILTERS]; 375 + 376 + /* size of the private static data */ 377 + size_t static_data_priv_len; 378 378 379 379 /* the current channel type */ 380 380 enum nl80211_channel_type channel_type;