diff mbox series

[1/1] media: Documentation: mc: Add media_device_{init,cleanup}

Message ID 20220309171006.12327-1-sakari.ailus@linux.intel.com
State Accepted
Commit 1d1d8669e5ca669267e87ffc94f6d26e62fcd867
Headers show
Series [1/1] media: Documentation: mc: Add media_device_{init,cleanup} | expand

Commit Message

Sakari Ailus March 9, 2022, 5:10 p.m. UTC
Document that drivers must first initialise a media device before
registering it, and clean up once the media device is unregistered.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 Documentation/driver-api/media/mc-core.rst | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Sakari Ailus April 29, 2022, 8:14 a.m. UTC | #1
Hi Laurent,

On Wed, Mar 09, 2022 at 07:14:58PM +0200, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Wed, Mar 09, 2022 at 07:10:06PM +0200, Sakari Ailus wrote:
> > Document that drivers must first initialise a media device before
> > registering it, and clean up once the media device is unregistered.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  Documentation/driver-api/media/mc-core.rst | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/Documentation/driver-api/media/mc-core.rst b/Documentation/driver-api/media/mc-core.rst
> > index 57b5bbba944e..02481a2513b9 100644
> > --- a/Documentation/driver-api/media/mc-core.rst
> > +++ b/Documentation/driver-api/media/mc-core.rst
> > @@ -42,9 +42,16 @@ Allocation of the structure is handled by the media device driver, usually by
> >  embedding the :c:type:`media_device` instance in a larger driver-specific
> >  structure.
> >  
> > -Drivers register media device instances by calling
> > -:c:func:`__media_device_register()` via the macro ``media_device_register()``
> > -and unregistered by calling :c:func:`media_device_unregister()`.
> > +Drivers initialise media device instances by calling
> > +:c:func:`media_device_init()`. After initialising a media device instance, it is
> > +registered by calling :c:func:`__media_device_register()` via the macro
> > +``media_device_register()`` and unregistered by calling
> > +:c:func:`media_device_unregister()`. An initialised media device must be
> > +eventually cleaned up by calling :c:func:`media_device_cleanup()`.
> > +
> > +Note that it is not allowed to unregister a media device instance that was not
> > +previously registered, or clean up a media device instance that was not
> > +previously initialised.
> 
> Could we fix this, to simplify drivers ? This patch is fine as it

I think this could be thought with object lifetime.

> documents the current behaviour, so
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks!
diff mbox series

Patch

diff --git a/Documentation/driver-api/media/mc-core.rst b/Documentation/driver-api/media/mc-core.rst
index 57b5bbba944e..02481a2513b9 100644
--- a/Documentation/driver-api/media/mc-core.rst
+++ b/Documentation/driver-api/media/mc-core.rst
@@ -42,9 +42,16 @@  Allocation of the structure is handled by the media device driver, usually by
 embedding the :c:type:`media_device` instance in a larger driver-specific
 structure.
 
-Drivers register media device instances by calling
-:c:func:`__media_device_register()` via the macro ``media_device_register()``
-and unregistered by calling :c:func:`media_device_unregister()`.
+Drivers initialise media device instances by calling
+:c:func:`media_device_init()`. After initialising a media device instance, it is
+registered by calling :c:func:`__media_device_register()` via the macro
+``media_device_register()`` and unregistered by calling
+:c:func:`media_device_unregister()`. An initialised media device must be
+eventually cleaned up by calling :c:func:`media_device_cleanup()`.
+
+Note that it is not allowed to unregister a media device instance that was not
+previously registered, or clean up a media device instance that was not
+previously initialised.
 
 Entities
 ^^^^^^^^