media: i2c: camera driver fixed pm get error

There is a case, the app may call s_ctrl before device power on,
pm_runtime_get will increment usage counter and call Sensor_runtime_resume,
but when the s_ctrl function judges that the return value of pm_runtime_get
is less than or equal to 0, it returns directly, causing pm_runtime_put
not to be executed. so device can't be suspended.

pm_runtime_get_if_in_use increment the device's counter when runtime PM status
is RPM_ACTIVE and the runtime PM usage counter is nonzero.

so used pm_runtime_get_if_in_use can avoid usage counter error.

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: I4e61cdefafd82083f2628f67181a6bb2eee50507
This commit is contained in:
Zefa Chen
2020-11-21 18:18:06 +08:00
committed by Tao Huang
parent 1c01cb8832
commit 7567930cd2
49 changed files with 51 additions and 64 deletions

View File

@@ -1415,7 +1415,7 @@ static int ar0230_set_ctrl(struct v4l2_ctrl *ctrl)
struct i2c_client *client = ar0230->client;
int ret = 0;
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -967,7 +967,7 @@ static int gc0403_set_ctrl(struct v4l2_ctrl *ctrl)
int analog_gain = 0;
int i = 0;
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -536,7 +536,7 @@ static int gc2053_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -547,7 +547,7 @@ static int gc2093_set_ctrl(struct v4l2_ctrl *ctrl)
gc2093->exposure->default_value);
break;
}
if (pm_runtime_get(gc2093->dev) <= 0)
if (!pm_runtime_get_if_in_use(gc2093->dev))
return 0;
switch (ctrl->id) {

View File

@@ -883,7 +883,7 @@ static int gc2355_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1207,7 +1207,7 @@ static int gc2375h_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -962,7 +962,7 @@ static int gc2385_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -2146,7 +2146,7 @@ static int gc4c33_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1065,7 +1065,7 @@ static int gc5024_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1622,7 +1622,7 @@ static int gc5025_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1150,7 +1150,7 @@ static int gc5035_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1899,7 +1899,7 @@ static int gc8034_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1510,7 +1510,7 @@ static int imx258_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1665,7 +1665,7 @@ static int imx307_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1246,7 +1246,7 @@ static int imx317_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -778,7 +778,7 @@ static int imx323_set_ctrl(struct v4l2_ctrl *ctrl)
struct i2c_client *client = imx323->client;
int ret = 0;
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1634,7 +1634,7 @@ static int imx327_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1515,7 +1515,7 @@ static int imx334_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1717,7 +1717,7 @@ static int imx335_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1828,7 +1828,7 @@ static int imx347_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -2609,7 +2609,7 @@ static int imx378_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1962,7 +1962,7 @@ static int imx415_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1255,7 +1255,7 @@ static int jx_f37_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -959,7 +959,7 @@ static int jx_h65_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1972,7 +1972,7 @@ static int os04a10_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1591,7 +1591,7 @@ static int ov02k10_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1304,7 +1304,7 @@ static int ov13850_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -972,7 +972,7 @@ static int ov2680_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -691,7 +691,8 @@ static int ov2685_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
pm_runtime_get_sync(&client->dev);
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
ov2685_set_exposure(ov2685, ctrl->val);

View File

@@ -8657,7 +8657,7 @@ static int ov2718_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -898,7 +898,7 @@ static int ov2735_set_ctrl(struct v4l2_ctrl *ctrl)
ov2735->exposure->default_value);
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
ret = ov2735_write_reg(client, PAGE_SELECT_REG, PAGE_ONE);

View File

@@ -1275,7 +1275,7 @@ static int OV4686_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1297,7 +1297,7 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1148,7 +1148,7 @@ static int ov5648_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1480,7 +1480,7 @@ static int ov5670_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1213,7 +1213,7 @@ static int ov5695_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -889,7 +889,7 @@ static int ov7251_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1006,7 +1006,7 @@ static int ov7750_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -2351,7 +2351,7 @@ static int ov8858_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -874,7 +874,7 @@ static int ov9281_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -993,7 +993,7 @@ static int ov9750_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -987,7 +987,7 @@ static int sc031gs_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -907,7 +907,7 @@ static int sc132gs_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1178,8 +1178,6 @@ static long sc200ai_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg)
case PREISP_CMD_SET_HDRAE_EXP:
sc200ai_set_hdrae(sc200ai, arg);
break;
case RKMODULE_GET_NR_SWITCH_THRESHOLD:
break;
case RKMODULE_SET_QUICK_STREAM:
stream = *((u32 *)arg);
@@ -1272,18 +1270,6 @@ static long sc200ai_compat_ioctl32(struct v4l2_subdev *sd,
ret = sc200ai_ioctl(sd, cmd, hdrae);
kfree(hdrae);
break;
case RKMODULE_GET_NR_SWITCH_THRESHOLD:
nr_switch = kzalloc(sizeof(*nr_switch), GFP_KERNEL);
if (!nr_switch) {
ret = -ENOMEM;
return ret;
}
ret = sc200ai_ioctl(sd, cmd, nr_switch);
if (!ret)
ret = copy_to_user(up, nr_switch, sizeof(*nr_switch));
kfree(nr_switch);
break;
case RKMODULE_SET_QUICK_STREAM:
ret = copy_from_user(&stream, up, sizeof(u32));
if (!ret)
@@ -1606,7 +1592,7 @@ static int sc200ai_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -376,7 +376,7 @@ static int sc210iot_set_ctrl(struct v4l2_ctrl *ctrl)
sc210iot->exposure->default_value);
break;
}
if (pm_runtime_get(sc210iot->dev) <= 0)
if (!pm_runtime_get_if_in_use(sc210iot->dev))
return 0;
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:

View File

@@ -863,7 +863,7 @@ static long sc2232_compat_ioctl32(struct v4l2_subdev *sd,
case RKMODULE_SET_QUICK_STREAM:
ret = copy_from_user(&stream, up, sizeof(u32));
if (!ret)
ret = sc2310_ioctl(sd, cmd, &stream);
ret = sc2232_ioctl(sd, cmd, &stream);
break;
default:
ret = -ENOIOCTLCMD;
@@ -1166,7 +1166,7 @@ static int sc2232_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -933,7 +933,7 @@ static int sc2239_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -1543,7 +1543,7 @@ static int sc2310_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {

View File

@@ -2058,7 +2058,7 @@ static int sc4238_set_ctrl(struct v4l2_ctrl *ctrl)
break;
}
if (pm_runtime_get(&client->dev) <= 0)
if (!pm_runtime_get_if_in_use(&client->dev))
return 0;
switch (ctrl->id) {