linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times
@ 2017-02-14 13:40 Pavel Machek
  2017-02-14 22:02 ` Sakari Ailus
  0 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2017-02-14 13:40 UTC (permalink / raw)
  To: sakari.ailus
  Cc: sre, pali.rohar, pavel, linux-media, linux-kernel,
	laurent.pinchart, mchehab, ivo.g.dimitrov.75

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

From: Sebastian Reichel <sre@kernel.org>

Without this, exposure / gain controls do not work in the camera application.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
 drivers/media/v4l2-core/v4l2-device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index f364cc1..b3afbe8 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
 		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
 			continue;
 
+		if(sd->devnode)
+			continue;
+
 		vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
 		if (!vdev) {
 			err = -ENOMEM;
-- 
2.1.4


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times
  2017-02-14 13:40 [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times Pavel Machek
@ 2017-02-14 22:02 ` Sakari Ailus
  2017-02-14 22:06   ` Laurent Pinchart
  2017-02-14 22:29   ` Pavel Machek
  0 siblings, 2 replies; 5+ messages in thread
From: Sakari Ailus @ 2017-02-14 22:02 UTC (permalink / raw)
  To: Pavel Machek
  Cc: sre, pali.rohar, linux-media, linux-kernel, laurent.pinchart,
	mchehab, ivo.g.dimitrov.75

Hi Pavel and Sebastian,

On Tue, Feb 14, 2017 at 02:40:00PM +0100, Pavel Machek wrote:
> From: Sebastian Reichel <sre@kernel.org>
> 
> Without this, exposure / gain controls do not work in the camera application.

:-)

> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> Signed-off-by: Pavel Machek <pavel@ucw.cz>
> ---
>  drivers/media/v4l2-core/v4l2-device.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
> index f364cc1..b3afbe8 100644
> --- a/drivers/media/v4l2-core/v4l2-device.c
> +++ b/drivers/media/v4l2-core/v4l2-device.c
> @@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
>  		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
>  			continue;
>  
> +		if(sd->devnode)
> +			continue;

This has been recognised as a problem but you're the first to submit a patch
I believe. Please add an appropriate description. :-)

s/if\(/if (/

I think this one should go in before the rest.

> +
>  		vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
>  		if (!vdev) {
>  			err = -ENOMEM;

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times
  2017-02-14 22:02 ` Sakari Ailus
@ 2017-02-14 22:06   ` Laurent Pinchart
  2017-02-14 22:11     ` Sakari Ailus
  2017-02-14 22:29   ` Pavel Machek
  1 sibling, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2017-02-14 22:06 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Pavel Machek, sre, pali.rohar, linux-media, linux-kernel,
	mchehab, ivo.g.dimitrov.75

Hi Sakari,

On Wednesday 15 Feb 2017 00:02:57 Sakari Ailus wrote:
> On Tue, Feb 14, 2017 at 02:40:00PM +0100, Pavel Machek wrote:
> > From: Sebastian Reichel <sre@kernel.org>
> > 
> > Without this, exposure / gain controls do not work in the camera
> > application.:
> :-)
> :
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> > Signed-off-by: Pavel Machek <pavel@ucw.cz>
> > ---
> > 
> >  drivers/media/v4l2-core/v4l2-device.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-device.c
> > b/drivers/media/v4l2-core/v4l2-device.c index f364cc1..b3afbe8 100644
> > --- a/drivers/media/v4l2-core/v4l2-device.c
> > +++ b/drivers/media/v4l2-core/v4l2-device.c
> > @@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct
> > v4l2_device *v4l2_dev)
> >  		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
> >  			continue;
> > 
> > +		if(sd->devnode)
> > +			continue;
> 
> This has been recognised as a problem but you're the first to submit a patch
> I believe. Please add an appropriate description. :-)
> 
> s/if\(/if (/
> 
> I think this one should go in before the rest.

But how can this happen ? Is v4l2_device_register_subdev_nodes() called 
multiple times ? Do we want to allow that ?

> > +
> >  		vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
> >  		if (!vdev) {
> >  			err = -ENOMEM;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times
  2017-02-14 22:06   ` Laurent Pinchart
@ 2017-02-14 22:11     ` Sakari Ailus
  0 siblings, 0 replies; 5+ messages in thread
From: Sakari Ailus @ 2017-02-14 22:11 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Pavel Machek, sre, pali.rohar, linux-media, linux-kernel,
	mchehab, ivo.g.dimitrov.75

Hi Laurent,

On Wed, Feb 15, 2017 at 12:06:17AM +0200, Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Wednesday 15 Feb 2017 00:02:57 Sakari Ailus wrote:
> > On Tue, Feb 14, 2017 at 02:40:00PM +0100, Pavel Machek wrote:
> > > From: Sebastian Reichel <sre@kernel.org>
> > > 
> > > Without this, exposure / gain controls do not work in the camera
> > > application.:
> > :-)
> > :
> > > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > > Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> > > Signed-off-by: Pavel Machek <pavel@ucw.cz>
> > > ---
> > > 
> > >  drivers/media/v4l2-core/v4l2-device.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/media/v4l2-core/v4l2-device.c
> > > b/drivers/media/v4l2-core/v4l2-device.c index f364cc1..b3afbe8 100644
> > > --- a/drivers/media/v4l2-core/v4l2-device.c
> > > +++ b/drivers/media/v4l2-core/v4l2-device.c
> > > @@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct
> > > v4l2_device *v4l2_dev)
> > >  		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
> > >  			continue;
> > > 
> > > +		if(sd->devnode)
> > > +			continue;
> > 
> > This has been recognised as a problem but you're the first to submit a patch
> > I believe. Please add an appropriate description. :-)
> > 
> > s/if\(/if (/
> > 
> > I think this one should go in before the rest.
> 
> But how can this happen ? Is v4l2_device_register_subdev_nodes() called 
> multiple times ? Do we want to allow that ?

A driver could do this even accidentally. It's much better to do the right
thing than to start corrupting system memory sooner or later.

In the future we'll need to be able to dynamically register device nodes
after the registration of the original device nodes in a media device has
completed anyway. I don't think this would be the means for that though.

What happens here though is that both the video bus switch and isp notifiers
completing will call the function, thus ending up trying to register many of
the nodes twice. Philipp had a different approach to the problem ---
postponing the complete until add the sub-devices have been bound. The patch
is called "v4l2-async: allow subdevices to add further subdevices to the
notifier waiting list".

-- 
Kind regards,

Sakari Ailus
e-mail: sakari.ailus@iki.fi	XMPP: sailus@retiisi.org.uk

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times
  2017-02-14 22:02 ` Sakari Ailus
  2017-02-14 22:06   ` Laurent Pinchart
@ 2017-02-14 22:29   ` Pavel Machek
  1 sibling, 0 replies; 5+ messages in thread
From: Pavel Machek @ 2017-02-14 22:29 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: sre, pali.rohar, linux-media, linux-kernel, laurent.pinchart,
	mchehab, ivo.g.dimitrov.75

[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]

On Wed 2017-02-15 00:02:57, Sakari Ailus wrote:
> Hi Pavel and Sebastian,
> 
> On Tue, Feb 14, 2017 at 02:40:00PM +0100, Pavel Machek wrote:
> > From: Sebastian Reichel <sre@kernel.org>
> > 
> > Without this, exposure / gain controls do not work in the camera application.
> 
> :-)
> 
> > 
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
> > Signed-off-by: Pavel Machek <pavel@ucw.cz>
> > ---
> >  drivers/media/v4l2-core/v4l2-device.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
> > index f364cc1..b3afbe8 100644
> > --- a/drivers/media/v4l2-core/v4l2-device.c
> > +++ b/drivers/media/v4l2-core/v4l2-device.c
> > @@ -235,6 +235,9 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
> >  		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
> >  			continue;
> >  
> > +		if(sd->devnode)
> > +			continue;
> 
> This has been recognised as a problem but you're the first to submit a patch
> I believe. Please add an appropriate description. :-)

Ugh. Will try :-).

> s/if\(/if (/
> 
> I think this one should go in before the rest.

Easy enough, and I'll move it to the first in the series.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-02-14 22:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-14 13:40 [RFC 07/13] v4l2: device_register_subdev_nodes: allow calling multiple times Pavel Machek
2017-02-14 22:02 ` Sakari Ailus
2017-02-14 22:06   ` Laurent Pinchart
2017-02-14 22:11     ` Sakari Ailus
2017-02-14 22:29   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).