media: ccs: Switch to guard and scoped_guard
Subsystems (2)
Sakari Ailus
maintainerPATCH 1/1 media: ccs: Switch to guard and scoped_guard
Replace the use of mutex_{,un}lock() by guard() and scoped_guard() where it makes sense (i.e. everywhere).
Signed-off-by Sakari Ailus <[email protected]>
--- drivers/media/i2c/ccs/ccs-core.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +6 -13
@@ -2006,9 +2006,8 @@ static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags) } } -mutex_lock (&sensor->mutex); - rval =ccs_pm_get_init (sensor); -mutex_unlock (&sensor->mutex); +scoped_guard (mutex, &sensor->mutex) + rval = ccs_pm_get_init(sensor);if (rval)return rval;
@@ -3045,7 +3044,7 @@ static int ccs_init_state(struct v4l2_subdev *sd,v4l2_subdev_state_get_crop (sd_state, pad);bool is_active = !sd->active_state || sd->active_state == sd_state; -mutex_lock (&sensor->mutex); +guard (mutex)(&sensor->mutex);ccs_get_native_size (ssd, crop);
@@ -3054,11 +3053,8 @@ static int ccs_init_state(struct v4l2_subdev *sd, fmt->code = sensor->internal_csi_format->code; fmt->field =V4L2_FIELD_NONE ; -if (ssd == sensor->pixel_array) { -mutex_unlock (&sensor->mutex); - +if (ssd == sensor->pixel_array)return 0 ; - } fmt =v4l2_subdev_state_get_format (sd_state,CCS_PAD_SRC ); fmt->code = ssd == sensor->src ?
@@ -3067,8 +3063,6 @@ static int ccs_init_state(struct v4l2_subdev *sd,ccs_propagate (sd, sd_state, is_active,V4L2_SEL_TGT_CROP ); -mutex_unlock (&sensor->mutex); -return 0 ; }
@@ -3553,9 +3547,8 @@ static int ccs_probe(struct i2c_client *client) goto out_cleanup; } -mutex_lock (&sensor->mutex); - rval =ccs_pll_blanking_update (sensor); -mutex_unlock (&sensor->mutex); +scoped_guard (mutex, &sensor->mutex) + rval = ccs_pll_blanking_update(sensor);if (rval) {dev_err (&client->dev,"update mode failed\n" ); goto out_cleanup;
Signature · 1 line
2.47.3
Quoted 5 lines · Sakari Ailus
Replace the use of mutex_{,un}lock() by
guard()andscoped_guard()where it makes sense (i.e. everywhere).Signed-off-by Sakari Ailus <[email protected]>---
Reviewed-by Frank Li <[email protected]>
Quoted 65 lines
drivers/media/i2c/ccs/ccs-core.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)drivers/media/i2c/ccs/ccs-core.c +6
-14@@ -2006,9 +2006,8 @@ static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags) } } -mutex_lock (&sensor->mutex); - rval =ccs_pm_get_init (sensor); -mutex_unlock (&sensor->mutex); +scoped_guard (mutex, &sensor->mutex) + rval = ccs_pm_get_init(sensor);if (rval)return rval;@@ -3045,7 +3044,7 @@ static int ccs_init_state(struct v4l2_subdev *sd,v4l2_subdev_state_get_crop (sd_state, pad);bool is_active = !sd->active_state || sd->active_state == sd_state; -mutex_lock (&sensor->mutex); +guard (mutex)(&sensor->mutex);ccs_get_native_size (ssd, crop);@@ -3054,11 +3053,8 @@ static int ccs_init_state(struct v4l2_subdev *sd, fmt->code = sensor->internal_csi_format->code; fmt->field =V4L2_FIELD_NONE ; -if (ssd == sensor->pixel_array) { -mutex_unlock (&sensor->mutex); - +if (ssd == sensor->pixel_array)return 0 ; - } fmt =v4l2_subdev_state_get_format (sd_state,CCS_PAD_SRC ); fmt->code = ssd == sensor->src ?@@ -3067,8 +3063,6 @@ static int ccs_init_state(struct v4l2_subdev *sd,ccs_propagate (sd, sd_state, is_active,V4L2_SEL_TGT_CROP ); -mutex_unlock (&sensor->mutex); -return 0 ; }@@ -3553,9 +3547,8 @@ static int ccs_probe(struct i2c_client *client) goto out_cleanup; } -mutex_lock (&sensor->mutex); - rval =ccs_pll_blanking_update (sensor); -mutex_unlock (&sensor->mutex); +scoped_guard (mutex, &sensor->mutex) + rval = ccs_pll_blanking_update(sensor);if (rval) {dev_err (&client->dev,"update mode failed\n" ); goto out_cleanup; --2.47.3