aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/videobuf-dvb.c52
-rw-r--r--include/media/videobuf-dvb.h1
2 files changed, 30 insertions, 23 deletions
diff --git a/drivers/media/video/videobuf-dvb.c b/drivers/media/video/videobuf-dvb.c
index 917277d36605..0e7dcba8e4ae 100644
--- a/drivers/media/video/videobuf-dvb.c
+++ b/drivers/media/video/videobuf-dvb.c
@@ -296,29 +296,7 @@ EXPORT_SYMBOL(videobuf_dvb_register_bus);
296 296
297void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f) 297void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f)
298{ 298{
299 struct list_head *list, *q; 299 videobuf_dvb_dealloc_frontends(f);
300 struct videobuf_dvb_frontend *fe;
301
302 mutex_lock(&f->lock);
303 list_for_each_safe(list, q, &f->felist) {
304 fe = list_entry(list, struct videobuf_dvb_frontend, felist);
305 if (fe->dvb.net.dvbdev) {
306 dvb_net_release(&fe->dvb.net);
307 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
308 &fe->dvb.fe_mem);
309 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
310 &fe->dvb.fe_hw);
311 dvb_dmxdev_release(&fe->dvb.dmxdev);
312 dvb_dmx_release(&fe->dvb.demux);
313 dvb_unregister_frontend(fe->dvb.frontend);
314 }
315 if (fe->dvb.frontend)
316 /* always allocated, may have been reset */
317 dvb_frontend_detach(fe->dvb.frontend);
318 list_del(list);
319 kfree(fe);
320 }
321 mutex_unlock(&f->lock);
322 300
323 dvb_unregister_adapter(&f->adapter); 301 dvb_unregister_adapter(&f->adapter);
324} 302}
@@ -389,3 +367,31 @@ fail_alloc:
389 return fe; 367 return fe;
390} 368}
391EXPORT_SYMBOL(videobuf_dvb_alloc_frontend); 369EXPORT_SYMBOL(videobuf_dvb_alloc_frontend);
370
371void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f)
372{
373 struct list_head *list, *q;
374 struct videobuf_dvb_frontend *fe;
375
376 mutex_lock(&f->lock);
377 list_for_each_safe(list, q, &f->felist) {
378 fe = list_entry(list, struct videobuf_dvb_frontend, felist);
379 if (fe->dvb.net.dvbdev) {
380 dvb_net_release(&fe->dvb.net);
381 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
382 &fe->dvb.fe_mem);
383 fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
384 &fe->dvb.fe_hw);
385 dvb_dmxdev_release(&fe->dvb.dmxdev);
386 dvb_dmx_release(&fe->dvb.demux);
387 dvb_unregister_frontend(fe->dvb.frontend);
388 }
389 if (fe->dvb.frontend)
390 /* always allocated, may have been reset */
391 dvb_frontend_detach(fe->dvb.frontend);
392 list_del(list); /* remove list entry */
393 kfree(fe); /* free frontend allocation */
394 }
395 mutex_unlock(&f->lock);
396}
397EXPORT_SYMBOL(videobuf_dvb_dealloc_frontends);
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h
index 80471c2b6343..6ba4f1271d23 100644
--- a/include/media/videobuf-dvb.h
+++ b/include/media/videobuf-dvb.h
@@ -47,6 +47,7 @@ int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f,
47void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f); 47void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f);
48 48
49struct videobuf_dvb_frontend * videobuf_dvb_alloc_frontend(struct videobuf_dvb_frontends *f, int id); 49struct videobuf_dvb_frontend * videobuf_dvb_alloc_frontend(struct videobuf_dvb_frontends *f, int id);
50void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f);
50 51
51struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id); 52struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id);
52int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p); 53int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p);