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 /drivers/media/dvb/dvb-usb/vp702x-fe.c | |
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>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/vp702x-fe.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x-fe.c | 89 |
1 files changed, 63 insertions, 26 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 | ||