fix a kmap leak in virtio_console
[linux/fpc-iii.git] / drivers / net / wireless / ti / wl18xx / acx.c
bloba169bb5a5dbf7984c0cdb52390492e0d6a27fbb0
1 /*
2 * This file is part of wl18xx
4 * Copyright (C) 2011 Texas Instruments Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
22 #include "../wlcore/cmd.h"
23 #include "../wlcore/debug.h"
24 #include "../wlcore/acx.h"
26 #include "acx.h"
28 int wl18xx_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap,
29 u32 sdio_blk_size, u32 extra_mem_blks,
30 u32 len_field_size)
32 struct wl18xx_acx_host_config_bitmap *bitmap_conf;
33 int ret;
35 wl1271_debug(DEBUG_ACX, "acx cfg bitmap %d blk %d spare %d field %d",
36 host_cfg_bitmap, sdio_blk_size, extra_mem_blks,
37 len_field_size);
39 bitmap_conf = kzalloc(sizeof(*bitmap_conf), GFP_KERNEL);
40 if (!bitmap_conf) {
41 ret = -ENOMEM;
42 goto out;
45 bitmap_conf->host_cfg_bitmap = cpu_to_le32(host_cfg_bitmap);
46 bitmap_conf->host_sdio_block_size = cpu_to_le32(sdio_blk_size);
47 bitmap_conf->extra_mem_blocks = cpu_to_le32(extra_mem_blks);
48 bitmap_conf->length_field_size = cpu_to_le32(len_field_size);
50 ret = wl1271_cmd_configure(wl, ACX_HOST_IF_CFG_BITMAP,
51 bitmap_conf, sizeof(*bitmap_conf));
52 if (ret < 0) {
53 wl1271_warning("wl1271 bitmap config opt failed: %d", ret);
54 goto out;
57 out:
58 kfree(bitmap_conf);
60 return ret;
63 int wl18xx_acx_set_checksum_state(struct wl1271 *wl)
65 struct wl18xx_acx_checksum_state *acx;
66 int ret;
68 wl1271_debug(DEBUG_ACX, "acx checksum state");
70 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
71 if (!acx) {
72 ret = -ENOMEM;
73 goto out;
76 acx->checksum_state = CHECKSUM_OFFLOAD_ENABLED;
78 ret = wl1271_cmd_configure(wl, ACX_CSUM_CONFIG, acx, sizeof(*acx));
79 if (ret < 0) {
80 wl1271_warning("failed to set Tx checksum state: %d", ret);
81 goto out;
84 out:
85 kfree(acx);
86 return ret;
89 int wl18xx_acx_clear_statistics(struct wl1271 *wl)
91 struct wl18xx_acx_clear_statistics *acx;
92 int ret = 0;
94 wl1271_debug(DEBUG_ACX, "acx clear statistics");
96 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
97 if (!acx) {
98 ret = -ENOMEM;
99 goto out;
102 ret = wl1271_cmd_configure(wl, ACX_CLEAR_STATISTICS, acx, sizeof(*acx));
103 if (ret < 0) {
104 wl1271_warning("failed to clear firmware statistics: %d", ret);
105 goto out;
108 out:
109 kfree(acx);
110 return ret;
113 int wl18xx_acx_peer_ht_operation_mode(struct wl1271 *wl, u8 hlid, bool wide)
115 struct wlcore_peer_ht_operation_mode *acx;
116 int ret;
118 wl1271_debug(DEBUG_ACX, "acx peer ht operation mode hlid %d bw %d",
119 hlid, wide);
121 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
122 if (!acx) {
123 ret = -ENOMEM;
124 goto out;
127 acx->hlid = hlid;
128 acx->bandwidth = wide ? WLCORE_BANDWIDTH_40MHZ : WLCORE_BANDWIDTH_20MHZ;
130 ret = wl1271_cmd_configure(wl, ACX_PEER_HT_OPERATION_MODE_CFG, acx,
131 sizeof(*acx));
133 if (ret < 0) {
134 wl1271_warning("acx peer ht operation mode failed: %d", ret);
135 goto out;
138 out:
139 kfree(acx);
140 return ret;
145 * this command is basically the same as wl1271_acx_ht_capabilities,
146 * with the addition of supported rates. they should be unified in
147 * the next fw api change
149 int wl18xx_acx_set_peer_cap(struct wl1271 *wl,
150 struct ieee80211_sta_ht_cap *ht_cap,
151 bool allow_ht_operation,
152 u32 rate_set, u8 hlid)
154 struct wlcore_acx_peer_cap *acx;
155 int ret = 0;
156 u32 ht_capabilites = 0;
158 wl1271_debug(DEBUG_ACX,
159 "acx set cap ht_supp: %d ht_cap: %d rates: 0x%x",
160 ht_cap->ht_supported, ht_cap->cap, rate_set);
162 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
163 if (!acx) {
164 ret = -ENOMEM;
165 goto out;
168 if (allow_ht_operation && ht_cap->ht_supported) {
169 /* no need to translate capabilities - use the spec values */
170 ht_capabilites = ht_cap->cap;
173 * this bit is not employed by the spec but only by FW to
174 * indicate peer HT support
176 ht_capabilites |= WL12XX_HT_CAP_HT_OPERATION;
178 /* get data from A-MPDU parameters field */
179 acx->ampdu_max_length = ht_cap->ampdu_factor;
180 acx->ampdu_min_spacing = ht_cap->ampdu_density;
183 acx->hlid = hlid;
184 acx->ht_capabilites = cpu_to_le32(ht_capabilites);
185 acx->supported_rates = cpu_to_le32(rate_set);
187 ret = wl1271_cmd_configure(wl, ACX_PEER_CAP, acx, sizeof(*acx));
188 if (ret < 0) {
189 wl1271_warning("acx ht capabilities setting failed: %d", ret);
190 goto out;
193 out:
194 kfree(acx);
195 return ret;