diff options
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9m111.c')
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9m111.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9m111.c b/drivers/media/i2c/soc_camera/mt9m111.c index 62fd94af599b..bbc4ff99603c 100644 --- a/drivers/media/i2c/soc_camera/mt9m111.c +++ b/drivers/media/i2c/soc_camera/mt9m111.c | |||
@@ -24,7 +24,8 @@ | |||
24 | /* | 24 | /* |
25 | * MT9M111, MT9M112 and MT9M131: | 25 | * MT9M111, MT9M112 and MT9M131: |
26 | * i2c address is 0x48 or 0x5d (depending on SADDR pin) | 26 | * i2c address is 0x48 or 0x5d (depending on SADDR pin) |
27 | * The platform has to define i2c_board_info and call i2c_register_board_info() | 27 | * The platform has to define struct i2c_board_info objects and link to them |
28 | * from struct soc_camera_host_desc | ||
28 | */ | 29 | */ |
29 | 30 | ||
30 | /* | 31 | /* |
@@ -799,17 +800,17 @@ static int mt9m111_init(struct mt9m111 *mt9m111) | |||
799 | static int mt9m111_power_on(struct mt9m111 *mt9m111) | 800 | static int mt9m111_power_on(struct mt9m111 *mt9m111) |
800 | { | 801 | { |
801 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); | 802 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); |
802 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 803 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
803 | int ret; | 804 | int ret; |
804 | 805 | ||
805 | ret = soc_camera_power_on(&client->dev, icl); | 806 | ret = soc_camera_power_on(&client->dev, ssdd); |
806 | if (ret < 0) | 807 | if (ret < 0) |
807 | return ret; | 808 | return ret; |
808 | 809 | ||
809 | ret = mt9m111_resume(mt9m111); | 810 | ret = mt9m111_resume(mt9m111); |
810 | if (ret < 0) { | 811 | if (ret < 0) { |
811 | dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret); | 812 | dev_err(&client->dev, "Failed to resume the sensor: %d\n", ret); |
812 | soc_camera_power_off(&client->dev, icl); | 813 | soc_camera_power_off(&client->dev, ssdd); |
813 | } | 814 | } |
814 | 815 | ||
815 | return ret; | 816 | return ret; |
@@ -818,10 +819,10 @@ static int mt9m111_power_on(struct mt9m111 *mt9m111) | |||
818 | static void mt9m111_power_off(struct mt9m111 *mt9m111) | 819 | static void mt9m111_power_off(struct mt9m111 *mt9m111) |
819 | { | 820 | { |
820 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); | 821 | struct i2c_client *client = v4l2_get_subdevdata(&mt9m111->subdev); |
821 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 822 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
822 | 823 | ||
823 | mt9m111_suspend(mt9m111); | 824 | mt9m111_suspend(mt9m111); |
824 | soc_camera_power_off(&client->dev, icl); | 825 | soc_camera_power_off(&client->dev, ssdd); |
825 | } | 826 | } |
826 | 827 | ||
827 | static int mt9m111_s_power(struct v4l2_subdev *sd, int on) | 828 | static int mt9m111_s_power(struct v4l2_subdev *sd, int on) |
@@ -879,13 +880,13 @@ static int mt9m111_g_mbus_config(struct v4l2_subdev *sd, | |||
879 | struct v4l2_mbus_config *cfg) | 880 | struct v4l2_mbus_config *cfg) |
880 | { | 881 | { |
881 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 882 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
882 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 883 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
883 | 884 | ||
884 | cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | | 885 | cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | |
885 | V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH | | 886 | V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_HIGH | |
886 | V4L2_MBUS_DATA_ACTIVE_HIGH; | 887 | V4L2_MBUS_DATA_ACTIVE_HIGH; |
887 | cfg->type = V4L2_MBUS_PARALLEL; | 888 | cfg->type = V4L2_MBUS_PARALLEL; |
888 | cfg->flags = soc_camera_apply_board_flags(icl, cfg); | 889 | cfg->flags = soc_camera_apply_board_flags(ssdd, cfg); |
889 | 890 | ||
890 | return 0; | 891 | return 0; |
891 | } | 892 | } |
@@ -956,10 +957,10 @@ static int mt9m111_probe(struct i2c_client *client, | |||
956 | { | 957 | { |
957 | struct mt9m111 *mt9m111; | 958 | struct mt9m111 *mt9m111; |
958 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 959 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
959 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 960 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
960 | int ret; | 961 | int ret; |
961 | 962 | ||
962 | if (!icl) { | 963 | if (!ssdd) { |
963 | dev_err(&client->dev, "mt9m111: driver needs platform data\n"); | 964 | dev_err(&client->dev, "mt9m111: driver needs platform data\n"); |
964 | return -EINVAL; | 965 | return -EINVAL; |
965 | } | 966 | } |
@@ -970,7 +971,7 @@ static int mt9m111_probe(struct i2c_client *client, | |||
970 | return -EIO; | 971 | return -EIO; |
971 | } | 972 | } |
972 | 973 | ||
973 | mt9m111 = kzalloc(sizeof(struct mt9m111), GFP_KERNEL); | 974 | mt9m111 = devm_kzalloc(&client->dev, sizeof(struct mt9m111), GFP_KERNEL); |
974 | if (!mt9m111) | 975 | if (!mt9m111) |
975 | return -ENOMEM; | 976 | return -ENOMEM; |
976 | 977 | ||
@@ -988,12 +989,8 @@ static int mt9m111_probe(struct i2c_client *client, | |||
988 | &mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, | 989 | &mt9m111_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, 1, 0, |
989 | V4L2_EXPOSURE_AUTO); | 990 | V4L2_EXPOSURE_AUTO); |
990 | mt9m111->subdev.ctrl_handler = &mt9m111->hdl; | 991 | mt9m111->subdev.ctrl_handler = &mt9m111->hdl; |
991 | if (mt9m111->hdl.error) { | 992 | if (mt9m111->hdl.error) |
992 | int err = mt9m111->hdl.error; | 993 | return mt9m111->hdl.error; |
993 | |||
994 | kfree(mt9m111); | ||
995 | return err; | ||
996 | } | ||
997 | 994 | ||
998 | /* Second stage probe - when a capture adapter is there */ | 995 | /* Second stage probe - when a capture adapter is there */ |
999 | mt9m111->rect.left = MT9M111_MIN_DARK_COLS; | 996 | mt9m111->rect.left = MT9M111_MIN_DARK_COLS; |
@@ -1005,10 +1002,8 @@ static int mt9m111_probe(struct i2c_client *client, | |||
1005 | mutex_init(&mt9m111->power_lock); | 1002 | mutex_init(&mt9m111->power_lock); |
1006 | 1003 | ||
1007 | ret = mt9m111_video_probe(client); | 1004 | ret = mt9m111_video_probe(client); |
1008 | if (ret) { | 1005 | if (ret) |
1009 | v4l2_ctrl_handler_free(&mt9m111->hdl); | 1006 | v4l2_ctrl_handler_free(&mt9m111->hdl); |
1010 | kfree(mt9m111); | ||
1011 | } | ||
1012 | 1007 | ||
1013 | return ret; | 1008 | return ret; |
1014 | } | 1009 | } |
@@ -1019,7 +1014,6 @@ static int mt9m111_remove(struct i2c_client *client) | |||
1019 | 1014 | ||
1020 | v4l2_device_unregister_subdev(&mt9m111->subdev); | 1015 | v4l2_device_unregister_subdev(&mt9m111->subdev); |
1021 | v4l2_ctrl_handler_free(&mt9m111->hdl); | 1016 | v4l2_ctrl_handler_free(&mt9m111->hdl); |
1022 | kfree(mt9m111); | ||
1023 | 1017 | ||
1024 | return 0; | 1018 | return 0; |
1025 | } | 1019 | } |