V4L/DVB (9335): videobuf: split unregister bus creating self-contained frontend de...
authorDarron Broad <darron@kewl.org>
Tue, 21 Oct 2008 14:28:46 +0000 (11:28 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 21 Oct 2008 16:32:08 +0000 (14:32 -0200)
This creates a self contained frontend de-allocator
for the instances where an adapter has not been
registered yet frontend de-allocation may
be required.

Signed-off-by: Darron Broad <darron@kewl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/videobuf-dvb.c
include/media/videobuf-dvb.h

index 917277d3660562b670399c3dc8eae25d72777b89..0e7dcba8e4ae08aa902a0a4c06213630d077bb76 100644 (file)
@@ -296,29 +296,7 @@ EXPORT_SYMBOL(videobuf_dvb_register_bus);
 
 void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f)
 {
-       struct list_head *list, *q;
-       struct videobuf_dvb_frontend *fe;
-
-       mutex_lock(&f->lock);
-       list_for_each_safe(list, q, &f->felist) {
-               fe = list_entry(list, struct videobuf_dvb_frontend, felist);
-               if (fe->dvb.net.dvbdev) {
-                       dvb_net_release(&fe->dvb.net);
-                       fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
-                               &fe->dvb.fe_mem);
-                       fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
-                               &fe->dvb.fe_hw);
-                       dvb_dmxdev_release(&fe->dvb.dmxdev);
-                       dvb_dmx_release(&fe->dvb.demux);
-                       dvb_unregister_frontend(fe->dvb.frontend);
-               }
-               if (fe->dvb.frontend)
-                       /* always allocated, may have been reset */
-                       dvb_frontend_detach(fe->dvb.frontend);
-               list_del(list);
-               kfree(fe);
-       }
-       mutex_unlock(&f->lock);
+       videobuf_dvb_dealloc_frontends(f);
 
        dvb_unregister_adapter(&f->adapter);
 }
@@ -389,3 +367,31 @@ fail_alloc:
        return fe;
 }
 EXPORT_SYMBOL(videobuf_dvb_alloc_frontend);
+
+void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f)
+{
+       struct list_head *list, *q;
+       struct videobuf_dvb_frontend *fe;
+
+       mutex_lock(&f->lock);
+       list_for_each_safe(list, q, &f->felist) {
+               fe = list_entry(list, struct videobuf_dvb_frontend, felist);
+               if (fe->dvb.net.dvbdev) {
+                       dvb_net_release(&fe->dvb.net);
+                       fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
+                               &fe->dvb.fe_mem);
+                       fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx,
+                               &fe->dvb.fe_hw);
+                       dvb_dmxdev_release(&fe->dvb.dmxdev);
+                       dvb_dmx_release(&fe->dvb.demux);
+                       dvb_unregister_frontend(fe->dvb.frontend);
+               }
+               if (fe->dvb.frontend)
+                       /* always allocated, may have been reset */
+                       dvb_frontend_detach(fe->dvb.frontend);
+               list_del(list); /* remove list entry */
+               kfree(fe);      /* free frontend allocation */
+       }
+       mutex_unlock(&f->lock);
+}
+EXPORT_SYMBOL(videobuf_dvb_dealloc_frontends);
index 80471c2b63436d3dc45a8cb730782552b8849f55..6ba4f1271d237f7af4c5166040992f7ad8a96200 100644 (file)
@@ -47,6 +47,7 @@ int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f,
 void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f);
 
 struct videobuf_dvb_frontend * videobuf_dvb_alloc_frontend(struct videobuf_dvb_frontends *f, int id);
+void videobuf_dvb_dealloc_frontends(struct videobuf_dvb_frontends *f);
 
 struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id);
 int videobuf_dvb_find_frontend(struct videobuf_dvb_frontends *f, struct dvb_frontend *p);