diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-03-13 04:40:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-02 20:07:36 -0400 |
commit | f46d740fb0258982f00ffdbddc6486e674edafb5 (patch) | |
tree | 9410d6f6cedaa02e4a5956a404f2c987a16408ae /drivers/media/platform | |
parent | 628821c84e9047bffab8357668a6b1ef6c0038a5 (diff) |
[media] vivid: turn this into a platform_device
This turns this driver into a platform device. This ensures that it
appears in /sys/bus/platform_device since it now has a proper parent
device.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r-- | drivers/media/platform/vivid/vivid-core.c | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c index a7e033a5d291..d2558db27751 100644 --- a/drivers/media/platform/vivid/vivid-core.c +++ b/drivers/media/platform/vivid/vivid-core.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/vmalloc.h> | 26 | #include <linux/vmalloc.h> |
27 | #include <linux/font.h> | 27 | #include <linux/font.h> |
28 | #include <linux/mutex.h> | 28 | #include <linux/mutex.h> |
29 | #include <linux/platform_device.h> | ||
29 | #include <linux/videodev2.h> | 30 | #include <linux/videodev2.h> |
30 | #include <linux/v4l2-dv-timings.h> | 31 | #include <linux/v4l2-dv-timings.h> |
31 | #include <media/videobuf2-vmalloc.h> | 32 | #include <media/videobuf2-vmalloc.h> |
@@ -618,7 +619,7 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { | |||
618 | Initialization and module stuff | 619 | Initialization and module stuff |
619 | ------------------------------------------------------------------*/ | 620 | ------------------------------------------------------------------*/ |
620 | 621 | ||
621 | static int __init vivid_create_instance(int inst) | 622 | static int vivid_create_instance(struct platform_device *pdev, int inst) |
622 | { | 623 | { |
623 | static const struct v4l2_dv_timings def_dv_timings = | 624 | static const struct v4l2_dv_timings def_dv_timings = |
624 | V4L2_DV_BT_CEA_1280X720P60; | 625 | V4L2_DV_BT_CEA_1280X720P60; |
@@ -646,7 +647,7 @@ static int __init vivid_create_instance(int inst) | |||
646 | /* register v4l2_device */ | 647 | /* register v4l2_device */ |
647 | snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), | 648 | snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), |
648 | "%s-%03d", VIVID_MODULE_NAME, inst); | 649 | "%s-%03d", VIVID_MODULE_NAME, inst); |
649 | ret = v4l2_device_register(NULL, &dev->v4l2_dev); | 650 | ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); |
650 | if (ret) | 651 | if (ret) |
651 | goto free_dev; | 652 | goto free_dev; |
652 | 653 | ||
@@ -1274,7 +1275,7 @@ free_dev: | |||
1274 | will succeed. This is limited to the maximum number of devices that | 1275 | will succeed. This is limited to the maximum number of devices that |
1275 | videodev supports, which is equal to VIDEO_NUM_DEVICES. | 1276 | videodev supports, which is equal to VIDEO_NUM_DEVICES. |
1276 | */ | 1277 | */ |
1277 | static int __init vivid_init(void) | 1278 | static int vivid_probe(struct platform_device *pdev) |
1278 | { | 1279 | { |
1279 | const struct font_desc *font = find_font("VGA8x16"); | 1280 | const struct font_desc *font = find_font("VGA8x16"); |
1280 | int ret = 0, i; | 1281 | int ret = 0, i; |
@@ -1289,7 +1290,7 @@ static int __init vivid_init(void) | |||
1289 | n_devs = clamp_t(unsigned, n_devs, 1, VIVID_MAX_DEVS); | 1290 | n_devs = clamp_t(unsigned, n_devs, 1, VIVID_MAX_DEVS); |
1290 | 1291 | ||
1291 | for (i = 0; i < n_devs; i++) { | 1292 | for (i = 0; i < n_devs; i++) { |
1292 | ret = vivid_create_instance(i); | 1293 | ret = vivid_create_instance(pdev, i); |
1293 | if (ret) { | 1294 | if (ret) { |
1294 | /* If some instantiations succeeded, keep driver */ | 1295 | /* If some instantiations succeeded, keep driver */ |
1295 | if (i) | 1296 | if (i) |
@@ -1309,7 +1310,7 @@ static int __init vivid_init(void) | |||
1309 | return ret; | 1310 | return ret; |
1310 | } | 1311 | } |
1311 | 1312 | ||
1312 | static void __exit vivid_exit(void) | 1313 | static int vivid_remove(struct platform_device *pdev) |
1313 | { | 1314 | { |
1314 | struct vivid_dev *dev; | 1315 | struct vivid_dev *dev; |
1315 | unsigned i; | 1316 | unsigned i; |
@@ -1370,6 +1371,45 @@ static void __exit vivid_exit(void) | |||
1370 | kfree(dev); | 1371 | kfree(dev); |
1371 | vivid_devs[i] = NULL; | 1372 | vivid_devs[i] = NULL; |
1372 | } | 1373 | } |
1374 | return 0; | ||
1375 | } | ||
1376 | |||
1377 | static void vivid_pdev_release(struct device *dev) | ||
1378 | { | ||
1379 | } | ||
1380 | |||
1381 | static struct platform_device vivid_pdev = { | ||
1382 | .name = "vivid", | ||
1383 | .dev.release = vivid_pdev_release, | ||
1384 | }; | ||
1385 | |||
1386 | static struct platform_driver vivid_pdrv = { | ||
1387 | .probe = vivid_probe, | ||
1388 | .remove = vivid_remove, | ||
1389 | .driver = { | ||
1390 | .name = "vivid", | ||
1391 | }, | ||
1392 | }; | ||
1393 | |||
1394 | static int __init vivid_init(void) | ||
1395 | { | ||
1396 | int ret; | ||
1397 | |||
1398 | ret = platform_device_register(&vivid_pdev); | ||
1399 | if (ret) | ||
1400 | return ret; | ||
1401 | |||
1402 | ret = platform_driver_register(&vivid_pdrv); | ||
1403 | if (ret) | ||
1404 | platform_device_unregister(&vivid_pdev); | ||
1405 | |||
1406 | return ret; | ||
1407 | } | ||
1408 | |||
1409 | static void __exit vivid_exit(void) | ||
1410 | { | ||
1411 | platform_driver_unregister(&vivid_pdrv); | ||
1412 | platform_device_unregister(&vivid_pdev); | ||
1373 | } | 1413 | } |
1374 | 1414 | ||
1375 | module_init(vivid_init); | 1415 | module_init(vivid_init); |