]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: ccs: Switch to guard and scoped_guard
authorSakari Ailus <sakari.ailus@linux.intel.com>
Fri, 16 Jan 2026 10:56:56 +0000 (12:56 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Fri, 16 Jan 2026 13:08:53 +0000 (14:08 +0100)
Replace the use of mutex_{,un}lock() by guard() and scoped_guard() where
it makes sense (i.e. everywhere).

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/i2c/ccs/ccs-core.c

index a08f0614909736aed62c6435b638a161ab7d6f48..81f81cb2c35413c357ba0a61fa413737fc9faaa2 100644 (file)
@@ -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;