From 827804d6d7608cb797e689eabe6e200fa9fb58e6 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Mon, 9 Oct 2023 14:54:57 +0300 Subject: [PATCH] media: ccs: Fix a (harmless) lockdep warning The v4l2_subdev_init_finalize() is a macro that creates an unique lockdep key and name. As the CCS driver initialises all three of its sub-devices using the same call site, this creates a lockdep warning. Address it. Fixes: d8bca3ed1d70 ("media: ccs: Use sub-device active state") Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil --- drivers/media/i2c/ccs/ccs-core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 14e89ae98294..12e6f0a26fc8 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -2955,7 +2955,9 @@ static void ccs_cleanup(struct ccs_sensor *sensor) static int ccs_init_subdev(struct ccs_sensor *sensor, struct ccs_subdev *ssd, const char *name, - unsigned short num_pads, u32 function) + unsigned short num_pads, u32 function, + const char *lock_name, + struct lock_class_key *lock_key) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); int rval; @@ -2993,7 +2995,7 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, return rval; } - rval = v4l2_subdev_init_finalize(&ssd->sd); + rval = __v4l2_subdev_init_finalize(&ssd->sd, lock_name, lock_key); if (rval) { media_entity_cleanup(&ssd->sd.entity); return rval; @@ -3206,6 +3208,8 @@ static int ccs_firmware_name(struct i2c_client *client, static int ccs_probe(struct i2c_client *client) { + static struct lock_class_key pixel_array_lock_key, binner_lock_key, + scaler_lock_key; const struct ccs_device *ccsdev = device_get_match_data(&client->dev); struct ccs_sensor *sensor; const struct firmware *fw; @@ -3489,15 +3493,18 @@ static int ccs_probe(struct i2c_client *client) } rval = ccs_init_subdev(sensor, sensor->scaler, " scaler", 2, - MEDIA_ENT_F_PROC_VIDEO_SCALER); + MEDIA_ENT_F_PROC_VIDEO_SCALER, + "ccs scaler mutex", &scaler_lock_key); if (rval) goto out_cleanup; rval = ccs_init_subdev(sensor, sensor->binner, " binner", 2, - MEDIA_ENT_F_PROC_VIDEO_SCALER); + MEDIA_ENT_F_PROC_VIDEO_SCALER, + "ccs binner mutex", &binner_lock_key); if (rval) goto out_cleanup; rval = ccs_init_subdev(sensor, sensor->pixel_array, " pixel_array", 1, - MEDIA_ENT_F_CAM_SENSOR); + MEDIA_ENT_F_CAM_SENSOR, "ccs pixel array mutex", + &pixel_array_lock_key); if (rval) goto out_cleanup;