summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/v4l2-common.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-03-18 12:17:14 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-18 12:17:14 -0300
commit976a91082e499203f3700aa589a54aefedc3c22a (patch)
tree311541d0a78d789d3f59dbba22637ce262227f51 /linux/drivers/media/video/v4l2-common.c
parentd42d95e43ed8a60e001ff0a8a4f323380098be7d (diff)
parent70bbc9f369222fa300c1fcb727eefd22da4db452 (diff)
downloadmediapointer-dvb-s2-976a91082e499203f3700aa589a54aefedc3c22a.tar.gz
mediapointer-dvb-s2-976a91082e499203f3700aa589a54aefedc3c22a.tar.bz2
merge: http://linuxtv.org/hg/~dheitmueller/hvr950q-analog2
From: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux/drivers/media/video/v4l2-common.c')
-rw-r--r--linux/drivers/media/video/v4l2-common.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index a5ce43102..32d0246d5 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -856,11 +856,11 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
We need better support from the kernel so that we
can easily wait for the load to finish. */
if (client == NULL || client->driver == NULL)
- return NULL;
+ goto error;
/* Lock the module so we can safely get the v4l2_subdev pointer */
if (!try_module_get(client->driver->driver.owner))
- return NULL;
+ goto error;
sd = i2c_get_clientdata(client);
/* Register with the v4l2_device which increases the module's
@@ -869,8 +869,15 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
sd = NULL;
/* Decrease the module use count to match the first try_module_get. */
module_put(client->driver->driver.owner);
- return sd;
+error:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
+ /* If we have a client but no subdev, then something went wrong and
+ we must unregister the client. */
+ if (client && sd == NULL)
+ i2c_unregister_device(client);
+#endif
+ return sd;
}
EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev);
@@ -918,11 +925,11 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
We need better support from the kernel so that we
can easily wait for the load to finish. */
if (client == NULL || client->driver == NULL)
- return NULL;
+ goto error;
/* Lock the module so we can safely get the v4l2_subdev pointer */
if (!try_module_get(client->driver->driver.owner))
- return NULL;
+ goto error;
sd = i2c_get_clientdata(client);
/* Register with the v4l2_device which increases the module's
@@ -931,6 +938,14 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
sd = NULL;
/* Decrease the module use count to match the first try_module_get. */
module_put(client->driver->driver.owner);
+
+error:
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
+ /* If we have a client but no subdev, then something went wrong and
+ we must unregister the client. */
+ if (client && sd == NULL)
+ i2c_unregister_device(client);
+#endif
return sd;
}
EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev);