diff mbox series

[v2,4/4] media: ccs: Fix a (harmless) lockdep warning

Message ID 20231009220906.221303-5-sakari.ailus@linux.intel.com
State Superseded
Headers show
Series V4L2 sub-device active state helper, CCS fixes | expand

Commit Message

Sakari Ailus Oct. 9, 2023, 10:09 p.m. UTC
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: 4b05b1baae3e ("media: ccs: Use sub-device active state")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/ccs/ccs-core.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 6589b0d84e06..2b3b712d60b5 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;
@@ -3208,6 +3210,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;
@@ -3491,15 +3495,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;