diff options
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9t031.c')
-rw-r--r-- | drivers/media/i2c/soc_camera/mt9t031.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9t031.c b/drivers/media/i2c/soc_camera/mt9t031.c index 40800b10a080..d80d044ebf15 100644 --- a/drivers/media/i2c/soc_camera/mt9t031.c +++ b/drivers/media/i2c/soc_camera/mt9t031.c | |||
@@ -31,8 +31,8 @@ | |||
31 | 31 | ||
32 | /* | 32 | /* |
33 | * mt9t031 i2c address 0x5d | 33 | * mt9t031 i2c address 0x5d |
34 | * The platform has to define i2c_board_info and link to it from | 34 | * The platform has to define struct i2c_board_info objects and link to them |
35 | * struct soc_camera_link | 35 | * from struct soc_camera_host_desc |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /* mt9t031 selected register addresses */ | 38 | /* mt9t031 selected register addresses */ |
@@ -608,18 +608,18 @@ static struct device_type mt9t031_dev_type = { | |||
608 | static int mt9t031_s_power(struct v4l2_subdev *sd, int on) | 608 | static int mt9t031_s_power(struct v4l2_subdev *sd, int on) |
609 | { | 609 | { |
610 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 610 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
611 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 611 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
612 | struct video_device *vdev = soc_camera_i2c_to_vdev(client); | 612 | struct video_device *vdev = soc_camera_i2c_to_vdev(client); |
613 | int ret; | 613 | int ret; |
614 | 614 | ||
615 | if (on) { | 615 | if (on) { |
616 | ret = soc_camera_power_on(&client->dev, icl); | 616 | ret = soc_camera_power_on(&client->dev, ssdd); |
617 | if (ret < 0) | 617 | if (ret < 0) |
618 | return ret; | 618 | return ret; |
619 | vdev->dev.type = &mt9t031_dev_type; | 619 | vdev->dev.type = &mt9t031_dev_type; |
620 | } else { | 620 | } else { |
621 | vdev->dev.type = NULL; | 621 | vdev->dev.type = NULL; |
622 | soc_camera_power_off(&client->dev, icl); | 622 | soc_camera_power_off(&client->dev, ssdd); |
623 | } | 623 | } |
624 | 624 | ||
625 | return 0; | 625 | return 0; |
@@ -707,13 +707,13 @@ static int mt9t031_g_mbus_config(struct v4l2_subdev *sd, | |||
707 | struct v4l2_mbus_config *cfg) | 707 | struct v4l2_mbus_config *cfg) |
708 | { | 708 | { |
709 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 709 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
710 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 710 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
711 | 711 | ||
712 | cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | | 712 | cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | |
713 | V4L2_MBUS_PCLK_SAMPLE_FALLING | V4L2_MBUS_HSYNC_ACTIVE_HIGH | | 713 | V4L2_MBUS_PCLK_SAMPLE_FALLING | V4L2_MBUS_HSYNC_ACTIVE_HIGH | |
714 | V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH; | 714 | V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH; |
715 | cfg->type = V4L2_MBUS_PARALLEL; | 715 | cfg->type = V4L2_MBUS_PARALLEL; |
716 | cfg->flags = soc_camera_apply_board_flags(icl, cfg); | 716 | cfg->flags = soc_camera_apply_board_flags(ssdd, cfg); |
717 | 717 | ||
718 | return 0; | 718 | return 0; |
719 | } | 719 | } |
@@ -722,9 +722,9 @@ static int mt9t031_s_mbus_config(struct v4l2_subdev *sd, | |||
722 | const struct v4l2_mbus_config *cfg) | 722 | const struct v4l2_mbus_config *cfg) |
723 | { | 723 | { |
724 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 724 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
725 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 725 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
726 | 726 | ||
727 | if (soc_camera_apply_board_flags(icl, cfg) & | 727 | if (soc_camera_apply_board_flags(ssdd, cfg) & |
728 | V4L2_MBUS_PCLK_SAMPLE_FALLING) | 728 | V4L2_MBUS_PCLK_SAMPLE_FALLING) |
729 | return reg_clear(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000); | 729 | return reg_clear(client, MT9T031_PIXEL_CLOCK_CONTROL, 0x8000); |
730 | else | 730 | else |
@@ -758,11 +758,11 @@ static int mt9t031_probe(struct i2c_client *client, | |||
758 | const struct i2c_device_id *did) | 758 | const struct i2c_device_id *did) |
759 | { | 759 | { |
760 | struct mt9t031 *mt9t031; | 760 | struct mt9t031 *mt9t031; |
761 | struct soc_camera_link *icl = soc_camera_i2c_to_link(client); | 761 | struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client); |
762 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | 762 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
763 | int ret; | 763 | int ret; |
764 | 764 | ||
765 | if (!icl) { | 765 | if (!ssdd) { |
766 | dev_err(&client->dev, "MT9T031 driver needs platform data\n"); | 766 | dev_err(&client->dev, "MT9T031 driver needs platform data\n"); |
767 | return -EINVAL; | 767 | return -EINVAL; |
768 | } | 768 | } |
@@ -773,7 +773,7 @@ static int mt9t031_probe(struct i2c_client *client, | |||
773 | return -EIO; | 773 | return -EIO; |
774 | } | 774 | } |
775 | 775 | ||
776 | mt9t031 = kzalloc(sizeof(struct mt9t031), GFP_KERNEL); | 776 | mt9t031 = devm_kzalloc(&client->dev, sizeof(struct mt9t031), GFP_KERNEL); |
777 | if (!mt9t031) | 777 | if (!mt9t031) |
778 | return -ENOMEM; | 778 | return -ENOMEM; |
779 | 779 | ||
@@ -797,12 +797,9 @@ static int mt9t031_probe(struct i2c_client *client, | |||
797 | V4L2_CID_EXPOSURE, 1, 255, 1, 255); | 797 | V4L2_CID_EXPOSURE, 1, 255, 1, 255); |
798 | 798 | ||
799 | mt9t031->subdev.ctrl_handler = &mt9t031->hdl; | 799 | mt9t031->subdev.ctrl_handler = &mt9t031->hdl; |
800 | if (mt9t031->hdl.error) { | 800 | if (mt9t031->hdl.error) |
801 | int err = mt9t031->hdl.error; | 801 | return mt9t031->hdl.error; |
802 | 802 | ||
803 | kfree(mt9t031); | ||
804 | return err; | ||
805 | } | ||
806 | v4l2_ctrl_auto_cluster(2, &mt9t031->autoexposure, | 803 | v4l2_ctrl_auto_cluster(2, &mt9t031->autoexposure, |
807 | V4L2_EXPOSURE_MANUAL, true); | 804 | V4L2_EXPOSURE_MANUAL, true); |
808 | 805 | ||
@@ -816,10 +813,8 @@ static int mt9t031_probe(struct i2c_client *client, | |||
816 | mt9t031->yskip = 1; | 813 | mt9t031->yskip = 1; |
817 | 814 | ||
818 | ret = mt9t031_video_probe(client); | 815 | ret = mt9t031_video_probe(client); |
819 | if (ret) { | 816 | if (ret) |
820 | v4l2_ctrl_handler_free(&mt9t031->hdl); | 817 | v4l2_ctrl_handler_free(&mt9t031->hdl); |
821 | kfree(mt9t031); | ||
822 | } | ||
823 | 818 | ||
824 | return ret; | 819 | return ret; |
825 | } | 820 | } |
@@ -830,7 +825,6 @@ static int mt9t031_remove(struct i2c_client *client) | |||
830 | 825 | ||
831 | v4l2_device_unregister_subdev(&mt9t031->subdev); | 826 | v4l2_device_unregister_subdev(&mt9t031->subdev); |
832 | v4l2_ctrl_handler_free(&mt9t031->hdl); | 827 | v4l2_ctrl_handler_free(&mt9t031->hdl); |
833 | kfree(mt9t031); | ||
834 | 828 | ||
835 | return 0; | 829 | return 0; |
836 | } | 830 | } |