diff mbox series

[v2,4/4] v4l: async, fwnode: Improve module organisation

Message ID 20210312125657.25442-5-sakari.ailus@linux.intel.com
State New
Headers show
Series Knead V4L2 async and fwnode frameworks a little | expand

Commit Message

Sakari Ailus March 12, 2021, 12:56 p.m. UTC
The V4L2 async framework is generally used with the V4L2 fwnode, which
also depends on the former. There is only one exception, the CAFE_CCIC
driver, which uses V4L2 async but does not need V4L2 fwnode.

At the same time there is a vast number of systems that need videodev
module, but have no use for v4l2-async that's now part of videodev.

In order to improve, build v4l2-async and v4l2-fwnode as a single module
called v4l2-async (the v4l2-async.c file is renamed as v4l2-async-core.c).
Also the menu item V4L2_FWNODE is renamed as V4L2_ASYNC.

This also moves the initialisation of the debufs entries for async subdevs
to loading of the v4l2-async module. The directory is named as
"v4l2-async".

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/Kconfig            |  8 ++++++++
 drivers/media/v4l2-core/Kconfig      |  4 ++++
 drivers/media/v4l2-core/Makefile     | 11 +++++++++--
 drivers/media/v4l2-core/v4l2-async.c | 23 +++++++++++++++++++++--
 drivers/media/v4l2-core/v4l2-dev.c   |  5 -----
 5 files changed, 42 insertions(+), 9 deletions(-)

Comments

Ezequiel Garcia March 23, 2021, 5:46 p.m. UTC | #1
On Fri, 2021-03-12 at 14:56 +0200, Sakari Ailus wrote:
> The V4L2 async framework is generally used with the V4L2 fwnode, which

> also depends on the former. There is only one exception, the CAFE_CCIC

> driver, which uses V4L2 async but does not need V4L2 fwnode.

> 

> At the same time there is a vast number of systems that need videodev

> module, but have no use for v4l2-async that's now part of videodev.

> 

> In order to improve, build v4l2-async and v4l2-fwnode as a single module

> called v4l2-async (the v4l2-async.c file is renamed as v4l2-async-core.c).

> Also the menu item V4L2_FWNODE is renamed as V4L2_ASYNC.

> 


Seems this is not what this patch is doing: the symbol is not renamed,
and now we have two modules v4l2-fwnode.ko and v4l2-async.ko, unless
I'm confused.

I personally was more fond of having just one v4l2-async.ko module,
but I'm not sure if you found any obstacles.

> This also moves the initialisation of the debufs entries for async subdevs

> to loading of the v4l2-async module. The directory is named as

> "v4l2-async".

> 

> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> ---

>  drivers/media/i2c/Kconfig            |  8 ++++++++

>  drivers/media/v4l2-core/Kconfig      |  4 ++++

>  drivers/media/v4l2-core/Makefile     | 11 +++++++++--

>  drivers/media/v4l2-core/v4l2-async.c | 23 +++++++++++++++++++++--

>  drivers/media/v4l2-core/v4l2-dev.c   |  5 -----

>  5 files changed, 42 insertions(+), 9 deletions(-)

> 

[..]
> diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile

> index e4cd589b99a5..eb5ebb5461fd 100644

> --- a/drivers/media/v4l2-core/Makefile

> +++ b/drivers/media/v4l2-core/Makefile

> @@ -7,15 +7,22 @@ tuner-objs    :=      tuner-core.o

>  

>  videodev-objs  :=      v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \

>                         v4l2-event.o v4l2-ctrls.o v4l2-subdev.o \

> -                       v4l2-async.o v4l2-common.o

> +                       v4l2-common.o

>  videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o

>  videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o

>  videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o

>  videodev-$(CONFIG_SPI) += v4l2-spi.o

>  videodev-$(CONFIG_VIDEO_V4L2_I2C) += v4l2-i2c.o

>  

> -obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o

>  obj-$(CONFIG_VIDEO_V4L2) += videodev.o

> +ifneq ($(findstring y,$(CONFIG_V4L2_ASYNC)$(CONFIG_V4L2_FWNODE)),)


Hm, to me this ifdefery is an indication that we are trying
to do something fishy.

Regards,
Ezequiel
Sakari Ailus March 23, 2021, 7:27 p.m. UTC | #2
Hi Ezequiel,

On Tue, Mar 23, 2021 at 02:46:04PM -0300, Ezequiel Garcia wrote:
> On Fri, 2021-03-12 at 14:56 +0200, Sakari Ailus wrote:

> > The V4L2 async framework is generally used with the V4L2 fwnode, which

> > also depends on the former. There is only one exception, the CAFE_CCIC

> > driver, which uses V4L2 async but does not need V4L2 fwnode.

> > 

> > At the same time there is a vast number of systems that need videodev

> > module, but have no use for v4l2-async that's now part of videodev.

> > 

> > In order to improve, build v4l2-async and v4l2-fwnode as a single module

> > called v4l2-async (the v4l2-async.c file is renamed as v4l2-async-core.c).

> > Also the menu item V4L2_FWNODE is renamed as V4L2_ASYNC.

> > 

> 

> Seems this is not what this patch is doing: the symbol is not renamed,

> and now we have two modules v4l2-fwnode.ko and v4l2-async.ko, unless

> I'm confused.


Oh, well, I changed what the patch does but forgot to update this. :-I

Basically this now splits v4l2-async out of videodev.

> 

> I personally was more fond of having just one v4l2-async.ko module,

> but I'm not sure if you found any obstacles.

> 

> > This also moves the initialisation of the debufs entries for async subdevs

> > to loading of the v4l2-async module. The directory is named as

> > "v4l2-async".

> > 

> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> > ---

> >  drivers/media/i2c/Kconfig            |  8 ++++++++

> >  drivers/media/v4l2-core/Kconfig      |  4 ++++

> >  drivers/media/v4l2-core/Makefile     | 11 +++++++++--

> >  drivers/media/v4l2-core/v4l2-async.c | 23 +++++++++++++++++++++--

> >  drivers/media/v4l2-core/v4l2-dev.c   |  5 -----

> >  5 files changed, 42 insertions(+), 9 deletions(-)

> > 

> [..]

> > diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile

> > index e4cd589b99a5..eb5ebb5461fd 100644

> > --- a/drivers/media/v4l2-core/Makefile

> > +++ b/drivers/media/v4l2-core/Makefile

> > @@ -7,15 +7,22 @@ tuner-objs    :=      tuner-core.o

> >  

> >  videodev-objs  :=      v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \

> >                         v4l2-event.o v4l2-ctrls.o v4l2-subdev.o \

> > -                       v4l2-async.o v4l2-common.o

> > +                       v4l2-common.o

> >  videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o

> >  videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o

> >  videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o

> >  videodev-$(CONFIG_SPI) += v4l2-spi.o

> >  videodev-$(CONFIG_VIDEO_V4L2_I2C) += v4l2-i2c.o

> >  

> > -obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o

> >  obj-$(CONFIG_VIDEO_V4L2) += videodev.o

> > +ifneq ($(findstring y,$(CONFIG_V4L2_ASYNC)$(CONFIG_V4L2_FWNODE)),)

> 

> Hm, to me this ifdefery is an indication that we are trying

> to do something fishy.


What's happening here is that v4l2-fwnode depends on v4l2-async, but for
drivers to avoid selecting both, v4l2-async is built if only
CONFIG_V4L2_FWNODE is set.

So this perhaps isn't too pretty but it saves hassle in Kconfig files.

-- 
Kind regards,

Sakari Ailus
Ezequiel Garcia March 28, 2021, 1:27 p.m. UTC | #3
On Tue, 2021-03-23 at 21:27 +0200, Sakari Ailus wrote:
> Hi Ezequiel,

> 

> On Tue, Mar 23, 2021 at 02:46:04PM -0300, Ezequiel Garcia wrote:

> > On Fri, 2021-03-12 at 14:56 +0200, Sakari Ailus wrote:

> > > The V4L2 async framework is generally used with the V4L2 fwnode, which

> > > also depends on the former. There is only one exception, the CAFE_CCIC

> > > driver, which uses V4L2 async but does not need V4L2 fwnode.

> > > 

> > > At the same time there is a vast number of systems that need videodev

> > > module, but have no use for v4l2-async that's now part of videodev.

> > > 

> > > In order to improve, build v4l2-async and v4l2-fwnode as a single module

> > > called v4l2-async (the v4l2-async.c file is renamed as v4l2-async-core.c).

> > > Also the menu item V4L2_FWNODE is renamed as V4L2_ASYNC.

> > > 

> > 

> > Seems this is not what this patch is doing: the symbol is not renamed,

> > and now we have two modules v4l2-fwnode.ko and v4l2-async.ko, unless

> > I'm confused.

> 

> Oh, well, I changed what the patch does but forgot to update this. :-I

> 

> Basically this now splits v4l2-async out of videodev.

> 

> > 

> > I personally was more fond of having just one v4l2-async.ko module,

> > but I'm not sure if you found any obstacles.

> > 

> > > This also moves the initialisation of the debufs entries for async subdevs

> > > to loading of the v4l2-async module. The directory is named as

> > > "v4l2-async".

> > > 

> > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> > > ---

> > >  drivers/media/i2c/Kconfig            |  8 ++++++++

> > >  drivers/media/v4l2-core/Kconfig      |  4 ++++

> > >  drivers/media/v4l2-core/Makefile     | 11 +++++++++--

> > >  drivers/media/v4l2-core/v4l2-async.c | 23 +++++++++++++++++++++--

> > >  drivers/media/v4l2-core/v4l2-dev.c   |  5 -----

> > >  5 files changed, 42 insertions(+), 9 deletions(-)

> > > 

> > [..]

> > > diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile

> > > index e4cd589b99a5..eb5ebb5461fd 100644

> > > --- a/drivers/media/v4l2-core/Makefile

> > > +++ b/drivers/media/v4l2-core/Makefile

> > > @@ -7,15 +7,22 @@ tuner-objs    :=      tuner-core.o

> > >  

> > >  videodev-objs  :=      v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \

> > >                         v4l2-event.o v4l2-ctrls.o v4l2-subdev.o \

> > > -                       v4l2-async.o v4l2-common.o

> > > +                       v4l2-common.o

> > >  videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o

> > >  videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o

> > >  videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o

> > >  videodev-$(CONFIG_SPI) += v4l2-spi.o

> > >  videodev-$(CONFIG_VIDEO_V4L2_I2C) += v4l2-i2c.o

> > >  

> > > -obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o

> > >  obj-$(CONFIG_VIDEO_V4L2) += videodev.o

> > > +ifneq ($(findstring y,$(CONFIG_V4L2_ASYNC)$(CONFIG_V4L2_FWNODE)),)

> > 

> > Hm, to me this ifdefery is an indication that we are trying

> > to do something fishy.

> 

> What's happening here is that v4l2-fwnode depends on v4l2-async, but for

> drivers to avoid selecting both, v4l2-async is built if only

> CONFIG_V4L2_FWNODE is set.

> 

> So this perhaps isn't too pretty but it saves hassle in Kconfig files.

> 


How about:

v4l2-async-objs := v4l2-async-core.o
v4l2-async-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
obj-$(CONFIG_V4L2_ASYNC) += v4l2-async.o

config V4L2_FWNODE
        bool
        select V4L2_ASYNC

config V4L2_ASYNC
        tristate

This avoids the ifdefs and expresses the same behavior
you stated above:

* v4l2-async is now out of videodev
* v4l2-fwnode depends on v4l2-async (through select in this case,
  given they are helper modules).
* v4l2-async is built if CONFIG_V4L2_FWNODE is set.

And v4l2-async is a module or built-in, depending on the
media subsystem (MEDIA_SUPPORT) being module or built-in,
which I think makes sense.

Thanks,
Ezequiel
Sakari Ailus April 30, 2021, 7:03 a.m. UTC | #4
Hi Ezequiel,

On Sun, Mar 28, 2021 at 10:27:35AM -0300, Ezequiel Garcia wrote:
> On Tue, 2021-03-23 at 21:27 +0200, Sakari Ailus wrote:

> > Hi Ezequiel,

> > 

> > On Tue, Mar 23, 2021 at 02:46:04PM -0300, Ezequiel Garcia wrote:

> > > On Fri, 2021-03-12 at 14:56 +0200, Sakari Ailus wrote:

> > > > The V4L2 async framework is generally used with the V4L2 fwnode, which

> > > > also depends on the former. There is only one exception, the CAFE_CCIC

> > > > driver, which uses V4L2 async but does not need V4L2 fwnode.

> > > > 

> > > > At the same time there is a vast number of systems that need videodev

> > > > module, but have no use for v4l2-async that's now part of videodev.

> > > > 

> > > > In order to improve, build v4l2-async and v4l2-fwnode as a single module

> > > > called v4l2-async (the v4l2-async.c file is renamed as v4l2-async-core.c).

> > > > Also the menu item V4L2_FWNODE is renamed as V4L2_ASYNC.

> > > > 

> > > 

> > > Seems this is not what this patch is doing: the symbol is not renamed,

> > > and now we have two modules v4l2-fwnode.ko and v4l2-async.ko, unless

> > > I'm confused.

> > 

> > Oh, well, I changed what the patch does but forgot to update this. :-I

> > 

> > Basically this now splits v4l2-async out of videodev.

> > 

> > > 

> > > I personally was more fond of having just one v4l2-async.ko module,

> > > but I'm not sure if you found any obstacles.

> > > 

> > > > This also moves the initialisation of the debufs entries for async subdevs

> > > > to loading of the v4l2-async module. The directory is named as

> > > > "v4l2-async".

> > > > 

> > > > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> > > > ---

> > > >  drivers/media/i2c/Kconfig            |  8 ++++++++

> > > >  drivers/media/v4l2-core/Kconfig      |  4 ++++

> > > >  drivers/media/v4l2-core/Makefile     | 11 +++++++++--

> > > >  drivers/media/v4l2-core/v4l2-async.c | 23 +++++++++++++++++++++--

> > > >  drivers/media/v4l2-core/v4l2-dev.c   |  5 -----

> > > >  5 files changed, 42 insertions(+), 9 deletions(-)

> > > > 

> > > [..]

> > > > diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile

> > > > index e4cd589b99a5..eb5ebb5461fd 100644

> > > > --- a/drivers/media/v4l2-core/Makefile

> > > > +++ b/drivers/media/v4l2-core/Makefile

> > > > @@ -7,15 +7,22 @@ tuner-objs    :=      tuner-core.o

> > > >  

> > > >  videodev-objs  :=      v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \

> > > >                         v4l2-event.o v4l2-ctrls.o v4l2-subdev.o \

> > > > -                       v4l2-async.o v4l2-common.o

> > > > +                       v4l2-common.o

> > > >  videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o

> > > >  videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o

> > > >  videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o

> > > >  videodev-$(CONFIG_SPI) += v4l2-spi.o

> > > >  videodev-$(CONFIG_VIDEO_V4L2_I2C) += v4l2-i2c.o

> > > >  

> > > > -obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o

> > > >  obj-$(CONFIG_VIDEO_V4L2) += videodev.o

> > > > +ifneq ($(findstring y,$(CONFIG_V4L2_ASYNC)$(CONFIG_V4L2_FWNODE)),)

> > > 

> > > Hm, to me this ifdefery is an indication that we are trying

> > > to do something fishy.

> > 

> > What's happening here is that v4l2-fwnode depends on v4l2-async, but for

> > drivers to avoid selecting both, v4l2-async is built if only

> > CONFIG_V4L2_FWNODE is set.

> > 

> > So this perhaps isn't too pretty but it saves hassle in Kconfig files.

> > 

> 

> How about:

> 

> v4l2-async-objs := v4l2-async-core.o

> v4l2-async-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o

> obj-$(CONFIG_V4L2_ASYNC) += v4l2-async.o

> 

> config V4L2_FWNODE

>         bool

>         select V4L2_ASYNC


Drivers are using select to enable V4L2_FWNODE. Select will select the
config option but will not care about its dependencies, i.e. V4L2_ASYNC in
this case.

I guess another option could be just to sprinkle both in Kconfig files as
needed.

I'm fraknkly not too concerned about the few lines in the Makefile. If
there's a need to get rid of them, there's always an easy way to get rid of
it.

> 

> config V4L2_ASYNC

>         tristate

> 

> This avoids the ifdefs and expresses the same behavior

> you stated above:

> 

> * v4l2-async is now out of videodev

> * v4l2-fwnode depends on v4l2-async (through select in this case,

>   given they are helper modules).

> * v4l2-async is built if CONFIG_V4L2_FWNODE is set.

> 

> And v4l2-async is a module or built-in, depending on the

> media subsystem (MEDIA_SUPPORT) being module or built-in,

> which I think makes sense.


-- 
Kind regards,

Sakari Ailus
diff mbox series

Patch

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 462c0e059754..4326e50c13c9 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -217,6 +217,7 @@  config VIDEO_ADV7180
 	depends on GPIOLIB && VIDEO_V4L2 && I2C
 	select MEDIA_CONTROLLER
 	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_ASYNC
 	help
 	  Support for the Analog Devices ADV7180 video decoder.
 
@@ -1341,6 +1342,7 @@  config VIDEO_AD5820
 	tristate "AD5820 lens voice coil support"
 	depends on GPIOLIB && I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
+	select V4L2_ASYNC
 	help
 	  This is a driver for the AD5820 camera lens voice coil.
 	  It is used for example in Nokia N900 (RX-51).
@@ -1350,6 +1352,7 @@  config VIDEO_AK7375
 	depends on I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
 	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_ASYNC
 	help
 	  This is a driver for the AK7375 camera lens voice coil.
 	  AK7375 is a 12 bit DAC with 120mA output current sink
@@ -1361,6 +1364,7 @@  config VIDEO_DW9714
 	depends on I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
 	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_ASYNC
 	help
 	  This is a driver for the DW9714 camera lens voice coil.
 	  DW9714 is a 10 bit DAC with 120mA output current sink
@@ -1384,6 +1388,7 @@  config VIDEO_DW9807_VCM
 	depends on I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
 	select VIDEO_V4L2_SUBDEV_API
+	select V4L2_ASYNC
 	help
 	  This is a driver for the DW9807 camera lens voice coil.
 	  DW9807 is a 10 bit DAC with 100mA output current sink
@@ -1399,6 +1404,7 @@  config VIDEO_ADP1653
 	tristate "ADP1653 flash support"
 	depends on I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
+	select V4L2_ASYNC
 	help
 	  This is a driver for the ADP1653 flash controller. It is used for
 	  example in Nokia N900.
@@ -1408,6 +1414,7 @@  config VIDEO_LM3560
 	depends on I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
 	select REGMAP_I2C
+	select V4L2_ASYNC
 	help
 	  This is a driver for the lm3560 dual flash controllers. It controls
 	  flash, torch LEDs.
@@ -1417,6 +1424,7 @@  config VIDEO_LM3646
 	depends on I2C && VIDEO_V4L2
 	select MEDIA_CONTROLLER
 	select REGMAP_I2C
+	select V4L2_ASYNC
 	help
 	  This is a driver for the lm3646 dual flash controllers. It controls
 	  flash, torch LEDs.
diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig
index bf49f83cb86f..61b023b56d75 100644
--- a/drivers/media/v4l2-core/Kconfig
+++ b/drivers/media/v4l2-core/Kconfig
@@ -62,6 +62,7 @@  config V4L2_FLASH_LED_CLASS
 	tristate "V4L2 flash API for LED flash class devices"
 	depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
 	depends on LEDS_CLASS_FLASH
+	select V4L2_ASYNC
 	help
 	  Say Y here to enable V4L2 flash API support for LED flash
 	  class drivers.
@@ -71,6 +72,9 @@  config V4L2_FLASH_LED_CLASS
 config V4L2_FWNODE
 	tristate
 
+config V4L2_ASYNC
+	tristate
+
 # Used by drivers that need Videobuf modules
 config VIDEOBUF_GEN
 	tristate
diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile
index e4cd589b99a5..eb5ebb5461fd 100644
--- a/drivers/media/v4l2-core/Makefile
+++ b/drivers/media/v4l2-core/Makefile
@@ -7,15 +7,22 @@  tuner-objs	:=	tuner-core.o
 
 videodev-objs	:=	v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
 			v4l2-event.o v4l2-ctrls.o v4l2-subdev.o \
-			v4l2-async.o v4l2-common.o
+			v4l2-common.o
 videodev-$(CONFIG_COMPAT) += v4l2-compat-ioctl32.o
 videodev-$(CONFIG_TRACEPOINTS) += v4l2-trace.o
 videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o
 videodev-$(CONFIG_SPI) += v4l2-spi.o
 videodev-$(CONFIG_VIDEO_V4L2_I2C) += v4l2-i2c.o
 
-obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
 obj-$(CONFIG_VIDEO_V4L2) += videodev.o
+ifneq ($(findstring y,$(CONFIG_V4L2_ASYNC)$(CONFIG_V4L2_FWNODE)),)
+obj-y += v4l2-async.o
+else
+ifneq ($(findstring m,$(CONFIG_V4L2_ASYNC)$(CONFIG_V4L2_FWNODE)),)
+obj-m += v4l2-async.o
+endif
+endif
+obj-$(CONFIG_V4L2_FWNODE) += v4l2-fwnode.o
 obj-$(CONFIG_VIDEO_V4L2) += v4l2-dv-timings.o
 
 obj-$(CONFIG_VIDEO_TUNER) += tuner.o
diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index 21b3890b96fc..6e49386f0284 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -852,8 +852,27 @@  static int pending_subdevs_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(pending_subdevs);
 
-void v4l2_async_debug_init(struct dentry *debugfs_dir)
+static struct dentry *v4l2_async_debugfs_dir;
+
+static int __init v4l2_async_init(void)
 {
-	debugfs_create_file("pending_async_subdevices", 0444, debugfs_dir, NULL,
+	v4l2_async_debugfs_dir = debugfs_create_dir("v4l2-async", NULL);
+	debugfs_create_file("pending_async_subdevices", 0444,
+			    v4l2_async_debugfs_dir, NULL,
 			    &pending_subdevs_fops);
+
+	return 0;
+}
+
+static void __exit v4l2_async_exit(void)
+{
+	debugfs_remove_recursive(v4l2_async_debugfs_dir);
 }
+
+subsys_initcall(v4l2_async_init);
+module_exit(v4l2_async_exit);
+
+MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
+MODULE_AUTHOR("Sakari Ailus <sakari.ailus@linux.intel.com>");
+MODULE_AUTHOR("Ezequiel Garcia <ezequiel@collabora.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index b6a72d297775..5002e3cd110f 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -39,8 +39,6 @@ 
 		       __func__, ##arg);				\
 } while (0)
 
-static struct dentry *v4l2_debugfs_dir;
-
 /*
  *	sysfs stuff
  */
@@ -1120,8 +1118,6 @@  static int __init videodev_init(void)
 		return -EIO;
 	}
 
-	v4l2_debugfs_dir = debugfs_create_dir("video4linux", NULL);
-	v4l2_async_debug_init(v4l2_debugfs_dir);
 	return 0;
 }
 
@@ -1129,7 +1125,6 @@  static void __exit videodev_exit(void)
 {
 	dev_t dev = MKDEV(VIDEO_MAJOR, 0);
 
-	debugfs_remove_recursive(v4l2_debugfs_dir);
 	class_unregister(&video_class);
 	unregister_chrdev_region(dev, VIDEO_NUM_DEVICES);
 }