diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-08-10 01:49:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:19:24 -0400 |
commit | 53dacb15705901e14b03dcba27e40364fedd9d09 (patch) | |
tree | ca3b4111465aca9d58024ace0f0072ee7952c11e /drivers/media/video/v4l2-common.c | |
parent | 0da2808ca27ab7f65346d4d191569c669db8f628 (diff) |
V4L/DVB (12540): v4l: simplify v4l2_i2c_new_subdev and friends
Rewrite v4l2_i2c_new_subdev as a simplified version of v4l2_i2c_new_subdev_cfg
and remove v4l2_i2c_new_probed_subdev and v4l2_i2c_new_probed_subdev_addr.
This simplifies this API substantially.
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.c | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 3a0c64935b0e..f5a93ae3cdf9 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c | |||
@@ -814,139 +814,6 @@ EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init); | |||
814 | 814 | ||
815 | 815 | ||
816 | /* Load an i2c sub-device. */ | 816 | /* Load an i2c sub-device. */ |
817 | struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, | ||
818 | struct i2c_adapter *adapter, | ||
819 | const char *module_name, const char *client_type, u8 addr) | ||
820 | { | ||
821 | struct v4l2_subdev *sd = NULL; | ||
822 | struct i2c_client *client; | ||
823 | struct i2c_board_info info; | ||
824 | |||
825 | BUG_ON(!v4l2_dev); | ||
826 | |||
827 | if (module_name) | ||
828 | request_module(module_name); | ||
829 | |||
830 | /* Setup the i2c board info with the device type and | ||
831 | the device address. */ | ||
832 | memset(&info, 0, sizeof(info)); | ||
833 | strlcpy(info.type, client_type, sizeof(info.type)); | ||
834 | info.addr = addr; | ||
835 | |||
836 | /* Create the i2c client */ | ||
837 | client = i2c_new_device(adapter, &info); | ||
838 | /* Note: it is possible in the future that | ||
839 | c->driver is NULL if the driver is still being loaded. | ||
840 | We need better support from the kernel so that we | ||
841 | can easily wait for the load to finish. */ | ||
842 | if (client == NULL || client->driver == NULL) | ||
843 | goto error; | ||
844 | |||
845 | /* Lock the module so we can safely get the v4l2_subdev pointer */ | ||
846 | if (!try_module_get(client->driver->driver.owner)) | ||
847 | goto error; | ||
848 | sd = i2c_get_clientdata(client); | ||
849 | |||
850 | /* Register with the v4l2_device which increases the module's | ||
851 | use count as well. */ | ||
852 | if (v4l2_device_register_subdev(v4l2_dev, sd)) | ||
853 | sd = NULL; | ||
854 | /* Decrease the module use count to match the first try_module_get. */ | ||
855 | module_put(client->driver->driver.owner); | ||
856 | |||
857 | if (sd) { | ||
858 | /* We return errors from v4l2_subdev_call only if we have the | ||
859 | callback as the .s_config is not mandatory */ | ||
860 | int err = v4l2_subdev_call(sd, core, s_config, 0, NULL); | ||
861 | |||
862 | if (err && err != -ENOIOCTLCMD) { | ||
863 | v4l2_device_unregister_subdev(sd); | ||
864 | sd = NULL; | ||
865 | } | ||
866 | } | ||
867 | |||
868 | error: | ||
869 | /* If we have a client but no subdev, then something went wrong and | ||
870 | we must unregister the client. */ | ||
871 | if (client && sd == NULL) | ||
872 | i2c_unregister_device(client); | ||
873 | return sd; | ||
874 | } | ||
875 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); | ||
876 | |||
877 | /* Probe and load an i2c sub-device. */ | ||
878 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, | ||
879 | struct i2c_adapter *adapter, | ||
880 | const char *module_name, const char *client_type, | ||
881 | const unsigned short *addrs) | ||
882 | { | ||
883 | struct v4l2_subdev *sd = NULL; | ||
884 | struct i2c_client *client = NULL; | ||
885 | struct i2c_board_info info; | ||
886 | |||
887 | BUG_ON(!v4l2_dev); | ||
888 | |||
889 | if (module_name) | ||
890 | request_module(module_name); | ||
891 | |||
892 | /* Setup the i2c board info with the device type and | ||
893 | the device address. */ | ||
894 | memset(&info, 0, sizeof(info)); | ||
895 | strlcpy(info.type, client_type, sizeof(info.type)); | ||
896 | |||
897 | /* Probe and create the i2c client */ | ||
898 | client = i2c_new_probed_device(adapter, &info, addrs); | ||
899 | /* Note: it is possible in the future that | ||
900 | c->driver is NULL if the driver is still being loaded. | ||
901 | We need better support from the kernel so that we | ||
902 | can easily wait for the load to finish. */ | ||
903 | if (client == NULL || client->driver == NULL) | ||
904 | goto error; | ||
905 | |||
906 | /* Lock the module so we can safely get the v4l2_subdev pointer */ | ||
907 | if (!try_module_get(client->driver->driver.owner)) | ||
908 | goto error; | ||
909 | sd = i2c_get_clientdata(client); | ||
910 | |||
911 | /* Register with the v4l2_device which increases the module's | ||
912 | use count as well. */ | ||
913 | if (v4l2_device_register_subdev(v4l2_dev, sd)) | ||
914 | sd = NULL; | ||
915 | /* Decrease the module use count to match the first try_module_get. */ | ||
916 | module_put(client->driver->driver.owner); | ||
917 | |||
918 | if (sd) { | ||
919 | /* We return errors from v4l2_subdev_call only if we have the | ||
920 | callback as the .s_config is not mandatory */ | ||
921 | int err = v4l2_subdev_call(sd, core, s_config, 0, NULL); | ||
922 | |||
923 | if (err && err != -ENOIOCTLCMD) { | ||
924 | v4l2_device_unregister_subdev(sd); | ||
925 | sd = NULL; | ||
926 | } | ||
927 | } | ||
928 | |||
929 | error: | ||
930 | /* If we have a client but no subdev, then something went wrong and | ||
931 | we must unregister the client. */ | ||
932 | if (client && sd == NULL) | ||
933 | i2c_unregister_device(client); | ||
934 | return sd; | ||
935 | } | ||
936 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev); | ||
937 | |||
938 | struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev, | ||
939 | struct i2c_adapter *adapter, | ||
940 | const char *module_name, const char *client_type, u8 addr) | ||
941 | { | ||
942 | unsigned short addrs[2] = { addr, I2C_CLIENT_END }; | ||
943 | |||
944 | return v4l2_i2c_new_probed_subdev(v4l2_dev, adapter, | ||
945 | module_name, client_type, addrs); | ||
946 | } | ||
947 | EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev_addr); | ||
948 | |||
949 | /* Load an i2c sub-device. */ | ||
950 | struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, | 817 | struct v4l2_subdev *v4l2_i2c_new_subdev_board(struct v4l2_device *v4l2_dev, |
951 | struct i2c_adapter *adapter, const char *module_name, | 818 | struct i2c_adapter *adapter, const char *module_name, |
952 | struct i2c_board_info *info, const unsigned short *probe_addrs) | 819 | struct i2c_board_info *info, const unsigned short *probe_addrs) |