aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/videobuf-dvb.c108
-rw-r--r--include/media/videobuf-dvb.h10
2 files changed, 50 insertions, 68 deletions
diff --git a/drivers/media/video/videobuf-dvb.c b/drivers/media/video/videobuf-dvb.c
index adf7674b4a02..917277d36605 100644
--- a/drivers/media/video/videobuf-dvb.c
+++ b/drivers/media/video/videobuf-dvb.c
@@ -133,55 +133,7 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed)
133 return err; 133 return err;
134} 134}
135 135
136/* ------------------------------------------------------------------ */ 136static int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *fe,
137/* Register a single adapter and one or more frontends */
138int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f,
139 struct module *module,
140 void *adapter_priv,
141 struct device *device,
142 short *adapter_nr,
143 int mfe_shared)
144{
145 struct list_head *list, *q;
146 struct videobuf_dvb_frontend *fe;
147 int res;
148
149 fe = videobuf_dvb_get_frontend(f, 1);
150 if (!fe) {
151 printk(KERN_WARNING "Unable to register the adapter which has no frontends\n");
152 return -EINVAL;
153 }
154
155 /* Bring up the adapter */
156 res = videobuf_dvb_register_adapter(f, module, adapter_priv, device,
157 fe->dvb.name, adapter_nr, mfe_shared);
158 if (res < 0) {
159 printk(KERN_WARNING "videobuf_dvb_register_adapter failed (errno = %d)\n", res);
160 return res;
161 }
162
163 /* Attach all of the frontends to the adapter */
164 mutex_lock(&f->lock);
165 list_for_each_safe(list, q, &f->felist) {
166 fe = list_entry(list, struct videobuf_dvb_frontend, felist);
167 res = videobuf_dvb_register_frontend(&f->adapter, &fe->dvb);
168 if (res < 0) {
169 printk(KERN_WARNING "%s: videobuf_dvb_register_frontend failed (errno = %d)\n",
170 fe->dvb.name, res);
171 goto err;
172 }
173 }
174 mutex_unlock(&f->lock);
175 return 0;
176
177err:
178 mutex_unlock(&f->lock);
179 videobuf_dvb_unregister_bus(f);
180 return res;
181}
182EXPORT_SYMBOL(videobuf_dvb_register_bus);
183
184int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *fe,
185 struct module *module, 137 struct module *module,
186 void *adapter_priv, 138 void *adapter_priv,
187 struct device *device, 139 struct device *device,
@@ -206,7 +158,7 @@ int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *fe,
206 return result; 158 return result;
207} 159}
208 160
209int videobuf_dvb_register_frontend(struct dvb_adapter *adapter, 161static int videobuf_dvb_register_frontend(struct dvb_adapter *adapter,
210 struct videobuf_dvb *dvb) 162 struct videobuf_dvb *dvb)
211{ 163{
212 int result; 164 int result;
@@ -294,6 +246,54 @@ fail_frontend:
294 return result; 246 return result;
295} 247}
296 248
249/* ------------------------------------------------------------------ */
250/* Register a single adapter and one or more frontends */
251int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f,
252 struct module *module,
253 void *adapter_priv,
254 struct device *device,
255 short *adapter_nr,
256 int mfe_shared)
257{
258 struct list_head *list, *q;
259 struct videobuf_dvb_frontend *fe;
260 int res;
261
262 fe = videobuf_dvb_get_frontend(f, 1);
263 if (!fe) {
264 printk(KERN_WARNING "Unable to register the adapter which has no frontends\n");
265 return -EINVAL;
266 }
267
268 /* Bring up the adapter */
269 res = videobuf_dvb_register_adapter(f, module, adapter_priv, device,
270 fe->dvb.name, adapter_nr, mfe_shared);
271 if (res < 0) {
272 printk(KERN_WARNING "videobuf_dvb_register_adapter failed (errno = %d)\n", res);
273 return res;
274 }
275
276 /* Attach all of the frontends to the adapter */
277 mutex_lock(&f->lock);
278 list_for_each_safe(list, q, &f->felist) {
279 fe = list_entry(list, struct videobuf_dvb_frontend, felist);
280 res = videobuf_dvb_register_frontend(&f->adapter, &fe->dvb);
281 if (res < 0) {
282 printk(KERN_WARNING "%s: videobuf_dvb_register_frontend failed (errno = %d)\n",
283 fe->dvb.name, res);
284 goto err;
285 }
286 }
287 mutex_unlock(&f->lock);
288 return 0;
289
290err:
291 mutex_unlock(&f->lock);
292 videobuf_dvb_unregister_bus(f);
293 return res;
294}
295EXPORT_SYMBOL(videobuf_dvb_register_bus);
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 struct list_head *list, *q;
@@ -389,11 +389,3 @@ fail_alloc:
389 return fe; 389 return fe;
390} 390}
391EXPORT_SYMBOL(videobuf_dvb_alloc_frontend); 391EXPORT_SYMBOL(videobuf_dvb_alloc_frontend);
392
393/* ------------------------------------------------------------------ */
394/*
395 * Local variables:
396 * c-basic-offset: 8
397 * compile-command: "make DVB=1"
398 * End:
399 */
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h
index 52ddda90d3f6..80471c2b6343 100644
--- a/include/media/videobuf-dvb.h
+++ b/include/media/videobuf-dvb.h
@@ -46,16 +46,6 @@ int videobuf_dvb_register_bus(struct videobuf_dvb_frontends *f,
46 46
47void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f); 47void videobuf_dvb_unregister_bus(struct videobuf_dvb_frontends *f);
48 48
49int videobuf_dvb_register_adapter(struct videobuf_dvb_frontends *f,
50 struct module *module,
51 void *adapter_priv,
52 struct device *device,
53 char *adapter_name,
54 short *adapter_nr,
55 int mfe_shared);
56
57int videobuf_dvb_register_frontend(struct dvb_adapter *adapter, struct videobuf_dvb *dvb);
58
59struct 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);
60 50
61struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id); 51struct videobuf_dvb_frontend * videobuf_dvb_get_frontend(struct videobuf_dvb_frontends *f, int id);