Many drivers has
v4l2_async_nf_unregister(¬ifier);
v4l2_async_nf_cleanup(¬ifier);
Introduce a helper function to call both functions in one line.
---
Julien Massot (2):
media: v4l: async: Add v4l2_async_nf_unregister_cleanup
media: convert all drivers to use v4l2_async_nf_unregister_cleanup
drivers/media/i2c/ds90ub913.c | 10 ++--------
drivers/media/i2c/ds90ub953.c | 10 ++--------
drivers/media/i2c/ds90ub960.c | 10 ++--------
drivers/media/i2c/max9286.c | 3 +--
drivers/media/i2c/st-mipid02.c | 6 ++----
drivers/media/i2c/tc358746.c | 3 +--
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 6 ++----
drivers/media/pci/intel/ipu6/ipu6-isys.c | 8 +-------
drivers/media/pci/intel/ivsc/mei_csi.c | 6 ++----
drivers/media/platform/atmel/atmel-isi.c | 3 +--
drivers/media/platform/cadence/cdns-csi2rx.c | 6 ++----
drivers/media/platform/intel/pxa_camera.c | 3 +--
drivers/media/platform/marvell/mcam-core.c | 6 ++----
drivers/media/platform/microchip/microchip-csi2dc.c | 3 +--
drivers/media/platform/microchip/microchip-isc-base.c | 6 ++----
drivers/media/platform/nxp/imx-mipi-csis.c | 6 ++----
drivers/media/platform/nxp/imx7-media-csi.c | 3 +--
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 3 +--
drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 6 ++----
drivers/media/platform/qcom/camss/camss.c | 3 +--
drivers/media/platform/renesas/rcar-csi2.c | 6 ++----
drivers/media/platform/renesas/rcar-isp.c | 6 ++----
drivers/media/platform/renesas/rcar-vin/rcar-core.c | 9 +++------
drivers/media/platform/renesas/rcar_drif.c | 3 +--
drivers/media/platform/renesas/renesas-ceu.c | 4 +---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c | 3 +--
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 6 ++----
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +--
drivers/media/platform/samsung/exynos4-is/media-dev.c | 3 +--
drivers/media/platform/st/stm32/stm32-dcmi.c | 3 +--
.../media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 3 +--
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c | 3 +--
.../media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 3 +--
.../platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 3 +--
.../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c | 3 +--
drivers/media/platform/ti/am437x/am437x-vpfe.c | 3 +--
drivers/media/platform/ti/cal/cal.c | 8 +-------
drivers/media/platform/ti/davinci/vpif_capture.c | 3 +--
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 10 ++--------
drivers/media/platform/ti/omap3isp/isp.c | 3 +--
drivers/media/platform/video-mux.c | 3 +--
drivers/media/platform/xilinx/xilinx-vipp.c | 3 +--
drivers/staging/media/deprecated/atmel/atmel-isc-base.c | 6 ++----
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c | 3 +--
drivers/staging/media/tegra-video/vi.c | 3 +--
include/media/v4l2-async.h | 17 +++++++++++++++++
46 files changed, 80 insertions(+), 153 deletions(-)
---
base-commit: 843a9f4a7a85988f2f3af98adf21797c2fd05ab1
change-id: 20240502-master-5deee133b4f5
Best regards,
--
Julien Massot <[email protected]>
Now that we have a function to unregister and cleanup a notifier,
use it!
This patch has been generated using the following Coccinelle script:
---------8<------------
@@
expression E1;
@@
- v4l2_async_nf_unregister(E1);
- v4l2_async_nf_cleanup(E1);
+ v4l2_async_nf_unregister_cleanup(E1);
---------8<------------
Manually removed helper functions doing the same
in various driver.
Suggested-by: Sakari Ailus <[email protected]>
Signed-off-by: Julien Massot <[email protected]>
---
drivers/media/i2c/ds90ub913.c | 10 ++--------
drivers/media/i2c/ds90ub953.c | 10 ++--------
drivers/media/i2c/ds90ub960.c | 10 ++--------
drivers/media/i2c/max9286.c | 3 +--
drivers/media/i2c/st-mipid02.c | 6 ++----
drivers/media/i2c/tc358746.c | 3 +--
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 6 ++----
drivers/media/pci/intel/ipu6/ipu6-isys.c | 8 +-------
drivers/media/pci/intel/ivsc/mei_csi.c | 6 ++----
drivers/media/platform/atmel/atmel-isi.c | 3 +--
drivers/media/platform/cadence/cdns-csi2rx.c | 6 ++----
drivers/media/platform/intel/pxa_camera.c | 3 +--
drivers/media/platform/marvell/mcam-core.c | 6 ++----
drivers/media/platform/microchip/microchip-csi2dc.c | 3 +--
drivers/media/platform/microchip/microchip-isc-base.c | 6 ++----
drivers/media/platform/nxp/imx-mipi-csis.c | 6 ++----
drivers/media/platform/nxp/imx7-media-csi.c | 3 +--
drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 3 +--
drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 6 ++----
drivers/media/platform/qcom/camss/camss.c | 3 +--
drivers/media/platform/renesas/rcar-csi2.c | 6 ++----
drivers/media/platform/renesas/rcar-isp.c | 6 ++----
drivers/media/platform/renesas/rcar-vin/rcar-core.c | 9 +++------
drivers/media/platform/renesas/rcar_drif.c | 3 +--
drivers/media/platform/renesas/renesas-ceu.c | 4 +---
drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c | 3 +--
drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 6 ++----
drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +--
drivers/media/platform/samsung/exynos4-is/media-dev.c | 3 +--
drivers/media/platform/st/stm32/stm32-dcmi.c | 3 +--
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 3 +--
drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c | 3 +--
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 3 +--
drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 3 +--
.../platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c | 3 +--
drivers/media/platform/ti/am437x/am437x-vpfe.c | 3 +--
drivers/media/platform/ti/cal/cal.c | 8 +-------
drivers/media/platform/ti/davinci/vpif_capture.c | 3 +--
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 10 ++--------
drivers/media/platform/ti/omap3isp/isp.c | 3 +--
drivers/media/platform/video-mux.c | 3 +--
drivers/media/platform/xilinx/xilinx-vipp.c | 3 +--
drivers/staging/media/deprecated/atmel/atmel-isc-base.c | 6 ++----
drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c | 3 +--
drivers/staging/media/tegra-video/vi.c | 3 +--
45 files changed, 63 insertions(+), 153 deletions(-)
diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c
index ca9bb29dab89..01afe34c0002 100644
--- a/drivers/media/i2c/ds90ub913.c
+++ b/drivers/media/i2c/ds90ub913.c
@@ -595,12 +595,6 @@ static int ub913_v4l2_notifier_register(struct ub913_data *priv)
return 0;
}
-static void ub913_v4l2_nf_unregister(struct ub913_data *priv)
-{
- v4l2_async_nf_unregister(&priv->notifier);
- v4l2_async_nf_cleanup(&priv->notifier);
-}
-
static int ub913_register_clkout(struct ub913_data *priv)
{
struct device *dev = &priv->client->dev;
@@ -779,7 +773,7 @@ static int ub913_subdev_init(struct ub913_data *priv)
return 0;
err_unreg_notif:
- ub913_v4l2_nf_unregister(priv);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
err_subdev_cleanup:
v4l2_subdev_cleanup(&priv->sd);
err_entity_cleanup:
@@ -791,7 +785,7 @@ static int ub913_subdev_init(struct ub913_data *priv)
static void ub913_subdev_uninit(struct ub913_data *priv)
{
v4l2_async_unregister_subdev(&priv->sd);
- ub913_v4l2_nf_unregister(priv);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
v4l2_subdev_cleanup(&priv->sd);
fwnode_handle_put(priv->sd.fwnode);
media_entity_cleanup(&priv->sd.entity);
diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c
index 16f88db14981..3c861dfdad49 100644
--- a/drivers/media/i2c/ds90ub953.c
+++ b/drivers/media/i2c/ds90ub953.c
@@ -811,12 +811,6 @@ static int ub953_v4l2_notifier_register(struct ub953_data *priv)
return 0;
}
-static void ub953_v4l2_notifier_unregister(struct ub953_data *priv)
-{
- v4l2_async_nf_unregister(&priv->notifier);
- v4l2_async_nf_cleanup(&priv->notifier);
-}
-
/*
* Probing
*/
@@ -1277,7 +1271,7 @@ static int ub953_subdev_init(struct ub953_data *priv)
return 0;
err_unreg_notif:
- ub953_v4l2_notifier_unregister(priv);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
err_free_state:
v4l2_subdev_cleanup(&priv->sd);
err_entity_cleanup:
@@ -1289,7 +1283,7 @@ static int ub953_subdev_init(struct ub953_data *priv)
static void ub953_subdev_uninit(struct ub953_data *priv)
{
v4l2_async_unregister_subdev(&priv->sd);
- ub953_v4l2_notifier_unregister(priv);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
v4l2_subdev_cleanup(&priv->sd);
fwnode_handle_put(priv->sd.fwnode);
media_entity_cleanup(&priv->sd.entity);
diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
index ffe5f25f8647..bdd9987d268b 100644
--- a/drivers/media/i2c/ds90ub960.c
+++ b/drivers/media/i2c/ds90ub960.c
@@ -3639,12 +3639,6 @@ static int ub960_v4l2_notifier_register(struct ub960_data *priv)
return 0;
}
-static void ub960_v4l2_notifier_unregister(struct ub960_data *priv)
-{
- v4l2_async_nf_unregister(&priv->notifier);
- v4l2_async_nf_cleanup(&priv->notifier);
-}
-
static int ub960_create_subdev(struct ub960_data *priv)
{
struct device *dev = &priv->client->dev;
@@ -3705,7 +3699,7 @@ static int ub960_create_subdev(struct ub960_data *priv)
return 0;
err_unreg_notif:
- ub960_v4l2_notifier_unregister(priv);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
err_subdev_cleanup:
v4l2_subdev_cleanup(&priv->sd);
err_entity_cleanup:
@@ -3718,7 +3712,7 @@ static int ub960_create_subdev(struct ub960_data *priv)
static void ub960_destroy_subdev(struct ub960_data *priv)
{
- ub960_v4l2_notifier_unregister(priv);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
v4l2_async_unregister_subdev(&priv->sd);
v4l2_subdev_cleanup(&priv->sd);
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index d685d445cf23..3731163ee13b 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -781,8 +781,7 @@ static void max9286_v4l2_notifier_unregister(struct max9286_priv *priv)
if (!priv->nsources)
return;
- v4l2_async_nf_unregister(&priv->notifier);
- v4l2_async_nf_cleanup(&priv->notifier);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
}
static int max9286_s_stream(struct v4l2_subdev *sd, int enable)
diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
index f250640729ca..2aa1bded70d9 100644
--- a/drivers/media/i2c/st-mipid02.c
+++ b/drivers/media/i2c/st-mipid02.c
@@ -909,8 +909,7 @@ static int mipid02_probe(struct i2c_client *client)
return 0;
unregister_notifier:
- v4l2_async_nf_unregister(&bridge->notifier);
- v4l2_async_nf_cleanup(&bridge->notifier);
+ v4l2_async_nf_unregister_cleanup(&bridge->notifier);
power_off:
mipid02_set_power_off(bridge);
entity_cleanup:
@@ -924,8 +923,7 @@ static void mipid02_remove(struct i2c_client *client)
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct mipid02_dev *bridge = to_mipid02_dev(sd);
- v4l2_async_nf_unregister(&bridge->notifier);
- v4l2_async_nf_cleanup(&bridge->notifier);
+ v4l2_async_nf_unregister_cleanup(&bridge->notifier);
v4l2_async_unregister_subdev(&bridge->sd);
mipid02_set_power_off(bridge);
media_entity_cleanup(&bridge->sd.entity);
diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c
index d676adc4401b..ca375b6ccf86 100644
--- a/drivers/media/i2c/tc358746.c
+++ b/drivers/media/i2c/tc358746.c
@@ -1607,8 +1607,7 @@ static void tc358746_remove(struct i2c_client *client)
v4l2_subdev_cleanup(sd);
v4l2_ctrl_handler_free(&tc358746->ctrl_hdl);
v4l2_fwnode_endpoint_free(&tc358746->csi_vep);
- v4l2_async_nf_unregister(&tc358746->notifier);
- v4l2_async_nf_cleanup(&tc358746->notifier);
+ v4l2_async_nf_unregister_cleanup(&tc358746->notifier);
v4l2_async_unregister_subdev(sd);
media_entity_cleanup(&sd->entity);
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
index 81ec8630453b..b110eb958a98 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
@@ -1770,8 +1770,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
return 0;
fail_clean_notifier:
- v4l2_async_nf_unregister(&cio2->notifier);
- v4l2_async_nf_cleanup(&cio2->notifier);
+ v4l2_async_nf_unregister_cleanup(&cio2->notifier);
cio2_queues_exit(cio2);
fail_v4l2_device_unregister:
v4l2_device_unregister(&cio2->v4l2_dev);
@@ -1790,8 +1789,7 @@ static void cio2_pci_remove(struct pci_dev *pci_dev)
struct cio2_device *cio2 = pci_get_drvdata(pci_dev);
media_device_unregister(&cio2->media_dev);
- v4l2_async_nf_unregister(&cio2->notifier);
- v4l2_async_nf_cleanup(&cio2->notifier);
+ v4l2_async_nf_unregister_cleanup(&cio2->notifier);
cio2_queues_exit(cio2);
cio2_fbpt_exit_dummy(cio2);
v4l2_device_unregister(&cio2->v4l2_dev);
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c
index 5992138c7290..1e76df39e010 100644
--- a/drivers/media/pci/intel/ipu6/ipu6-isys.c
+++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c
@@ -767,12 +767,6 @@ static int isys_notifier_init(struct ipu6_isys *isys)
return ret;
}
-static void isys_notifier_cleanup(struct ipu6_isys *isys)
-{
- v4l2_async_nf_unregister(&isys->notifier);
- v4l2_async_nf_cleanup(&isys->notifier);
-}
-
static int isys_register_devices(struct ipu6_isys *isys)
{
struct device *dev = &isys->adev->auxdev.dev;
@@ -942,7 +936,7 @@ static void isys_remove(struct auxiliary_device *auxdev)
fwmsg, fwmsg->dma_addr, 0);
isys_unregister_devices(isys);
- isys_notifier_cleanup(isys);
+ v4l2_async_nf_unregister_cleanup(&isys->notifier);
cpu_latency_qos_remove_request(&isys->pm_qos);
diff --git a/drivers/media/pci/intel/ivsc/mei_csi.c b/drivers/media/pci/intel/ivsc/mei_csi.c
index 89b582a221ab..ae9fe6f63544 100644
--- a/drivers/media/pci/intel/ivsc/mei_csi.c
+++ b/drivers/media/pci/intel/ivsc/mei_csi.c
@@ -752,8 +752,7 @@ static int mei_csi_probe(struct mei_cl_device *cldev,
err_ctrl_handler:
v4l2_ctrl_handler_free(&csi->ctrl_handler);
- v4l2_async_nf_unregister(&csi->notifier);
- v4l2_async_nf_cleanup(&csi->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi->notifier);
err_disable:
mei_cldev_disable(cldev);
@@ -768,8 +767,7 @@ static void mei_csi_remove(struct mei_cl_device *cldev)
{
struct mei_csi *csi = mei_cldev_get_drvdata(cldev);
- v4l2_async_nf_unregister(&csi->notifier);
- v4l2_async_nf_cleanup(&csi->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi->notifier);
v4l2_ctrl_handler_free(&csi->ctrl_handler);
v4l2_async_unregister_subdev(&csi->subdev);
v4l2_subdev_cleanup(&csi->subdev);
diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c
index c1108df72dd5..9753c5823b62 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -1327,8 +1327,7 @@ static void atmel_isi_remove(struct platform_device *pdev)
isi->p_fb_descriptors,
isi->fb_descriptors_phys);
pm_runtime_disable(&pdev->dev);
- v4l2_async_nf_unregister(&isi->notifier);
- v4l2_async_nf_cleanup(&isi->notifier);
+ v4l2_async_nf_unregister_cleanup(&isi->notifier);
v4l2_device_unregister(&isi->v4l2_dev);
}
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 6f7d27a48eff..8d9147edbb83 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -722,8 +722,7 @@ static int csi2rx_probe(struct platform_device *pdev)
err_free_state:
v4l2_subdev_cleanup(&csi2rx->subdev);
err_cleanup:
- v4l2_async_nf_unregister(&csi2rx->notifier);
- v4l2_async_nf_cleanup(&csi2rx->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi2rx->notifier);
media_entity_cleanup(&csi2rx->subdev.entity);
err_free_priv:
kfree(csi2rx);
@@ -734,8 +733,7 @@ static void csi2rx_remove(struct platform_device *pdev)
{
struct csi2rx_priv *csi2rx = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&csi2rx->notifier);
- v4l2_async_nf_cleanup(&csi2rx->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi2rx->notifier);
v4l2_async_unregister_subdev(&csi2rx->subdev);
v4l2_subdev_cleanup(&csi2rx->subdev);
media_entity_cleanup(&csi2rx->subdev.entity);
diff --git a/drivers/media/platform/intel/pxa_camera.c b/drivers/media/platform/intel/pxa_camera.c
index d904952bf00e..4e4150b4ee83 100644
--- a/drivers/media/platform/intel/pxa_camera.c
+++ b/drivers/media/platform/intel/pxa_camera.c
@@ -2433,8 +2433,7 @@ static void pxa_camera_remove(struct platform_device *pdev)
dma_release_channel(pcdev->dma_chans[1]);
dma_release_channel(pcdev->dma_chans[2]);
- v4l2_async_nf_unregister(&pcdev->notifier);
- v4l2_async_nf_cleanup(&pcdev->notifier);
+ v4l2_async_nf_unregister_cleanup(&pcdev->notifier);
v4l2_device_unregister(&pcdev->v4l2_dev);
diff --git a/drivers/media/platform/marvell/mcam-core.c b/drivers/media/platform/marvell/mcam-core.c
index 66688b4aece5..5f3296ec981a 100644
--- a/drivers/media/platform/marvell/mcam-core.c
+++ b/drivers/media/platform/marvell/mcam-core.c
@@ -1907,8 +1907,7 @@ int mccic_register(struct mcam_camera *cam)
return 0;
out:
- v4l2_async_nf_unregister(&cam->notifier);
- v4l2_async_nf_cleanup(&cam->notifier);
+ v4l2_async_nf_unregister_cleanup(&cam->notifier);
return ret;
}
EXPORT_SYMBOL_GPL(mccic_register);
@@ -1928,8 +1927,7 @@ void mccic_shutdown(struct mcam_camera *cam)
if (cam->buffer_mode == B_vmalloc)
mcam_free_dma_bufs(cam);
v4l2_ctrl_handler_free(&cam->ctrl_handler);
- v4l2_async_nf_unregister(&cam->notifier);
- v4l2_async_nf_cleanup(&cam->notifier);
+ v4l2_async_nf_unregister_cleanup(&cam->notifier);
}
EXPORT_SYMBOL_GPL(mccic_shutdown);
diff --git a/drivers/media/platform/microchip/microchip-csi2dc.c b/drivers/media/platform/microchip/microchip-csi2dc.c
index fee73260bb1e..8a1087e1415f 100644
--- a/drivers/media/platform/microchip/microchip-csi2dc.c
+++ b/drivers/media/platform/microchip/microchip-csi2dc.c
@@ -750,8 +750,7 @@ static void csi2dc_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
v4l2_async_unregister_subdev(&csi2dc->csi2dc_sd);
- v4l2_async_nf_unregister(&csi2dc->notifier);
- v4l2_async_nf_cleanup(&csi2dc->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi2dc->notifier);
media_entity_cleanup(&csi2dc->csi2dc_sd.entity);
}
diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c
index f3a5cbacadbe..ed7511b8ace7 100644
--- a/drivers/media/platform/microchip/microchip-isc-base.c
+++ b/drivers/media/platform/microchip/microchip-isc-base.c
@@ -1856,10 +1856,8 @@ void microchip_isc_subdev_cleanup(struct isc_device *isc)
{
struct isc_subdev_entity *subdev_entity;
- list_for_each_entry(subdev_entity, &isc->subdev_entities, list) {
- v4l2_async_nf_unregister(&subdev_entity->notifier);
- v4l2_async_nf_cleanup(&subdev_entity->notifier);
- }
+ list_for_each_entry(subdev_entity, &isc->subdev_entities, list)
+ v4l2_async_nf_unregister_cleanup(&subdev_entity->notifier);
INIT_LIST_HEAD(&isc->subdev_entities);
}
diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index f49b06978f14..fa02a4443b79 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -1513,8 +1513,7 @@ static int mipi_csis_probe(struct platform_device *pdev)
err_cleanup:
v4l2_subdev_cleanup(&csis->sd);
media_entity_cleanup(&csis->sd.entity);
- v4l2_async_nf_unregister(&csis->notifier);
- v4l2_async_nf_cleanup(&csis->notifier);
+ v4l2_async_nf_unregister_cleanup(&csis->notifier);
v4l2_async_unregister_subdev(&csis->sd);
return ret;
@@ -1526,8 +1525,7 @@ static void mipi_csis_remove(struct platform_device *pdev)
struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
mipi_csis_debugfs_exit(csis);
- v4l2_async_nf_unregister(&csis->notifier);
- v4l2_async_nf_cleanup(&csis->notifier);
+ v4l2_async_nf_unregister_cleanup(&csis->notifier);
v4l2_async_unregister_subdev(&csis->sd);
if (!pm_runtime_enabled(&pdev->dev))
diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 9566ff738818..23819a8da9bf 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -2266,8 +2266,7 @@ static void imx7_csi_remove(struct platform_device *pdev)
imx7_csi_media_cleanup(csi);
- v4l2_async_nf_unregister(&csi->notifier);
- v4l2_async_nf_cleanup(&csi->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi->notifier);
v4l2_async_unregister_subdev(&csi->sd);
}
diff --git a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
index c2013995049c..af0f6c105573 100644
--- a/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
+++ b/drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c
@@ -223,8 +223,7 @@ static void mxc_isi_v4l2_cleanup(struct mxc_isi_dev *isi)
{
unsigned int i;
- v4l2_async_nf_unregister(&isi->notifier);
- v4l2_async_nf_cleanup(&isi->notifier);
+ v4l2_async_nf_unregister_cleanup(&isi->notifier);
v4l2_device_unregister(&isi->v4l2_dev);
media_device_unregister(&isi->media_dev);
diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
index ba2e81f24965..70c857f62ce3 100644
--- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
+++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c
@@ -917,8 +917,7 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev)
media_entity_cleanup(&state->sd.entity);
v4l2_subdev_cleanup(&state->sd);
- v4l2_async_nf_unregister(&state->notifier);
- v4l2_async_nf_cleanup(&state->notifier);
+ v4l2_async_nf_unregister_cleanup(&state->notifier);
v4l2_async_unregister_subdev(&state->sd);
icc:
imx8mq_mipi_csi_release_icc(pdev);
@@ -933,8 +932,7 @@ static void imx8mq_mipi_csi_remove(struct platform_device *pdev)
struct v4l2_subdev *sd = platform_get_drvdata(pdev);
struct csi_state *state = mipi_sd_to_csi2_state(sd);
- v4l2_async_nf_unregister(&state->notifier);
- v4l2_async_nf_cleanup(&state->notifier);
+ v4l2_async_nf_unregister_cleanup(&state->notifier);
v4l2_async_unregister_subdev(&state->sd);
pm_runtime_disable(&pdev->dev);
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 1923615f0eea..ed82fb2adbd2 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -2052,8 +2052,7 @@ static void camss_remove(struct platform_device *pdev)
{
struct camss *camss = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&camss->notifier);
- v4l2_async_nf_cleanup(&camss->notifier);
+ v4l2_async_nf_unregister_cleanup(&camss->notifier);
camss_unregister_entities(camss);
if (atomic_read(&camss->ref_count) == 0)
diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c
index 582d5e35db0e..a1a956d065c0 100644
--- a/drivers/media/platform/renesas/rcar-csi2.c
+++ b/drivers/media/platform/renesas/rcar-csi2.c
@@ -1921,8 +1921,7 @@ static int rcsi2_probe(struct platform_device *pdev)
return 0;
error_async:
- v4l2_async_nf_unregister(&priv->notifier);
- v4l2_async_nf_cleanup(&priv->notifier);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
error_mutex:
mutex_destroy(&priv->lock);
@@ -1933,8 +1932,7 @@ static void rcsi2_remove(struct platform_device *pdev)
{
struct rcar_csi2 *priv = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&priv->notifier);
- v4l2_async_nf_cleanup(&priv->notifier);
+ v4l2_async_nf_unregister_cleanup(&priv->notifier);
v4l2_async_unregister_subdev(&priv->subdev);
pm_runtime_disable(&pdev->dev);
diff --git a/drivers/media/platform/renesas/rcar-isp.c b/drivers/media/platform/renesas/rcar-isp.c
index 4512ac338ca5..b79097e80147 100644
--- a/drivers/media/platform/renesas/rcar-isp.c
+++ b/drivers/media/platform/renesas/rcar-isp.c
@@ -491,8 +491,7 @@ static int risp_probe(struct platform_device *pdev)
return 0;
error_notifier:
- v4l2_async_nf_unregister(&isp->notifier);
- v4l2_async_nf_cleanup(&isp->notifier);
+ v4l2_async_nf_unregister_cleanup(&isp->notifier);
error_pm:
pm_runtime_disable(&pdev->dev);
error_mutex:
@@ -505,8 +504,7 @@ static void risp_remove(struct platform_device *pdev)
{
struct rcar_isp *isp = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&isp->notifier);
- v4l2_async_nf_cleanup(&isp->notifier);
+ v4l2_async_nf_unregister_cleanup(&isp->notifier);
v4l2_async_unregister_subdev(&isp->subdev);
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
index 809c3a38cc4a..c1b11a47affe 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c
@@ -345,10 +345,8 @@ static int rvin_group_parse_of(struct rvin_dev *vin, unsigned int port,
static void rvin_group_notifier_cleanup(struct rvin_dev *vin)
{
- if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) {
- v4l2_async_nf_unregister(&vin->group->notifier);
- v4l2_async_nf_cleanup(&vin->group->notifier);
- }
+ if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev)
+ v4l2_async_nf_unregister_cleanup(&vin->group->notifier);
}
static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port,
@@ -704,8 +702,7 @@ static int rvin_parallel_parse_of(struct rvin_dev *vin)
static void rvin_parallel_cleanup(struct rvin_dev *vin)
{
- v4l2_async_nf_unregister(&vin->notifier);
- v4l2_async_nf_cleanup(&vin->notifier);
+ v4l2_async_nf_unregister_cleanup(&vin->notifier);
}
static int rvin_parallel_init(struct rvin_dev *vin)
diff --git a/drivers/media/platform/renesas/rcar_drif.c b/drivers/media/platform/renesas/rcar_drif.c
index f21d05054341..4564d29aa091 100644
--- a/drivers/media/platform/renesas/rcar_drif.c
+++ b/drivers/media/platform/renesas/rcar_drif.c
@@ -1361,8 +1361,7 @@ static int rcar_drif_sdr_probe(struct rcar_drif_sdr *sdr)
/* V4L2 SDR device remove */
static void rcar_drif_sdr_remove(struct rcar_drif_sdr *sdr)
{
- v4l2_async_nf_unregister(&sdr->notifier);
- v4l2_async_nf_cleanup(&sdr->notifier);
+ v4l2_async_nf_unregister_cleanup(&sdr->notifier);
v4l2_device_unregister(&sdr->v4l2_dev);
}
diff --git a/drivers/media/platform/renesas/renesas-ceu.c b/drivers/media/platform/renesas/renesas-ceu.c
index 167760276796..3a300cc25bf3 100644
--- a/drivers/media/platform/renesas/renesas-ceu.c
+++ b/drivers/media/platform/renesas/renesas-ceu.c
@@ -1701,9 +1701,7 @@ static void ceu_remove(struct platform_device *pdev)
pm_runtime_disable(ceudev->dev);
- v4l2_async_nf_unregister(&ceudev->notifier);
-
- v4l2_async_nf_cleanup(&ceudev->notifier);
+ v4l2_async_nf_unregister_cleanup(&ceudev->notifier);
v4l2_device_unregister(&ceudev->v4l2_dev);
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
index 280efd2a8185..85ab03029353 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c
@@ -303,8 +303,7 @@ static void rzg2l_cru_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- v4l2_async_nf_unregister(&cru->notifier);
- v4l2_async_nf_cleanup(&cru->notifier);
+ v4l2_async_nf_unregister_cleanup(&cru->notifier);
rzg2l_cru_video_unregister(cru);
media_device_cleanup(&cru->mdev);
diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
index e68fcdaea207..822ad5dc46c3 100644
--- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
+++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c
@@ -819,8 +819,7 @@ static int rzg2l_csi2_probe(struct platform_device *pdev)
error_subdev:
v4l2_subdev_cleanup(&csi2->subdev);
error_async:
- v4l2_async_nf_unregister(&csi2->notifier);
- v4l2_async_nf_cleanup(&csi2->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi2->notifier);
media_entity_cleanup(&csi2->subdev.entity);
error_pm:
pm_runtime_disable(&pdev->dev);
@@ -832,8 +831,7 @@ static void rzg2l_csi2_remove(struct platform_device *pdev)
{
struct rzg2l_csi2 *csi2 = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&csi2->notifier);
- v4l2_async_nf_cleanup(&csi2->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi2->notifier);
v4l2_async_unregister_subdev(&csi2->subdev);
v4l2_subdev_cleanup(&csi2->subdev);
media_entity_cleanup(&csi2->subdev.entity);
diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
index bb0202386c70..da40d5a49cdb 100644
--- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
+++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c
@@ -720,8 +720,7 @@ static void rkisp1_remove(struct platform_device *pdev)
{
struct rkisp1_device *rkisp1 = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&rkisp1->notifier);
- v4l2_async_nf_cleanup(&rkisp1->notifier);
+ v4l2_async_nf_unregister_cleanup(&rkisp1->notifier);
rkisp1_entities_unregister(rkisp1);
if (rkisp1_has_feature(rkisp1, MIPI_CSI2))
diff --git a/drivers/media/platform/samsung/exynos4-is/media-dev.c b/drivers/media/platform/samsung/exynos4-is/media-dev.c
index 5f10bb4eb4f7..97d6ed03b935 100644
--- a/drivers/media/platform/samsung/exynos4-is/media-dev.c
+++ b/drivers/media/platform/samsung/exynos4-is/media-dev.c
@@ -1538,8 +1538,7 @@ static void fimc_md_remove(struct platform_device *pdev)
return;
fimc_md_unregister_clk_provider(fmd);
- v4l2_async_nf_unregister(&fmd->subdev_notifier);
- v4l2_async_nf_cleanup(&fmd->subdev_notifier);
+ v4l2_async_nf_unregister_cleanup(&fmd->subdev_notifier);
v4l2_device_unregister(&fmd->v4l2_dev);
device_remove_file(&pdev->dev, &dev_attr_subdev_conf_mode);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c b/drivers/media/platform/st/stm32/stm32-dcmi.c
index ff3331af9406..9c3d20cef6c2 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
@@ -2089,8 +2089,7 @@ static void dcmi_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- v4l2_async_nf_unregister(&dcmi->notifier);
- v4l2_async_nf_cleanup(&dcmi->notifier);
+ v4l2_async_nf_unregister_cleanup(&dcmi->notifier);
media_entity_cleanup(&dcmi->vdev->entity);
v4l2_device_unregister(&dcmi->v4l2_dev);
media_device_cleanup(&dcmi->mdev);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
index bce821eb71ce..7602fc02978f 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
@@ -524,8 +524,7 @@ static void dcmipp_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- v4l2_async_nf_unregister(&dcmipp->notifier);
- v4l2_async_nf_cleanup(&dcmipp->notifier);
+ v4l2_async_nf_unregister_cleanup(&dcmipp->notifier);
for (i = 0; i < dcmipp->pipe_cfg->num_ents; i++)
dcmipp->pipe_cfg->ents[i].release(dcmipp->entity[i]);
diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
index 097a3a08ef7d..ae2584eb07ca 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
@@ -265,8 +265,7 @@ static void sun4i_csi_remove(struct platform_device *pdev)
struct sun4i_csi *csi = platform_get_drvdata(pdev);
pm_runtime_disable(&pdev->dev);
- v4l2_async_nf_unregister(&csi->notifier);
- v4l2_async_nf_cleanup(&csi->notifier);
+ v4l2_async_nf_unregister_cleanup(&csi->notifier);
vb2_video_unregister_device(&csi->vdev);
media_device_unregister(&csi->mdev);
sun4i_csi_dma_unregister(csi);
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
index d006d9dd0170..f2412e663d2a 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c
@@ -863,8 +863,7 @@ void sun6i_csi_bridge_cleanup(struct sun6i_csi_device *csi_dev)
struct v4l2_subdev *subdev = &csi_dev->bridge.subdev;
struct v4l2_async_notifier *notifier = &csi_dev->bridge.notifier;
- v4l2_async_nf_unregister(notifier);
- v4l2_async_nf_cleanup(notifier);
+ v4l2_async_nf_unregister_cleanup(notifier);
v4l2_device_unregister_subdev(subdev);
diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
index f9d4dc45b490..74540146181f 100644
--- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c
@@ -577,8 +577,7 @@ sun6i_mipi_csi2_bridge_cleanup(struct sun6i_mipi_csi2_device *csi2_dev)
struct v4l2_async_notifier *notifier = &csi2_dev->bridge.notifier;
v4l2_async_unregister_subdev(subdev);
- v4l2_async_nf_unregister(notifier);
- v4l2_async_nf_cleanup(notifier);
+ v4l2_async_nf_unregister_cleanup(notifier);
media_entity_cleanup(&subdev->entity);
}
diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
index 4a5698eb12b7..13c640192d0a 100644
--- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
+++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c
@@ -615,8 +615,7 @@ sun8i_a83t_mipi_csi2_bridge_cleanup(struct sun8i_a83t_mipi_csi2_device *csi2_dev
struct v4l2_async_notifier *notifier = &csi2_dev->bridge.notifier;
v4l2_async_unregister_subdev(subdev);
- v4l2_async_nf_unregister(notifier);
- v4l2_async_nf_cleanup(notifier);
+ v4l2_async_nf_unregister_cleanup(notifier);
media_entity_cleanup(&subdev->entity);
}
diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c
index 77e12457d149..bdaf52d77b24 100644
--- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
@@ -2485,8 +2485,7 @@ static void vpfe_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
- v4l2_async_nf_unregister(&vpfe->notifier);
- v4l2_async_nf_cleanup(&vpfe->notifier);
+ v4l2_async_nf_unregister_cleanup(&vpfe->notifier);
video_unregister_device(&vpfe->video_dev);
v4l2_device_unregister(&vpfe->v4l2_dev);
}
diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/ti/cal/cal.c
index 528909ae4bd6..65f812197dc1 100644
--- a/drivers/media/platform/ti/cal/cal.c
+++ b/drivers/media/platform/ti/cal/cal.c
@@ -902,12 +902,6 @@ static int cal_async_notifier_register(struct cal_dev *cal)
return ret;
}
-static void cal_async_notifier_unregister(struct cal_dev *cal)
-{
- v4l2_async_nf_unregister(&cal->notifier);
- v4l2_async_nf_cleanup(&cal->notifier);
-}
-
/* ------------------------------------------------------------------
* Media and V4L2 device handling
* ------------------------------------------------------------------
@@ -952,7 +946,7 @@ static void cal_media_unregister(struct cal_dev *cal)
for (i = 0; i < cal->num_contexts; i++)
cal_ctx_v4l2_unregister(cal->ctx[i]);
- cal_async_notifier_unregister(cal);
+ v4l2_async_nf_unregister_cleanup(&cal->notifier);
media_device_unregister(&cal->mdev);
}
diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c b/drivers/media/platform/ti/davinci/vpif_capture.c
index c28794b6677b..3bcd5f305d8f 100644
--- a/drivers/media/platform/ti/davinci/vpif_capture.c
+++ b/drivers/media/platform/ti/davinci/vpif_capture.c
@@ -1720,8 +1720,7 @@ static void vpif_remove(struct platform_device *device)
struct channel_obj *ch;
int i;
- v4l2_async_nf_unregister(&vpif_obj.notifier);
- v4l2_async_nf_cleanup(&vpif_obj.notifier);
+ v4l2_async_nf_unregister_cleanup(&vpif_obj.notifier);
v4l2_device_unregister(&vpif_obj.v4l2_dev);
kfree(vpif_obj.sd);
diff --git a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
index 22442fce7607..75498d18a692 100644
--- a/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
+++ b/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c
@@ -1074,12 +1074,6 @@ static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi)
media_device_cleanup(&csi->mdev);
}
-static void ti_csi2rx_cleanup_subdev(struct ti_csi2rx_dev *csi)
-{
- v4l2_async_nf_unregister(&csi->notifier);
- v4l2_async_nf_cleanup(&csi->notifier);
-}
-
static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi)
{
vb2_queue_release(&csi->vidq);
@@ -1129,7 +1123,7 @@ static int ti_csi2rx_probe(struct platform_device *pdev)
return 0;
err_subdev:
- ti_csi2rx_cleanup_subdev(csi);
+ v4l2_async_nf_unregister_cleanup(&csi->notifier);
err_vb2q:
ti_csi2rx_cleanup_vb2q(csi);
err_v4l2:
@@ -1148,7 +1142,7 @@ static void ti_csi2rx_remove(struct platform_device *pdev)
video_unregister_device(&csi->vdev);
ti_csi2rx_cleanup_vb2q(csi);
- ti_csi2rx_cleanup_subdev(csi);
+ v4l2_async_nf_unregister_cleanup(&csi->notifier);
ti_csi2rx_cleanup_v4l2(csi);
ti_csi2rx_cleanup_dma(csi);
diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platform/ti/omap3isp/isp.c
index 1cda23244c7b..4d3ae5832d37 100644
--- a/drivers/media/platform/ti/omap3isp/isp.c
+++ b/drivers/media/platform/ti/omap3isp/isp.c
@@ -2001,8 +2001,7 @@ static void isp_remove(struct platform_device *pdev)
{
struct isp_device *isp = platform_get_drvdata(pdev);
- v4l2_async_nf_unregister(&isp->notifier);
- v4l2_async_nf_cleanup(&isp->notifier);
+ v4l2_async_nf_unregister_cleanup(&isp->notifier);
isp_unregister_entities(isp);
isp_cleanup_modules(isp);
isp_xclk_cleanup(isp);
diff --git a/drivers/media/platform/video-mux.c b/drivers/media/platform/video-mux.c
index 31e9e92e723e..d46379a4cd76 100644
--- a/drivers/media/platform/video-mux.c
+++ b/drivers/media/platform/video-mux.c
@@ -471,8 +471,7 @@ static void video_mux_remove(struct platform_device *pdev)
struct video_mux *vmux = platform_get_drvdata(pdev);
struct v4l2_subdev *sd = &vmux->subdev;
- v4l2_async_nf_unregister(&vmux->notifier);
- v4l2_async_nf_cleanup(&vmux->notifier);
+ v4l2_async_nf_unregister_cleanup(&vmux->notifier);
v4l2_async_unregister_subdev(sd);
v4l2_subdev_cleanup(sd);
media_entity_cleanup(&sd->entity);
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c
index 996684a73038..52bd0946c314 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -481,8 +481,7 @@ static void xvip_graph_cleanup(struct xvip_composite_device *xdev)
struct xvip_dma *dmap;
struct xvip_dma *dma;
- v4l2_async_nf_unregister(&xdev->notifier);
- v4l2_async_nf_cleanup(&xdev->notifier);
+ v4l2_async_nf_unregister_cleanup(&xdev->notifier);
list_for_each_entry_safe(dma, dmap, &xdev->dmas, list) {
xvip_dma_cleanup(dma);
diff --git a/drivers/staging/media/deprecated/atmel/atmel-isc-base.c b/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
index 305b103153d7..d01f03c326fd 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-isc-base.c
@@ -1944,10 +1944,8 @@ void atmel_isc_subdev_cleanup(struct isc_device *isc)
{
struct isc_subdev_entity *subdev_entity;
- list_for_each_entry(subdev_entity, &isc->subdev_entities, list) {
- v4l2_async_nf_unregister(&subdev_entity->notifier);
- v4l2_async_nf_cleanup(&subdev_entity->notifier);
- }
+ list_for_each_entry(subdev_entity, &isc->subdev_entities, list)
+ v4l2_async_nf_unregister_cleanup(&subdev_entity->notifier);
INIT_LIST_HEAD(&isc->subdev_entities);
}
diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c
index 46a334b602f1..1064c0839fdf 100644
--- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c
+++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c
@@ -573,8 +573,7 @@ void sun6i_isp_proc_cleanup(struct sun6i_isp_device *isp_dev)
struct v4l2_async_notifier *notifier = &isp_dev->proc.notifier;
struct v4l2_subdev *subdev = &isp_dev->proc.subdev;
- v4l2_async_nf_unregister(notifier);
- v4l2_async_nf_cleanup(notifier);
+ v4l2_async_nf_unregister_cleanup(notifier);
v4l2_device_unregister_subdev(subdev);
media_entity_cleanup(&subdev->entity);
diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
index 57a856a21e90..7e23d494ef85 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -1802,8 +1802,7 @@ static void tegra_vi_graph_cleanup(struct tegra_vi *vi)
list_for_each_entry(chan, &vi->vi_chans, list) {
vb2_video_unregister_device(&chan->video);
- v4l2_async_nf_unregister(&chan->notifier);
- v4l2_async_nf_cleanup(&chan->notifier);
+ v4l2_async_nf_unregister_cleanup(&chan->notifier);
}
}
--
2.44.0
Hi Julien,
On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote:
> Many drivers has
> v4l2_async_nf_unregister(¬ifier);
> v4l2_async_nf_cleanup(¬ifier);
>
> Introduce a helper function to call both functions in one line.
Does this really go in the right direction ? For other objects (video
devices, media devices, ...), the unregistration should be done at
remove() time, and the cleanup at .release() time (the operation called
when the last reference to the object is released). This is needed to
ensure proper lifetime management of the objects, and avoid a
use-after-free for objects that can be reached from userspace.
It could be argued that the notifier isn't exposed to userspace, but can
we guarantee that no driver will have a need to access the notifier in a
code path triggered by a userspace operation ? I think it would be safer
to adopt the same split for the nofifier unregistration and cleanup. In
my opinion using the same rule across different APIs also make it easier
for driver authors and for reviewers to get it right.
As shown by your series, lots of drivers call v4l2_async_nf_cleanup()
and .remove() time instead of .release(). That's because most drivers
get lifetime management wrong and don't even implement .release().
That's something Sakari is addressing with ongoing work. This patch
series seems to go in the opposite direction.
> ---
> Julien Massot (2):
> media: v4l: async: Add v4l2_async_nf_unregister_cleanup
> media: convert all drivers to use v4l2_async_nf_unregister_cleanup
>
> drivers/media/i2c/ds90ub913.c | 10 ++--------
> drivers/media/i2c/ds90ub953.c | 10 ++--------
> drivers/media/i2c/ds90ub960.c | 10 ++--------
> drivers/media/i2c/max9286.c | 3 +--
> drivers/media/i2c/st-mipid02.c | 6 ++----
> drivers/media/i2c/tc358746.c | 3 +--
> drivers/media/pci/intel/ipu3/ipu3-cio2.c | 6 ++----
> drivers/media/pci/intel/ipu6/ipu6-isys.c | 8 +-------
> drivers/media/pci/intel/ivsc/mei_csi.c | 6 ++----
> drivers/media/platform/atmel/atmel-isi.c | 3 +--
> drivers/media/platform/cadence/cdns-csi2rx.c | 6 ++----
> drivers/media/platform/intel/pxa_camera.c | 3 +--
> drivers/media/platform/marvell/mcam-core.c | 6 ++----
> drivers/media/platform/microchip/microchip-csi2dc.c | 3 +--
> drivers/media/platform/microchip/microchip-isc-base.c | 6 ++----
> drivers/media/platform/nxp/imx-mipi-csis.c | 6 ++----
> drivers/media/platform/nxp/imx7-media-csi.c | 3 +--
> drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c | 3 +--
> drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 6 ++----
> drivers/media/platform/qcom/camss/camss.c | 3 +--
> drivers/media/platform/renesas/rcar-csi2.c | 6 ++----
> drivers/media/platform/renesas/rcar-isp.c | 6 ++----
> drivers/media/platform/renesas/rcar-vin/rcar-core.c | 9 +++------
> drivers/media/platform/renesas/rcar_drif.c | 3 +--
> drivers/media/platform/renesas/renesas-ceu.c | 4 +---
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c | 3 +--
> drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 6 ++----
> drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 +--
> drivers/media/platform/samsung/exynos4-is/media-dev.c | 3 +--
> drivers/media/platform/st/stm32/stm32-dcmi.c | 3 +--
> .../media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 3 +--
> drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c | 3 +--
> .../media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c | 3 +--
> .../platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 3 +--
> .../sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c | 3 +--
> drivers/media/platform/ti/am437x/am437x-vpfe.c | 3 +--
> drivers/media/platform/ti/cal/cal.c | 8 +-------
> drivers/media/platform/ti/davinci/vpif_capture.c | 3 +--
> drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 10 ++--------
> drivers/media/platform/ti/omap3isp/isp.c | 3 +--
> drivers/media/platform/video-mux.c | 3 +--
> drivers/media/platform/xilinx/xilinx-vipp.c | 3 +--
> drivers/staging/media/deprecated/atmel/atmel-isc-base.c | 6 ++----
> drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c | 3 +--
> drivers/staging/media/tegra-video/vi.c | 3 +--
> include/media/v4l2-async.h | 17 +++++++++++++++++
> 46 files changed, 80 insertions(+), 153 deletions(-)
> ---
> base-commit: 843a9f4a7a85988f2f3af98adf21797c2fd05ab1
> change-id: 20240502-master-5deee133b4f5
--
Regards,
Laurent Pinchart
On Thu, May 02, 2024 at 04:01:45PM +0000, Sakari Ailus wrote:
> On Thu, May 02, 2024 at 06:56:26PM +0300, Laurent Pinchart wrote:
> > On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote:
> > > Many drivers has
> > > v4l2_async_nf_unregister(¬ifier);
> > > v4l2_async_nf_cleanup(¬ifier);
> > >
> > > Introduce a helper function to call both functions in one line.
> >
> > Does this really go in the right direction ? For other objects (video
> > devices, media devices, ...), the unregistration should be done at
> > .remove() time, and the cleanup at .release() time (the operation called
> > when the last reference to the object is released). This is needed to
> > ensure proper lifetime management of the objects, and avoid a
> > use-after-free for objects that can be reached from userspace.
> >
> > It could be argued that the notifier isn't exposed to userspace, but can
> > we guarantee that no driver will have a need to access the notifier in a
> > code path triggered by a userspace operation ? I think it would be safer
> > to adopt the same split for the nofifier unregistration and cleanup. In
> > my opinion using the same rule across different APIs also make it easier
> > for driver authors and for reviewers to get it right.
> >
> > As shown by your series, lots of drivers call v4l2_async_nf_cleanup()
> > and .remove() time instead of .release(). That's because most drivers
> > get lifetime management wrong and don't even implement .release().
> > That's something Sakari is addressing with ongoing work. This patch
> > series seems to go in the opposite direction.
>
> This still avoids the driver authors feeling they need to implement wrapper
> functions for v4l2_async_nf_{unregister,cleanup}. I'd be in favour merging
> this.
>
> I don't see this getting in the way of adding use counts as the code will
> need to be changed in any case.
Fixing the lifetime issues would essentially revert 2/2 and move the
v4l2_async_nf_cleanup() call to .remove(). I don't think providing a
helper that forces the cleanup at .remove() time is a good idea, it
gives a false sense of doing things right to drivers. This is the same
reason why devm_kzalloc() is so harmful, it gave the wrong message, and
created (or participated in) all those lifetime issues.
--
Regards,
Laurent Pinchart
Hi Laurent,
On Thu, May 02, 2024 at 06:56:26PM +0300, Laurent Pinchart wrote:
> Hi Julien,
>
> On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote:
> > Many drivers has
> > v4l2_async_nf_unregister(¬ifier);
> > v4l2_async_nf_cleanup(¬ifier);
> >
> > Introduce a helper function to call both functions in one line.
>
> Does this really go in the right direction ? For other objects (video
> devices, media devices, ...), the unregistration should be done at
> .remove() time, and the cleanup at .release() time (the operation called
> when the last reference to the object is released). This is needed to
> ensure proper lifetime management of the objects, and avoid a
> use-after-free for objects that can be reached from userspace.
>
> It could be argued that the notifier isn't exposed to userspace, but can
> we guarantee that no driver will have a need to access the notifier in a
> code path triggered by a userspace operation ? I think it would be safer
> to adopt the same split for the nofifier unregistration and cleanup. In
> my opinion using the same rule across different APIs also make it easier
> for driver authors and for reviewers to get it right.
>
> As shown by your series, lots of drivers call v4l2_async_nf_cleanup()
> and .remove() time instead of .release(). That's because most drivers
> get lifetime management wrong and don't even implement .release().
> That's something Sakari is addressing with ongoing work. This patch
> series seems to go in the opposite direction.
This still avoids the driver authors feeling they need to implement wrapper
functions for v4l2_async_nf_{unregister,cleanup}. I'd be in favour merging
this.
I don't see this getting in the way of adding use counts as the code will
need to be changed in any case.
--
Regards,
Sakari Ailus
Hi Laurent,
On Thu, May 02, 2024 at 07:08:30PM +0300, Laurent Pinchart wrote:
> On Thu, May 02, 2024 at 04:01:45PM +0000, Sakari Ailus wrote:
> > On Thu, May 02, 2024 at 06:56:26PM +0300, Laurent Pinchart wrote:
> > > On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote:
> > > > Many drivers has
> > > > v4l2_async_nf_unregister(¬ifier);
> > > > v4l2_async_nf_cleanup(¬ifier);
> > > >
> > > > Introduce a helper function to call both functions in one line.
> > >
> > > Does this really go in the right direction ? For other objects (video
> > > devices, media devices, ...), the unregistration should be done at
> > > .remove() time, and the cleanup at .release() time (the operation called
> > > when the last reference to the object is released). This is needed to
> > > ensure proper lifetime management of the objects, and avoid a
> > > use-after-free for objects that can be reached from userspace.
> > >
> > > It could be argued that the notifier isn't exposed to userspace, but can
> > > we guarantee that no driver will have a need to access the notifier in a
> > > code path triggered by a userspace operation ? I think it would be safer
> > > to adopt the same split for the nofifier unregistration and cleanup. In
> > > my opinion using the same rule across different APIs also make it easier
> > > for driver authors and for reviewers to get it right.
> > >
> > > As shown by your series, lots of drivers call v4l2_async_nf_cleanup()
> > > and .remove() time instead of .release(). That's because most drivers
> > > get lifetime management wrong and don't even implement .release().
> > > That's something Sakari is addressing with ongoing work. This patch
> > > series seems to go in the opposite direction.
> >
> > This still avoids the driver authors feeling they need to implement wrapper
> > functions for v4l2_async_nf_{unregister,cleanup}. I'd be in favour merging
> > this.
> >
> > I don't see this getting in the way of adding use counts as the code will
> > need to be changed in any case.
>
> Fixing the lifetime issues would essentially revert 2/2 and move the
> v4l2_async_nf_cleanup() call to .remove(). I don't think providing a
> helper that forces the cleanup at .remove() time is a good idea, it
> gives a false sense of doing things right to drivers. This is the same
> reason why devm_kzalloc() is so harmful, it gave the wrong message, and
> created (or participated in) all those lifetime issues.
I still prefer having devm_*alloc() functions than having the drivers open
coding the same -- with the same result. The frameworks won't enable doing
this right at the moment and I don't think drivers (or us!) should be
penalised for that. The driver authors will only change what they do, with
these patches or without, when told so. But we don't really have an
alternative today.
A similar situation exists with clk_unprepare() and clk_disable().
--
Kind regards,
Sakari Ailus
On Thu, May 02, 2024 at 04:24:04PM +0000, Sakari Ailus wrote:
> On Thu, May 02, 2024 at 07:08:30PM +0300, Laurent Pinchart wrote:
> > On Thu, May 02, 2024 at 04:01:45PM +0000, Sakari Ailus wrote:
> > > On Thu, May 02, 2024 at 06:56:26PM +0300, Laurent Pinchart wrote:
> > > > On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote:
> > > > > Many drivers has
> > > > > v4l2_async_nf_unregister(¬ifier);
> > > > > v4l2_async_nf_cleanup(¬ifier);
> > > > >
> > > > > Introduce a helper function to call both functions in one line.
> > > >
> > > > Does this really go in the right direction ? For other objects (video
> > > > devices, media devices, ...), the unregistration should be done at
> > > > .remove() time, and the cleanup at .release() time (the operation called
> > > > when the last reference to the object is released). This is needed to
> > > > ensure proper lifetime management of the objects, and avoid a
> > > > use-after-free for objects that can be reached from userspace.
> > > >
> > > > It could be argued that the notifier isn't exposed to userspace, but can
> > > > we guarantee that no driver will have a need to access the notifier in a
> > > > code path triggered by a userspace operation ? I think it would be safer
> > > > to adopt the same split for the nofifier unregistration and cleanup. In
> > > > my opinion using the same rule across different APIs also make it easier
> > > > for driver authors and for reviewers to get it right.
> > > >
> > > > As shown by your series, lots of drivers call v4l2_async_nf_cleanup()
> > > > and .remove() time instead of .release(). That's because most drivers
> > > > get lifetime management wrong and don't even implement .release().
> > > > That's something Sakari is addressing with ongoing work. This patch
> > > > series seems to go in the opposite direction.
> > >
> > > This still avoids the driver authors feeling they need to implement wrapper
> > > functions for v4l2_async_nf_{unregister,cleanup}. I'd be in favour merging
> > > this.
> > >
> > > I don't see this getting in the way of adding use counts as the code will
> > > need to be changed in any case.
> >
> > Fixing the lifetime issues would essentially revert 2/2 and move the
> > v4l2_async_nf_cleanup() call to .remove(). I don't think providing a
> > helper that forces the cleanup at .remove() time is a good idea, it
> > gives a false sense of doing things right to drivers. This is the same
> > reason why devm_kzalloc() is so harmful, it gave the wrong message, and
> > created (or participated in) all those lifetime issues.
>
> I still prefer having devm_*alloc() functions than having the drivers open
> coding the same -- with the same result. The frameworks won't enable doing
> this right at the moment and I don't think drivers (or us!) should be
> penalised for that.
I don't really see where the penalty is. What's the urgency to switch
from calling v4l2_async_nf_unregister() and v4l2_async_nf_cleanup() to a
helper that we know goes in the wrong direction ?
> The driver authors will only change what they do, with
> these patches or without, when told so. But we don't really have an
> alternative today.
There's already a .release() callback that can be used, and some drivers
use it.
> A similar situation exists with clk_unprepare() and clk_disable().
--
Regards,
Laurent Pinchart