From: Hans Verkuil Date: Fri, 13 Mar 2015 08:40:37 +0000 (-0300) Subject: [media] vivid: turn this into a platform_device X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f46d740fb0258982f00ffdbddc6486e674edafb5;p=linux-beck.git [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 Signed-off-by: Mauro Carvalho Chehab --- 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 @@ #include #include #include +#include #include #include #include @@ -618,7 +619,7 @@ static const struct v4l2_ioctl_ops vivid_ioctl_ops = { Initialization and module stuff ------------------------------------------------------------------*/ -static int __init vivid_create_instance(int inst) +static int vivid_create_instance(struct platform_device *pdev, int inst) { static const struct v4l2_dv_timings def_dv_timings = V4L2_DV_BT_CEA_1280X720P60; @@ -646,7 +647,7 @@ static int __init vivid_create_instance(int inst) /* register v4l2_device */ snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s-%03d", VIVID_MODULE_NAME, inst); - ret = v4l2_device_register(NULL, &dev->v4l2_dev); + ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) goto free_dev; @@ -1274,7 +1275,7 @@ free_dev: will succeed. This is limited to the maximum number of devices that videodev supports, which is equal to VIDEO_NUM_DEVICES. */ -static int __init vivid_init(void) +static int vivid_probe(struct platform_device *pdev) { const struct font_desc *font = find_font("VGA8x16"); int ret = 0, i; @@ -1289,7 +1290,7 @@ static int __init vivid_init(void) n_devs = clamp_t(unsigned, n_devs, 1, VIVID_MAX_DEVS); for (i = 0; i < n_devs; i++) { - ret = vivid_create_instance(i); + ret = vivid_create_instance(pdev, i); if (ret) { /* If some instantiations succeeded, keep driver */ if (i) @@ -1309,7 +1310,7 @@ static int __init vivid_init(void) return ret; } -static void __exit vivid_exit(void) +static int vivid_remove(struct platform_device *pdev) { struct vivid_dev *dev; unsigned i; @@ -1370,6 +1371,45 @@ static void __exit vivid_exit(void) kfree(dev); vivid_devs[i] = NULL; } + return 0; +} + +static void vivid_pdev_release(struct device *dev) +{ +} + +static struct platform_device vivid_pdev = { + .name = "vivid", + .dev.release = vivid_pdev_release, +}; + +static struct platform_driver vivid_pdrv = { + .probe = vivid_probe, + .remove = vivid_remove, + .driver = { + .name = "vivid", + }, +}; + +static int __init vivid_init(void) +{ + int ret; + + ret = platform_device_register(&vivid_pdev); + if (ret) + return ret; + + ret = platform_driver_register(&vivid_pdrv); + if (ret) + platform_device_unregister(&vivid_pdev); + + return ret; +} + +static void __exit vivid_exit(void) +{ + platform_driver_unregister(&vivid_pdrv); + platform_device_unregister(&vivid_pdev); } module_init(vivid_init);