diff options
| -rw-r--r-- | drivers/media/i2c/dw9714.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c index 78322102fa3f..57460dadddd1 100644 --- a/drivers/media/i2c/dw9714.c +++ b/drivers/media/i2c/dw9714.c | |||
| @@ -42,7 +42,6 @@ | |||
| 42 | 42 | ||
| 43 | /* dw9714 device structure */ | 43 | /* dw9714 device structure */ |
| 44 | struct dw9714_device { | 44 | struct dw9714_device { |
| 45 | struct i2c_client *client; | ||
| 46 | struct v4l2_ctrl_handler ctrls_vcm; | 45 | struct v4l2_ctrl_handler ctrls_vcm; |
| 47 | struct v4l2_subdev sd; | 46 | struct v4l2_subdev sd; |
| 48 | u16 current_val; | 47 | u16 current_val; |
| @@ -73,7 +72,7 @@ static int dw9714_i2c_write(struct i2c_client *client, u16 data) | |||
| 73 | 72 | ||
| 74 | static int dw9714_t_focus_vcm(struct dw9714_device *dw9714_dev, u16 val) | 73 | static int dw9714_t_focus_vcm(struct dw9714_device *dw9714_dev, u16 val) |
| 75 | { | 74 | { |
| 76 | struct i2c_client *client = dw9714_dev->client; | 75 | struct i2c_client *client = v4l2_get_subdevdata(&dw9714_dev->sd); |
| 77 | 76 | ||
| 78 | dw9714_dev->current_val = val; | 77 | dw9714_dev->current_val = val; |
| 79 | 78 | ||
| @@ -96,13 +95,11 @@ static const struct v4l2_ctrl_ops dw9714_vcm_ctrl_ops = { | |||
| 96 | 95 | ||
| 97 | static int dw9714_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) | 96 | static int dw9714_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) |
| 98 | { | 97 | { |
| 99 | struct dw9714_device *dw9714_dev = sd_to_dw9714_vcm(sd); | ||
| 100 | struct device *dev = &dw9714_dev->client->dev; | ||
| 101 | int rval; | 98 | int rval; |
| 102 | 99 | ||
| 103 | rval = pm_runtime_get_sync(dev); | 100 | rval = pm_runtime_get_sync(sd->dev); |
| 104 | if (rval < 0) { | 101 | if (rval < 0) { |
| 105 | pm_runtime_put_noidle(dev); | 102 | pm_runtime_put_noidle(sd->dev); |
| 106 | return rval; | 103 | return rval; |
| 107 | } | 104 | } |
| 108 | 105 | ||
| @@ -111,10 +108,7 @@ static int dw9714_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) | |||
| 111 | 108 | ||
| 112 | static int dw9714_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) | 109 | static int dw9714_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) |
| 113 | { | 110 | { |
| 114 | struct dw9714_device *dw9714_dev = sd_to_dw9714_vcm(sd); | 111 | pm_runtime_put(sd->dev); |
| 115 | struct device *dev = &dw9714_dev->client->dev; | ||
| 116 | |||
| 117 | pm_runtime_put(dev); | ||
| 118 | 112 | ||
| 119 | return 0; | 113 | return 0; |
| 120 | } | 114 | } |
| @@ -137,7 +131,6 @@ static int dw9714_init_controls(struct dw9714_device *dev_vcm) | |||
| 137 | { | 131 | { |
| 138 | struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; | 132 | struct v4l2_ctrl_handler *hdl = &dev_vcm->ctrls_vcm; |
| 139 | const struct v4l2_ctrl_ops *ops = &dw9714_vcm_ctrl_ops; | 133 | const struct v4l2_ctrl_ops *ops = &dw9714_vcm_ctrl_ops; |
| 140 | struct i2c_client *client = dev_vcm->client; | ||
| 141 | 134 | ||
| 142 | v4l2_ctrl_handler_init(hdl, 1); | 135 | v4l2_ctrl_handler_init(hdl, 1); |
| 143 | 136 | ||
| @@ -145,7 +138,7 @@ static int dw9714_init_controls(struct dw9714_device *dev_vcm) | |||
| 145 | 0, DW9714_MAX_FOCUS_POS, DW9714_FOCUS_STEPS, 0); | 138 | 0, DW9714_MAX_FOCUS_POS, DW9714_FOCUS_STEPS, 0); |
| 146 | 139 | ||
| 147 | if (hdl->error) | 140 | if (hdl->error) |
| 148 | dev_err(&client->dev, "%s fail error: 0x%x\n", | 141 | dev_err(dev_vcm->sd.dev, "%s fail error: 0x%x\n", |
| 149 | __func__, hdl->error); | 142 | __func__, hdl->error); |
| 150 | dev_vcm->sd.ctrl_handler = hdl; | 143 | dev_vcm->sd.ctrl_handler = hdl; |
| 151 | return hdl->error; | 144 | return hdl->error; |
| @@ -161,8 +154,6 @@ static int dw9714_probe(struct i2c_client *client) | |||
| 161 | if (dw9714_dev == NULL) | 154 | if (dw9714_dev == NULL) |
| 162 | return -ENOMEM; | 155 | return -ENOMEM; |
| 163 | 156 | ||
| 164 | dw9714_dev->client = client; | ||
| 165 | |||
| 166 | v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops); | 157 | v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops); |
| 167 | dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; | 158 | dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; |
| 168 | dw9714_dev->sd.internal_ops = &dw9714_int_ops; | 159 | dw9714_dev->sd.internal_ops = &dw9714_int_ops; |
