A long standing issue is how to find the associated media device for a V4L or DVB device node. This is primarily useful for applications like v4l2-ctl and v4l2-compliance. Until recently these applications relied on /sys and the fact that the media device was accessible in /sys via: /sys/class/video4linux/videoX/device/mediaY/ But commit ee494cf377e1 ("media: v4l2-device: Link subdevices to their parent devices if available") broke that scheme for subdevices. That scheme was rather a hack anyway. Attempts to report the major/minor number of the media device via the public API (i.e. by extending VIDIOC_QUERYCAP or VIDIOC_SUBDEV_QUERYCAP) failed, so this patch series now just adds a media_dev attribute when a V4L or DVB device node is created. This attribute contains the major:minor of the media device. It is only created if the device node is actually associated with a media controller. This issue was reported by Sebastian Frick: https://lore.kernel.org/linux-media/20210120183054.5ltnjdtrmumplevt@basti-TUXEDO-Book-XA1510/T/#t Regards, Hans Changes since v1: use the is_visible callback to ensure the attribute is only shown if mdev is non-NULL. Hans Verkuil (2): v4l2-dev: add /sys media_dev attr for video devices dvbdev: add /sys media_dev attr for dvb devices drivers/media/dvb-core/dvbdev.c | 46 ++++++++++++++++++++++++++++ drivers/media/v4l2-core/v4l2-dev.c | 48 +++++++++++++++++++++++++++++- 2 files changed, 93 insertions(+), 1 deletion(-) -- 2.29.2