aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-common.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-12 17:56:15 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:20 -0400
commit7c026c35114d169d77c2543fdf4d5689a1c9a51d (patch)
tree6c179ab3dc681829fc8e8042dae02755cc111f8d /drivers/media/video/v4l2-common.c
parent2c79252326421dd49c059aceec0880d2cf15b17a (diff)
V4L/DVB (10983): v4l2-common: add missing i2c_unregister_device.
If the i2c sub-device cannot be found, then we must unregister the i2c_client. Otherwise this will prevent a possible probe for a different device on that same address. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-common.c')
-rw-r--r--drivers/media/video/v4l2-common.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index dbced906aa06..49aad1ed0b26 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -813,11 +813,11 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
813 We need better support from the kernel so that we 813 We need better support from the kernel so that we
814 can easily wait for the load to finish. */ 814 can easily wait for the load to finish. */
815 if (client == NULL || client->driver == NULL) 815 if (client == NULL || client->driver == NULL)
816 return NULL; 816 goto error;
817 817
818 /* Lock the module so we can safely get the v4l2_subdev pointer */ 818 /* Lock the module so we can safely get the v4l2_subdev pointer */
819 if (!try_module_get(client->driver->driver.owner)) 819 if (!try_module_get(client->driver->driver.owner))
820 return NULL; 820 goto error;
821 sd = i2c_get_clientdata(client); 821 sd = i2c_get_clientdata(client);
822 822
823 /* Register with the v4l2_device which increases the module's 823 /* Register with the v4l2_device which increases the module's
@@ -826,8 +826,13 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
826 sd = NULL; 826 sd = NULL;
827 /* Decrease the module use count to match the first try_module_get. */ 827 /* Decrease the module use count to match the first try_module_get. */
828 module_put(client->driver->driver.owner); 828 module_put(client->driver->driver.owner);
829 return sd;
830 829
830error:
831 /* If we have a client but no subdev, then something went wrong and
832 we must unregister the client. */
833 if (client && sd == NULL)
834 i2c_unregister_device(client);
835 return sd;
831} 836}
832EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); 837EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev);
833 838
@@ -860,11 +865,11 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
860 We need better support from the kernel so that we 865 We need better support from the kernel so that we
861 can easily wait for the load to finish. */ 866 can easily wait for the load to finish. */
862 if (client == NULL || client->driver == NULL) 867 if (client == NULL || client->driver == NULL)
863 return NULL; 868 goto error;
864 869
865 /* Lock the module so we can safely get the v4l2_subdev pointer */ 870 /* Lock the module so we can safely get the v4l2_subdev pointer */
866 if (!try_module_get(client->driver->driver.owner)) 871 if (!try_module_get(client->driver->driver.owner))
867 return NULL; 872 goto error;
868 sd = i2c_get_clientdata(client); 873 sd = i2c_get_clientdata(client);
869 874
870 /* Register with the v4l2_device which increases the module's 875 /* Register with the v4l2_device which increases the module's
@@ -873,6 +878,12 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
873 sd = NULL; 878 sd = NULL;
874 /* Decrease the module use count to match the first try_module_get. */ 879 /* Decrease the module use count to match the first try_module_get. */
875 module_put(client->driver->driver.owner); 880 module_put(client->driver->driver.owner);
881
882error:
883 /* If we have a client but no subdev, then something went wrong and
884 we must unregister the client. */
885 if (client && sd == NULL)
886 i2c_unregister_device(client);
876 return sd; 887 return sd;
877} 888}
878EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev); 889EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev);