Commit 91cbe225 authored by Martin Kepplinger's avatar Martin Kepplinger
Browse files

hi846: fix mutex usage

parent 73d36596
......@@ -1030,7 +1030,7 @@ static int hi846_set_video_mode(struct hi846 *hi846, int fps)
static int hi846_start_streaming(struct hi846 *hi846)
{
struct i2c_client *client = v4l2_get_subdevdata(&hi846->sd);
int ret;
int ret = 0;
u8 val;
mutex_lock(&hi846->mutex);
......@@ -1041,31 +1041,33 @@ static int hi846_start_streaming(struct hi846 *hi846)
ret = hi846_write_reg_list(hi846, &hi846_init_regs_list_4lane);
if (ret) {
dev_err(&client->dev, "failed to set plls: %d\n", ret);
return ret;
goto out;
}
ret = hi846_write_reg_list(hi846, &hi846->cur_mode->reg_list_config);
if (ret) {
dev_err(&client->dev, "failed to set mode: %d\n", ret);
return ret;
goto out;
}
if (hi846->nr_lanes == 2) {
if (!&hi846->cur_mode->reg_list_2lane) {
dev_err(&client->dev, "2 lanes unsupported for this mode\n");
return -EINVAL;
ret = -EINVAL;
goto out;
}
ret = hi846_write_reg_list(hi846, &hi846->cur_mode->reg_list_2lane);
} else {
if (!&hi846->cur_mode->reg_list_4lane) {
dev_err(&client->dev, "4 lanes unsupported for this mode\n");
return -EINVAL;
ret = -EINVAL;
goto out;
}
ret = hi846_write_reg_list(hi846, &hi846->cur_mode->reg_list_4lane);
}
if (ret) {
dev_err(&client->dev, "failed to set mipi mode: %d\n", ret);
return ret;
goto out;
}
hi846_set_video_mode(hi846, hi846->cur_mode->fps);
......@@ -1077,34 +1079,35 @@ static int hi846_start_streaming(struct hi846 *hi846)
ret = hi846_write_reg_list(hi846, hi846->debug_regs);
if (ret) {
dev_err(&client->dev, "failed to write debug regs: %d\n", ret);
return ret;
goto out;
}
}
ret = __v4l2_ctrl_handler_setup(hi846->sd.ctrl_handler);
if (ret)
return ret;
goto out;
ret = hi846_write_reg(hi846, HI846_REG_MODE_SELECT,
HI846_MODE_STREAMING);
if (ret) {
dev_err(&client->dev, "failed to start stream");
return ret;
goto out;
}
hi846->streaming = 1;
mutex_unlock(&hi846->mutex);
dev_dbg(&client->dev, "%s: STARTED\n", __func__);
ret = hi846_read_reg(hi846, 0x0034, &val);
if (ret)
return ret;
goto out;
if (!(val & BIT(2)))
dev_info(&client->dev, "visible pixel width and height is 0\n");
return 0;
out:
mutex_unlock(&hi846->mutex);
return ret;
}
static void hi846_stop_streaming(struct hi846 *hi846)
......@@ -1138,8 +1141,7 @@ static int hi846_set_stream(struct v4l2_subdev *sd, int enable)
ret = pm_runtime_get_sync(&client->dev);
if (ret < 0) {
pm_runtime_put_noidle(&client->dev);
mutex_unlock(&hi846->mutex);
return ret;
goto out;
}
ret = hi846_start_streaming(hi846);
......@@ -1155,6 +1157,7 @@ static int hi846_set_stream(struct v4l2_subdev *sd, int enable)
pm_runtime_put_autosuspend(&client->dev);
}
out:
return ret;
}
......@@ -1177,12 +1180,9 @@ static int __maybe_unused hi846_suspend(struct device *dev)
dev_dbg(dev, "%s\n", __func__);
mutex_lock(&hi846->mutex);
if (hi846->streaming)
hi846_stop_streaming(hi846);
mutex_unlock(&hi846->mutex);
if (!IS_ERR(hi846->clock))
clk_disable_unprepare(hi846->clock);
......@@ -1207,7 +1207,6 @@ static int __maybe_unused hi846_resume(struct device *dev)
ret = hi846_regulator_enable(hi846);
if (ret) {
dev_err(dev, "enable regulator failed\n");
mutex_unlock(&hi846->mutex);
return ret;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment