Skip to contentSkip to conversation

media: i2c: cx25840: guard media_entity_cleanup() calls

PATCH In review Zixin Wang 3 participants 3 messages Nov 12 – Nov 25 Media (V4L/DVB)

lore
Share & tools
lore

Zixin Wang

author
#0 lore raw

PATCH 1/1 media: i2c: cx25840: guard media_entity_cleanup() calls

sd->entity only exists when CONFIG_MEDIA_CONTROLLER is enabled, but the two media_entity_cleanup() calls added by commit 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()") are unconditional. Building with CONFIG_MEDIA_CONTROLLER=n therefore fails:

drivers/media/i2c/cx25840/cx25840-core.c:3964:41: error:
'struct v4l2_subdev' has no member named 'entity'

Guard both calls with #if defined(CONFIG_MEDIA_CONTROLLER), matching the existing media entity setup in cx25840_probe().

The failure was reproduced with CONFIG_MEDIA_CONTROLLER=n. After the change the driver builds with both CONFIG_MEDIA_CONTROLLER=n and =y.

AI assistance: the fix and this changelog were drafted with the Qoder coding assistant; the sender reviewed the change and ran the builds.

Fixes 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")
---
 drivers/media/i2c/cx25840/cx25840-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/i2c/cx25840/cx25840-core.c +4 -0
index 7066b2252afd..91794ec59e2d 100644
@@ -3961,7 +3961,9 @@ static int cx25840_probe(struct i2c_client *client)
 		int err = state->hdl.error;
 
 		v4l2_ctrl_handler_free(&state->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
 		media_entity_cleanup(&sd->entity);
+#endif
 		return err;
 	}
 	if (!is_cx2583x(state))
@@ -3986,7 +3988,9 @@ static void cx25840_remove(struct i2c_client *client)
 	cx25840_ir_remove(sd);
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&state->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
 	media_entity_cleanup(&sd->entity);
+#endif
 }
 
 static const struct i2c_device_id cx25840_id[] = {
Signature · 1 line
2.56.1
#1 lore raw

Hi Zixin,

Quoted 7 lines · Zixin Wang

sd->entity only exists when CONFIG_MEDIA_CONTROLLER is enabled, but the two media_entity_cleanup() calls added by commit 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()") are unconditional. Building with CONFIG_MEDIA_CONTROLLER=n therefore fails:

drivers/media/i2c/cx25840/cx25840-core.c:3964:41: error:
'struct v4l2_subdev' has no member named 'entity'

How about instead turning media_entity_cleanup() into a macro that does nothing with the arguments if MC is disabled?

Quoted 9 lines

Guard both calls with #if defined(CONFIG_MEDIA_CONTROLLER), matching the existing media entity setup in cx25840_probe().

The failure was reproduced with CONFIG_MEDIA_CONTROLLER=n. After the change the driver builds with both CONFIG_MEDIA_CONTROLLER=n and =y.

AI assistance: the fix and this changelog were drafted with the Qoder coding assistant; the sender reviewed the change and ran the builds.

This goes below the '---' line.

Quoted 32 lines
Fixes 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")
---
 drivers/media/i2c/cx25840/cx25840-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/i2c/cx25840/cx25840-core.c +4 -0
index 7066b2252afd..91794ec59e2d 100644
@@ -3961,7 +3961,9 @@ static int cx25840_probe(struct i2c_client *client)
 		int err = state->hdl.error;
 
 		v4l2_ctrl_handler_free(&state->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
 		media_entity_cleanup(&sd->entity);
+#endif
 		return err;
 	}
 	if (!is_cx2583x(state))
@@ -3986,7 +3988,9 @@ static void cx25840_remove(struct i2c_client *client)
 	cx25840_ir_remove(sd);
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&state->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
 	media_entity_cleanup(&sd->entity);
+#endif
 }
 
 static const struct i2c_device_id cx25840_id[] = {
Signature · 3 lines
Regards,

Sakari Ailus
#2 lore raw
Quoted 8 lines · Sakari Ailus

Hi Zixin,

Quoted 5 lines · Zixin Wang

sd->entity only exists when CONFIG_MEDIA_CONTROLLER is enabled, but the two media_entity_cleanup() calls added by commit 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()") are unconditional. Building with CONFIG_MEDIA_CONTROLLER=n therefore fails:

Quoted 5 lines
Quoted 2 lines

drivers/media/i2c/cx25840/cx25840-core.c:3964:41: error:
'struct v4l2_subdev' has no member named 'entity'

How about instead turning media_entity_cleanup() into a macro that does nothing with the arguments if MC is disabled?

That would be inconsistent with the way the current include/media/media-entity.h header works.

I'll take this patch rather than changing the header.

Regards,

Hans

Quoted 46 lines
Quoted 10 lines

Guard both calls with #if defined(CONFIG_MEDIA_CONTROLLER), matching the existing media entity setup in cx25840_probe().

The failure was reproduced with CONFIG_MEDIA_CONTROLLER=n. After the change the driver builds with both CONFIG_MEDIA_CONTROLLER=n and =y.

AI assistance: the fix and this changelog were drafted with the Qoder coding assistant; the sender reviewed the change and ran the builds.

This goes below the '---' line.

Quoted 32 lines
Fixes 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")
---
 drivers/media/i2c/cx25840/cx25840-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/media/i2c/cx25840/cx25840-core.c +4 -0
index 7066b2252afd..91794ec59e2d 100644
@@ -3961,7 +3961,9 @@ static int cx25840_probe(struct i2c_client *client)
 		int err = state->hdl.error;
 
 		v4l2_ctrl_handler_free(&state->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
 		media_entity_cleanup(&sd->entity);
+#endif
 		return err;
 	}
 	if (!is_cx2583x(state))
@@ -3986,7 +3988,9 @@ static void cx25840_remove(struct i2c_client *client)
 	cx25840_ir_remove(sd);
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&state->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
 	media_entity_cleanup(&sd->entity);
+#endif
 }
 
 static const struct i2c_device_id cx25840_id[] = {