* [PATCH v2 0/3] media: v4l: async: add helper API v4l2_async_pad_init_and_register_subdev()
@ 2026-02-26 22:55 Frank Li
2026-02-26 22:55 ` [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() Frank Li
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Frank Li @ 2026-02-26 22:55 UTC (permalink / raw)
To: Sakari Ailus, Mauro Carvalho Chehab, Michael Riesch,
Maxime Ripard
Cc: linux-media, linux-kernel, imx, Frank Li
Add the helper API v4l2_async_pad_init_and_register_subdev(), which
combines media_entity_pads_init(), v4l2_subdev_init_finalize(), and
v4l2_async_register_subdev() into a single call.
Reduce code duplication and simplify error handling in drivers.
Only change dwc and cdns. If agree add API, more driver can be simplified.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Changes in v2:
- Change API name to media_async_register_subdev()
- pass down __v4l2_async_register_subdev() as argument to extend more
support in future.
- Link to v1: https://lore.kernel.org/r/20260210-v4l2_init_register-v1-0-8fe43f7d349f@nxp.com
---
Frank Li (3):
media: v4l: async: add helper API media_async_register_subdev()
media: synopsys: Use media_async_register_subdev() to simplify code
media: cadence: cdns-csi2rx: Use media_async_register_subdev() to simplify code
drivers/media/platform/cadence/cdns-csi2rx.c | 17 +++---------
drivers/media/platform/synopsys/dw-mipi-csi2rx.c | 13 +---------
drivers/media/v4l2-core/v4l2-async.c | 33 ++++++++++++++++++++++++
include/media/v4l2-async.h | 22 ++++++++++++++++
4 files changed, 59 insertions(+), 26 deletions(-)
---
base-commit: bc0bfce7d0f8204e0bbadcee72e87ad9ec105c73
change-id: 20260210-v4l2_init_register-0e6d0adcfa21
Best regards,
--
Frank Li <Frank.Li@nxp.com>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() 2026-02-26 22:55 [PATCH v2 0/3] media: v4l: async: add helper API v4l2_async_pad_init_and_register_subdev() Frank Li @ 2026-02-26 22:55 ` Frank Li 2026-03-02 13:21 ` Sakari Ailus 2026-02-26 22:55 ` [PATCH v2 2/3] media: synopsys: Use media_async_register_subdev() to simplify code Frank Li 2026-02-26 22:55 ` [PATCH v2 3/3] media: cadence: cdns-csi2rx: " Frank Li 2 siblings, 1 reply; 7+ messages in thread From: Frank Li @ 2026-02-26 22:55 UTC (permalink / raw) To: Sakari Ailus, Mauro Carvalho Chehab, Michael Riesch, Maxime Ripard Cc: linux-media, linux-kernel, imx, Frank Li Add the helper API media_async_register_subdev(), which combines media_entity_pads_init(), v4l2_subdev_init_finalize(), and v4l2_async_register_subdev() into a single call. Reduce code duplication and simplify error handling in drivers. Signed-off-by: Frank Li <Frank.Li@nxp.com> --- drivers/media/v4l2-core/v4l2-async.c | 33 +++++++++++++++++++++++++++++++++ include/media/v4l2-async.h | 22 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 1c08bba9ecb91f46b7479da613d6c1688d4b0b5c..e07173f566fbd8fa332b5e58be288e806b4c0482 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -19,6 +19,7 @@ #include <linux/slab.h> #include <linux/types.h> +#include <media/media-entity.h> #include <media/v4l2-async.h> #include <media/v4l2-device.h> #include <media/v4l2-fwnode.h> @@ -881,6 +882,38 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module) } EXPORT_SYMBOL(__v4l2_async_register_subdev); +int __media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, + struct media_pad *pads, + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), + struct module *module) +{ + int ret; + + if (!register_subdev) + return -EINVAL; + + ret = media_entity_pads_init(&sd->entity, num_pads, pads); + if (ret) + return ret; + + ret = v4l2_subdev_init_finalize(sd); + if (ret) + goto err_entity_cleanup; + + ret = register_subdev(sd, module); + if (ret) + goto err_subdev_cleanup; + + return 0; + +err_subdev_cleanup: + v4l2_subdev_cleanup(sd); +err_entity_cleanup: + media_entity_cleanup(&sd->entity); + return ret; +} +EXPORT_SYMBOL(__media_pad_init_and_register_subdev); + void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) { struct v4l2_async_connection *asc, *asc_tmp; diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index f26c323e9c963065fd7c19d6d9835df1194bc069..220a302a626732e15452f3efb19b03bdc51e64d5 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -336,6 +336,28 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module); int __must_check v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd); +struct media_pad; + +int __must_check +__media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, + struct media_pad *pads, + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), + struct module *module); + +/** + * media_async_register_subdev - Initialize the entity pads and + * registers a sub-device to the + * asynchronous subdevice framework + * @sd: pointer to &struct v4l2_subdev + * @num_pads: total number of sink and source pads + * @pads: Array of @num_pads pads. + * + * Returns an error on failure, 0 on success. + */ +#define media_async_register_subdev(sd, num_pads, pads) \ + __media_pad_init_and_register_subdev(sd, num_pads, pads, \ + __v4l2_async_register_subdev, \ + THIS_MODULE) /** * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous * subdevice framework -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() 2026-02-26 22:55 ` [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() Frank Li @ 2026-03-02 13:21 ` Sakari Ailus 2026-03-02 15:43 ` Frank Li 0 siblings, 1 reply; 7+ messages in thread From: Sakari Ailus @ 2026-03-02 13:21 UTC (permalink / raw) To: Frank Li Cc: Mauro Carvalho Chehab, Michael Riesch, Maxime Ripard, linux-media, linux-kernel, imx Hi Frank, Thanks for the set. On Thu, Feb 26, 2026 at 05:55:26PM -0500, Frank Li wrote: > Add the helper API media_async_register_subdev(), which > combines media_entity_pads_init(), v4l2_subdev_init_finalize(), and > v4l2_async_register_subdev() into a single call. > > Reduce code duplication and simplify error handling in drivers. I appreciate your efforts to try to simplify registering a sensor sub-device, but I'm not sure this gets far enough to make a notable difference: the new function calls two functions typically needed and requires the driver to implement a new one for registering a sub-device. > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > --- > drivers/media/v4l2-core/v4l2-async.c | 33 +++++++++++++++++++++++++++++++++ > include/media/v4l2-async.h | 22 ++++++++++++++++++++++ > 2 files changed, 55 insertions(+) > > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c > index 1c08bba9ecb91f46b7479da613d6c1688d4b0b5c..e07173f566fbd8fa332b5e58be288e806b4c0482 100644 > --- a/drivers/media/v4l2-core/v4l2-async.c > +++ b/drivers/media/v4l2-core/v4l2-async.c > @@ -19,6 +19,7 @@ > #include <linux/slab.h> > #include <linux/types.h> > > +#include <media/media-entity.h> > #include <media/v4l2-async.h> > #include <media/v4l2-device.h> > #include <media/v4l2-fwnode.h> > @@ -881,6 +882,38 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module) > } > EXPORT_SYMBOL(__v4l2_async_register_subdev); > > +int __media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, > + struct media_pad *pads, > + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), > + struct module *module) > +{ > + int ret; > + > + if (!register_subdev) > + return -EINVAL; > + > + ret = media_entity_pads_init(&sd->entity, num_pads, pads); > + if (ret) > + return ret; > + > + ret = v4l2_subdev_init_finalize(sd); > + if (ret) > + goto err_entity_cleanup; > + > + ret = register_subdev(sd, module); > + if (ret) > + goto err_subdev_cleanup; > + > + return 0; > + > +err_subdev_cleanup: > + v4l2_subdev_cleanup(sd); > +err_entity_cleanup: > + media_entity_cleanup(&sd->entity); > + return ret; > +} > +EXPORT_SYMBOL(__media_pad_init_and_register_subdev); > + > void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) > { > struct v4l2_async_connection *asc, *asc_tmp; > diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h > index f26c323e9c963065fd7c19d6d9835df1194bc069..220a302a626732e15452f3efb19b03bdc51e64d5 100644 > --- a/include/media/v4l2-async.h > +++ b/include/media/v4l2-async.h > @@ -336,6 +336,28 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module); > int __must_check > v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd); > > +struct media_pad; > + > +int __must_check > +__media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, > + struct media_pad *pads, > + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), > + struct module *module); > + > +/** > + * media_async_register_subdev - Initialize the entity pads and > + * registers a sub-device to the > + * asynchronous subdevice framework > + * @sd: pointer to &struct v4l2_subdev > + * @num_pads: total number of sink and source pads > + * @pads: Array of @num_pads pads. > + * > + * Returns an error on failure, 0 on success. > + */ > +#define media_async_register_subdev(sd, num_pads, pads) \ > + __media_pad_init_and_register_subdev(sd, num_pads, pads, \ > + __v4l2_async_register_subdev, \ > + THIS_MODULE) > /** > * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous > * subdevice framework > -- Kind regards, Sakari Ailus ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() 2026-03-02 13:21 ` Sakari Ailus @ 2026-03-02 15:43 ` Frank Li 2026-03-04 22:04 ` Frank Li 0 siblings, 1 reply; 7+ messages in thread From: Frank Li @ 2026-03-02 15:43 UTC (permalink / raw) To: Sakari Ailus Cc: Mauro Carvalho Chehab, Michael Riesch, Maxime Ripard, linux-media, linux-kernel, imx On Mon, Mar 02, 2026 at 03:21:39PM +0200, Sakari Ailus wrote: > Hi Frank, > > Thanks for the set. > > On Thu, Feb 26, 2026 at 05:55:26PM -0500, Frank Li wrote: > > Add the helper API media_async_register_subdev(), which > > combines media_entity_pads_init(), v4l2_subdev_init_finalize(), and > > v4l2_async_register_subdev() into a single call. > > > > Reduce code duplication and simplify error handling in drivers. > > I appreciate your efforts to try to simplify registering a sensor > sub-device, but I'm not sure this gets far enough to make a notable > difference: the new function calls two functions typically needed and > requires the driver to implement a new one for registering a sub-device. I not sure what's you means. Actually online one media_async_register_subdev() funciton need be called at driver's probe, which simple error handler much. You can refer patch 2/3. (reduce 12 line codes) In file, drivers/media/platform/synopsys/dw-mipi-csi2rx.c, about 600 line codes, only 20-30 line related hardware register access, others is overhead of subdev driver. Frank > > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > --- > > drivers/media/v4l2-core/v4l2-async.c | 33 +++++++++++++++++++++++++++++++++ > > include/media/v4l2-async.h | 22 ++++++++++++++++++++++ > > 2 files changed, 55 insertions(+) > > > > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c > > index 1c08bba9ecb91f46b7479da613d6c1688d4b0b5c..e07173f566fbd8fa332b5e58be288e806b4c0482 100644 > > --- a/drivers/media/v4l2-core/v4l2-async.c > > +++ b/drivers/media/v4l2-core/v4l2-async.c > > @@ -19,6 +19,7 @@ > > #include <linux/slab.h> > > #include <linux/types.h> > > > > +#include <media/media-entity.h> > > #include <media/v4l2-async.h> > > #include <media/v4l2-device.h> > > #include <media/v4l2-fwnode.h> > > @@ -881,6 +882,38 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module) > > } > > EXPORT_SYMBOL(__v4l2_async_register_subdev); > > > > +int __media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, > > + struct media_pad *pads, > > + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), > > + struct module *module) > > +{ > > + int ret; > > + > > + if (!register_subdev) > > + return -EINVAL; > > + > > + ret = media_entity_pads_init(&sd->entity, num_pads, pads); > > + if (ret) > > + return ret; > > + > > + ret = v4l2_subdev_init_finalize(sd); > > + if (ret) > > + goto err_entity_cleanup; > > + > > + ret = register_subdev(sd, module); > > + if (ret) > > + goto err_subdev_cleanup; > > + > > + return 0; > > + > > +err_subdev_cleanup: > > + v4l2_subdev_cleanup(sd); > > +err_entity_cleanup: > > + media_entity_cleanup(&sd->entity); > > + return ret; > > +} > > +EXPORT_SYMBOL(__media_pad_init_and_register_subdev); > > + > > void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) > > { > > struct v4l2_async_connection *asc, *asc_tmp; > > diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h > > index f26c323e9c963065fd7c19d6d9835df1194bc069..220a302a626732e15452f3efb19b03bdc51e64d5 100644 > > --- a/include/media/v4l2-async.h > > +++ b/include/media/v4l2-async.h > > @@ -336,6 +336,28 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module); > > int __must_check > > v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd); > > > > +struct media_pad; > > + > > +int __must_check > > +__media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, > > + struct media_pad *pads, > > + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), > > + struct module *module); > > + > > +/** > > + * media_async_register_subdev - Initialize the entity pads and > > + * registers a sub-device to the > > + * asynchronous subdevice framework > > + * @sd: pointer to &struct v4l2_subdev > > + * @num_pads: total number of sink and source pads > > + * @pads: Array of @num_pads pads. > > + * > > + * Returns an error on failure, 0 on success. > > + */ > > +#define media_async_register_subdev(sd, num_pads, pads) \ > > + __media_pad_init_and_register_subdev(sd, num_pads, pads, \ > > + __v4l2_async_register_subdev, \ > > + THIS_MODULE) > > /** > > * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous > > * subdevice framework > > > > -- > Kind regards, > > Sakari Ailus ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() 2026-03-02 15:43 ` Frank Li @ 2026-03-04 22:04 ` Frank Li 0 siblings, 0 replies; 7+ messages in thread From: Frank Li @ 2026-03-04 22:04 UTC (permalink / raw) To: Sakari Ailus Cc: Mauro Carvalho Chehab, Michael Riesch, Maxime Ripard, linux-media, linux-kernel, imx On Mon, Mar 02, 2026 at 10:43:26AM -0500, Frank Li wrote: > On Mon, Mar 02, 2026 at 03:21:39PM +0200, Sakari Ailus wrote: > > Hi Frank, > > > > Thanks for the set. > > > > On Thu, Feb 26, 2026 at 05:55:26PM -0500, Frank Li wrote: > > > Add the helper API media_async_register_subdev(), which > > > combines media_entity_pads_init(), v4l2_subdev_init_finalize(), and > > > v4l2_async_register_subdev() into a single call. > > > > > > Reduce code duplication and simplify error handling in drivers. > > > > I appreciate your efforts to try to simplify registering a sensor > > sub-device, but I'm not sure this gets far enough to make a notable > > difference: the new function calls two functions typically needed and > > requires the driver to implement a new one for registering a sub-device. > > I not sure what's you means. Actually online one > media_async_register_subdev() funciton need be called at driver's probe, > which simple error handler much. You can refer patch 2/3. (reduce 12 line > codes) > > In file, drivers/media/platform/synopsys/dw-mipi-csi2rx.c, about 600 line > codes, only 20-30 line related hardware register access, others is overhead > of subdev driver. Any feedback? Original I plan to create function similar to v4l2_async_register_subdev_sensor(), like v4l2_async_register_subdev_1to1() for only 1 sink and 1 source sub-devices and delete dw_mipi_csi2rx_register_notifier(), many driver duplicate similar logic. But slow review process and try start a simple refraction firstly. Frank > > Frank > > > > > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > > --- > > > drivers/media/v4l2-core/v4l2-async.c | 33 +++++++++++++++++++++++++++++++++ > > > include/media/v4l2-async.h | 22 ++++++++++++++++++++++ > > > 2 files changed, 55 insertions(+) > > > > > > diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c > > > index 1c08bba9ecb91f46b7479da613d6c1688d4b0b5c..e07173f566fbd8fa332b5e58be288e806b4c0482 100644 > > > --- a/drivers/media/v4l2-core/v4l2-async.c > > > +++ b/drivers/media/v4l2-core/v4l2-async.c > > > @@ -19,6 +19,7 @@ > > > #include <linux/slab.h> > > > #include <linux/types.h> > > > > > > +#include <media/media-entity.h> > > > #include <media/v4l2-async.h> > > > #include <media/v4l2-device.h> > > > #include <media/v4l2-fwnode.h> > > > @@ -881,6 +882,38 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module) > > > } > > > EXPORT_SYMBOL(__v4l2_async_register_subdev); > > > > > > +int __media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, > > > + struct media_pad *pads, > > > + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), > > > + struct module *module) > > > +{ > > > + int ret; > > > + > > > + if (!register_subdev) > > > + return -EINVAL; > > > + > > > + ret = media_entity_pads_init(&sd->entity, num_pads, pads); > > > + if (ret) > > > + return ret; > > > + > > > + ret = v4l2_subdev_init_finalize(sd); > > > + if (ret) > > > + goto err_entity_cleanup; > > > + > > > + ret = register_subdev(sd, module); > > > + if (ret) > > > + goto err_subdev_cleanup; > > > + > > > + return 0; > > > + > > > +err_subdev_cleanup: > > > + v4l2_subdev_cleanup(sd); > > > +err_entity_cleanup: > > > + media_entity_cleanup(&sd->entity); > > > + return ret; > > > +} > > > +EXPORT_SYMBOL(__media_pad_init_and_register_subdev); > > > + > > > void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) > > > { > > > struct v4l2_async_connection *asc, *asc_tmp; > > > diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h > > > index f26c323e9c963065fd7c19d6d9835df1194bc069..220a302a626732e15452f3efb19b03bdc51e64d5 100644 > > > --- a/include/media/v4l2-async.h > > > +++ b/include/media/v4l2-async.h > > > @@ -336,6 +336,28 @@ int __v4l2_async_register_subdev(struct v4l2_subdev *sd, struct module *module); > > > int __must_check > > > v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd); > > > > > > +struct media_pad; > > > + > > > +int __must_check > > > +__media_pad_init_and_register_subdev(struct v4l2_subdev *sd, u16 num_pads, > > > + struct media_pad *pads, > > > + int (*register_subdev)(struct v4l2_subdev *sd, struct module *module), > > > + struct module *module); > > > + > > > +/** > > > + * media_async_register_subdev - Initialize the entity pads and > > > + * registers a sub-device to the > > > + * asynchronous subdevice framework > > > + * @sd: pointer to &struct v4l2_subdev > > > + * @num_pads: total number of sink and source pads > > > + * @pads: Array of @num_pads pads. > > > + * > > > + * Returns an error on failure, 0 on success. > > > + */ > > > +#define media_async_register_subdev(sd, num_pads, pads) \ > > > + __media_pad_init_and_register_subdev(sd, num_pads, pads, \ > > > + __v4l2_async_register_subdev, \ > > > + THIS_MODULE) > > > /** > > > * v4l2_async_unregister_subdev - unregisters a sub-device to the asynchronous > > > * subdevice framework > > > > > > > -- > > Kind regards, > > > > Sakari Ailus ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] media: synopsys: Use media_async_register_subdev() to simplify code 2026-02-26 22:55 [PATCH v2 0/3] media: v4l: async: add helper API v4l2_async_pad_init_and_register_subdev() Frank Li 2026-02-26 22:55 ` [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() Frank Li @ 2026-02-26 22:55 ` Frank Li 2026-02-26 22:55 ` [PATCH v2 3/3] media: cadence: cdns-csi2rx: " Frank Li 2 siblings, 0 replies; 7+ messages in thread From: Frank Li @ 2026-02-26 22:55 UTC (permalink / raw) To: Sakari Ailus, Mauro Carvalho Chehab, Michael Riesch, Maxime Ripard Cc: linux-media, linux-kernel, imx, Frank Li Use media_async_register_subdev() to simplify the code. No functional changes. Signed-off-by: Frank Li <Frank.Li@nxp.com> --- drivers/media/platform/synopsys/dw-mipi-csi2rx.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/media/platform/synopsys/dw-mipi-csi2rx.c b/drivers/media/platform/synopsys/dw-mipi-csi2rx.c index 5dc55b59d6aeed4b6cb207c8e2ebe0fb3c462644..1898b3c82efae6a74192bf987876a87848cffb48 100644 --- a/drivers/media/platform/synopsys/dw-mipi-csi2rx.c +++ b/drivers/media/platform/synopsys/dw-mipi-csi2rx.c @@ -681,15 +681,8 @@ static int dw_mipi_csi2rx_register(struct dw_mipi_csi2rx_device *csi2) pads[DW_MIPI_CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; pads[DW_MIPI_CSI2RX_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE; - ret = media_entity_pads_init(&sd->entity, DW_MIPI_CSI2RX_PAD_MAX, pads); - if (ret) - goto err_notifier_unregister; - - ret = v4l2_subdev_init_finalize(sd); - if (ret) - goto err_entity_cleanup; - ret = v4l2_async_register_subdev(sd); + ret = media_async_register_subdev(sd, DW_MIPI_CSI2RX_PAD_MAX, pads); if (ret) { dev_err(sd->dev, "failed to register CSI-2 subdev\n"); goto err_subdev_cleanup; @@ -698,10 +691,6 @@ static int dw_mipi_csi2rx_register(struct dw_mipi_csi2rx_device *csi2) return 0; err_subdev_cleanup: - v4l2_subdev_cleanup(sd); -err_entity_cleanup: - media_entity_cleanup(&sd->entity); -err_notifier_unregister: v4l2_async_nf_unregister(&csi2->notifier); v4l2_async_nf_cleanup(&csi2->notifier); err: -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] media: cadence: cdns-csi2rx: Use media_async_register_subdev() to simplify code 2026-02-26 22:55 [PATCH v2 0/3] media: v4l: async: add helper API v4l2_async_pad_init_and_register_subdev() Frank Li 2026-02-26 22:55 ` [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() Frank Li 2026-02-26 22:55 ` [PATCH v2 2/3] media: synopsys: Use media_async_register_subdev() to simplify code Frank Li @ 2026-02-26 22:55 ` Frank Li 2 siblings, 0 replies; 7+ messages in thread From: Frank Li @ 2026-02-26 22:55 UTC (permalink / raw) To: Sakari Ailus, Mauro Carvalho Chehab, Michael Riesch, Maxime Ripard Cc: linux-media, linux-kernel, imx, Frank Li Use media_async_register_subdev() to simplify the code. No functional changes. Signed-off-by: Frank Li <Frank.Li@nxp.com> --- build test only --- drivers/media/platform/cadence/cdns-csi2rx.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 8c19f125da3e50f55a0ae280b05e7918ce115101..e0fec1027c9b74dd7dc46375f3aa4cc5fc951138 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -855,11 +855,6 @@ static int csi2rx_probe(struct platform_device *pdev) csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; csi2rx->subdev.entity.ops = &csi2rx_media_ops; - ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX, - csi2rx->pads); - if (ret) - goto err_cleanup; - csi2rx->error_irq = platform_get_irq_byname_optional(pdev, "error_irq"); if (csi2rx->error_irq < 0) { @@ -875,13 +870,10 @@ static int csi2rx_probe(struct platform_device *pdev) } } - ret = v4l2_subdev_init_finalize(&csi2rx->subdev); - if (ret) - goto err_cleanup; - - ret = v4l2_async_register_subdev(&csi2rx->subdev); + ret = media_async_register_subdev(&csi2rx->subdev, CSI2RX_PAD_MAX, + csi2rx->pads); if (ret < 0) - goto err_free_state; + goto err_cleanup; dev_info(&pdev->dev, "Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n", @@ -891,12 +883,9 @@ static int csi2rx_probe(struct platform_device *pdev) return 0; -err_free_state: - v4l2_subdev_cleanup(&csi2rx->subdev); err_cleanup: v4l2_async_nf_unregister(&csi2rx->notifier); v4l2_async_nf_cleanup(&csi2rx->notifier); - media_entity_cleanup(&csi2rx->subdev.entity); err_free_priv: kfree(csi2rx); return ret; -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-04 22:04 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-02-26 22:55 [PATCH v2 0/3] media: v4l: async: add helper API v4l2_async_pad_init_and_register_subdev() Frank Li 2026-02-26 22:55 ` [PATCH v2 1/3] media: v4l: async: add helper API media_async_register_subdev() Frank Li 2026-03-02 13:21 ` Sakari Ailus 2026-03-02 15:43 ` Frank Li 2026-03-04 22:04 ` Frank Li 2026-02-26 22:55 ` [PATCH v2 2/3] media: synopsys: Use media_async_register_subdev() to simplify code Frank Li 2026-02-26 22:55 ` [PATCH v2 3/3] media: cadence: cdns-csi2rx: " Frank Li
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox