aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/v4l2-device.c')
-rw-r--r--drivers/media/video/v4l2-device.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 7fe6f92af480..ce64fe16bc60 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -100,6 +100,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
100 is a platform bus, then it is never deleted. */ 100 is a platform bus, then it is never deleted. */
101 if (client) 101 if (client)
102 i2c_unregister_device(client); 102 i2c_unregister_device(client);
103 continue;
103 } 104 }
104#endif 105#endif
105#if defined(CONFIG_SPI) 106#if defined(CONFIG_SPI)
@@ -108,6 +109,7 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev)
108 109
109 if (spi) 110 if (spi)
110 spi_unregister_device(spi); 111 spi_unregister_device(spi);
112 continue;
111 } 113 }
112#endif 114#endif
113 } 115 }
@@ -126,11 +128,19 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
126 WARN_ON(sd->v4l2_dev != NULL); 128 WARN_ON(sd->v4l2_dev != NULL);
127 if (!try_module_get(sd->owner)) 129 if (!try_module_get(sd->owner))
128 return -ENODEV; 130 return -ENODEV;
131 sd->v4l2_dev = v4l2_dev;
132 if (sd->internal_ops && sd->internal_ops->registered) {
133 err = sd->internal_ops->registered(sd);
134 if (err)
135 return err;
136 }
129 /* This just returns 0 if either of the two args is NULL */ 137 /* This just returns 0 if either of the two args is NULL */
130 err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler); 138 err = v4l2_ctrl_add_handler(v4l2_dev->ctrl_handler, sd->ctrl_handler);
131 if (err) 139 if (err) {
140 if (sd->internal_ops && sd->internal_ops->unregistered)
141 sd->internal_ops->unregistered(sd);
132 return err; 142 return err;
133 sd->v4l2_dev = v4l2_dev; 143 }
134 spin_lock(&v4l2_dev->lock); 144 spin_lock(&v4l2_dev->lock);
135 list_add_tail(&sd->list, &v4l2_dev->subdevs); 145 list_add_tail(&sd->list, &v4l2_dev->subdevs);
136 spin_unlock(&v4l2_dev->lock); 146 spin_unlock(&v4l2_dev->lock);
@@ -146,6 +156,8 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd)
146 spin_lock(&sd->v4l2_dev->lock); 156 spin_lock(&sd->v4l2_dev->lock);
147 list_del(&sd->list); 157 list_del(&sd->list);
148 spin_unlock(&sd->v4l2_dev->lock); 158 spin_unlock(&sd->v4l2_dev->lock);
159 if (sd->internal_ops && sd->internal_ops->unregistered)
160 sd->internal_ops->unregistered(sd);
149 sd->v4l2_dev = NULL; 161 sd->v4l2_dev = NULL;
150 module_put(sd->owner); 162 module_put(sd->owner);
151} 163}