xref: /openbmc/linux/drivers/net/wireless/microchip/wilc1000/wlan_cfg.c (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
15625f965SAjay Singh // SPDX-License-Identifier: GPL-2.0
25625f965SAjay Singh /*
35625f965SAjay Singh  * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
45625f965SAjay Singh  * All rights reserved.
55625f965SAjay Singh  */
65625f965SAjay Singh 
75625f965SAjay Singh #include <linux/bitfield.h>
85625f965SAjay Singh #include "wlan_if.h"
95625f965SAjay Singh #include "wlan.h"
105625f965SAjay Singh #include "wlan_cfg.h"
115625f965SAjay Singh #include "netdev.h"
125625f965SAjay Singh 
135625f965SAjay Singh enum cfg_cmd_type {
145625f965SAjay Singh 	CFG_BYTE_CMD	= 0,
155625f965SAjay Singh 	CFG_HWORD_CMD	= 1,
165625f965SAjay Singh 	CFG_WORD_CMD	= 2,
175625f965SAjay Singh 	CFG_STR_CMD	= 3,
185625f965SAjay Singh 	CFG_BIN_CMD	= 4
195625f965SAjay Singh };
205625f965SAjay Singh 
215625f965SAjay Singh static const struct wilc_cfg_byte g_cfg_byte[] = {
225625f965SAjay Singh 	{WID_STATUS, 0},
235625f965SAjay Singh 	{WID_RSSI, 0},
245625f965SAjay Singh 	{WID_LINKSPEED, 0},
252f6e44eeSAjay Singh 	{WID_TX_POWER, 0},
260ec5408cSAjay Singh 	{WID_WOWLAN_TRIGGER, 0},
275625f965SAjay Singh 	{WID_NIL, 0}
285625f965SAjay Singh };
295625f965SAjay Singh 
305625f965SAjay Singh static const struct wilc_cfg_hword g_cfg_hword[] = {
315625f965SAjay Singh 	{WID_NIL, 0}
325625f965SAjay Singh };
335625f965SAjay Singh 
345625f965SAjay Singh static const struct wilc_cfg_word g_cfg_word[] = {
355625f965SAjay Singh 	{WID_FAILED_COUNT, 0},
365625f965SAjay Singh 	{WID_RECEIVED_FRAGMENT_COUNT, 0},
375625f965SAjay Singh 	{WID_SUCCESS_FRAME_COUNT, 0},
385625f965SAjay Singh 	{WID_GET_INACTIVE_TIME, 0},
395625f965SAjay Singh 	{WID_NIL, 0}
405625f965SAjay Singh 
415625f965SAjay Singh };
425625f965SAjay Singh 
435625f965SAjay Singh static const struct wilc_cfg_str g_cfg_str[] = {
445625f965SAjay Singh 	{WID_FIRMWARE_VERSION, NULL},
455625f965SAjay Singh 	{WID_MAC_ADDR, NULL},
465625f965SAjay Singh 	{WID_ASSOC_RES_INFO, NULL},
475625f965SAjay Singh 	{WID_NIL, NULL}
485625f965SAjay Singh };
495625f965SAjay Singh 
505625f965SAjay Singh #define WILC_RESP_MSG_TYPE_CONFIG_REPLY		'R'
515625f965SAjay Singh #define WILC_RESP_MSG_TYPE_STATUS_INFO		'I'
525625f965SAjay Singh #define WILC_RESP_MSG_TYPE_NETWORK_INFO		'N'
535625f965SAjay Singh #define WILC_RESP_MSG_TYPE_SCAN_COMPLETE	'S'
545625f965SAjay Singh 
555625f965SAjay Singh /********************************************
565625f965SAjay Singh  *
575625f965SAjay Singh  *      Configuration Functions
585625f965SAjay Singh  *
595625f965SAjay Singh  ********************************************/
605625f965SAjay Singh 
wilc_wlan_cfg_set_byte(u8 * frame,u32 offset,u16 id,u8 val8)615625f965SAjay Singh static int wilc_wlan_cfg_set_byte(u8 *frame, u32 offset, u16 id, u8 val8)
625625f965SAjay Singh {
635625f965SAjay Singh 	if ((offset + 4) >= WILC_MAX_CFG_FRAME_SIZE)
645625f965SAjay Singh 		return 0;
655625f965SAjay Singh 
665625f965SAjay Singh 	put_unaligned_le16(id, &frame[offset]);
675625f965SAjay Singh 	put_unaligned_le16(1, &frame[offset + 2]);
685625f965SAjay Singh 	frame[offset + 4] = val8;
695625f965SAjay Singh 	return 5;
705625f965SAjay Singh }
715625f965SAjay Singh 
wilc_wlan_cfg_set_hword(u8 * frame,u32 offset,u16 id,u16 val16)725625f965SAjay Singh static int wilc_wlan_cfg_set_hword(u8 *frame, u32 offset, u16 id, u16 val16)
735625f965SAjay Singh {
745625f965SAjay Singh 	if ((offset + 5) >= WILC_MAX_CFG_FRAME_SIZE)
755625f965SAjay Singh 		return 0;
765625f965SAjay Singh 
775625f965SAjay Singh 	put_unaligned_le16(id, &frame[offset]);
785625f965SAjay Singh 	put_unaligned_le16(2, &frame[offset + 2]);
795625f965SAjay Singh 	put_unaligned_le16(val16, &frame[offset + 4]);
805625f965SAjay Singh 
815625f965SAjay Singh 	return 6;
825625f965SAjay Singh }
835625f965SAjay Singh 
wilc_wlan_cfg_set_word(u8 * frame,u32 offset,u16 id,u32 val32)845625f965SAjay Singh static int wilc_wlan_cfg_set_word(u8 *frame, u32 offset, u16 id, u32 val32)
855625f965SAjay Singh {
865625f965SAjay Singh 	if ((offset + 7) >= WILC_MAX_CFG_FRAME_SIZE)
875625f965SAjay Singh 		return 0;
885625f965SAjay Singh 
895625f965SAjay Singh 	put_unaligned_le16(id, &frame[offset]);
905625f965SAjay Singh 	put_unaligned_le16(4, &frame[offset + 2]);
915625f965SAjay Singh 	put_unaligned_le32(val32, &frame[offset + 4]);
925625f965SAjay Singh 
935625f965SAjay Singh 	return 8;
945625f965SAjay Singh }
955625f965SAjay Singh 
wilc_wlan_cfg_set_str(u8 * frame,u32 offset,u16 id,u8 * str,u32 size)965625f965SAjay Singh static int wilc_wlan_cfg_set_str(u8 *frame, u32 offset, u16 id, u8 *str,
975625f965SAjay Singh 				 u32 size)
985625f965SAjay Singh {
995625f965SAjay Singh 	if ((offset + size + 4) >= WILC_MAX_CFG_FRAME_SIZE)
1005625f965SAjay Singh 		return 0;
1015625f965SAjay Singh 
1025625f965SAjay Singh 	put_unaligned_le16(id, &frame[offset]);
1035625f965SAjay Singh 	put_unaligned_le16(size, &frame[offset + 2]);
1045625f965SAjay Singh 	if (str && size != 0)
1055625f965SAjay Singh 		memcpy(&frame[offset + 4], str, size);
1065625f965SAjay Singh 
1075625f965SAjay Singh 	return (size + 4);
1085625f965SAjay Singh }
1095625f965SAjay Singh 
wilc_wlan_cfg_set_bin(u8 * frame,u32 offset,u16 id,u8 * b,u32 size)1105625f965SAjay Singh static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size)
1115625f965SAjay Singh {
1125625f965SAjay Singh 	u32 i;
1135625f965SAjay Singh 	u8 checksum = 0;
1145625f965SAjay Singh 
1155625f965SAjay Singh 	if ((offset + size + 5) >= WILC_MAX_CFG_FRAME_SIZE)
1165625f965SAjay Singh 		return 0;
1175625f965SAjay Singh 
1185625f965SAjay Singh 	put_unaligned_le16(id, &frame[offset]);
1195625f965SAjay Singh 	put_unaligned_le16(size, &frame[offset + 2]);
1205625f965SAjay Singh 
1215625f965SAjay Singh 	if ((b) && size != 0) {
1225625f965SAjay Singh 		memcpy(&frame[offset + 4], b, size);
1235625f965SAjay Singh 		for (i = 0; i < size; i++)
1245625f965SAjay Singh 			checksum += frame[offset + i + 4];
1255625f965SAjay Singh 	}
1265625f965SAjay Singh 
1275625f965SAjay Singh 	frame[offset + size + 4] = checksum;
1285625f965SAjay Singh 
1295625f965SAjay Singh 	return (size + 5);
1305625f965SAjay Singh }
1315625f965SAjay Singh 
1325625f965SAjay Singh /********************************************
1335625f965SAjay Singh  *
1345625f965SAjay Singh  *      Configuration Response Functions
1355625f965SAjay Singh  *
1365625f965SAjay Singh  ********************************************/
1375625f965SAjay Singh 
wilc_wlan_parse_response_frame(struct wilc * wl,u8 * info,int size)1385625f965SAjay Singh static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
1395625f965SAjay Singh {
1405625f965SAjay Singh 	u16 wid;
1415625f965SAjay Singh 	u32 len = 0, i = 0;
1425625f965SAjay Singh 	struct wilc_cfg *cfg = &wl->cfg;
1435625f965SAjay Singh 
1445625f965SAjay Singh 	while (size > 0) {
1455625f965SAjay Singh 		i = 0;
1465625f965SAjay Singh 		wid = get_unaligned_le16(info);
1475625f965SAjay Singh 
1485625f965SAjay Singh 		switch (FIELD_GET(WILC_WID_TYPE, wid)) {
1495625f965SAjay Singh 		case WID_CHAR:
1505625f965SAjay Singh 			while (cfg->b[i].id != WID_NIL && cfg->b[i].id != wid)
1515625f965SAjay Singh 				i++;
1525625f965SAjay Singh 
1535625f965SAjay Singh 			if (cfg->b[i].id == wid)
1545625f965SAjay Singh 				cfg->b[i].val = info[4];
1555625f965SAjay Singh 
1565625f965SAjay Singh 			len = 3;
1575625f965SAjay Singh 			break;
1585625f965SAjay Singh 
1595625f965SAjay Singh 		case WID_SHORT:
1605625f965SAjay Singh 			while (cfg->hw[i].id != WID_NIL && cfg->hw[i].id != wid)
1615625f965SAjay Singh 				i++;
1625625f965SAjay Singh 
1635625f965SAjay Singh 			if (cfg->hw[i].id == wid)
1645625f965SAjay Singh 				cfg->hw[i].val = get_unaligned_le16(&info[4]);
1655625f965SAjay Singh 
1665625f965SAjay Singh 			len = 4;
1675625f965SAjay Singh 			break;
1685625f965SAjay Singh 
1695625f965SAjay Singh 		case WID_INT:
1705625f965SAjay Singh 			while (cfg->w[i].id != WID_NIL && cfg->w[i].id != wid)
1715625f965SAjay Singh 				i++;
1725625f965SAjay Singh 
1735625f965SAjay Singh 			if (cfg->w[i].id == wid)
1745625f965SAjay Singh 				cfg->w[i].val = get_unaligned_le32(&info[4]);
1755625f965SAjay Singh 
1765625f965SAjay Singh 			len = 6;
1775625f965SAjay Singh 			break;
1785625f965SAjay Singh 
1795625f965SAjay Singh 		case WID_STR:
1805625f965SAjay Singh 			while (cfg->s[i].id != WID_NIL && cfg->s[i].id != wid)
1815625f965SAjay Singh 				i++;
1825625f965SAjay Singh 
1835625f965SAjay Singh 			if (cfg->s[i].id == wid)
184*12fb1ae5SAjay Singh 				memcpy(cfg->s[i].str, &info[2],
185*12fb1ae5SAjay Singh 				       get_unaligned_le16(&info[2]) + 2);
1865625f965SAjay Singh 
187*12fb1ae5SAjay Singh 			len = 2 + get_unaligned_le16(&info[2]);
1885625f965SAjay Singh 			break;
1895625f965SAjay Singh 
1905625f965SAjay Singh 		default:
1915625f965SAjay Singh 			break;
1925625f965SAjay Singh 		}
1935625f965SAjay Singh 		size -= (2 + len);
1945625f965SAjay Singh 		info += (2 + len);
1955625f965SAjay Singh 	}
1965625f965SAjay Singh }
1975625f965SAjay Singh 
wilc_wlan_parse_info_frame(struct wilc * wl,u8 * info)1985625f965SAjay Singh static void wilc_wlan_parse_info_frame(struct wilc *wl, u8 *info)
1995625f965SAjay Singh {
2005625f965SAjay Singh 	u32 wid, len;
2015625f965SAjay Singh 
2025625f965SAjay Singh 	wid = get_unaligned_le16(info);
2035625f965SAjay Singh 
2045625f965SAjay Singh 	len = info[2];
2055625f965SAjay Singh 
2065625f965SAjay Singh 	if (len == 1 && wid == WID_STATUS) {
2075625f965SAjay Singh 		int i = 0;
2085625f965SAjay Singh 
2095625f965SAjay Singh 		while (wl->cfg.b[i].id != WID_NIL &&
2105625f965SAjay Singh 		       wl->cfg.b[i].id != wid)
2115625f965SAjay Singh 			i++;
2125625f965SAjay Singh 
2135625f965SAjay Singh 		if (wl->cfg.b[i].id == wid)
2145625f965SAjay Singh 			wl->cfg.b[i].val = info[3];
2155625f965SAjay Singh 	}
2165625f965SAjay Singh }
2175625f965SAjay Singh 
2185625f965SAjay Singh /********************************************
2195625f965SAjay Singh  *
2205625f965SAjay Singh  *      Configuration Exported Functions
2215625f965SAjay Singh  *
2225625f965SAjay Singh  ********************************************/
2235625f965SAjay Singh 
wilc_wlan_cfg_set_wid(u8 * frame,u32 offset,u16 id,u8 * buf,int size)2245625f965SAjay Singh int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size)
2255625f965SAjay Singh {
2265625f965SAjay Singh 	u8 type = FIELD_GET(WILC_WID_TYPE, id);
2275625f965SAjay Singh 	int ret = 0;
2285625f965SAjay Singh 
2295625f965SAjay Singh 	switch (type) {
2305625f965SAjay Singh 	case CFG_BYTE_CMD:
2315625f965SAjay Singh 		if (size >= 1)
2325625f965SAjay Singh 			ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf);
2335625f965SAjay Singh 		break;
2345625f965SAjay Singh 
2355625f965SAjay Singh 	case CFG_HWORD_CMD:
2365625f965SAjay Singh 		if (size >= 2)
2375625f965SAjay Singh 			ret = wilc_wlan_cfg_set_hword(frame, offset, id,
2385625f965SAjay Singh 						      *((u16 *)buf));
2395625f965SAjay Singh 		break;
2405625f965SAjay Singh 
2415625f965SAjay Singh 	case CFG_WORD_CMD:
2425625f965SAjay Singh 		if (size >= 4)
2435625f965SAjay Singh 			ret = wilc_wlan_cfg_set_word(frame, offset, id,
2445625f965SAjay Singh 						     *((u32 *)buf));
2455625f965SAjay Singh 		break;
2465625f965SAjay Singh 
2475625f965SAjay Singh 	case CFG_STR_CMD:
2485625f965SAjay Singh 		ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size);
2495625f965SAjay Singh 		break;
2505625f965SAjay Singh 
2515625f965SAjay Singh 	case CFG_BIN_CMD:
2525625f965SAjay Singh 		ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size);
2535625f965SAjay Singh 		break;
2545625f965SAjay Singh 	}
2555625f965SAjay Singh 
2565625f965SAjay Singh 	return ret;
2575625f965SAjay Singh }
2585625f965SAjay Singh 
wilc_wlan_cfg_get_wid(u8 * frame,u32 offset,u16 id)2595625f965SAjay Singh int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id)
2605625f965SAjay Singh {
2615625f965SAjay Singh 	if ((offset + 2) >= WILC_MAX_CFG_FRAME_SIZE)
2625625f965SAjay Singh 		return 0;
2635625f965SAjay Singh 
2645625f965SAjay Singh 	put_unaligned_le16(id, &frame[offset]);
2655625f965SAjay Singh 
2665625f965SAjay Singh 	return 2;
2675625f965SAjay Singh }
2685625f965SAjay Singh 
wilc_wlan_cfg_get_val(struct wilc * wl,u16 wid,u8 * buffer,u32 buffer_size)2695625f965SAjay Singh int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
2705625f965SAjay Singh 			  u32 buffer_size)
2715625f965SAjay Singh {
2725625f965SAjay Singh 	u8 type = FIELD_GET(WILC_WID_TYPE, wid);
2735625f965SAjay Singh 	int i, ret = 0;
2745625f965SAjay Singh 	struct wilc_cfg *cfg = &wl->cfg;
2755625f965SAjay Singh 
2765625f965SAjay Singh 	i = 0;
2775625f965SAjay Singh 	if (type == CFG_BYTE_CMD) {
2785625f965SAjay Singh 		while (cfg->b[i].id != WID_NIL && cfg->b[i].id != wid)
2795625f965SAjay Singh 			i++;
2805625f965SAjay Singh 
2815625f965SAjay Singh 		if (cfg->b[i].id == wid) {
2825625f965SAjay Singh 			memcpy(buffer, &cfg->b[i].val, 1);
2835625f965SAjay Singh 			ret = 1;
2845625f965SAjay Singh 		}
2855625f965SAjay Singh 	} else if (type == CFG_HWORD_CMD) {
2865625f965SAjay Singh 		while (cfg->hw[i].id != WID_NIL && cfg->hw[i].id != wid)
2875625f965SAjay Singh 			i++;
2885625f965SAjay Singh 
2895625f965SAjay Singh 		if (cfg->hw[i].id == wid) {
2905625f965SAjay Singh 			memcpy(buffer, &cfg->hw[i].val, 2);
2915625f965SAjay Singh 			ret = 2;
2925625f965SAjay Singh 		}
2935625f965SAjay Singh 	} else if (type == CFG_WORD_CMD) {
2945625f965SAjay Singh 		while (cfg->w[i].id != WID_NIL && cfg->w[i].id != wid)
2955625f965SAjay Singh 			i++;
2965625f965SAjay Singh 
2975625f965SAjay Singh 		if (cfg->w[i].id == wid) {
2985625f965SAjay Singh 			memcpy(buffer, &cfg->w[i].val, 4);
2995625f965SAjay Singh 			ret = 4;
3005625f965SAjay Singh 		}
3015625f965SAjay Singh 	} else if (type == CFG_STR_CMD) {
3025625f965SAjay Singh 		while (cfg->s[i].id != WID_NIL && cfg->s[i].id != wid)
3035625f965SAjay Singh 			i++;
3045625f965SAjay Singh 
3055625f965SAjay Singh 		if (cfg->s[i].id == wid) {
3065625f965SAjay Singh 			u16 size = get_unaligned_le16(cfg->s[i].str);
3075625f965SAjay Singh 
3085625f965SAjay Singh 			if (buffer_size >= size) {
3095625f965SAjay Singh 				memcpy(buffer, &cfg->s[i].str[2], size);
3105625f965SAjay Singh 				ret = size;
3115625f965SAjay Singh 			}
3125625f965SAjay Singh 		}
3135625f965SAjay Singh 	}
3145625f965SAjay Singh 	return ret;
3155625f965SAjay Singh }
3165625f965SAjay Singh 
wilc_wlan_cfg_indicate_rx(struct wilc * wilc,u8 * frame,int size,struct wilc_cfg_rsp * rsp)3175625f965SAjay Singh void wilc_wlan_cfg_indicate_rx(struct wilc *wilc, u8 *frame, int size,
3185625f965SAjay Singh 			       struct wilc_cfg_rsp *rsp)
3195625f965SAjay Singh {
3205625f965SAjay Singh 	u8 msg_type;
3215625f965SAjay Singh 	u8 msg_id;
3225625f965SAjay Singh 
3235625f965SAjay Singh 	msg_type = frame[0];
3245625f965SAjay Singh 	msg_id = frame[1];      /* seq no */
3255625f965SAjay Singh 	frame += 4;
3265625f965SAjay Singh 	size -= 4;
3275625f965SAjay Singh 	rsp->type = 0;
3285625f965SAjay Singh 
3295625f965SAjay Singh 	switch (msg_type) {
3305625f965SAjay Singh 	case WILC_RESP_MSG_TYPE_CONFIG_REPLY:
3315625f965SAjay Singh 		wilc_wlan_parse_response_frame(wilc, frame, size);
3325625f965SAjay Singh 		rsp->type = WILC_CFG_RSP;
3335625f965SAjay Singh 		rsp->seq_no = msg_id;
3345625f965SAjay Singh 		break;
3355625f965SAjay Singh 
3365625f965SAjay Singh 	case WILC_RESP_MSG_TYPE_STATUS_INFO:
3375625f965SAjay Singh 		wilc_wlan_parse_info_frame(wilc, frame);
3385625f965SAjay Singh 		rsp->type = WILC_CFG_RSP_STATUS;
3395625f965SAjay Singh 		rsp->seq_no = msg_id;
3405625f965SAjay Singh 		/* call host interface info parse as well */
3415625f965SAjay Singh 		wilc_gnrl_async_info_received(wilc, frame - 4, size + 4);
3425625f965SAjay Singh 		break;
3435625f965SAjay Singh 
3445625f965SAjay Singh 	case WILC_RESP_MSG_TYPE_NETWORK_INFO:
3455625f965SAjay Singh 		wilc_network_info_received(wilc, frame - 4, size + 4);
3465625f965SAjay Singh 		break;
3475625f965SAjay Singh 
3485625f965SAjay Singh 	case WILC_RESP_MSG_TYPE_SCAN_COMPLETE:
3495625f965SAjay Singh 		wilc_scan_complete_received(wilc, frame - 4, size + 4);
3505625f965SAjay Singh 		break;
3515625f965SAjay Singh 
3525625f965SAjay Singh 	default:
3535625f965SAjay Singh 		rsp->seq_no = msg_id;
3545625f965SAjay Singh 		break;
3555625f965SAjay Singh 	}
3565625f965SAjay Singh }
3575625f965SAjay Singh 
wilc_wlan_cfg_init(struct wilc * wl)3585625f965SAjay Singh int wilc_wlan_cfg_init(struct wilc *wl)
3595625f965SAjay Singh {
3605625f965SAjay Singh 	struct wilc_cfg_str_vals *str_vals;
3615625f965SAjay Singh 	int i = 0;
3625625f965SAjay Singh 
3635625f965SAjay Singh 	wl->cfg.b = kmemdup(g_cfg_byte, sizeof(g_cfg_byte), GFP_KERNEL);
3645625f965SAjay Singh 	if (!wl->cfg.b)
3655625f965SAjay Singh 		return -ENOMEM;
3665625f965SAjay Singh 
3675625f965SAjay Singh 	wl->cfg.hw = kmemdup(g_cfg_hword, sizeof(g_cfg_hword), GFP_KERNEL);
3685625f965SAjay Singh 	if (!wl->cfg.hw)
3695625f965SAjay Singh 		goto out_b;
3705625f965SAjay Singh 
3715625f965SAjay Singh 	wl->cfg.w = kmemdup(g_cfg_word, sizeof(g_cfg_word), GFP_KERNEL);
3725625f965SAjay Singh 	if (!wl->cfg.w)
3735625f965SAjay Singh 		goto out_hw;
3745625f965SAjay Singh 
3755625f965SAjay Singh 	wl->cfg.s = kmemdup(g_cfg_str, sizeof(g_cfg_str), GFP_KERNEL);
3765625f965SAjay Singh 	if (!wl->cfg.s)
3775625f965SAjay Singh 		goto out_w;
3785625f965SAjay Singh 
3795625f965SAjay Singh 	str_vals = kzalloc(sizeof(*str_vals), GFP_KERNEL);
3805625f965SAjay Singh 	if (!str_vals)
3815625f965SAjay Singh 		goto out_s;
3825625f965SAjay Singh 
3835625f965SAjay Singh 	wl->cfg.str_vals = str_vals;
3845625f965SAjay Singh 	/* store the string cfg parameters */
3855625f965SAjay Singh 	wl->cfg.s[i].id = WID_FIRMWARE_VERSION;
3865625f965SAjay Singh 	wl->cfg.s[i].str = str_vals->firmware_version;
3875625f965SAjay Singh 	i++;
3885625f965SAjay Singh 	wl->cfg.s[i].id = WID_MAC_ADDR;
3895625f965SAjay Singh 	wl->cfg.s[i].str = str_vals->mac_address;
3905625f965SAjay Singh 	i++;
3915625f965SAjay Singh 	wl->cfg.s[i].id = WID_ASSOC_RES_INFO;
3925625f965SAjay Singh 	wl->cfg.s[i].str = str_vals->assoc_rsp;
3935625f965SAjay Singh 	i++;
3945625f965SAjay Singh 	wl->cfg.s[i].id = WID_NIL;
3955625f965SAjay Singh 	wl->cfg.s[i].str = NULL;
3965625f965SAjay Singh 	return 0;
3975625f965SAjay Singh 
3985625f965SAjay Singh out_s:
3995625f965SAjay Singh 	kfree(wl->cfg.s);
4005625f965SAjay Singh out_w:
4015625f965SAjay Singh 	kfree(wl->cfg.w);
4025625f965SAjay Singh out_hw:
4035625f965SAjay Singh 	kfree(wl->cfg.hw);
4045625f965SAjay Singh out_b:
4055625f965SAjay Singh 	kfree(wl->cfg.b);
4065625f965SAjay Singh 	return -ENOMEM;
4075625f965SAjay Singh }
4085625f965SAjay Singh 
wilc_wlan_cfg_deinit(struct wilc * wl)4095625f965SAjay Singh void wilc_wlan_cfg_deinit(struct wilc *wl)
4105625f965SAjay Singh {
4115625f965SAjay Singh 	kfree(wl->cfg.b);
4125625f965SAjay Singh 	kfree(wl->cfg.hw);
4135625f965SAjay Singh 	kfree(wl->cfg.w);
4145625f965SAjay Singh 	kfree(wl->cfg.s);
4155625f965SAjay Singh 	kfree(wl->cfg.str_vals);
4165625f965SAjay Singh }
417