All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member
@ 2021-06-09 11:54 Paul Kocialkowski
  2021-06-09 11:54 ` [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional Paul Kocialkowski
  2021-06-09 12:30 ` [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Sakari Ailus
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2021-06-09 11:54 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Mauro Carvalho Chehab, Niklas Söderlund, Hans Verkuil,
	Sakari Ailus, Sebastian Reichel, Thomas Petazzoni,
	Paul Kocialkowski

Fix the name of the function that registers the subdev_notifier member
of the v4l2_subdev structure.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 include/media/v4l2-subdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index d0e9a5bdb08b..f3b657dfe304 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -854,7 +854,7 @@ struct v4l2_subdev_platform_data {
  * @asd: Pointer to respective &struct v4l2_async_subdev.
  * @notifier: Pointer to the managing notifier.
  * @subdev_notifier: A sub-device notifier implicitly registered for the sub-
- *		     device using v4l2_device_register_sensor_subdev().
+ *		     device using v4l2_async_register_subdev_sensor_common().
  * @pdata: common part of subdevice platform data
  *
  * Each instance of a subdev driver should create this struct, either
-- 
2.31.1


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

* [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional
  2021-06-09 11:54 [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Paul Kocialkowski
@ 2021-06-09 11:54 ` Paul Kocialkowski
  2021-06-09 12:27   ` Sakari Ailus
  2021-06-09 12:30 ` [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Sakari Ailus
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Kocialkowski @ 2021-06-09 11:54 UTC (permalink / raw)
  To: linux-media, linux-kernel
  Cc: Mauro Carvalho Chehab, Niklas Söderlund, Hans Verkuil,
	Sakari Ailus, Sebastian Reichel, Thomas Petazzoni,
	Paul Kocialkowski

A dedicated subdev notified is registered when using the helper
dedicated to sensors (v4l2_async_register_subdev_sensor_common),
but this is not the case when a driver uses v4l2_async_register_subdev
directly.

As a result, add a conditional check to deal with the dedicated subdev
notifier only when necessary at the async subdev unregister step
(and avoid operating on/freeing an unallocated notifier).

Fixes: aef69d54755d ("media: v4l: fwnode: Add a convenience function for registering sensors")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/media/v4l2-core/v4l2-async.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
index cd9e78c63791..e0f4f7551ff3 100644
--- a/drivers/media/v4l2-core/v4l2-async.c
+++ b/drivers/media/v4l2-core/v4l2-async.c
@@ -780,10 +780,12 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
 
 	mutex_lock(&list_lock);
 
-	__v4l2_async_notifier_unregister(sd->subdev_notifier);
-	__v4l2_async_notifier_cleanup(sd->subdev_notifier);
-	kfree(sd->subdev_notifier);
-	sd->subdev_notifier = NULL;
+	if (sd->subdev_notifier) {
+		__v4l2_async_notifier_unregister(sd->subdev_notifier);
+		__v4l2_async_notifier_cleanup(sd->subdev_notifier);
+		kfree(sd->subdev_notifier);
+		sd->subdev_notifier = NULL;
+	}
 
 	if (sd->asd) {
 		struct v4l2_async_notifier *notifier = sd->notifier;
-- 
2.31.1


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

* Re: [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional
  2021-06-09 11:54 ` [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional Paul Kocialkowski
@ 2021-06-09 12:27   ` Sakari Ailus
  2021-06-09 13:01     ` Paul Kocialkowski
  0 siblings, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2021-06-09 12:27 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: linux-media, linux-kernel, Mauro Carvalho Chehab,
	Niklas Söderlund, Hans Verkuil, Sebastian Reichel,
	Thomas Petazzoni

Hi Paul,

On Wed, Jun 09, 2021 at 01:54:57PM +0200, Paul Kocialkowski wrote:
> A dedicated subdev notified is registered when using the helper
> dedicated to sensors (v4l2_async_register_subdev_sensor_common),
> but this is not the case when a driver uses v4l2_async_register_subdev
> directly.

Is this a problem?

The notifier unregistration and cleanup functions should be safe to call on
a notifier that's not been initialised or registered. The same goes for
kfree with NULL argument.

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member
  2021-06-09 11:54 [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Paul Kocialkowski
  2021-06-09 11:54 ` [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional Paul Kocialkowski
@ 2021-06-09 12:30 ` Sakari Ailus
  2021-06-09 13:03   ` Paul Kocialkowski
  1 sibling, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2021-06-09 12:30 UTC (permalink / raw)
  To: Paul Kocialkowski
  Cc: linux-media, linux-kernel, Mauro Carvalho Chehab,
	Niklas Söderlund, Hans Verkuil, Sebastian Reichel,
	Thomas Petazzoni

Hi Paul,

On Wed, Jun 09, 2021 at 01:54:56PM +0200, Paul Kocialkowski wrote:
> Fix the name of the function that registers the subdev_notifier member
> of the v4l2_subdev structure.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  include/media/v4l2-subdev.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index d0e9a5bdb08b..f3b657dfe304 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -854,7 +854,7 @@ struct v4l2_subdev_platform_data {
>   * @asd: Pointer to respective &struct v4l2_async_subdev.
>   * @notifier: Pointer to the managing notifier.
>   * @subdev_notifier: A sub-device notifier implicitly registered for the sub-
> - *		     device using v4l2_device_register_sensor_subdev().
> + *		     device using v4l2_async_register_subdev_sensor_common().

I agree in principle, but the function is nowadays called
v4l2_async_register_subdev_sensor().

I can fix this while applying.

-- 
Regards,

Sakari Ailus

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

* Re: [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional
  2021-06-09 12:27   ` Sakari Ailus
@ 2021-06-09 13:01     ` Paul Kocialkowski
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2021-06-09 13:01 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-media, linux-kernel, Mauro Carvalho Chehab,
	Niklas Söderlund, Hans Verkuil, Sebastian Reichel,
	Thomas Petazzoni

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

Hi Sakari,

On Wed 09 Jun 21, 15:27, Sakari Ailus wrote:
> Hi Paul,
> 
> On Wed, Jun 09, 2021 at 01:54:57PM +0200, Paul Kocialkowski wrote:
> > A dedicated subdev notified is registered when using the helper
> > dedicated to sensors (v4l2_async_register_subdev_sensor_common),
> > but this is not the case when a driver uses v4l2_async_register_subdev
> > directly.
> 
> Is this a problem?
> 
> The notifier unregistration and cleanup functions should be safe to call on
> a notifier that's not been initialised or registered. The same goes for
> kfree with NULL argument.

I think you're right, the functions and kfree are indeed safe.
I think I mixed things up with debugging an issue and assumed this was part
of the fix I needed.

Sorry for the noise!

Paul

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member
  2021-06-09 12:30 ` [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Sakari Ailus
@ 2021-06-09 13:03   ` Paul Kocialkowski
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2021-06-09 13:03 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: linux-media, linux-kernel, Mauro Carvalho Chehab,
	Niklas Söderlund, Hans Verkuil, Sebastian Reichel,
	Thomas Petazzoni

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

Hi Sakari,

On Wed 09 Jun 21, 15:30, Sakari Ailus wrote:
> Hi Paul,
> 
> On Wed, Jun 09, 2021 at 01:54:56PM +0200, Paul Kocialkowski wrote:
> > Fix the name of the function that registers the subdev_notifier member
> > of the v4l2_subdev structure.
> > 
> > Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> > ---
> >  include/media/v4l2-subdev.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> > index d0e9a5bdb08b..f3b657dfe304 100644
> > --- a/include/media/v4l2-subdev.h
> > +++ b/include/media/v4l2-subdev.h
> > @@ -854,7 +854,7 @@ struct v4l2_subdev_platform_data {
> >   * @asd: Pointer to respective &struct v4l2_async_subdev.
> >   * @notifier: Pointer to the managing notifier.
> >   * @subdev_notifier: A sub-device notifier implicitly registered for the sub-
> > - *		     device using v4l2_device_register_sensor_subdev().
> > + *		     device using v4l2_async_register_subdev_sensor_common().
> 
> I agree in principle, but the function is nowadays called
> v4l2_async_register_subdev_sensor().
> 
> I can fix this while applying.

Looks like I missed the rename when rebasing my patch on media/master!
Of course, feel free to update with the new name.

Thanks,

Paul

-- 
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2021-06-09 13:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 11:54 [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Paul Kocialkowski
2021-06-09 11:54 ` [PATCH 2/2] media: v4l2-async: Make subdev notifier cleanup conditional Paul Kocialkowski
2021-06-09 12:27   ` Sakari Ailus
2021-06-09 13:01     ` Paul Kocialkowski
2021-06-09 12:30 ` [PATCH 1/2] media: v4l2-subdev: Fix documentation of the subdev_notifier member Sakari Ailus
2021-06-09 13:03   ` Paul Kocialkowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.