[media] soc-camera: switch I2C subdevice drivers to use v4l2-clk
[deliverable/linux.git] / drivers / media / i2c / soc_camera / ov9740.c
index 012bd62711242a03b061e8e387d648532ae8c6e4..ea76863dfdb44e22bb265d3ee6928a0611e60f63 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/v4l2-mediabus.h>
 
 #include <media/soc_camera.h>
-#include <media/v4l2-chip-ident.h>
+#include <media/v4l2-clk.h>
 #include <media/v4l2-ctrls.h>
 
 #define to_ov9740(sd)          container_of(sd, struct ov9740_priv, subdev)
@@ -196,8 +196,8 @@ struct ov9740_reg {
 struct ov9740_priv {
        struct v4l2_subdev              subdev;
        struct v4l2_ctrl_handler        hdl;
+       struct v4l2_clk                 *clk;
 
-       int                             ident;
        u16                             model;
        u8                              revision;
        u8                              manid;
@@ -772,18 +772,6 @@ static int ov9740_s_ctrl(struct v4l2_ctrl *ctrl)
        return 0;
 }
 
-/* Get chip identification */
-static int ov9740_g_chip_ident(struct v4l2_subdev *sd,
-                              struct v4l2_dbg_chip_ident *id)
-{
-       struct ov9740_priv *priv = to_ov9740(sd);
-
-       id->ident = priv->ident;
-       id->revision = priv->revision;
-
-       return 0;
-}
-
 static int ov9740_s_power(struct v4l2_subdev *sd, int on)
 {
        struct i2c_client *client = v4l2_get_subdevdata(sd);
@@ -792,7 +780,7 @@ static int ov9740_s_power(struct v4l2_subdev *sd, int on)
        int ret;
 
        if (on) {
-               ret = soc_camera_power_on(&client->dev, ssdd);
+               ret = soc_camera_power_on(&client->dev, ssdd, priv->clk);
                if (ret < 0)
                        return ret;
 
@@ -806,7 +794,7 @@ static int ov9740_s_power(struct v4l2_subdev *sd, int on)
                        priv->current_enable = true;
                }
 
-               soc_camera_power_off(&client->dev, ssdd);
+               soc_camera_power_off(&client->dev, ssdd, priv->clk);
        }
 
        return 0;
@@ -887,8 +875,6 @@ static int ov9740_video_probe(struct i2c_client *client)
                goto done;
        }
 
-       priv->ident = V4L2_IDENT_OV9740;
-
        dev_info(&client->dev, "ov9740 Model ID 0x%04x, Revision 0x%02x, "
                 "Manufacturer 0x%02x, SMIA Version 0x%02x\n",
                 priv->model, priv->revision, priv->manid, priv->smiaver);
@@ -927,7 +913,6 @@ static struct v4l2_subdev_video_ops ov9740_video_ops = {
 };
 
 static struct v4l2_subdev_core_ops ov9740_core_ops = {
-       .g_chip_ident           = ov9740_g_chip_ident,
        .s_power                = ov9740_s_power,
 #ifdef CONFIG_VIDEO_ADV_DEBUG
        .g_register             = ov9740_get_register,
@@ -975,9 +960,18 @@ static int ov9740_probe(struct i2c_client *client,
        if (priv->hdl.error)
                return priv->hdl.error;
 
+       priv->clk = v4l2_clk_get(&client->dev, "mclk");
+       if (IS_ERR(priv->clk)) {
+               ret = PTR_ERR(priv->clk);
+               goto eclkget;
+       }
+
        ret = ov9740_video_probe(client);
-       if (ret < 0)
+       if (ret < 0) {
+               v4l2_clk_put(priv->clk);
+eclkget:
                v4l2_ctrl_handler_free(&priv->hdl);
+       }
 
        return ret;
 }
@@ -986,6 +980,7 @@ static int ov9740_remove(struct i2c_client *client)
 {
        struct ov9740_priv *priv = i2c_get_clientdata(client);
 
+       v4l2_clk_put(priv->clk);
        v4l2_device_unregister_subdev(&priv->subdev);
        v4l2_ctrl_handler_free(&priv->hdl);
        return 0;
This page took 0.025577 seconds and 5 git commands to generate.