All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] media: v4l2-device: Link subdevices to their parent devices if available
@ 2017-12-15  4:32 Tomasz Figa
  2017-12-15  9:14 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: Tomasz Figa @ 2017-12-15  4:32 UTC (permalink / raw)
  To: linux-media
  Cc: linux-kernel, Mauro Carvalho Chehab, Sakari Ailus,
	Ivaylo Dimitrov, Sebastian Reichel, Laurent Pinchart,
	Hans Verkuil, Tomasz Figa

Currently v4l2_device_register_subdev_nodes() does not initialize the
dev_parent field of the video_device structs it creates for subdevices
being registered. This leads to __video_register_device() falling back
to the parent device of associated v4l2_device struct, which often does
not match the physical device the subdevice is registered for.

Due to the problem above, the links between real devices and v4l-subdev
nodes cannot be obtained from sysfs, which might be confusing for the
userspace trying to identify the hardware.

Fix this by initializing the dev_parent field of the video_device struct
with the value of dev field of the v4l2_subdev struct. In case of
subdevices without a parent struct device, the field will be NULL and the
old behavior will be preserved by the semantics of
__video_register_device().

Signed-off-by: Tomasz Figa <tfiga@chromium.org>
---
 drivers/media/v4l2-core/v4l2-device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
index 937c6de85606..450c97caf2c6 100644
--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -246,6 +246,7 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev)
 
 		video_set_drvdata(vdev, sd);
 		strlcpy(vdev->name, sd->name, sizeof(vdev->name));
+		vdev->dev_parent = sd->dev;
 		vdev->v4l2_dev = v4l2_dev;
 		vdev->fops = &v4l2_subdev_fops;
 		vdev->release = v4l2_device_release_subdev_node;
-- 
2.15.1.504.g5279b80103-goog

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

* Re: [RFC PATCH] media: v4l2-device: Link subdevices to their parent devices if available
  2017-12-15  4:32 [RFC PATCH] media: v4l2-device: Link subdevices to their parent devices if available Tomasz Figa
@ 2017-12-15  9:14 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2017-12-15  9:14 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: linux-media, linux-kernel, Mauro Carvalho Chehab,
	Ivaylo Dimitrov, Sebastian Reichel, Laurent Pinchart,
	Hans Verkuil

On Fri, Dec 15, 2017 at 01:32:21PM +0900, Tomasz Figa wrote:
> Currently v4l2_device_register_subdev_nodes() does not initialize the
> dev_parent field of the video_device structs it creates for subdevices
> being registered. This leads to __video_register_device() falling back
> to the parent device of associated v4l2_device struct, which often does
> not match the physical device the subdevice is registered for.
> 
> Due to the problem above, the links between real devices and v4l-subdev
> nodes cannot be obtained from sysfs, which might be confusing for the
> userspace trying to identify the hardware.
> 
> Fix this by initializing the dev_parent field of the video_device struct
> with the value of dev field of the v4l2_subdev struct. In case of
> subdevices without a parent struct device, the field will be NULL and the
> old behavior will be preserved by the semantics of
> __video_register_device().
> 
> Signed-off-by: Tomasz Figa <tfiga@chromium.org>

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

-- 
Sakari Ailus
sakari.ailus@linux.intel.com

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

end of thread, other threads:[~2017-12-15  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15  4:32 [RFC PATCH] media: v4l2-device: Link subdevices to their parent devices if available Tomasz Figa
2017-12-15  9:14 ` Sakari Ailus

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.