diff options
Diffstat (limited to 'drivers/media/dvb-core/dvbdev.c')
-rw-r--r-- | drivers/media/dvb-core/dvbdev.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index 60e9c2ba26be..787fe06df217 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
27 | #include <linux/i2c.h> | ||
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
28 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
29 | #include <linux/device.h> | 30 | #include <linux/device.h> |
@@ -941,6 +942,55 @@ out: | |||
941 | return err; | 942 | return err; |
942 | } | 943 | } |
943 | 944 | ||
945 | #if IS_ENABLED(CONFIG_I2C) | ||
946 | struct i2c_client *dvb_module_probe(const char *module_name, | ||
947 | const char *name, | ||
948 | struct i2c_adapter *adap, | ||
949 | unsigned char addr, | ||
950 | void *platform_data) | ||
951 | { | ||
952 | struct i2c_client *client; | ||
953 | struct i2c_board_info *board_info; | ||
954 | |||
955 | board_info = kzalloc(sizeof(*board_info), GFP_KERNEL); | ||
956 | if (!board_info) | ||
957 | return NULL; | ||
958 | |||
959 | if (name) | ||
960 | strlcpy(board_info->type, name, I2C_NAME_SIZE); | ||
961 | else | ||
962 | strlcpy(board_info->type, module_name, I2C_NAME_SIZE); | ||
963 | |||
964 | board_info->addr = addr; | ||
965 | board_info->platform_data = platform_data; | ||
966 | request_module(module_name); | ||
967 | client = i2c_new_device(adap, board_info); | ||
968 | if (client == NULL || client->dev.driver == NULL) { | ||
969 | kfree(board_info); | ||
970 | return NULL; | ||
971 | } | ||
972 | |||
973 | if (!try_module_get(client->dev.driver->owner)) { | ||
974 | i2c_unregister_device(client); | ||
975 | client = NULL; | ||
976 | } | ||
977 | |||
978 | kfree(board_info); | ||
979 | return client; | ||
980 | } | ||
981 | EXPORT_SYMBOL_GPL(dvb_module_probe); | ||
982 | |||
983 | void dvb_module_release(struct i2c_client *client) | ||
984 | { | ||
985 | if (!client) | ||
986 | return; | ||
987 | |||
988 | module_put(client->dev.driver->owner); | ||
989 | i2c_unregister_device(client); | ||
990 | } | ||
991 | EXPORT_SYMBOL_GPL(dvb_module_release); | ||
992 | #endif | ||
993 | |||
944 | static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env) | 994 | static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env) |
945 | { | 995 | { |
946 | struct dvb_device *dvbdev = dev_get_drvdata(dev); | 996 | struct dvb_device *dvbdev = dev_get_drvdata(dev); |