Linux kernel staging patches
 help / color / mirror / Atom feed
* Re: [PATCH] staging: fb_tinylcd Alignment to open parenthesis
From: Julia Lawall @ 2024-05-03  6:54 UTC (permalink / raw)
  To: Ashok Kumar
  Cc: Greg Kroah-Hartman, dri-devel, linux-fbdev, linux-staging,
	linux-kernel, outreachy
In-Reply-To: <ZjRDUO6/M+RDCcQJ@c>



On Thu, 2 May 2024, Ashok Kumar wrote:

> Corrected coding style CHECK: Alignment should match open parenthesis

Ashok, I think the code is nicer as is, because it has all the constant
numbers lined up.

julia

>
> Signed-off-by: Ashok Kumar <ashokemailat@yahoo.com>
> ---
>  drivers/staging/fbtft/fb_tinylcd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/fbtft/fb_tinylcd.c b/drivers/staging/fbtft/fb_tinylcd.c
> index 9469248f2c50..60cda57bcb33 100644
> --- a/drivers/staging/fbtft/fb_tinylcd.c
> +++ b/drivers/staging/fbtft/fb_tinylcd.c
> @@ -38,7 +38,7 @@ static int init_display(struct fbtft_par *par)
>  	write_reg(par, 0xE5, 0x00);
>  	write_reg(par, 0xF0, 0x36, 0xA5, 0x53);
>  	write_reg(par, 0xE0, 0x00, 0x35, 0x33, 0x00, 0x00, 0x00,
> -		       0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
> +		  0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
>  	write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, 0x55);
>  	write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
>  	udelay(250);
> --
> 2.34.1
>
>
>

^ permalink raw reply

* Re: [PATCH] staging: fb_tinylcd Alignment to open parenthesis
From: Dan Carpenter @ 2024-05-03  5:11 UTC (permalink / raw)
  To: Ashok Kumar
  Cc: Greg Kroah-Hartman, dri-devel, linux-fbdev, linux-staging,
	linux-kernel, outreachy
In-Reply-To: <ZjRDUO6/M+RDCcQJ@c>

On Thu, May 02, 2024 at 06:52:16PM -0700, Ashok Kumar wrote:
> Corrected coding style CHECK: Alignment should match open parenthesis
> 

The original author was aligned it deliberately to improve readability.

Just ignore checkpatch on this.

regards,
dan carpenter


^ permalink raw reply

* [PATCH] staging: fb_tinylcd Alignment to open parenthesis
From: Ashok Kumar @ 2024-05-03  1:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman, dri-devel, linux-fbdev, linux-staging,
	linux-kernel, outreachy
  Cc: ashokemailat
In-Reply-To: <ZjRDUO6/M+RDCcQJ.ref@c>

Corrected coding style CHECK: Alignment should match open parenthesis

Signed-off-by: Ashok Kumar <ashokemailat@yahoo.com>
---
 drivers/staging/fbtft/fb_tinylcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fb_tinylcd.c b/drivers/staging/fbtft/fb_tinylcd.c
index 9469248f2c50..60cda57bcb33 100644
--- a/drivers/staging/fbtft/fb_tinylcd.c
+++ b/drivers/staging/fbtft/fb_tinylcd.c
@@ -38,7 +38,7 @@ static int init_display(struct fbtft_par *par)
 	write_reg(par, 0xE5, 0x00);
 	write_reg(par, 0xF0, 0x36, 0xA5, 0x53);
 	write_reg(par, 0xE0, 0x00, 0x35, 0x33, 0x00, 0x00, 0x00,
-		       0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
+		  0x00, 0x35, 0x33, 0x00, 0x00, 0x00);
 	write_reg(par, MIPI_DCS_SET_PIXEL_FORMAT, 0x55);
 	write_reg(par, MIPI_DCS_EXIT_SLEEP_MODE);
 	udelay(250);
-- 
2.34.1


^ permalink raw reply related

* Re: [PATCH 0/2] Introduce v4l2_async_nf_unregister_cleanup
From: Sakari Ailus @ 2024-05-02 16:24 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Julien Massot, Mauro Carvalho Chehab, Tomi Valkeinen,
	Jacopo Mondi, Kieran Bingham, Niklas Söderlund,
	Benjamin Mugnier, Sylvain Petinot, Yong Zhi, Bingbu Cao,
	Dan Scally, Tianshu Qiu, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Robert Foss, Todor Tomov, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli, linux-media, linux-kernel,
	linux-arm-kernel, imx, linux-arm-msm, linux-renesas-soc,
	linux-rockchip, linux-samsung-soc, linux-stm32, linux-sunxi,
	linux-staging, linux-tegra
In-Reply-To: <20240502160830.GB11443@pendragon.ideasonboard.com>

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(&notifier);
> > > >   v4l2_async_nf_cleanup(&notifier);
> > > > 
> > > > 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

^ permalink raw reply

* Re: [PATCH 0/2] Introduce v4l2_async_nf_unregister_cleanup
From: Laurent Pinchart @ 2024-05-02 16:08 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Julien Massot, Mauro Carvalho Chehab, Tomi Valkeinen,
	Jacopo Mondi, Kieran Bingham, Niklas Söderlund,
	Benjamin Mugnier, Sylvain Petinot, Yong Zhi, Bingbu Cao,
	Dan Scally, Tianshu Qiu, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Robert Foss, Todor Tomov, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli, linux-media, linux-kernel,
	linux-arm-kernel, imx, linux-arm-msm, linux-renesas-soc,
	linux-rockchip, linux-samsung-soc, linux-stm32, linux-sunxi,
	linux-staging, linux-tegra
In-Reply-To: <ZjO46Uo_tVcRTdA0@kekkonen.localdomain>

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(&notifier);
> > >   v4l2_async_nf_cleanup(&notifier);
> > > 
> > > 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

^ permalink raw reply

* Re: [PATCH 0/2] Introduce v4l2_async_nf_unregister_cleanup
From: Sakari Ailus @ 2024-05-02 16:01 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Julien Massot, Mauro Carvalho Chehab, Tomi Valkeinen,
	Jacopo Mondi, Kieran Bingham, Niklas Söderlund,
	Benjamin Mugnier, Sylvain Petinot, Yong Zhi, Bingbu Cao,
	Dan Scally, Tianshu Qiu, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Robert Foss, Todor Tomov, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli, linux-media, linux-kernel,
	linux-arm-kernel, imx, linux-arm-msm, linux-renesas-soc,
	linux-rockchip, linux-samsung-soc, linux-stm32, linux-sunxi,
	linux-staging, linux-tegra
In-Reply-To: <20240502155626.GD15807@pendragon.ideasonboard.com>

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(&notifier);
> >   v4l2_async_nf_cleanup(&notifier);
> > 
> > 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

^ permalink raw reply

* Re: [PATCH 0/2] Introduce v4l2_async_nf_unregister_cleanup
From: Laurent Pinchart @ 2024-05-02 15:56 UTC (permalink / raw)
  To: Julien Massot
  Cc: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jacopo Mondi,
	Kieran Bingham, Niklas Söderlund, Benjamin Mugnier,
	Sylvain Petinot, Yong Zhi, Bingbu Cao, Dan Scally, Tianshu Qiu,
	Eugen Hristev, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Maxime Ripard, Rui Miguel Silva, Martin Kepplinger,
	Purism Kernel Team, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Robert Foss, Todor Tomov,
	Bryan O'Donoghue, Bjorn Andersson, Konrad Dybcio,
	Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli, linux-media, linux-kernel,
	linux-arm-kernel, imx, linux-arm-msm, linux-renesas-soc,
	linux-rockchip, linux-samsung-soc, linux-stm32, linux-sunxi,
	linux-staging, linux-tegra
In-Reply-To: <20240502-master-v1-0-8bd109c6a3ba@collabora.com>

Hi Julien,

On Thu, May 02, 2024 at 05:22:20PM +0200, Julien Massot wrote:
> Many drivers has
>   v4l2_async_nf_unregister(&notifier);
>   v4l2_async_nf_cleanup(&notifier);
> 
> 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

^ permalink raw reply

* [PATCH 2/2] media: convert all drivers to use v4l2_async_nf_unregister_cleanup
From: Julien Massot @ 2024-05-02 15:22 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jacopo Mondi,
	Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
	Benjamin Mugnier, Sylvain Petinot, Yong Zhi, Bingbu Cao,
	Dan Scally, Tianshu Qiu, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Robert Foss, Todor Tomov, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli
  Cc: linux-media, linux-kernel, linux-arm-kernel, imx, linux-arm-msm,
	linux-renesas-soc, linux-rockchip, linux-samsung-soc, linux-stm32,
	linux-sunxi, linux-staging, linux-tegra, Julien Massot,
	Sakari Ailus
In-Reply-To: <20240502-master-v1-0-8bd109c6a3ba@collabora.com>

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 <sakari.ailus@iki.fi>
Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 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


^ permalink raw reply related

* [PATCH 1/2] media: v4l: async: Add v4l2_async_nf_unregister_cleanup
From: Julien Massot @ 2024-05-02 15:22 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jacopo Mondi,
	Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
	Benjamin Mugnier, Sylvain Petinot, Yong Zhi, Bingbu Cao,
	Dan Scally, Tianshu Qiu, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Robert Foss, Todor Tomov, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli
  Cc: linux-media, linux-kernel, linux-arm-kernel, imx, linux-arm-msm,
	linux-renesas-soc, linux-rockchip, linux-samsung-soc, linux-stm32,
	linux-sunxi, linux-staging, linux-tegra, Julien Massot,
	Sakari Ailus
In-Reply-To: <20240502-master-v1-0-8bd109c6a3ba@collabora.com>

Many drivers are calling v4l2_async_nf_unregister, and
v4l2_async_nf_cleanup, add a function to do it.

Suggested-by: Sakari Ailus <sakari.ailus@iki.fi>
Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 include/media/v4l2-async.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h
index f26c323e9c96..cdbe63c26779 100644
--- a/include/media/v4l2-async.h
+++ b/include/media/v4l2-async.h
@@ -304,6 +304,23 @@ void v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier);
  */
 void v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier);
 
+/**
+ * v4l2_async_nf_unregister_cleanup - unregister and clean up notifier resources
+ * @notifier: the notifier  the notifier to unregister and for which
+ *            the resources are to be cleaned up
+ *
+ * Unregister a subdevice asynchronous device and release memory resources
+ * related to a notifier.
+ * Convenient function to call v4l2_async_nf_unregister() and
+ * v4l2_async_nf_cleanup().
+ */
+static inline void
+v4l2_async_nf_unregister_cleanup(struct v4l2_async_notifier *notifier)
+{
+	v4l2_async_nf_unregister(notifier);
+	v4l2_async_nf_cleanup(notifier);
+};
+
 /**
  * v4l2_async_register_subdev - registers a sub-device to the asynchronous
  *	subdevice framework

-- 
2.44.0


^ permalink raw reply related

* [PATCH 0/2] Introduce v4l2_async_nf_unregister_cleanup
From: Julien Massot @ 2024-05-02 15:22 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, Tomi Valkeinen, Jacopo Mondi,
	Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
	Benjamin Mugnier, Sylvain Petinot, Yong Zhi, Bingbu Cao,
	Dan Scally, Tianshu Qiu, Eugen Hristev, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea, Maxime Ripard,
	Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
	Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Robert Foss, Todor Tomov, Bryan O'Donoghue, Bjorn Andersson,
	Konrad Dybcio, Fabrizio Castro, Dafna Hirschfeld, Heiko Stuebner,
	Sylwester Nawrocki, Krzysztof Kozlowski, Alim Akhtar,
	Hugues Fruchet, Alain Volmat, Maxime Coquelin, Alexandre Torgue,
	Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Yong Deng,
	Paul Kocialkowski, Benoit Parrot, Jai Luthra, Philipp Zabel,
	Michal Simek, Greg Kroah-Hartman, Thierry Reding, Jonathan Hunter,
	Sowjanya Komatineni, Luca Ceresoli
  Cc: linux-media, linux-kernel, linux-arm-kernel, imx, linux-arm-msm,
	linux-renesas-soc, linux-rockchip, linux-samsung-soc, linux-stm32,
	linux-sunxi, linux-staging, linux-tegra, Julien Massot,
	Sakari Ailus

Many drivers has
  v4l2_async_nf_unregister(&notifier);
  v4l2_async_nf_cleanup(&notifier);

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 <julien.massot@collabora.com>


^ permalink raw reply

* Re: [PATCH 2/2] staging: pi433: Rename goto label.
From: Dan Carpenter @ 2024-05-02  8:59 UTC (permalink / raw)
  To: Shahar Avidar
  Cc: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	linux-staging, linux-kernel
In-Reply-To: <b0cd37c3-5465-467d-8074-67fa2fddcc4d@gmail.com>

On Thu, May 02, 2024 at 11:44:15AM +0300, Shahar Avidar wrote:
> On 01/05/2024 17:06, Dan Carpenter wrote:
> > On Wed, May 01, 2024 at 08:58:20AM +0300, Shahar Avidar wrote:
> > > Use destroy_class_and_remove_dbfs instead of unreg_class_and_remove_dbfs.
> > > 
> > > Signed-off-by: Shahar Avidar <ikobh7@gmail.com>
> > > ---
> > >   drivers/staging/pi433/pi433_if.c | 4 ++--
> > >   1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> > > index c8c1d296184b..4fffd7007040 100644
> > > --- a/drivers/staging/pi433/pi433_if.c
> > > +++ b/drivers/staging/pi433/pi433_if.c
> > > @@ -1409,11 +1409,11 @@ static int __init pi433_init(void)
> > >   	status = spi_register_driver(&pi433_spi_driver);
> > >   	if (status < 0)
> > > -		goto unreg_class_and_remove_dbfs;
> > > +		goto destroy_class_and_remove_dbfs;
> > >   	return 0;
> > > -unreg_class_and_remove_dbfs:
> > > +destroy_class_and_remove_dbfs:
> > >   	debugfs_remove(root_dir);
> > >   	class_destroy(pi433_class);
> > 
> > This is cleaning up something which changed in patch 1 so it should have
> > been done in patch 1.
> > 
> Thanks for your input.
> I thought of a previous comment you had were you noted Greg preferred small
> patches, so I did my best to keep the first patch the with minimum changes
> without breaking git digest.

The rule is not "as small as possible", it's "one thing per patch".
It's a bit subtle, but you're doing half a thing in this patch.  Not a
huge deal.  It's part of the learning process.

regards,
dan carpenter

^ permalink raw reply

* Re: [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Greg KH @ 2024-05-02  8:54 UTC (permalink / raw)
  To: Shahar Avidar
  Cc: hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	dan.carpenter, linux-staging, linux-kernel
In-Reply-To: <fede8589-dd11-4b0c-aa70-7ec23aed64b1@gmail.com>

On Thu, May 02, 2024 at 11:40:44AM +0300, Shahar Avidar wrote:
> On 01/05/2024 17:12, Greg KH wrote:
> > On Wed, May 01, 2024 at 08:58:19AM +0300, Shahar Avidar wrote:
> > > Make use of a higher level API.
> > 
> > What does this mean?
> > 
> By "higher level" I meant a wrapper function that includes the
> "class_register" call.
> 
> > > Reduce global memory allocation from struct class to pointer size.
> > 
> > No, you increased memory allocation here, why do you think you reduced
> > it?
> > 
> Reducing *global* memory allocation.

And again, you *increased* memory allocation by making this be
dynamically created instead of the current code which is a static and
can be placed into read-only memory with no padding required unlike a
dynamic memory chunk is.  You also removed the read-only markings of the
structure for no reason, in a way, making the code a tad be more
insecure as well as increasing memory usage.

So be careful please.

> I understand the tradeoff would be allocating in run time the class struct
> anyway, but than, it could also be freed.

When is it freed that the current code is not also freed?

> Since the Pi433 is a RasPi expansion board and can be attached\removed in an
> asynchronous matter by the user, and only one can be attached at a time, I
> thought it is best not to statically allocate memory which won't be freed
> even if the hat is removed.

Is that what happens in the code?

> By using the class_create & class_destroy I thought of reducing memory
> allocated by the RasPi if the pi433 is removed.

Try it and see :)

> But following your response I now actually see that the class struct will
> have the same lifespan anyway if allocated statically or dynamically if its
> alive between the init\exit calls.

Yes.

> > Also, this looks like a revert of commit f267da65bb6b ("staging: pi433:
> > make pi433_class constant"), accepted a few months ago, why not just
> > call it out as an explicit revert if that's what you want to do?
> > 
> I actually saw this commit, but for some reason did not connect the dots
> when I wrote this patch. My bad.
> 
> > class_create is going away "soon", why add this back when people are
> > working so hard to remove its usage?  What tutorial did you read that
> > made you want to make this change?
> > 
> It's true, I got it the wrong way I guess. I thought class_create is the
> preferred API (but now that you mentioned commit f267da65bb6b, I see it's
> not). I did notice it in many other drivers though, and took them as an
> example (e.g. gnss).

There are patches out that replace almost all users of class_create()
such that it should be almost gone from the tree.

> > thanks,
> > 
> > greg k-h
> 
> I actually initially thought that the pi433 class should be removed since it
> doesn't bring any new attributes with it, and that spi_slave_class is more
> appropriate, but then I saw no other driver using it. Any thoughts about
> that?

The whole driver is going to be removed soon, please see the mailing
list archives for the details.

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Shahar Avidar @ 2024-05-02  8:51 UTC (permalink / raw)
  To: Greg KH, Dan Carpenter
  Cc: hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	linux-staging, linux-kernel
In-Reply-To: <2024050158-mutilated-zero-13b0@gregkh>

On 01/05/2024 17:14, Greg KH wrote:
> On Wed, May 01, 2024 at 05:00:44PM +0300, Dan Carpenter wrote:
>> On Wed, May 01, 2024 at 08:58:19AM +0300, Shahar Avidar wrote:
>>> Make use of a higher level API.
>>> Reduce global memory allocation from struct class to pointer size.
>>
>> Doesn't this move the memory in the opposite direction from what we
>> want?  Originally, it's static const.  Isn't that the simplest best
>> kind of memory?
> 
> Our reviews just crossed...  This is just a revert (in 2 steps oddly),
> of a previous commit that changed this api call, and for that reason
> alone we can't take it :)
> 
Thank you for your input.
I replied to Greg's review on another thread.
I won't pursue this change.

-- 
Regards,

Shahar


^ permalink raw reply

* Re: [PATCH 2/2] staging: pi433: Rename goto label.
From: Shahar Avidar @ 2024-05-02  8:44 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	linux-staging, linux-kernel
In-Reply-To: <3005db51-58f7-4247-a37b-02933767f644@moroto.mountain>

On 01/05/2024 17:06, Dan Carpenter wrote:
> On Wed, May 01, 2024 at 08:58:20AM +0300, Shahar Avidar wrote:
>> Use destroy_class_and_remove_dbfs instead of unreg_class_and_remove_dbfs.
>>
>> Signed-off-by: Shahar Avidar <ikobh7@gmail.com>
>> ---
>>   drivers/staging/pi433/pi433_if.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
>> index c8c1d296184b..4fffd7007040 100644
>> --- a/drivers/staging/pi433/pi433_if.c
>> +++ b/drivers/staging/pi433/pi433_if.c
>> @@ -1409,11 +1409,11 @@ static int __init pi433_init(void)
>>   
>>   	status = spi_register_driver(&pi433_spi_driver);
>>   	if (status < 0)
>> -		goto unreg_class_and_remove_dbfs;
>> +		goto destroy_class_and_remove_dbfs;
>>   
>>   	return 0;
>>   
>> -unreg_class_and_remove_dbfs:
>> +destroy_class_and_remove_dbfs:
>>   	debugfs_remove(root_dir);
>>   	class_destroy(pi433_class);
> 
> This is cleaning up something which changed in patch 1 so it should have
> been done in patch 1.
> 
Thanks for your input.
I thought of a previous comment you had were you noted Greg preferred 
small patches, so I did my best to keep the first patch the with minimum 
changes without breaking git digest.

This patchset won't be accepted anyway.

> regards,
> dan carpenter
> 
>>   unreg_chrdev:
>> -- 
>> 2.34.1
-- 
Regards,

Shahar


^ permalink raw reply

* Re: [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Shahar Avidar @ 2024-05-02  8:40 UTC (permalink / raw)
  To: Greg KH
  Cc: hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	dan.carpenter, linux-staging, linux-kernel
In-Reply-To: <2024050109-reward-vision-58e9@gregkh>

On 01/05/2024 17:12, Greg KH wrote:
> On Wed, May 01, 2024 at 08:58:19AM +0300, Shahar Avidar wrote:
>> Make use of a higher level API.
> 
> What does this mean?
> 
By "higher level" I meant a wrapper function that includes the 
"class_register" call.

>> Reduce global memory allocation from struct class to pointer size.
> 
> No, you increased memory allocation here, why do you think you reduced
> it?
> 
Reducing *global* memory allocation.
I understand the tradeoff would be allocating in run time the class 
struct anyway, but than, it could also be freed.

Since the Pi433 is a RasPi expansion board and can be attached\removed 
in an asynchronous matter by the user, and only one can be attached at a 
time, I thought it is best not to statically allocate memory which won't 
be freed even if the hat is removed.

By using the class_create & class_destroy I thought of reducing memory 
allocated by the RasPi if the pi433 is removed.

But following your response I now actually see that the class struct 
will have the same lifespan anyway if allocated statically or 
dynamically if its alive between the init\exit calls.

> Also, this looks like a revert of commit f267da65bb6b ("staging: pi433:
> make pi433_class constant"), accepted a few months ago, why not just
> call it out as an explicit revert if that's what you want to do?
> 
I actually saw this commit, but for some reason did not connect the dots 
when I wrote this patch. My bad.

> class_create is going away "soon", why add this back when people are
> working so hard to remove its usage?  What tutorial did you read that
> made you want to make this change?
> 
It's true, I got it the wrong way I guess. I thought class_create is the 
preferred API (but now that you mentioned commit f267da65bb6b, I see 
it's not). I did notice it in many other drivers though, and took them 
as an example (e.g. gnss).


> thanks,
> 
> greg k-h

I actually initially thought that the pi433 class should be removed 
since it doesn't bring any new attributes with it, and that 
spi_slave_class is more appropriate, but then I saw no other driver 
using it. Any thoughts about that?
-- 
Regards,

Shahar


^ permalink raw reply

* [PATCH] staging: atomisp: Fix spelling mistake in csi_rx_public.h
From: Roshan Khatri @ 2024-05-02  4:34 UTC (permalink / raw)
  To: hdegoede, mchehab, sakari.ailus, hpa, gregkh
  Cc: Roshan Khatri, linux-media, linux-staging, linux-kernel

codespell reported misspelled register in
csi_rx_public.h. This patch fixes the misspellings.

Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
---
 .../atomisp/pci/hive_isp_css_include/host/csi_rx_public.h     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_include/host/csi_rx_public.h b/drivers/staging/media/atomisp/pci/hive_isp_css_include/host/csi_rx_public.h
index 693154e8ec2f..7e37f0809034 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_include/host/csi_rx_public.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_include/host/csi_rx_public.h
@@ -94,7 +94,7 @@ hrt_data csi_rx_fe_ctrl_reg_load(
     const hrt_address reg);
 /**
  * @brief Store a value to the register.
- * Store a value to the registe of the csi rx fe.
+ * Store a value to the register of the csi rx fe.
  *
  * @param[in]	ID		The global unique ID for the ibuf-controller instance.
  * @param[in]	reg		The offset address of the register.
@@ -119,7 +119,7 @@ hrt_data csi_rx_be_ctrl_reg_load(
     const hrt_address reg);
 /**
  * @brief Store a value to the register.
- * Store a value to the registe of the csi rx be.
+ * Store a value to the register of the csi rx be.
  *
  * @param[in]	ID		The global unique ID for the ibuf-controller instance.
  * @param[in]	reg		The offset address of the register.
-- 
2.34.1


^ permalink raw reply related

* Re: [PATCH] staging: nvec: make i2c controller register writes robust
From: Marc Dietrich @ 2024-05-01 19:03 UTC (permalink / raw)
  To: Ben Dooks
  Cc: Marc Dietrich, linux-staging, linux-tegra, gregkh, Thierry Reding
In-Reply-To: <2338e58b-1ec2-4500-9675-2d8a3aaa107f@codethink.co.uk>

Hi Ben,

On Mon, 22 Apr 2024, Ben Dooks wrote:

> On 21/04/2024 11:46, Marc Dietrich wrote:
>> The i2c controller needs to read back the data written to its registers.
>> This way we can avoid the long delay in the interrupt handler.
>>
>> Signed-off-by: Marc Dietrich <marvin24@gmx.de>
>> ---
>>   drivers/staging/nvec/nvec.c | 41 ++++++++++++++++++++++---------------
>>   1 file changed, 24 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
>> index 45df190c2f94..214839f51048 100644
>> --- a/drivers/staging/nvec/nvec.c
>> +++ b/drivers/staging/nvec/nvec.c
>> @@ -570,6 +570,22 @@ static void nvec_tx_set(struct nvec_chip *nvec)
>>   		(uint)nvec->tx->size, nvec->tx->data[1]);
>>   }
>>
>> +/**
>> + * i2c_writel - safely write to an I2C client controller register
>> + * @val: value to be written
>> + * @reg: register to write to
>> + *
>> + * A write to an I2C controller register needs to be read back to make
>> sure
>> + * that the value has arrived.
>> + */
>> +static void i2c_writel(u32 val, void *reg)
>> +{
>> +	writel_relaxed(val, reg);
>> +
>> +	/* read back register to make sure that register writes completed */
>> +	readl_relaxed(reg);
>> +}
>
> I thought the default behaviour of writel() should be to force writes
> out of any CPU buffers. Are there any bus isuses here causing the code
> to be necessary (and if so, why is there another buffer breaking the
> writel behaviour?)

if fear that's a question only NVIDIA can answer.

Marc


^ permalink raw reply

* [PATCH] staging: atomisp: Fix spelling mistake in sh_css_internal.h
From: Roshan Khatri @ 2024-05-01 16:26 UTC (permalink / raw)
  To: hdegoede, mchehab, sakari.ailus, gregkh, hpa
  Cc: Roshan Khatri, linux-media, linux-staging, linux-kernel

codespell reported misspelled words still and member.
This patch fixes misspellings.

Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
---
 drivers/staging/media/atomisp/pci/sh_css_internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_internal.h b/drivers/staging/media/atomisp/pci/sh_css_internal.h
index 2349eb4d3767..5395be1ed26b 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_internal.h
+++ b/drivers/staging/media/atomisp/pci/sh_css_internal.h
@@ -509,7 +509,7 @@ struct sh_css_sp_pipeline {
  * of the associated pipe. Dynamic means that the data address can
  * change with every (frame) iteration of the associated pipe
  *
- * s3a and dis are now also dynamic but (stil) handled separately
+ * s3a and dis are now also dynamic but (still) handled separately
  */
 #define SH_CSS_NUM_DYNAMIC_FRAME_IDS (3)
 
@@ -597,7 +597,7 @@ struct sh_css_sp_stage {
 
 /*
  * Time: 2012-07-19, 17:40.
- * Note: Add a new data memeber "debug" in "sh_css_sp_group". This
+ * Note: Add a new data member "debug" in "sh_css_sp_group". This
  * data member is used to pass the debugging command from the
  * Host to the SP.
  *
-- 
2.34.1


^ permalink raw reply related

* Re: [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Greg KH @ 2024-05-01 14:14 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Shahar Avidar, hverkuil-cisco, andriy.shevchenko, robh,
	felixkimbu1, krzysztof.kozlowski, linux-staging, linux-kernel
In-Reply-To: <cc00ea68-0ec9-40af-a147-e8f67f7f29d0@moroto.mountain>

On Wed, May 01, 2024 at 05:00:44PM +0300, Dan Carpenter wrote:
> On Wed, May 01, 2024 at 08:58:19AM +0300, Shahar Avidar wrote:
> > Make use of a higher level API.
> > Reduce global memory allocation from struct class to pointer size.
> 
> Doesn't this move the memory in the opposite direction from what we
> want?  Originally, it's static const.  Isn't that the simplest best
> kind of memory?

Our reviews just crossed...  This is just a revert (in 2 steps oddly),
of a previous commit that changed this api call, and for that reason
alone we can't take it :)

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Greg KH @ 2024-05-01 14:12 UTC (permalink / raw)
  To: Shahar Avidar
  Cc: hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	dan.carpenter, krzysztof.kozlowski, linux-staging, linux-kernel
In-Reply-To: <20240501055820.603272-2-ikobh7@gmail.com>

On Wed, May 01, 2024 at 08:58:19AM +0300, Shahar Avidar wrote:
> Make use of a higher level API.

What does this mean?

> Reduce global memory allocation from struct class to pointer size.

No, you increased memory allocation here, why do you think you reduced
it?

Also, this looks like a revert of commit f267da65bb6b ("staging: pi433:
make pi433_class constant"), accepted a few months ago, why not just
call it out as an explicit revert if that's what you want to do?

class_create is going away "soon", why add this back when people are
working so hard to remove its usage?  What tutorial did you read that
made you want to make this change?

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 2/2] staging: pi433: Rename goto label.
From: Dan Carpenter @ 2024-05-01 14:06 UTC (permalink / raw)
  To: Shahar Avidar
  Cc: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	krzysztof.kozlowski, linux-staging, linux-kernel
In-Reply-To: <20240501055820.603272-3-ikobh7@gmail.com>

On Wed, May 01, 2024 at 08:58:20AM +0300, Shahar Avidar wrote:
> Use destroy_class_and_remove_dbfs instead of unreg_class_and_remove_dbfs.
> 
> Signed-off-by: Shahar Avidar <ikobh7@gmail.com>
> ---
>  drivers/staging/pi433/pi433_if.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
> index c8c1d296184b..4fffd7007040 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -1409,11 +1409,11 @@ static int __init pi433_init(void)
>  
>  	status = spi_register_driver(&pi433_spi_driver);
>  	if (status < 0)
> -		goto unreg_class_and_remove_dbfs;
> +		goto destroy_class_and_remove_dbfs;
>  
>  	return 0;
>  
> -unreg_class_and_remove_dbfs:
> +destroy_class_and_remove_dbfs:
>  	debugfs_remove(root_dir);
>  	class_destroy(pi433_class);

This is cleaning up something which changed in patch 1 so it should have
been done in patch 1.

regards,
dan carpenter

>  unreg_chrdev:
> -- 
> 2.34.1

^ permalink raw reply

* Re: [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Dan Carpenter @ 2024-05-01 14:00 UTC (permalink / raw)
  To: Shahar Avidar
  Cc: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	krzysztof.kozlowski, linux-staging, linux-kernel
In-Reply-To: <20240501055820.603272-2-ikobh7@gmail.com>

On Wed, May 01, 2024 at 08:58:19AM +0300, Shahar Avidar wrote:
> Make use of a higher level API.
> Reduce global memory allocation from struct class to pointer size.

Doesn't this move the memory in the opposite direction from what we
want?  Originally, it's static const.  Isn't that the simplest best
kind of memory?

regards,
dan carpenter


^ permalink raw reply

* [PATCH 2/2] staging: pi433: Rename goto label.
From: Shahar Avidar @ 2024-05-01  5:58 UTC (permalink / raw)
  To: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	dan.carpenter, krzysztof.kozlowski
  Cc: linux-staging, linux-kernel
In-Reply-To: <20240501055820.603272-1-ikobh7@gmail.com>

Use destroy_class_and_remove_dbfs instead of unreg_class_and_remove_dbfs.

Signed-off-by: Shahar Avidar <ikobh7@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index c8c1d296184b..4fffd7007040 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -1409,11 +1409,11 @@ static int __init pi433_init(void)
 
 	status = spi_register_driver(&pi433_spi_driver);
 	if (status < 0)
-		goto unreg_class_and_remove_dbfs;
+		goto destroy_class_and_remove_dbfs;
 
 	return 0;
 
-unreg_class_and_remove_dbfs:
+destroy_class_and_remove_dbfs:
 	debugfs_remove(root_dir);
 	class_destroy(pi433_class);
 unreg_chrdev:
-- 
2.34.1


^ permalink raw reply related

* [PATCH 1/2] staging: pi433: Use class_create instead of class_register.
From: Shahar Avidar @ 2024-05-01  5:58 UTC (permalink / raw)
  To: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	dan.carpenter, krzysztof.kozlowski
  Cc: linux-staging, linux-kernel
In-Reply-To: <20240501055820.603272-1-ikobh7@gmail.com>

Make use of a higher level API.
Reduce global memory allocation from struct class to pointer size.

Signed-off-by: Shahar Avidar <ikobh7@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 31aeabb1f153..c8c1d296184b 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -59,9 +59,7 @@ static DEFINE_MUTEX(minor_lock); /* Protect idr accesses */
 static struct dentry *root_dir;	/* debugfs root directory for the driver */
 
 /* mainly for udev to create /dev/pi433 */
-static const struct class pi433_class = {
-	.name = "pi433",
-};
+static const struct class *pi433_class;
 
 /*
  * tx config is instance specific
@@ -1263,7 +1261,7 @@ static int pi433_probe(struct spi_device *spi)
 
 	/* create device */
 	pi433->devt = MKDEV(MAJOR(pi433_devt), pi433->minor);
-	pi433->dev = device_create(&pi433_class,
+	pi433->dev = device_create(pi433_class,
 				   &spi->dev,
 				   pi433->devt,
 				   pi433,
@@ -1319,7 +1317,7 @@ static int pi433_probe(struct spi_device *spi)
 cdev_failed:
 	kthread_stop(pi433->tx_task_struct);
 send_thread_failed:
-	device_destroy(&pi433_class, pi433->devt);
+	device_destroy(pi433_class, pi433->devt);
 device_create_failed:
 	pi433_free_minor(pi433);
 minor_failed:
@@ -1346,7 +1344,7 @@ static void pi433_remove(struct spi_device *spi)
 
 	kthread_stop(pi433->tx_task_struct);
 
-	device_destroy(&pi433_class, pi433->devt);
+	device_destroy(pi433_class, pi433->devt);
 
 	cdev_del(pi433->cdev);
 
@@ -1401,9 +1399,11 @@ static int __init pi433_init(void)
 	if (status < 0)
 		return status;
 
-	status = class_register(&pi433_class);
-	if (status)
+	pi433_class = class_create("pi433");
+	if (IS_ERR(pi433_class)) {
+		status = PTR_ERR(pi433_class);
 		goto unreg_chrdev;
+	}
 
 	root_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
 
@@ -1415,7 +1415,7 @@ static int __init pi433_init(void)
 
 unreg_class_and_remove_dbfs:
 	debugfs_remove(root_dir);
-	class_unregister(&pi433_class);
+	class_destroy(pi433_class);
 unreg_chrdev:
 	unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name);
 	return status;
@@ -1427,7 +1427,7 @@ static void __exit pi433_exit(void)
 {
 	spi_unregister_driver(&pi433_spi_driver);
 	debugfs_remove(root_dir);
-	class_unregister(&pi433_class);
+	class_destroy(pi433_class);
 	unregister_chrdev(MAJOR(pi433_devt), pi433_spi_driver.driver.name);
 }
 module_exit(pi433_exit);

base-commit: 75ff53c44f5e151d21d949416633b56e56160124
prerequisite-patch-id: 91943193af2fea74182be67fb583235a3fbeb77b
prerequisite-patch-id: 2cad031ba6a0782a67ab1645ff034a8be65c2e76
prerequisite-patch-id: 1a852ed8f9d133aec7c651fd9007e59e39c55fb7
-- 
2.34.1


^ permalink raw reply related

* [PATCH 0/2] staging: pi433: Use class_create API.
From: Shahar Avidar @ 2024-05-01  5:58 UTC (permalink / raw)
  To: gregkh, hverkuil-cisco, andriy.shevchenko, robh, felixkimbu1,
	dan.carpenter, krzysztof.kozlowski
  Cc: linux-staging, linux-kernel

This patchset reduces static allocated memory by using class_create
instead of class_register.

Shahar Avidar (2):
  staging: pi433: Use class_create instead of class_register.
  staging: pi433: Rename goto label.

 drivers/staging/pi433/pi433_if.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)


base-commit: 75ff53c44f5e151d21d949416633b56e56160124
prerequisite-patch-id: 91943193af2fea74182be67fb583235a3fbeb77b
prerequisite-patch-id: 2cad031ba6a0782a67ab1645ff034a8be65c2e76
prerequisite-patch-id: 1a852ed8f9d133aec7c651fd9007e59e39c55fb7
-- 
2.34.1


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox