diff options
author | Florian Mickler <florian@mickler.org> | 2011-03-21 06:19:10 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 08:28:08 -0400 |
commit | 57873c720caddf19eef2d5fe734575f7175abb48 (patch) | |
tree | 94c3bfba53001f63d48b51f0e9251fcc0780849c | |
parent | cf53b82d5d6eae920a1527b564f17c86e8118f0c (diff) |
[media] vp702x: get rid of on-stack dma buffers
usb_control_msg initiates (and waits for completion of) a dma transfer using
the supplied buffer. That buffer thus has to be seperately allocated on
the heap.
In lib/dma_debug.c the function check_for_stack even warns about it:
WARNING: at lib/dma-debug.c:866 check_for_stack
Note: This change is tested to compile only, as I don't have the hardware.
Signed-off-by: Florian Mickler <florian@mickler.org>
Cc: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x-fe.c | 89 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x.c | 78 |
2 files changed, 124 insertions, 43 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c index ccc7e4452664..7468a3839c5d 100644 --- a/drivers/media/dvb/dvb-usb/vp702x-fe.c +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c | |||
@@ -41,15 +41,26 @@ struct vp702x_fe_state { | |||
41 | 41 | ||
42 | static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) | 42 | static int vp702x_fe_refresh_state(struct vp702x_fe_state *st) |
43 | { | 43 | { |
44 | u8 buf[10]; | 44 | u8 *buf; |
45 | if (time_after(jiffies,st->next_status_check)) { | 45 | |
46 | vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10); | 46 | if (time_after(jiffies, st->next_status_check)) { |
47 | 47 | buf = kmalloc(10, GFP_KERNEL); | |
48 | if (!buf) { | ||
49 | deb_fe("%s: buffer alloc failed\n", __func__); | ||
50 | return -ENOMEM; | ||
51 | } | ||
52 | vp702x_usb_in_op(st->d, READ_STATUS, 0, 0, buf, 10); | ||
48 | st->lock = buf[4]; | 53 | st->lock = buf[4]; |
49 | vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1); | 54 | |
50 | vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1); | 55 | vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x11, 0, buf, 1); |
56 | st->snr = buf[0]; | ||
57 | |||
58 | vp702x_usb_in_op(st->d, READ_TUNER_REG_REQ, 0x15, 0, buf, 1); | ||
59 | st->sig = buf[0]; | ||
60 | |||
51 | 61 | ||
52 | st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; | 62 | st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000; |
63 | kfree(buf); | ||
53 | } | 64 | } |
54 | return 0; | 65 | return 0; |
55 | } | 66 | } |
@@ -134,7 +145,11 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe, | |||
134 | /*CalFrequency*/ | 145 | /*CalFrequency*/ |
135 | /* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ | 146 | /* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */ |
136 | u64 sr; | 147 | u64 sr; |
137 | u8 cmd[8] = { 0 },ibuf[10]; | 148 | u8 *cmd; |
149 | |||
150 | cmd = kzalloc(10, GFP_KERNEL); | ||
151 | if (!cmd) | ||
152 | return -ENOMEM; | ||
138 | 153 | ||
139 | cmd[0] = (freq >> 8) & 0x7f; | 154 | cmd[0] = (freq >> 8) & 0x7f; |
140 | cmd[1] = freq & 0xff; | 155 | cmd[1] = freq & 0xff; |
@@ -170,13 +185,14 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe, | |||
170 | st->status_check_interval = 250; | 185 | st->status_check_interval = 250; |
171 | st->next_status_check = jiffies; | 186 | st->next_status_check = jiffies; |
172 | 187 | ||
173 | vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); | 188 | vp702x_usb_inout_op(st->d, cmd, 8, cmd, 10, 100); |
174 | 189 | ||
175 | if (ibuf[2] == 0 && ibuf[3] == 0) | 190 | if (cmd[2] == 0 && cmd[3] == 0) |
176 | deb_fe("tuning failed.\n"); | 191 | deb_fe("tuning failed.\n"); |
177 | else | 192 | else |
178 | deb_fe("tuning succeeded.\n"); | 193 | deb_fe("tuning succeeded.\n"); |
179 | 194 | ||
195 | kfree(cmd); | ||
180 | return 0; | 196 | return 0; |
181 | } | 197 | } |
182 | 198 | ||
@@ -204,28 +220,36 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe, | |||
204 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | 220 | static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, |
205 | struct dvb_diseqc_master_cmd *m) | 221 | struct dvb_diseqc_master_cmd *m) |
206 | { | 222 | { |
223 | int ret; | ||
224 | u8 *cmd; | ||
207 | struct vp702x_fe_state *st = fe->demodulator_priv; | 225 | struct vp702x_fe_state *st = fe->demodulator_priv; |
208 | u8 cmd[8],ibuf[10]; | 226 | |
209 | memset(cmd,0,8); | 227 | cmd = kzalloc(10, GFP_KERNEL); |
228 | if (!cmd) | ||
229 | return -ENOMEM; | ||
210 | 230 | ||
211 | deb_fe("%s\n",__func__); | 231 | deb_fe("%s\n",__func__); |
212 | 232 | ||
213 | if (m->msg_len > 4) | 233 | if (m->msg_len > 4) { |
214 | return -EINVAL; | 234 | ret = -EINVAL; |
235 | goto out; | ||
236 | } | ||
215 | 237 | ||
216 | cmd[1] = SET_DISEQC_CMD; | 238 | cmd[1] = SET_DISEQC_CMD; |
217 | cmd[2] = m->msg_len; | 239 | cmd[2] = m->msg_len; |
218 | memcpy(&cmd[3], m->msg, m->msg_len); | 240 | memcpy(&cmd[3], m->msg, m->msg_len); |
219 | cmd[7] = vp702x_chksum(cmd,0,7); | 241 | cmd[7] = vp702x_chksum(cmd, 0, 7); |
220 | 242 | ||
221 | vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100); | 243 | vp702x_usb_inout_op(st->d, cmd, 8, cmd, 10, 100); |
222 | 244 | ||
223 | if (ibuf[2] == 0 && ibuf[3] == 0) | 245 | if (cmd[2] == 0 && cmd[3] == 0) |
224 | deb_fe("diseqc cmd failed.\n"); | 246 | deb_fe("diseqc cmd failed.\n"); |
225 | else | 247 | else |
226 | deb_fe("diseqc cmd succeeded.\n"); | 248 | deb_fe("diseqc cmd succeeded.\n"); |
227 | 249 | ret = 0; | |
228 | return 0; | 250 | out: |
251 | kfree(cmd); | ||
252 | return ret; | ||
229 | } | 253 | } |
230 | 254 | ||
231 | static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | 255 | static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) |
@@ -237,9 +261,14 @@ static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd | |||
237 | static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | 261 | static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) |
238 | { | 262 | { |
239 | struct vp702x_fe_state *st = fe->demodulator_priv; | 263 | struct vp702x_fe_state *st = fe->demodulator_priv; |
240 | u8 ibuf[10]; | 264 | u8 *buf; |
265 | |||
241 | deb_fe("%s\n",__func__); | 266 | deb_fe("%s\n",__func__); |
242 | 267 | ||
268 | buf = kmalloc(10, GFP_KERNEL); | ||
269 | if (!buf) | ||
270 | return -ENOMEM; | ||
271 | |||
243 | st->tone_mode = tone; | 272 | st->tone_mode = tone; |
244 | 273 | ||
245 | if (tone == SEC_TONE_ON) | 274 | if (tone == SEC_TONE_ON) |
@@ -247,14 +276,16 @@ static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
247 | else | 276 | else |
248 | st->lnb_buf[2] = 0x00; | 277 | st->lnb_buf[2] = 0x00; |
249 | 278 | ||
250 | st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); | 279 | st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7); |
280 | memcpy(buf, st->lnb_buf, 8); | ||
251 | 281 | ||
252 | vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); | 282 | vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100); |
253 | if (ibuf[2] == 0 && ibuf[3] == 0) | 283 | if (buf[2] == 0 && buf[3] == 0) |
254 | deb_fe("set_tone cmd failed.\n"); | 284 | deb_fe("set_tone cmd failed.\n"); |
255 | else | 285 | else |
256 | deb_fe("set_tone cmd succeeded.\n"); | 286 | deb_fe("set_tone cmd succeeded.\n"); |
257 | 287 | ||
288 | kfree(buf); | ||
258 | return 0; | 289 | return 0; |
259 | } | 290 | } |
260 | 291 | ||
@@ -262,9 +293,13 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t | |||
262 | voltage) | 293 | voltage) |
263 | { | 294 | { |
264 | struct vp702x_fe_state *st = fe->demodulator_priv; | 295 | struct vp702x_fe_state *st = fe->demodulator_priv; |
265 | u8 ibuf[10]; | 296 | u8 *buf; |
266 | deb_fe("%s\n",__func__); | 297 | deb_fe("%s\n",__func__); |
267 | 298 | ||
299 | buf = kmalloc(10, GFP_KERNEL); | ||
300 | if (!buf) | ||
301 | return -ENOMEM; | ||
302 | |||
268 | st->voltage = voltage; | 303 | st->voltage = voltage; |
269 | 304 | ||
270 | if (voltage != SEC_VOLTAGE_OFF) | 305 | if (voltage != SEC_VOLTAGE_OFF) |
@@ -272,14 +307,16 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t | |||
272 | else | 307 | else |
273 | st->lnb_buf[4] = 0x00; | 308 | st->lnb_buf[4] = 0x00; |
274 | 309 | ||
275 | st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7); | 310 | st->lnb_buf[7] = vp702x_chksum(st->lnb_buf, 0, 7); |
311 | memcpy(buf, st->lnb_buf, 8); | ||
276 | 312 | ||
277 | vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100); | 313 | vp702x_usb_inout_op(st->d, buf, 8, buf, 10, 100); |
278 | if (ibuf[2] == 0 && ibuf[3] == 0) | 314 | if (buf[2] == 0 && buf[3] == 0) |
279 | deb_fe("set_voltage cmd failed.\n"); | 315 | deb_fe("set_voltage cmd failed.\n"); |
280 | else | 316 | else |
281 | deb_fe("set_voltage cmd succeeded.\n"); | 317 | deb_fe("set_voltage cmd succeeded.\n"); |
282 | 318 | ||
319 | kfree(buf); | ||
283 | return 0; | 320 | return 0; |
284 | } | 321 | } |
285 | 322 | ||
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index 569c93fbb86c..35fe778993c1 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c | |||
@@ -93,38 +93,61 @@ int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int il | |||
93 | static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, | 93 | static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o, |
94 | int olen, u8 *i, int ilen, int msec) | 94 | int olen, u8 *i, int ilen, int msec) |
95 | { | 95 | { |
96 | u8 bout[olen+2]; | ||
97 | u8 bin[ilen+1]; | ||
98 | int ret = 0; | 96 | int ret = 0; |
97 | u8 *buf; | ||
98 | int buflen = max(olen + 2, ilen + 1); | ||
99 | 99 | ||
100 | bout[0] = 0x00; | 100 | buf = kmalloc(buflen, GFP_KERNEL); |
101 | bout[1] = cmd; | 101 | if (!buf) |
102 | memcpy(&bout[2],o,olen); | 102 | return -ENOMEM; |
103 | 103 | ||
104 | ret = vp702x_usb_inout_op(d, bout, olen+2, bin, ilen+1,msec); | 104 | buf[0] = 0x00; |
105 | buf[1] = cmd; | ||
106 | memcpy(&buf[2], o, olen); | ||
107 | |||
108 | ret = vp702x_usb_inout_op(d, buf, olen+2, buf, ilen+1, msec); | ||
105 | 109 | ||
106 | if (ret == 0) | 110 | if (ret == 0) |
107 | memcpy(i,&bin[1],ilen); | 111 | memcpy(i, &buf[1], ilen); |
108 | 112 | ||
113 | kfree(buf); | ||
109 | return ret; | 114 | return ret; |
110 | } | 115 | } |
111 | 116 | ||
112 | static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass) | 117 | static int vp702x_set_pld_mode(struct dvb_usb_adapter *adap, u8 bypass) |
113 | { | 118 | { |
114 | u8 buf[16] = { 0 }; | 119 | int ret; |
115 | return vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e, 0, buf, 16); | 120 | u8 *buf = kzalloc(16, GFP_KERNEL); |
121 | if (!buf) | ||
122 | return -ENOMEM; | ||
123 | |||
124 | ret = vp702x_usb_in_op(adap->dev, 0xe0, (bypass << 8) | 0x0e, | ||
125 | 0, buf, 16); | ||
126 | kfree(buf); | ||
127 | return ret; | ||
116 | } | 128 | } |
117 | 129 | ||
118 | static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state) | 130 | static int vp702x_set_pld_state(struct dvb_usb_adapter *adap, u8 state) |
119 | { | 131 | { |
120 | u8 buf[16] = { 0 }; | 132 | int ret; |
121 | return vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f, 0, buf, 16); | 133 | u8 *buf = kzalloc(16, GFP_KERNEL); |
134 | if (!buf) | ||
135 | return -ENOMEM; | ||
136 | |||
137 | ret = vp702x_usb_in_op(adap->dev, 0xe0, (state << 8) | 0x0f, | ||
138 | 0, buf, 16); | ||
139 | kfree(buf); | ||
140 | return ret; | ||
122 | } | 141 | } |
123 | 142 | ||
124 | static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff) | 143 | static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onoff) |
125 | { | 144 | { |
126 | struct vp702x_adapter_state *st = adap->priv; | 145 | struct vp702x_adapter_state *st = adap->priv; |
127 | u8 buf[16] = { 0 }; | 146 | u8 *buf; |
147 | |||
148 | buf = kzalloc(16, GFP_KERNEL); | ||
149 | if (!buf) | ||
150 | return -ENOMEM; | ||
128 | 151 | ||
129 | if (onoff) | 152 | if (onoff) |
130 | st->pid_filter_state |= (1 << id); | 153 | st->pid_filter_state |= (1 << id); |
@@ -138,6 +161,8 @@ static int vp702x_set_pid(struct dvb_usb_adapter *adap, u16 pid, u8 id, int onof | |||
138 | vp702x_set_pld_state(adap, st->pid_filter_state); | 161 | vp702x_set_pld_state(adap, st->pid_filter_state); |
139 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16); | 162 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid >> 8) & 0xff) << 8) | (id), 0, buf, 16); |
140 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16); | 163 | vp702x_usb_in_op(adap->dev, 0xe0, (((pid ) & 0xff) << 8) | (id+1), 0, buf, 16); |
164 | |||
165 | kfree(buf); | ||
141 | return 0; | 166 | return 0; |
142 | } | 167 | } |
143 | 168 | ||
@@ -146,13 +171,17 @@ static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) | |||
146 | { | 171 | { |
147 | struct vp702x_adapter_state *st = adap->priv; | 172 | struct vp702x_adapter_state *st = adap->priv; |
148 | int i; | 173 | int i; |
149 | u8 b[10] = { 0 }; | 174 | u8 *b; |
175 | |||
176 | b = kzalloc(10, GFP_KERNEL); | ||
177 | if (!b) | ||
178 | return -ENOMEM; | ||
150 | 179 | ||
151 | st->pid_filter_count = 8; | 180 | st->pid_filter_count = 8; |
152 | st->pid_filter_can_bypass = 1; | 181 | st->pid_filter_can_bypass = 1; |
153 | st->pid_filter_state = 0x00; | 182 | st->pid_filter_state = 0x00; |
154 | 183 | ||
155 | vp702x_set_pld_mode(adap, 1); // bypass | 184 | vp702x_set_pld_mode(adap, 1); /* bypass */ |
156 | 185 | ||
157 | for (i = 0; i < st->pid_filter_count; i++) | 186 | for (i = 0; i < st->pid_filter_count; i++) |
158 | vp702x_set_pid(adap, 0xffff, i, 1); | 187 | vp702x_set_pid(adap, 0xffff, i, 1); |
@@ -162,6 +191,7 @@ static int vp702x_init_pid_filter(struct dvb_usb_adapter *adap) | |||
162 | vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10); | 191 | vp702x_usb_in_op(adap->dev, 0xb5, 1, 0, b, 10); |
163 | 192 | ||
164 | //vp702x_set_pld_mode(d, 0); // filter | 193 | //vp702x_set_pld_mode(d, 0); // filter |
194 | kfree(b); | ||
165 | return 0; | 195 | return 0; |
166 | } | 196 | } |
167 | 197 | ||
@@ -179,18 +209,23 @@ static struct rc_map_table rc_map_vp702x_table[] = { | |||
179 | /* remote control stuff (does not work with my box) */ | 209 | /* remote control stuff (does not work with my box) */ |
180 | static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 210 | static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
181 | { | 211 | { |
182 | u8 key[10]; | 212 | u8 *key; |
183 | int i; | 213 | int i; |
184 | 214 | ||
185 | /* remove the following return to enabled remote querying */ | 215 | /* remove the following return to enabled remote querying */ |
186 | return 0; | 216 | return 0; |
187 | 217 | ||
218 | key = kmalloc(10, GFP_KERNEL); | ||
219 | if (!key) | ||
220 | return -ENOMEM; | ||
221 | |||
188 | vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); | 222 | vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10); |
189 | 223 | ||
190 | deb_rc("remote query key: %x %d\n",key[1],key[1]); | 224 | deb_rc("remote query key: %x %d\n",key[1],key[1]); |
191 | 225 | ||
192 | if (key[1] == 0x44) { | 226 | if (key[1] == 0x44) { |
193 | *state = REMOTE_NO_KEY_PRESSED; | 227 | *state = REMOTE_NO_KEY_PRESSED; |
228 | kfree(key); | ||
194 | return 0; | 229 | return 0; |
195 | } | 230 | } |
196 | 231 | ||
@@ -200,15 +235,24 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
200 | *event = rc_map_vp702x_table[i].keycode; | 235 | *event = rc_map_vp702x_table[i].keycode; |
201 | break; | 236 | break; |
202 | } | 237 | } |
238 | kfree(key); | ||
203 | return 0; | 239 | return 0; |
204 | } | 240 | } |
205 | 241 | ||
206 | 242 | ||
207 | static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) | 243 | static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6]) |
208 | { | 244 | { |
209 | u8 i; | 245 | u8 i, *buf; |
246 | |||
247 | buf = kmalloc(6, GFP_KERNEL); | ||
248 | if (!buf) | ||
249 | return -ENOMEM; | ||
250 | |||
210 | for (i = 6; i < 12; i++) | 251 | for (i = 6; i < 12; i++) |
211 | vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &mac[i - 6], 1); | 252 | vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1); |
253 | |||
254 | memcpy(mac, buf, 6); | ||
255 | kfree(buf); | ||
212 | return 0; | 256 | return 0; |
213 | } | 257 | } |
214 | 258 | ||