Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: v4l: Set sub-device's owner field to the caller's module

Set a sub-device's owner field to the caller's module, provided as an
argument to the function. v4l2_device_register_subdev() becomes a macro
passing THIS_MODULE to the __v4l2_device_register_subdev() function.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Sakari Ailus and committed by
Mauro Carvalho Chehab
aa7b1488 03479d56

+15 -10
+1 -1
drivers/media/v4l2-core/v4l2-async.c
··· 341 341 int ret; 342 342 343 343 if (list_empty(&sd->asc_list)) { 344 - ret = v4l2_device_register_subdev(v4l2_dev, sd); 344 + ret = __v4l2_device_register_subdev(v4l2_dev, sd, sd->owner); 345 345 if (ret < 0) 346 346 return ret; 347 347 registered = true;
+7 -5
drivers/media/v4l2-core/v4l2-device.c
··· 108 108 } 109 109 EXPORT_SYMBOL_GPL(v4l2_device_unregister); 110 110 111 - int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, 112 - struct v4l2_subdev *sd) 111 + int __v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, 112 + struct v4l2_subdev *sd, struct module *module) 113 113 { 114 114 int err; 115 115 ··· 125 125 * try_module_get() such sub-device owners. 126 126 */ 127 127 sd->owner_v4l2_dev = v4l2_dev->dev && v4l2_dev->dev->driver && 128 - sd->owner == v4l2_dev->dev->driver->owner; 128 + module == v4l2_dev->dev->driver->owner; 129 129 130 - if (!sd->owner_v4l2_dev && !try_module_get(sd->owner)) 130 + if (!sd->owner_v4l2_dev && !try_module_get(module)) 131 131 return -ENODEV; 132 132 133 133 sd->v4l2_dev = v4l2_dev; ··· 152 152 goto error_unregister; 153 153 } 154 154 155 + sd->owner = module; 156 + 155 157 spin_lock(&v4l2_dev->lock); 156 158 list_add_tail(&sd->list, &v4l2_dev->subdevs); 157 159 spin_unlock(&v4l2_dev->lock); ··· 170 168 sd->v4l2_dev = NULL; 171 169 return err; 172 170 } 173 - EXPORT_SYMBOL_GPL(v4l2_device_register_subdev); 171 + EXPORT_SYMBOL_GPL(__v4l2_device_register_subdev); 174 172 175 173 static void v4l2_subdev_release(struct v4l2_subdev *sd) 176 174 {
+1 -1
drivers/media/v4l2-core/v4l2-i2c.c
··· 100 100 * Register with the v4l2_device which increases the module's 101 101 * use count as well. 102 102 */ 103 - if (v4l2_device_register_subdev(v4l2_dev, sd)) 103 + if (__v4l2_device_register_subdev(v4l2_dev, sd, sd->owner)) 104 104 sd = NULL; 105 105 /* Decrease the module use count to match the first try_module_get. */ 106 106 module_put(client->dev.driver->owner);
+1 -1
drivers/media/v4l2-core/v4l2-spi.c
··· 59 59 * Register with the v4l2_device which increases the module's 60 60 * use count as well. 61 61 */ 62 - if (v4l2_device_register_subdev(v4l2_dev, sd)) 62 + if (__v4l2_device_register_subdev(v4l2_dev, sd, sd->owner)) 63 63 sd = NULL; 64 64 65 65 /* Decrease the module use count to match the first try_module_get. */
+5 -2
include/media/v4l2-device.h
··· 156 156 * An error is returned if the module is no longer loaded on any attempts 157 157 * to register it. 158 158 */ 159 - int __must_check v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, 160 - struct v4l2_subdev *sd); 159 + #define v4l2_device_register_subdev(v4l2_dev, sd) \ 160 + __v4l2_device_register_subdev(v4l2_dev, sd, THIS_MODULE) 161 + int __must_check __v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, 162 + struct v4l2_subdev *sd, 163 + struct module *module); 161 164 162 165 /** 163 166 * v4l2_device_unregister_subdev - Unregisters a subdev with a v4l2 device.