aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2013-12-12 10:38:17 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-05-13 12:39:00 -0400
commit85de721c46ba8ad9b283b2b3e307c9a3e8425042 (patch)
treefd49693fa164755b123d15636a10d3ee3d949d85
parent743e18377cae643f88ff62b4c2b87c45e4ecd024 (diff)
[media] media: Use a better owner for the media device
mdev->fops->owner is actually the owner of the very same module which implements media_device_register(), so it can't be unloaded anyway. Instead, use THIS_MODULE through a macro as does video_register_device(). Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r--drivers/media/media-device.c7
-rw-r--r--drivers/media/media-devnode.c5
-rw-r--r--include/media/media-device.h4
-rw-r--r--include/media/media-devnode.h3
4 files changed, 12 insertions, 7 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index d5a7a135f75d..51217f00a668 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -372,7 +372,8 @@ static void media_device_release(struct media_devnode *mdev)
372 * - dev must point to the parent device 372 * - dev must point to the parent device
373 * - model must be filled with the device model name 373 * - model must be filled with the device model name
374 */ 374 */
375int __must_check media_device_register(struct media_device *mdev) 375int __must_check __media_device_register(struct media_device *mdev,
376 struct module *owner)
376{ 377{
377 int ret; 378 int ret;
378 379
@@ -388,7 +389,7 @@ int __must_check media_device_register(struct media_device *mdev)
388 mdev->devnode.fops = &media_device_fops; 389 mdev->devnode.fops = &media_device_fops;
389 mdev->devnode.parent = mdev->dev; 390 mdev->devnode.parent = mdev->dev;
390 mdev->devnode.release = media_device_release; 391 mdev->devnode.release = media_device_release;
391 ret = media_devnode_register(&mdev->devnode); 392 ret = media_devnode_register(&mdev->devnode, owner);
392 if (ret < 0) 393 if (ret < 0)
393 return ret; 394 return ret;
394 395
@@ -400,7 +401,7 @@ int __must_check media_device_register(struct media_device *mdev)
400 401
401 return 0; 402 return 0;
402} 403}
403EXPORT_SYMBOL_GPL(media_device_register); 404EXPORT_SYMBOL_GPL(__media_device_register);
404 405
405/** 406/**
406 * media_device_unregister - unregister a media device 407 * media_device_unregister - unregister a media device
diff --git a/drivers/media/media-devnode.c b/drivers/media/media-devnode.c
index fb0f0469fad7..7acd19c881de 100644
--- a/drivers/media/media-devnode.c
+++ b/drivers/media/media-devnode.c
@@ -232,7 +232,8 @@ static const struct file_operations media_devnode_fops = {
232 * the media_devnode structure is *not* called, so the caller is responsible for 232 * the media_devnode structure is *not* called, so the caller is responsible for
233 * freeing any data. 233 * freeing any data.
234 */ 234 */
235int __must_check media_devnode_register(struct media_devnode *mdev) 235int __must_check media_devnode_register(struct media_devnode *mdev,
236 struct module *owner)
236{ 237{
237 int minor; 238 int minor;
238 int ret; 239 int ret;
@@ -253,7 +254,7 @@ int __must_check media_devnode_register(struct media_devnode *mdev)
253 254
254 /* Part 2: Initialize and register the character device */ 255 /* Part 2: Initialize and register the character device */
255 cdev_init(&mdev->cdev, &media_devnode_fops); 256 cdev_init(&mdev->cdev, &media_devnode_fops);
256 mdev->cdev.owner = mdev->fops->owner; 257 mdev->cdev.owner = owner;
257 258
258 ret = cdev_add(&mdev->cdev, MKDEV(MAJOR(media_dev_t), mdev->minor), 1); 259 ret = cdev_add(&mdev->cdev, MKDEV(MAJOR(media_dev_t), mdev->minor), 1);
259 if (ret < 0) { 260 if (ret < 0) {
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 12155a9596c4..6e6db78f1ee2 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -87,7 +87,9 @@ struct media_device {
87/* media_devnode to media_device */ 87/* media_devnode to media_device */
88#define to_media_device(node) container_of(node, struct media_device, devnode) 88#define to_media_device(node) container_of(node, struct media_device, devnode)
89 89
90int __must_check media_device_register(struct media_device *mdev); 90int __must_check __media_device_register(struct media_device *mdev,
91 struct module *owner);
92#define media_device_register(mdev) __media_device_register(mdev, THIS_MODULE)
91void media_device_unregister(struct media_device *mdev); 93void media_device_unregister(struct media_device *mdev);
92 94
93int __must_check media_device_register_entity(struct media_device *mdev, 95int __must_check media_device_register_entity(struct media_device *mdev,
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h
index 3446af279fca..0dc7060f9625 100644
--- a/include/media/media-devnode.h
+++ b/include/media/media-devnode.h
@@ -82,7 +82,8 @@ struct media_devnode {
82/* dev to media_devnode */ 82/* dev to media_devnode */
83#define to_media_devnode(cd) container_of(cd, struct media_devnode, dev) 83#define to_media_devnode(cd) container_of(cd, struct media_devnode, dev)
84 84
85int __must_check media_devnode_register(struct media_devnode *mdev); 85int __must_check media_devnode_register(struct media_devnode *mdev,
86 struct module *owner);
86void media_devnode_unregister(struct media_devnode *mdev); 87void media_devnode_unregister(struct media_devnode *mdev);
87 88
88static inline struct media_devnode *media_devnode_data(struct file *filp) 89static inline struct media_devnode *media_devnode_data(struct file *filp)