Commit 6d84f928 authored by Martin Kepplinger's avatar Martin Kepplinger
Browse files

hi846: fix probe() error paths and minor cleanups

parent afc13a16
Pipeline #70754 passed with stage
in 69 minutes and 50 seconds
......@@ -19,7 +19,7 @@
#define HI846_MEDIA_BUS_FORMAT MEDIA_BUS_FMT_SGBRG10_1X10
#define HI846_RGB_DEPTH 10
/* Frame length lines / Vertical timings */
/* Frame length lines / vertical timings */
#define HI846_REG_FLL 0x0006
#define HI846_FLL_MAX 0xffff
......@@ -56,7 +56,7 @@
/*
* Long exposure time. Actually, exposure is a 20 bit value that
* includes the lower 4 bits of 0x0073 too. only 16 bit are used
* includes the lower 4 bits of 0x0073 too. Only 16 bits are used
* right now
*/
#define HI846_REG_EXPOSURE 0x0074
......@@ -225,14 +225,14 @@ struct hi846_mode {
u16 fps;
/* vertical timining size */
/* Vertical timining size */
u16 frame_len;
const struct hi846_reg_list reg_list_config;
const struct hi846_reg_list reg_list_2lane;
const struct hi846_reg_list reg_list_4lane;
/* position inside of the 3264x2448 pixel array */
/* Position inside of the 3264x2448 pixel array */
struct v4l2_rect crop;
};
......@@ -1344,7 +1344,7 @@ static int hi846_read_reg(struct hi846 *hi846, u16 reg, u8 *val)
msgs[1].addr = client->addr;
msgs[1].flags = I2C_M_RD;
msgs[1].len = 1;
msgs[1].buf = &data_buf[0];
msgs[1].buf = data_buf;
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
if (ret != ARRAY_SIZE(msgs)) {
......@@ -1379,17 +1379,18 @@ static int hi846_write_reg(struct hi846 *hi846, u16 reg, u8 val)
static void hi846_write_reg_16(struct hi846 *hi846, u16 reg, u16 val, int *err)
{
struct i2c_client *client = v4l2_get_subdevdata(&hi846->sd);
u8 buf[6];
u8 buf[4];
int ret;
if (*err < 0)
return;
put_unaligned_be16(reg, buf);
put_unaligned_be32(val << 8 * 2, buf + 2);
ret = i2c_master_send(client, buf, 4);
if (ret != 4) {
dev_err(&client->dev, "i2c_master_send != 4: %d\n", ret);
put_unaligned_be16(val, buf + 2);
ret = i2c_master_send(client, buf, sizeof(buf));
if (ret != sizeof(buf)) {
dev_err(&client->dev, "i2c_master_send != %zu: %d\n",
sizeof(buf), ret);
*err = -EIO;
}
}
......@@ -1738,12 +1739,9 @@ static int hi846_set_stream(struct v4l2_subdev *sd, int enable)
}
ret = hi846_start_streaming(hi846);
if (ret) {
enable = 0;
hi846_stop_streaming(hi846);
pm_runtime_put(&client->dev);
}
} else {
}
if (!enable || ret) {
hi846_stop_streaming(hi846);
pm_runtime_put(&client->dev);
}
......@@ -2263,18 +2261,18 @@ static int hi846_probe(struct i2c_client *client)
ret = hi846_power_on(hi846);
if (ret)
goto probe_error_media_entity_cleanup;
goto err_mutex;
ret = hi846_identify_module(hi846);
if (ret)
goto probe_error_power_off;
goto err_power_off;
hi846->cur_mode = &supported_modes[0];
ret = hi846_init_controls(hi846);
if (ret) {
dev_err(&client->dev, "failed to init controls: %d", ret);
return ret;
goto err_power_off;
}
hi846->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
......@@ -2284,14 +2282,14 @@ static int hi846_probe(struct i2c_client *client)
ret = media_entity_pads_init(&hi846->sd.entity, 1, &hi846->pad);
if (ret) {
dev_err(&client->dev, "failed to init entity pads: %d", ret);
goto probe_error_v4l2_ctrl_handler_free;
goto err_v4l2_ctrl_handler_free;
}
ret = v4l2_async_register_subdev_sensor(&hi846->sd);
if (ret < 0) {
dev_err(&client->dev, "failed to register V4L2 subdev: %d",
ret);
goto probe_error_power_off;
goto err_media_entity_cleanup;
}
pm_runtime_set_active(&client->dev);
......@@ -2310,14 +2308,16 @@ static int hi846_probe(struct i2c_client *client)
return 0;
probe_error_power_off:
hi846_power_off(hi846);
probe_error_media_entity_cleanup:
err_media_entity_cleanup:
media_entity_cleanup(&hi846->sd.entity);
probe_error_v4l2_ctrl_handler_free:
err_v4l2_ctrl_handler_free:
v4l2_ctrl_handler_free(hi846->sd.ctrl_handler);
err_power_off:
hi846_power_off(hi846);
err_mutex:
mutex_destroy(&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