aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2014-12-17 06:25:03 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-02-03 13:22:24 -0500
commitd5eec231becd745c8a943dcac27c681dabb013d7 (patch)
treecd7f2f981568efd5ad277238dee87720bdda268f /drivers/media
parent6a53fa2350f724ca84b0a1946f3046855e1efd41 (diff)
[media] rtl2832_sdr: refcount to rtl28xxu
We are consumer of DVB frontend provided by rtl28xxu module. Due to that we must use refcount to ensure none could remove rtl28xxu when we are alive (or when we are streaming, if more fine-grained refcounting is wanted). Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb-frontends/rtl2832_sdr.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/media/dvb-frontends/rtl2832_sdr.c b/drivers/media/dvb-frontends/rtl2832_sdr.c
index 62e85a3b2234..3ff8806ca584 100644
--- a/drivers/media/dvb-frontends/rtl2832_sdr.c
+++ b/drivers/media/dvb-frontends/rtl2832_sdr.c
@@ -1310,10 +1310,21 @@ static int rtl2832_sdr_probe(struct platform_device *pdev)
1310 ret = -EINVAL; 1310 ret = -EINVAL;
1311 goto err; 1311 goto err;
1312 } 1312 }
1313 if (!pdev->dev.parent->driver) {
1314 dev_dbg(&pdev->dev, "No parent device\n");
1315 ret = -EINVAL;
1316 goto err;
1317 }
1318 /* try to refcount host drv since we are the consumer */
1319 if (!try_module_get(pdev->dev.parent->driver->owner)) {
1320 dev_err(&pdev->dev, "Refcount fail");
1321 ret = -EINVAL;
1322 goto err;
1323 }
1313 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1324 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1314 if (dev == NULL) { 1325 if (dev == NULL) {
1315 ret = -ENOMEM; 1326 ret = -ENOMEM;
1316 goto err; 1327 goto err_module_put;
1317 } 1328 }
1318 1329
1319 /* setup the state */ 1330 /* setup the state */
@@ -1426,6 +1437,8 @@ err_v4l2_ctrl_handler_free:
1426 v4l2_ctrl_handler_free(&dev->hdl); 1437 v4l2_ctrl_handler_free(&dev->hdl);
1427err_kfree: 1438err_kfree:
1428 kfree(dev); 1439 kfree(dev);
1440err_module_put:
1441 module_put(pdev->dev.parent->driver->owner);
1429err: 1442err:
1430 return ret; 1443 return ret;
1431} 1444}
@@ -1444,8 +1457,8 @@ static int rtl2832_sdr_remove(struct platform_device *pdev)
1444 video_unregister_device(&dev->vdev); 1457 video_unregister_device(&dev->vdev);
1445 mutex_unlock(&dev->v4l2_lock); 1458 mutex_unlock(&dev->v4l2_lock);
1446 mutex_unlock(&dev->vb_queue_lock); 1459 mutex_unlock(&dev->vb_queue_lock);
1447
1448 v4l2_device_put(&dev->v4l2_dev); 1460 v4l2_device_put(&dev->v4l2_dev);
1461 module_put(pdev->dev.parent->driver->owner);
1449 1462
1450 return 0; 1463 return 0;
1451} 1464}