Commit 823b460e authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] dvb-usb-v2: create one media_dev per adapter

Instead of assuming just one adapter, change the code to store
one media controller per adapter.

This works fine for dvb-usb, as, on all drivers here, it is not
possible to write a media graph that would mix resources between
the two different adapters.
Acked-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 6f6c77d8
...@@ -392,10 +392,6 @@ struct dvb_usb_device { ...@@ -392,10 +392,6 @@ struct dvb_usb_device {
struct delayed_work rc_query_work; struct delayed_work rc_query_work;
void *priv; void *priv;
#if defined(CONFIG_MEDIA_CONTROLLER_DVB)
struct media_device *media_dev;
#endif
}; };
extern int dvb_usbv2_probe(struct usb_interface *, extern int dvb_usbv2_probe(struct usb_interface *,
......
...@@ -400,11 +400,11 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) ...@@ -400,11 +400,11 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
return ret; return ret;
} }
static void dvb_usbv2_media_device_register(struct dvb_usb_device *d) static void dvb_usbv2_media_device_register(struct dvb_usb_adapter *adap)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
struct media_device *mdev; struct media_device *mdev;
struct dvb_usb_device *d = adap_to_d(adap);
struct usb_device *udev = d->udev; struct usb_device *udev = d->udev;
int ret; int ret;
...@@ -429,22 +429,23 @@ static void dvb_usbv2_media_device_register(struct dvb_usb_device *d) ...@@ -429,22 +429,23 @@ static void dvb_usbv2_media_device_register(struct dvb_usb_device *d)
return; return;
} }
d->media_dev = mdev; adap->dvb_adap.mdev = mdev;
dev_info(&d->udev->dev, "media controller created\n"); dev_info(&d->udev->dev, "media controller created\n");
#endif #endif
} }
static void dvb_usbv2_media_device_unregister(struct dvb_usb_device *d) static void dvb_usbv2_media_device_unregister(struct dvb_usb_adapter *adap)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
if (!d->media_dev)
if (!adap->dvb_adap.mdev)
return; return;
media_device_unregister(d->media_dev); media_device_unregister(adap->dvb_adap.mdev);
kfree(d->media_dev); kfree(adap->dvb_adap.mdev);
d->media_dev = NULL; adap->dvb_adap.mdev = NULL;
#endif #endif
} }
...@@ -453,6 +454,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -453,6 +454,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
{ {
int ret; int ret;
struct dvb_usb_device *d = adap_to_d(adap); struct dvb_usb_device *d = adap_to_d(adap);
dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, adap->id); dev_dbg(&d->udev->dev, "%s: adap=%d\n", __func__, adap->id);
ret = dvb_register_adapter(&adap->dvb_adap, d->name, d->props->owner, ret = dvb_register_adapter(&adap->dvb_adap, d->name, d->props->owner,
...@@ -466,8 +468,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -466,8 +468,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->dvb_adap.priv = adap; adap->dvb_adap.priv = adap;
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
dvb_usbv2_media_device_register(d); dvb_usbv2_media_device_register(adap);
adap->dvb_adap.mdev = d->media_dev;
#endif #endif
if (d->props->read_mac_address) { if (d->props->read_mac_address) {
...@@ -518,7 +519,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -518,7 +519,7 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
err_dvb_dmxdev_init: err_dvb_dmxdev_init:
dvb_dmx_release(&adap->demux); dvb_dmx_release(&adap->demux);
err_dvb_dmx_init: err_dvb_dmx_init:
dvb_usbv2_media_device_unregister(d); dvb_usbv2_media_device_unregister(adap);
dvb_unregister_adapter(&adap->dvb_adap); dvb_unregister_adapter(&adap->dvb_adap);
err_dvb_register_adapter: err_dvb_register_adapter:
adap->dvb_adap.priv = NULL; adap->dvb_adap.priv = NULL;
...@@ -537,7 +538,7 @@ static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap) ...@@ -537,7 +538,7 @@ static int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap)
adap->demux.dmx.close(&adap->demux.dmx); adap->demux.dmx.close(&adap->demux.dmx);
dvb_dmxdev_release(&adap->dmxdev); dvb_dmxdev_release(&adap->dmxdev);
dvb_dmx_release(&adap->demux); dvb_dmx_release(&adap->demux);
dvb_usbv2_media_device_unregister(d); dvb_usbv2_media_device_unregister(adap);
dvb_unregister_adapter(&adap->dvb_adap); dvb_unregister_adapter(&adap->dvb_adap);
} }
...@@ -701,7 +702,7 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap) ...@@ -701,7 +702,7 @@ static int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap)
} }
} }
dvb_create_media_graph(d->media_dev); dvb_create_media_graph(adap->dvb_adap.mdev);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment