linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Set bus_info field in framework
@ 2022-01-22 16:36 Sakari Ailus
  2022-01-22 16:36 ` [PATCH 1/3] media: Provide a helper for setting bus_info field Sakari Ailus
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Sakari Ailus @ 2022-01-22 16:36 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, hverkuil

Hi folks,

This innocious-looking patchset moves setting the bus_info fields in
struct media_device and struct v4l2_capability from drivers to the
framework for PCI and platform devices. USB and I²C devices are possible,
too, but not yet implemented. Using this is optional so that drivers which
have special requirements or archaic bugs are unaffected.

If people like this, I'll see if the same could be done to the driver
fields.

Sakari Ailus (3):
  media: Provide a helper for setting bus_info field
  media: Set bus_info in media_device_init()
  v4l: ioctl: Set bus_info in v4l_querycap()

 drivers/media/common/saa7146/saa7146_video.c  |  1 -
 drivers/media/mc/mc-device.c                  |  2 ++
 drivers/media/pci/bt8xx/bttv-driver.c         |  2 --
 drivers/media/pci/cx18/cx18-ioctl.c           |  2 --
 drivers/media/pci/cx88/cx88-blackbird.c       |  1 -
 drivers/media/pci/cx88/cx88-video.c           |  1 -
 drivers/media/pci/dt3155/dt3155.c             |  1 -
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c |  4 ---
 drivers/media/pci/ivtv/ivtv-ioctl.c           |  1 -
 drivers/media/pci/meye/meye.c                 |  1 -
 drivers/media/pci/saa7134/saa7134-go7007.c    |  1 -
 drivers/media/pci/saa7134/saa7134-video.c     |  1 -
 drivers/media/pci/saa7164/saa7164-encoder.c   |  1 -
 drivers/media/pci/saa7164/saa7164-vbi.c       |  1 -
 .../media/pci/solo6x10/solo6x10-v4l2-enc.c    |  2 --
 drivers/media/pci/solo6x10/solo6x10-v4l2.c    |  2 --
 drivers/media/pci/sta2x11/sta2x11_vip.c       |  2 --
 drivers/media/pci/tw5864/tw5864-video.c       |  1 -
 drivers/media/pci/tw68/tw68-video.c           |  1 -
 drivers/media/pci/tw686x/tw686x-video.c       |  2 --
 .../media/platform/allegro-dvt/allegro-core.c |  2 --
 drivers/media/platform/davinci/vpbe_display.c |  2 --
 drivers/media/platform/davinci/vpif_capture.c |  2 --
 drivers/media/platform/davinci/vpif_display.c |  2 --
 drivers/media/platform/exynos-gsc/gsc-m2m.c   |  2 --
 drivers/media/platform/exynos4-is/common.c    |  2 --
 drivers/media/platform/exynos4-is/fimc-lite.c |  2 --
 drivers/media/platform/imx-jpeg/mxc-jpeg.c    |  2 --
 .../media/platform/marvell-ccic/cafe-driver.c |  1 -
 .../media/platform/mtk-jpeg/mtk_jpeg_core.c   |  2 --
 .../media/platform/qcom/camss/camss-video.c   |  2 --
 drivers/media/platform/rcar-vin/rcar-core.c   |  2 --
 drivers/media/platform/rcar-vin/rcar-v4l2.c   |  2 --
 drivers/media/platform/rcar_jpu.c             |  2 --
 drivers/media/platform/s5p-jpeg/jpeg-core.c   |  2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c  |  2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c  |  2 --
 drivers/media/platform/stm32/stm32-dcmi.c     |  2 --
 .../platform/sunxi/sun4i-csi/sun4i_csi.c      |  2 --
 .../platform/sunxi/sun4i-csi/sun4i_v4l2.c     |  2 --
 .../platform/sunxi/sun6i-csi/sun6i_csi.c      |  2 --
 drivers/media/platform/ti-vpe/cal-video.c     |  2 --
 drivers/media/platform/ti-vpe/cal.c           |  2 --
 drivers/media/platform/vsp1/vsp1_drv.c        |  2 --
 drivers/media/platform/vsp1/vsp1_histo.c      |  2 --
 drivers/media/platform/vsp1/vsp1_video.c      |  2 --
 drivers/media/radio/radio-maxiradio.c         |  2 --
 drivers/media/v4l2-core/v4l2-ioctl.c          |  3 ++
 include/media/media-device.h                  | 30 +++++++++++++++++--
 49 files changed, 32 insertions(+), 84 deletions(-)

-- 
2.30.2


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

* [PATCH 1/3] media: Provide a helper for setting bus_info field
  2022-01-22 16:36 [PATCH 0/3] Set bus_info field in framework Sakari Ailus
@ 2022-01-22 16:36 ` Sakari Ailus
  2022-01-22 23:44   ` Laurent Pinchart
  2022-01-25 12:54   ` Hans Verkuil
  2022-01-22 16:36 ` [PATCH 2/3] media: Set bus_info in media_device_init() Sakari Ailus
  2022-01-22 16:36 ` [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap() Sakari Ailus
  2 siblings, 2 replies; 15+ messages in thread
From: Sakari Ailus @ 2022-01-22 16:36 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, hverkuil

The bus_info or a similar field exists in a lot of structs, yet drivers
tend to set the value of that field by themselves in a determinable way.
Thus provide a helper for doing this. To be used in subsequent patches.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 include/media/media-device.h | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/include/media/media-device.h b/include/media/media-device.h
index 1345e6da688a..9f0458068196 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -13,12 +13,13 @@
 
 #include <linux/list.h>
 #include <linux/mutex.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
 
 #include <media/media-devnode.h>
 #include <media/media-entity.h>
 
 struct ida;
-struct device;
 struct media_device;
 
 /**
@@ -181,8 +182,7 @@ struct media_device {
 	atomic_t request_id;
 };
 
-/* We don't need to include pci.h or usb.h here */
-struct pci_dev;
+/* We don't need to include usb.h here */
 struct usb_device;
 
 #ifdef CONFIG_MEDIA_CONTROLLER
@@ -496,4 +496,28 @@ static inline void __media_device_usb_init(struct media_device *mdev,
 #define media_device_usb_init(mdev, udev, name) \
 	__media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
 
+static inline void
+__media_set_bus_info(char *bus_info, size_t bus_info_size, struct device *dev)
+{
+	if (!dev || *bus_info)
+		return;
+
+	if (dev_is_platform(dev))
+		snprintf(bus_info, bus_info_size, "platform:%s", dev_name(dev));
+	else if (dev_is_pci(dev))
+		snprintf(bus_info, bus_info_size, "PCI:%s", dev_name(dev));
+}
+
+/**
+ * media_set_bus_info() - Conditionally set bus_info
+ *
+ * @bus_info:	Variable where to write the bus info (char array)
+ * @dev:	Related struct device
+ *
+ * Sets bus information based on device conditionally, if the first character of
+ * &bus_info is not '\0' and dev is non-NULL.
+ */
+#define media_set_bus_info(bus_info, dev) \
+	__media_set_bus_info(bus_info, sizeof(bus_info), dev)
+
 #endif
-- 
2.30.2


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

* [PATCH 2/3] media: Set bus_info in media_device_init()
  2022-01-22 16:36 [PATCH 0/3] Set bus_info field in framework Sakari Ailus
  2022-01-22 16:36 ` [PATCH 1/3] media: Provide a helper for setting bus_info field Sakari Ailus
@ 2022-01-22 16:36 ` Sakari Ailus
  2022-01-22 23:48   ` Laurent Pinchart
  2022-01-22 16:36 ` [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap() Sakari Ailus
  2 siblings, 1 reply; 15+ messages in thread
From: Sakari Ailus @ 2022-01-22 16:36 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, hverkuil

Set bus_info field based on struct device in media_device_init(). Also
remove corresponding code from drivers.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/mc/mc-device.c                       | 2 ++
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c      | 2 --
 drivers/media/platform/rcar-vin/rcar-core.c        | 2 --
 drivers/media/platform/stm32/stm32-dcmi.c          | 2 --
 drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c | 2 --
 drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 2 --
 drivers/media/platform/ti-vpe/cal.c                | 2 --
 drivers/media/platform/vsp1/vsp1_drv.c             | 2 --
 8 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
index cf5e459b1d96..f7e1d63cec14 100644
--- a/drivers/media/mc/mc-device.c
+++ b/drivers/media/mc/mc-device.c
@@ -715,6 +715,8 @@ void media_device_init(struct media_device *mdev)
 
 	atomic_set(&mdev->request_id, 0);
 
+	media_set_bus_info(mdev->bus_info, mdev->dev);
+
 	dev_dbg(mdev->dev, "Media device initialized\n");
 }
 EXPORT_SYMBOL_GPL(media_device_init);
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index 0e9b0503b62a..b15fac775e14 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -1777,8 +1777,6 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
 	cio2->media_dev.dev = dev;
 	strscpy(cio2->media_dev.model, CIO2_DEVICE_NAME,
 		sizeof(cio2->media_dev.model));
-	snprintf(cio2->media_dev.bus_info, sizeof(cio2->media_dev.bus_info),
-		 "PCI:%s", pci_name(cio2->pci_dev));
 	cio2->media_dev.hw_revision = 0;
 
 	media_device_init(&cio2->media_dev);
diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
index 0186ae235113..1099cab7d95d 100644
--- a/drivers/media/platform/rcar-vin/rcar-core.c
+++ b/drivers/media/platform/rcar-vin/rcar-core.c
@@ -94,8 +94,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin,
 
 	strscpy(mdev->driver_name, KBUILD_MODNAME, sizeof(mdev->driver_name));
 	strscpy(mdev->model, match->compatible, sizeof(mdev->model));
-	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
-		 dev_name(mdev->dev));
 
 	media_device_init(mdev);
 
diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
index 7694ffef5c00..90c69113ce60 100644
--- a/drivers/media/platform/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/stm32/stm32-dcmi.c
@@ -1970,8 +1970,6 @@ static int dcmi_probe(struct platform_device *pdev)
 
 	/* Initialize media device */
 	strscpy(dcmi->mdev.model, DRV_NAME, sizeof(dcmi->mdev.model));
-	snprintf(dcmi->mdev.bus_info, sizeof(dcmi->mdev.bus_info),
-		 "platform:%s", DRV_NAME);
 	dcmi->mdev.dev = &pdev->dev;
 	media_device_init(&dcmi->mdev);
 
diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
index 80a10f238bbe..18e6c65f4737 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
@@ -173,8 +173,6 @@ static int sun4i_csi_probe(struct platform_device *pdev)
 	strscpy(csi->mdev.model, "Allwinner Video Capture Device",
 		sizeof(csi->mdev.model));
 	csi->mdev.hw_revision = 0;
-	snprintf(csi->mdev.bus_info, sizeof(csi->mdev.bus_info), "platform:%s",
-		 dev_name(csi->dev));
 	media_device_init(&csi->mdev);
 	csi->v4l.mdev = &csi->mdev;
 
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index fc96921b0583..a971587dbbd1 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -733,8 +733,6 @@ static int sun6i_csi_v4l2_init(struct sun6i_csi *csi)
 	strscpy(csi->media_dev.model, "Allwinner Video Capture Device",
 		sizeof(csi->media_dev.model));
 	csi->media_dev.hw_revision = 0;
-	snprintf(csi->media_dev.bus_info, sizeof(csi->media_dev.bus_info),
-		 "platform:%s", dev_name(csi->dev));
 
 	media_device_init(&csi->media_dev);
 	v4l2_async_nf_init(&csi->notifier);
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 4a4a6c5983f7..11f67abc2f38 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -884,8 +884,6 @@ static int cal_media_init(struct cal_dev *cal)
 	mdev->dev = cal->dev;
 	mdev->hw_revision = cal->revision;
 	strscpy(mdev->model, "CAL", sizeof(mdev->model));
-	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
-		 dev_name(mdev->dev));
 	media_device_init(mdev);
 
 	/*
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index c9044785b903..d27594dbf0e1 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -243,8 +243,6 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 	mdev->dev = vsp1->dev;
 	mdev->hw_revision = vsp1->version;
 	strscpy(mdev->model, vsp1->info->model, sizeof(mdev->model));
-	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
-		 dev_name(mdev->dev));
 	media_device_init(mdev);
 
 	vsp1->media_ops.link_setup = vsp1_entity_link_setup;
-- 
2.30.2


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

* [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap()
  2022-01-22 16:36 [PATCH 0/3] Set bus_info field in framework Sakari Ailus
  2022-01-22 16:36 ` [PATCH 1/3] media: Provide a helper for setting bus_info field Sakari Ailus
  2022-01-22 16:36 ` [PATCH 2/3] media: Set bus_info in media_device_init() Sakari Ailus
@ 2022-01-22 16:36 ` Sakari Ailus
  2022-01-22 23:51   ` Laurent Pinchart
  2 siblings, 1 reply; 15+ messages in thread
From: Sakari Ailus @ 2022-01-22 16:36 UTC (permalink / raw)
  To: linux-media; +Cc: laurent.pinchart, hverkuil

The bus_info field is set by most drivers based on the type of the device
bus as well as the name of the device. Do this in v4l_querycap() so
drivers don't need to. This keeps compatibility with non-default and silly
bus_info.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/common/saa7146/saa7146_video.c        | 1 -
 drivers/media/pci/bt8xx/bttv-driver.c               | 2 --
 drivers/media/pci/cx18/cx18-ioctl.c                 | 2 --
 drivers/media/pci/cx88/cx88-blackbird.c             | 1 -
 drivers/media/pci/cx88/cx88-video.c                 | 1 -
 drivers/media/pci/dt3155/dt3155.c                   | 1 -
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c       | 2 --
 drivers/media/pci/ivtv/ivtv-ioctl.c                 | 1 -
 drivers/media/pci/meye/meye.c                       | 1 -
 drivers/media/pci/saa7134/saa7134-go7007.c          | 1 -
 drivers/media/pci/saa7134/saa7134-video.c           | 1 -
 drivers/media/pci/saa7164/saa7164-encoder.c         | 1 -
 drivers/media/pci/saa7164/saa7164-vbi.c             | 1 -
 drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c      | 2 --
 drivers/media/pci/solo6x10/solo6x10-v4l2.c          | 2 --
 drivers/media/pci/sta2x11/sta2x11_vip.c             | 2 --
 drivers/media/pci/tw5864/tw5864-video.c             | 1 -
 drivers/media/pci/tw68/tw68-video.c                 | 1 -
 drivers/media/pci/tw686x/tw686x-video.c             | 2 --
 drivers/media/platform/allegro-dvt/allegro-core.c   | 2 --
 drivers/media/platform/davinci/vpbe_display.c       | 2 --
 drivers/media/platform/davinci/vpif_capture.c       | 2 --
 drivers/media/platform/davinci/vpif_display.c       | 2 --
 drivers/media/platform/exynos-gsc/gsc-m2m.c         | 2 --
 drivers/media/platform/exynos4-is/common.c          | 2 --
 drivers/media/platform/exynos4-is/fimc-lite.c       | 2 --
 drivers/media/platform/imx-jpeg/mxc-jpeg.c          | 2 --
 drivers/media/platform/marvell-ccic/cafe-driver.c   | 1 -
 drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c     | 2 --
 drivers/media/platform/qcom/camss/camss-video.c     | 2 --
 drivers/media/platform/rcar-vin/rcar-v4l2.c         | 2 --
 drivers/media/platform/rcar_jpu.c                   | 2 --
 drivers/media/platform/s5p-jpeg/jpeg-core.c         | 2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_dec.c        | 2 --
 drivers/media/platform/s5p-mfc/s5p_mfc_enc.c        | 2 --
 drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 2 --
 drivers/media/platform/ti-vpe/cal-video.c           | 2 --
 drivers/media/platform/vsp1/vsp1_histo.c            | 2 --
 drivers/media/platform/vsp1/vsp1_video.c            | 2 --
 drivers/media/radio/radio-maxiradio.c               | 2 --
 drivers/media/v4l2-core/v4l2-ioctl.c                | 3 +++
 41 files changed, 3 insertions(+), 67 deletions(-)

diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
index 66215d9106a4..2296765079a4 100644
--- a/drivers/media/common/saa7146/saa7146_video.c
+++ b/drivers/media/common/saa7146/saa7146_video.c
@@ -443,7 +443,6 @@ static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *
 
 	strscpy((char *)cap->driver, "saa7146 v4l2", sizeof(cap->driver));
 	strscpy((char *)cap->card, dev->ext->name, sizeof(cap->card));
-	sprintf((char *)cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY |
 			    V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
 			    V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 8cc9bec43688..c3512299794c 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2435,8 +2435,6 @@ static int bttv_querycap(struct file *file, void  *priv,
 
 	strscpy(cap->driver, "bttv", sizeof(cap->driver));
 	strscpy(cap->card, btv->video_dev.name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info),
-		 "PCI:%s", pci_name(btv->c.pci));
 	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
 			    V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
 	if (no_overlay <= 0)
diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
index ce3f0141f94e..c8ba7841c720 100644
--- a/drivers/media/pci/cx18/cx18-ioctl.c
+++ b/drivers/media/pci/cx18/cx18-ioctl.c
@@ -389,8 +389,6 @@ static int cx18_querycap(struct file *file, void *fh,
 
 	strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
 	strscpy(vcap->card, cx->card_name, sizeof(vcap->card));
-	snprintf(vcap->bus_info, sizeof(vcap->bus_info),
-		 "PCI:%s", pci_name(cx->pci_dev));
 	vcap->capabilities = cx->v4l2_cap | V4L2_CAP_DEVICE_CAPS;
 	return 0;
 }
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index d5da3bd5695d..c1b41a9283c1 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -796,7 +796,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
 	struct cx88_core *core = dev->core;
 
 	strscpy(cap->driver, "cx88_blackbird", sizeof(cap->driver));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	return cx88_querycap(file, core, cap);
 }
 
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index c17ad9f7d822..d3729be89252 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -808,7 +808,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
 	struct cx88_core *core = dev->core;
 
 	strscpy(cap->driver, "cx8800", sizeof(cap->driver));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	return cx88_querycap(file, core, cap);
 }
 
diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c
index 961f844de99c..3ad72a53f2a5 100644
--- a/drivers/media/pci/dt3155/dt3155.c
+++ b/drivers/media/pci/dt3155/dt3155.c
@@ -296,7 +296,6 @@ static int dt3155_querycap(struct file *filp, void *p,
 
 	strscpy(cap->driver, DT3155_NAME, sizeof(cap->driver));
 	strscpy(cap->card, DT3155_NAME " frame grabber", sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(pd->pdev));
 	return 0;
 }
 
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index b15fac775e14..de8cbacba793 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -1050,8 +1050,6 @@ static int cio2_v4l2_querycap(struct file *file, void *fh,
 
 	strscpy(cap->driver, CIO2_NAME, sizeof(cap->driver));
 	strscpy(cap->card, CIO2_DEVICE_NAME, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info),
-		 "PCI:%s", pci_name(cio2->pci_dev));
 
 	return 0;
 }
diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
index 0cdf6b3210c2..e5bc581ee464 100644
--- a/drivers/media/pci/ivtv/ivtv-ioctl.c
+++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
@@ -732,7 +732,6 @@ static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vc
 
 	strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
 	strscpy(vcap->card, itv->card_name, sizeof(vcap->card));
-	snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->pdev));
 	vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS;
 	return 0;
 }
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index 8944e4bd4638..5d87efd9b95c 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1012,7 +1012,6 @@ static int vidioc_querycap(struct file *file, void *fh,
 {
 	strscpy(cap->driver, "meye", sizeof(cap->driver));
 	strscpy(cap->card, "meye", sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev));
 	return 0;
 }
 
diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c
index da83893ffee9..c0985ae2a05b 100644
--- a/drivers/media/pci/saa7134/saa7134-go7007.c
+++ b/drivers/media/pci/saa7134/saa7134-go7007.c
@@ -421,7 +421,6 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
 	}
 
 	go->board_id = GO7007_BOARDID_PCI_VOYAGER;
-	snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci));
 	strscpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
 	go->hpi_ops = &saa7134_go7007_hpi_ops;
 	go->hpi_context = saa;
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 374c8e1087de..013314d6d78b 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1478,7 +1478,6 @@ int saa7134_querycap(struct file *file, void *priv,
 	strscpy(cap->driver, "saa7134", sizeof(cap->driver));
 	strscpy(cap->card, saa7134_boards[dev->board].name,
 		sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
 			    V4L2_CAP_RADIO | V4L2_CAP_VIDEO_CAPTURE |
 			    V4L2_CAP_VBI_CAPTURE | V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index 1d1d32e043f1..c1b6a0596801 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -490,7 +490,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
 	strscpy(cap->driver, dev->name, sizeof(cap->driver));
 	strscpy(cap->card, saa7164_boards[dev->board].name,
 		sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
 			    V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE |
 			    V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
index cb2e09f0841d..a6738baab688 100644
--- a/drivers/media/pci/saa7164/saa7164-vbi.c
+++ b/drivers/media/pci/saa7164/saa7164-vbi.c
@@ -201,7 +201,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
 	strscpy(cap->driver, dev->name, sizeof(cap->driver));
 	strscpy(cap->card, saa7164_boards[dev->board].name,
 		sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
 			    V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE |
 			    V4L2_CAP_DEVICE_CAPS;
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
index 7766cadb73ea..956b2bbe9b71 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
@@ -769,8 +769,6 @@ static int solo_enc_querycap(struct file *file, void  *priv,
 	strscpy(cap->driver, SOLO6X10_NAME, sizeof(cap->driver));
 	snprintf(cap->card, sizeof(cap->card), "Softlogic 6x10 Enc %d",
 		 solo_enc->ch);
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
-		 pci_name(solo_dev->pdev));
 	return 0;
 }
 
diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
index 24ef0c446bef..f0c0e66a9d58 100644
--- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
+++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
@@ -376,8 +376,6 @@ static int solo_querycap(struct file *file, void  *priv,
 
 	strscpy(cap->driver, SOLO6X10_NAME, sizeof(cap->driver));
 	strscpy(cap->card, "Softlogic 6x10", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
-		 pci_name(solo_dev->pdev));
 	return 0;
 }
 
diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
index 524912f20d9f..9365ffd271c2 100644
--- a/drivers/media/pci/sta2x11/sta2x11_vip.c
+++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
@@ -405,8 +405,6 @@ static int vidioc_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
 	strscpy(cap->card, KBUILD_MODNAME, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
-		 pci_name(vip->pdev));
 	return 0;
 }
 
diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
index 9131265c2b87..197ed8978102 100644
--- a/drivers/media/pci/tw5864/tw5864-video.c
+++ b/drivers/media/pci/tw5864/tw5864-video.c
@@ -604,7 +604,6 @@ static int tw5864_querycap(struct file *file, void *priv,
 	strscpy(cap->driver, "tw5864", sizeof(cap->driver));
 	snprintf(cap->card, sizeof(cap->card), "TW5864 Encoder %d",
 		 input->nr);
-	sprintf(cap->bus_info, "PCI:%s", pci_name(input->root->pci));
 	return 0;
 }
 
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index fe94944d0531..6013ff4f33ac 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -717,7 +717,6 @@ static int tw68_querycap(struct file *file, void  *priv,
 	strscpy(cap->driver, "tw68", sizeof(cap->driver));
 	strscpy(cap->card, "Techwell Capture Card",
 		sizeof(cap->card));
-	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
 	return 0;
 }
 
diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
index b227e9e78ebd..6344a479119f 100644
--- a/drivers/media/pci/tw686x/tw686x-video.c
+++ b/drivers/media/pci/tw686x/tw686x-video.c
@@ -762,8 +762,6 @@ static int tw686x_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, "tw686x", sizeof(cap->driver));
 	strscpy(cap->card, dev->name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info),
-		 "PCI:%s", pci_name(dev->pci_dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
index 4a3d06c70e34..b023a38c0ff4 100644
--- a/drivers/media/platform/allegro-dvt/allegro-core.c
+++ b/drivers/media/platform/allegro-dvt/allegro-core.c
@@ -3254,8 +3254,6 @@ static int allegro_querycap(struct file *file, void *fh,
 
 	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
 	strscpy(cap->card, "Allegro DVT Video Encoder", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(&dev->plat_dev->dev));
 
 	return 0;
 }
diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
index bf3c3e76b921..9ea70817538e 100644
--- a/drivers/media/platform/davinci/vpbe_display.c
+++ b/drivers/media/platform/davinci/vpbe_display.c
@@ -630,8 +630,6 @@ static int vpbe_display_querycap(struct file *file, void  *priv,
 
 	snprintf(cap->driver, sizeof(cap->driver), "%s",
 		dev_name(vpbe_dev->pdev));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(vpbe_dev->pdev));
 	strscpy(cap->card, vpbe_dev->cfg->module_name, sizeof(cap->card));
 
 	return 0;
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 8fe55374c5a3..d4def719b71b 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1067,8 +1067,6 @@ static int vpif_querycap(struct file *file, void  *priv,
 	struct vpif_capture_config *config = vpif_dev->platform_data;
 
 	strscpy(cap->driver, VPIF_DRIVER_NAME, sizeof(cap->driver));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(vpif_dev));
 	strscpy(cap->card, config->card_name, sizeof(cap->card));
 
 	return 0;
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 59f6b782e104..dfd4693ce67f 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -585,8 +585,6 @@ static int vpif_querycap(struct file *file, void  *priv,
 	struct vpif_display_config *config = vpif_dev->platform_data;
 
 	strscpy(cap->driver, VPIF_DRIVER_NAME, sizeof(cap->driver));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(vpif_dev));
 	strscpy(cap->card, config->card_name, sizeof(cap->card));
 
 	return 0;
diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
index f1cf847d1cc2..b6f54a513256 100644
--- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
+++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
@@ -290,8 +290,6 @@ static int gsc_m2m_querycap(struct file *file, void *fh,
 
 	strscpy(cap->driver, GSC_MODULE_NAME, sizeof(cap->driver));
 	strscpy(cap->card, GSC_MODULE_NAME " gscaler", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(&gsc->pdev->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/exynos4-is/common.c b/drivers/media/platform/exynos4-is/common.c
index 944b224eb621..cc1dc620d758 100644
--- a/drivers/media/platform/exynos4-is/common.c
+++ b/drivers/media/platform/exynos4-is/common.c
@@ -38,8 +38,6 @@ void __fimc_vidioc_querycap(struct device *dev, struct v4l2_capability *cap)
 {
 	strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
 	strscpy(cap->card, dev->driver->name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info),
-				"platform:%s", dev_name(dev));
 }
 EXPORT_SYMBOL(__fimc_vidioc_querycap);
 
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index aaa3af0493ce..d077e2e2f1f3 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -650,8 +650,6 @@ static int fimc_lite_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, FIMC_LITE_DRV_NAME, sizeof(cap->driver));
 	strscpy(cap->card, FIMC_LITE_DRV_NAME, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-					dev_name(&fimc->pdev->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
index 4ca96cf9def7..812bfa79df27 100644
--- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c
+++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
@@ -1531,8 +1531,6 @@ static int mxc_jpeg_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, MXC_JPEG_NAME " codec", sizeof(cap->driver));
 	strscpy(cap->card, MXC_JPEG_NAME " codec", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(mxc_jpeg->dev));
 	cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
 	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
 
diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c
index 03dcf8bf705e..ae97ce4ead98 100644
--- a/drivers/media/platform/marvell-ccic/cafe-driver.c
+++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
@@ -497,7 +497,6 @@ static int cafe_pci_probe(struct pci_dev *pdev,
 	mcam->plat_power_up = cafe_ctlr_power_up;
 	mcam->plat_power_down = cafe_ctlr_power_down;
 	mcam->dev = &pdev->dev;
-	snprintf(mcam->bus_info, sizeof(mcam->bus_info), "PCI:%s", pci_name(pdev));
 	/*
 	 * Vmalloc mode for buffers is traditional with this driver.
 	 * We *might* be able to run DMA_contig, especially on a system
diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index f332beb06d51..97afa57a165e 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -138,8 +138,6 @@ static int mtk_jpeg_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, jpeg->variant->dev_name, sizeof(cap->driver));
 	strscpy(cap->card, jpeg->variant->dev_name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(jpeg->dev));
 
 	return 0;
 }
diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
index f282275af626..a1dc4d9c7215 100644
--- a/drivers/media/platform/qcom/camss/camss-video.c
+++ b/drivers/media/platform/qcom/camss/camss-video.c
@@ -578,8 +578,6 @@ static int video_querycap(struct file *file, void *fh,
 
 	strscpy(cap->driver, "qcom-camss", sizeof(cap->driver));
 	strscpy(cap->card, "Qualcomm Camera Subsystem", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(video->camss->dev));
 
 	return 0;
 }
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 2e60b9fce03b..4be2aff89d40 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -311,8 +311,6 @@ static int rvin_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
 	strscpy(cap->card, "R_Car_VIN", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(vin->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
index 56bb464629ed..776e21491506 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -670,8 +670,6 @@ static int jpu_querycap(struct file *file, void *priv,
 		strscpy(cap->card, DRV_NAME " decoder", sizeof(cap->card));
 
 	strscpy(cap->driver, DRV_NAME, sizeof(cap->driver));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(ctx->jpu->dev));
 	memset(cap->reserved, 0, sizeof(cap->reserved));
 
 	return 0;
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index a8d9159d5ed8..73d05bc904f2 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -1257,8 +1257,6 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,
 		strscpy(cap->card, S5P_JPEG_M2M_NAME " decoder",
 			sizeof(cap->card));
 	}
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(ctx->jpeg->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
index c1d3bda8385b..2f41feb07902 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
@@ -270,8 +270,6 @@ static int vidioc_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, S5P_MFC_NAME, sizeof(cap->driver));
 	strscpy(cap->card, dev->vfd_dec->name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(&dev->plat_dev->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
index 1fad99edb091..6678d551ae37 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
@@ -1309,8 +1309,6 @@ static int vidioc_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, S5P_MFC_NAME, sizeof(cap->driver));
 	strscpy(cap->card, dev->vfd_enc->name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(&dev->plat_dev->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
index 3872027ed2fa..adffedce5e4b 100644
--- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
+++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
@@ -57,8 +57,6 @@ static int sun4i_csi_querycap(struct file *file, void *priv,
 
 	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
 	strscpy(cap->card, "sun4i-csi", sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(csi->dev));
 
 	return 0;
 }
diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c
index 7799da1cc261..2efb1ba97695 100644
--- a/drivers/media/platform/ti-vpe/cal-video.c
+++ b/drivers/media/platform/ti-vpe/cal-video.c
@@ -52,8 +52,6 @@ static int cal_querycap(struct file *file, void *priv,
 	strscpy(cap->driver, CAL_MODULE_NAME, sizeof(cap->driver));
 	strscpy(cap->card, CAL_MODULE_NAME, sizeof(cap->card));
 
-	snprintf(cap->bus_info, sizeof(cap->bus_info),
-		 "platform:%s", dev_name(ctx->cal->dev));
 	return 0;
 }
 
diff --git a/drivers/media/platform/vsp1/vsp1_histo.c b/drivers/media/platform/vsp1/vsp1_histo.c
index 5e5013d2cd2a..f22449dd654c 100644
--- a/drivers/media/platform/vsp1/vsp1_histo.c
+++ b/drivers/media/platform/vsp1/vsp1_histo.c
@@ -434,8 +434,6 @@ static int histo_v4l2_querycap(struct file *file, void *fh,
 
 	strscpy(cap->driver, "vsp1", sizeof(cap->driver));
 	strscpy(cap->card, histo->video.name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(histo->entity.vsp1->dev));
 
 	return 0;
 }
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 044eb5778820..497f352e9f8c 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -959,8 +959,6 @@ vsp1_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
 
 	strscpy(cap->driver, "vsp1", sizeof(cap->driver));
 	strscpy(cap->card, video->video.name, sizeof(cap->card));
-	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
-		 dev_name(video->vsp1->dev));
 
 	return 0;
 }
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index de107e2cbcd6..1a5dbae24ef4 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -144,8 +144,6 @@ static int maxiradio_probe(struct pci_dev *pdev,
 	dev->tea.v4l2_dev = v4l2_dev;
 	dev->tea.radio_nr = radio_nr;
 	strscpy(dev->tea.card, "Maxi Radio FM2000", sizeof(dev->tea.card));
-	snprintf(dev->tea.bus_info, sizeof(dev->tea.bus_info),
-			"PCI:%s", pci_name(pdev));
 
 	retval = -ENODEV;
 
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 642cb90f457c..81ebf6cca522 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -18,6 +18,7 @@
 
 #include <linux/videodev2.h>
 
+#include <media/media-device.h> /* for media_set_bus_info() */
 #include <media/v4l2-common.h>
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-ctrls.h>
@@ -1069,6 +1070,8 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
 	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
 	cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
 
+	media_set_bus_info(cap->bus_info, vfd->dev_parent);
+
 	return ret;
 }
 
-- 
2.30.2


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

* Re: [PATCH 1/3] media: Provide a helper for setting bus_info field
  2022-01-22 16:36 ` [PATCH 1/3] media: Provide a helper for setting bus_info field Sakari Ailus
@ 2022-01-22 23:44   ` Laurent Pinchart
  2022-01-24 15:55     ` Sakari Ailus
  2022-01-25 12:54   ` Hans Verkuil
  1 sibling, 1 reply; 15+ messages in thread
From: Laurent Pinchart @ 2022-01-22 23:44 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-media, hverkuil

Hi Sakari,

Thank you for the patch.

On Sat, Jan 22, 2022 at 06:36:54PM +0200, Sakari Ailus wrote:
> The bus_info or a similar field exists in a lot of structs, yet drivers
> tend to set the value of that field by themselves in a determinable way.
> Thus provide a helper for doing this. To be used in subsequent patches.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  include/media/media-device.h | 30 +++++++++++++++++++++++++++---
>  1 file changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/include/media/media-device.h b/include/media/media-device.h
> index 1345e6da688a..9f0458068196 100644
> --- a/include/media/media-device.h
> +++ b/include/media/media-device.h
> @@ -13,12 +13,13 @@
>  
>  #include <linux/list.h>
>  #include <linux/mutex.h>
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
>  
>  #include <media/media-devnode.h>
>  #include <media/media-entity.h>
>  
>  struct ida;
> -struct device;
>  struct media_device;
>  
>  /**
> @@ -181,8 +182,7 @@ struct media_device {
>  	atomic_t request_id;
>  };
>  
> -/* We don't need to include pci.h or usb.h here */
> -struct pci_dev;
> +/* We don't need to include usb.h here */
>  struct usb_device;
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER
> @@ -496,4 +496,28 @@ static inline void __media_device_usb_init(struct media_device *mdev,
>  #define media_device_usb_init(mdev, udev, name) \
>  	__media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
>  
> +static inline void
> +__media_set_bus_info(char *bus_info, size_t bus_info_size, struct device *dev)
> +{
> +	if (!dev || *bus_info)
> +		return;
> +
> +	if (dev_is_platform(dev))
> +		snprintf(bus_info, bus_info_size, "platform:%s", dev_name(dev));
> +	else if (dev_is_pci(dev))
> +		snprintf(bus_info, bus_info_size, "PCI:%s", dev_name(dev));
> +}

Does this have to be inline ?

> +
> +/**
> + * media_set_bus_info() - Conditionally set bus_info
> + *
> + * @bus_info:	Variable where to write the bus info (char array)
> + * @dev:	Related struct device
> + *
> + * Sets bus information based on device conditionally, if the first character of
> + * &bus_info is not '\0' and dev is non-NULL.
> + */
> +#define media_set_bus_info(bus_info, dev) \
> +	__media_set_bus_info(bus_info, sizeof(bus_info), dev)

I like the idea, but if the bus_info passed to the macro is a char *
instead of a char[], I think this will still compile, with
sizeof(bus_info) not giving the expected value. Could we either get a
compilation failure in that case, of maybe turn this into two inline
functions, one for media_device and the other one for v4l2_capability,
that would both call __media_set_bus_info() ? The latter may be better.

> +
>  #endif

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 2/3] media: Set bus_info in media_device_init()
  2022-01-22 16:36 ` [PATCH 2/3] media: Set bus_info in media_device_init() Sakari Ailus
@ 2022-01-22 23:48   ` Laurent Pinchart
  2022-01-24 15:59     ` Sakari Ailus
  0 siblings, 1 reply; 15+ messages in thread
From: Laurent Pinchart @ 2022-01-22 23:48 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-media, hverkuil

Hi Sakari,

Thank you for the patch.

On Sat, Jan 22, 2022 at 06:36:55PM +0200, Sakari Ailus wrote:
> Set bus_info field based on struct device in media_device_init(). Also
> remove corresponding code from drivers.

This looks fine to me, but the documentation should be updated to
explain that bus_info will be set by media_device_init(), and that
driver may then override the value if desired (and probably also list
the rules under which such an override is allowed).

> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/mc/mc-device.c                       | 2 ++
>  drivers/media/pci/intel/ipu3/ipu3-cio2-main.c      | 2 --
>  drivers/media/platform/rcar-vin/rcar-core.c        | 2 --
>  drivers/media/platform/stm32/stm32-dcmi.c          | 2 --
>  drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c | 2 --
>  drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 2 --
>  drivers/media/platform/ti-vpe/cal.c                | 2 --
>  drivers/media/platform/vsp1/vsp1_drv.c             | 2 --
>  8 files changed, 2 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
> index cf5e459b1d96..f7e1d63cec14 100644
> --- a/drivers/media/mc/mc-device.c
> +++ b/drivers/media/mc/mc-device.c
> @@ -715,6 +715,8 @@ void media_device_init(struct media_device *mdev)
>  
>  	atomic_set(&mdev->request_id, 0);
>  
> +	media_set_bus_info(mdev->bus_info, mdev->dev);
> +
>  	dev_dbg(mdev->dev, "Media device initialized\n");
>  }
>  EXPORT_SYMBOL_GPL(media_device_init);
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> index 0e9b0503b62a..b15fac775e14 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> @@ -1777,8 +1777,6 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
>  	cio2->media_dev.dev = dev;
>  	strscpy(cio2->media_dev.model, CIO2_DEVICE_NAME,
>  		sizeof(cio2->media_dev.model));
> -	snprintf(cio2->media_dev.bus_info, sizeof(cio2->media_dev.bus_info),
> -		 "PCI:%s", pci_name(cio2->pci_dev));
>  	cio2->media_dev.hw_revision = 0;
>  
>  	media_device_init(&cio2->media_dev);
> diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c
> index 0186ae235113..1099cab7d95d 100644
> --- a/drivers/media/platform/rcar-vin/rcar-core.c
> +++ b/drivers/media/platform/rcar-vin/rcar-core.c
> @@ -94,8 +94,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin,
>  
>  	strscpy(mdev->driver_name, KBUILD_MODNAME, sizeof(mdev->driver_name));
>  	strscpy(mdev->model, match->compatible, sizeof(mdev->model));
> -	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
> -		 dev_name(mdev->dev));
>  
>  	media_device_init(mdev);
>  
> diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c
> index 7694ffef5c00..90c69113ce60 100644
> --- a/drivers/media/platform/stm32/stm32-dcmi.c
> +++ b/drivers/media/platform/stm32/stm32-dcmi.c
> @@ -1970,8 +1970,6 @@ static int dcmi_probe(struct platform_device *pdev)
>  
>  	/* Initialize media device */
>  	strscpy(dcmi->mdev.model, DRV_NAME, sizeof(dcmi->mdev.model));
> -	snprintf(dcmi->mdev.bus_info, sizeof(dcmi->mdev.bus_info),
> -		 "platform:%s", DRV_NAME);
>  	dcmi->mdev.dev = &pdev->dev;
>  	media_device_init(&dcmi->mdev);
>  
> diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
> index 80a10f238bbe..18e6c65f4737 100644
> --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
> +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_csi.c
> @@ -173,8 +173,6 @@ static int sun4i_csi_probe(struct platform_device *pdev)
>  	strscpy(csi->mdev.model, "Allwinner Video Capture Device",
>  		sizeof(csi->mdev.model));
>  	csi->mdev.hw_revision = 0;
> -	snprintf(csi->mdev.bus_info, sizeof(csi->mdev.bus_info), "platform:%s",
> -		 dev_name(csi->dev));
>  	media_device_init(&csi->mdev);
>  	csi->v4l.mdev = &csi->mdev;
>  
> diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> index fc96921b0583..a971587dbbd1 100644
> --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
> @@ -733,8 +733,6 @@ static int sun6i_csi_v4l2_init(struct sun6i_csi *csi)
>  	strscpy(csi->media_dev.model, "Allwinner Video Capture Device",
>  		sizeof(csi->media_dev.model));
>  	csi->media_dev.hw_revision = 0;
> -	snprintf(csi->media_dev.bus_info, sizeof(csi->media_dev.bus_info),
> -		 "platform:%s", dev_name(csi->dev));
>  
>  	media_device_init(&csi->media_dev);
>  	v4l2_async_nf_init(&csi->notifier);
> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> index 4a4a6c5983f7..11f67abc2f38 100644
> --- a/drivers/media/platform/ti-vpe/cal.c
> +++ b/drivers/media/platform/ti-vpe/cal.c
> @@ -884,8 +884,6 @@ static int cal_media_init(struct cal_dev *cal)
>  	mdev->dev = cal->dev;
>  	mdev->hw_revision = cal->revision;
>  	strscpy(mdev->model, "CAL", sizeof(mdev->model));
> -	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
> -		 dev_name(mdev->dev));
>  	media_device_init(mdev);
>  
>  	/*
> diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
> index c9044785b903..d27594dbf0e1 100644
> --- a/drivers/media/platform/vsp1/vsp1_drv.c
> +++ b/drivers/media/platform/vsp1/vsp1_drv.c
> @@ -243,8 +243,6 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
>  	mdev->dev = vsp1->dev;
>  	mdev->hw_revision = vsp1->version;
>  	strscpy(mdev->model, vsp1->info->model, sizeof(mdev->model));
> -	snprintf(mdev->bus_info, sizeof(mdev->bus_info), "platform:%s",
> -		 dev_name(mdev->dev));
>  	media_device_init(mdev);
>  
>  	vsp1->media_ops.link_setup = vsp1_entity_link_setup;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap()
  2022-01-22 16:36 ` [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap() Sakari Ailus
@ 2022-01-22 23:51   ` Laurent Pinchart
  2022-01-24 16:02     ` Sakari Ailus
  0 siblings, 1 reply; 15+ messages in thread
From: Laurent Pinchart @ 2022-01-22 23:51 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-media, hverkuil

Hi Sakari,

Thank you for the patch.

On Sat, Jan 22, 2022 at 06:36:56PM +0200, Sakari Ailus wrote:
> The bus_info field is set by most drivers based on the type of the device
> bus as well as the name of the device. Do this in v4l_querycap() so
> drivers don't need to. This keeps compatibility with non-default and silly
> bus_info.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/common/saa7146/saa7146_video.c        | 1 -
>  drivers/media/pci/bt8xx/bttv-driver.c               | 2 --
>  drivers/media/pci/cx18/cx18-ioctl.c                 | 2 --
>  drivers/media/pci/cx88/cx88-blackbird.c             | 1 -
>  drivers/media/pci/cx88/cx88-video.c                 | 1 -
>  drivers/media/pci/dt3155/dt3155.c                   | 1 -
>  drivers/media/pci/intel/ipu3/ipu3-cio2-main.c       | 2 --
>  drivers/media/pci/ivtv/ivtv-ioctl.c                 | 1 -
>  drivers/media/pci/meye/meye.c                       | 1 -
>  drivers/media/pci/saa7134/saa7134-go7007.c          | 1 -
>  drivers/media/pci/saa7134/saa7134-video.c           | 1 -
>  drivers/media/pci/saa7164/saa7164-encoder.c         | 1 -
>  drivers/media/pci/saa7164/saa7164-vbi.c             | 1 -
>  drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c      | 2 --
>  drivers/media/pci/solo6x10/solo6x10-v4l2.c          | 2 --
>  drivers/media/pci/sta2x11/sta2x11_vip.c             | 2 --
>  drivers/media/pci/tw5864/tw5864-video.c             | 1 -
>  drivers/media/pci/tw68/tw68-video.c                 | 1 -
>  drivers/media/pci/tw686x/tw686x-video.c             | 2 --
>  drivers/media/platform/allegro-dvt/allegro-core.c   | 2 --
>  drivers/media/platform/davinci/vpbe_display.c       | 2 --
>  drivers/media/platform/davinci/vpif_capture.c       | 2 --
>  drivers/media/platform/davinci/vpif_display.c       | 2 --
>  drivers/media/platform/exynos-gsc/gsc-m2m.c         | 2 --
>  drivers/media/platform/exynos4-is/common.c          | 2 --
>  drivers/media/platform/exynos4-is/fimc-lite.c       | 2 --
>  drivers/media/platform/imx-jpeg/mxc-jpeg.c          | 2 --
>  drivers/media/platform/marvell-ccic/cafe-driver.c   | 1 -
>  drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c     | 2 --
>  drivers/media/platform/qcom/camss/camss-video.c     | 2 --
>  drivers/media/platform/rcar-vin/rcar-v4l2.c         | 2 --
>  drivers/media/platform/rcar_jpu.c                   | 2 --
>  drivers/media/platform/s5p-jpeg/jpeg-core.c         | 2 --
>  drivers/media/platform/s5p-mfc/s5p_mfc_dec.c        | 2 --
>  drivers/media/platform/s5p-mfc/s5p_mfc_enc.c        | 2 --
>  drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c | 2 --
>  drivers/media/platform/ti-vpe/cal-video.c           | 2 --
>  drivers/media/platform/vsp1/vsp1_histo.c            | 2 --
>  drivers/media/platform/vsp1/vsp1_video.c            | 2 --
>  drivers/media/radio/radio-maxiradio.c               | 2 --
>  drivers/media/v4l2-core/v4l2-ioctl.c                | 3 +++
>  41 files changed, 3 insertions(+), 67 deletions(-)
> 
> diff --git a/drivers/media/common/saa7146/saa7146_video.c b/drivers/media/common/saa7146/saa7146_video.c
> index 66215d9106a4..2296765079a4 100644
> --- a/drivers/media/common/saa7146/saa7146_video.c
> +++ b/drivers/media/common/saa7146/saa7146_video.c
> @@ -443,7 +443,6 @@ static int vidioc_querycap(struct file *file, void *fh, struct v4l2_capability *
>  
>  	strscpy((char *)cap->driver, "saa7146 v4l2", sizeof(cap->driver));
>  	strscpy((char *)cap->card, dev->ext->name, sizeof(cap->card));
> -	sprintf((char *)cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OVERLAY |
>  			    V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
>  			    V4L2_CAP_DEVICE_CAPS;
> diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
> index 8cc9bec43688..c3512299794c 100644
> --- a/drivers/media/pci/bt8xx/bttv-driver.c
> +++ b/drivers/media/pci/bt8xx/bttv-driver.c
> @@ -2435,8 +2435,6 @@ static int bttv_querycap(struct file *file, void  *priv,
>  
>  	strscpy(cap->driver, "bttv", sizeof(cap->driver));
>  	strscpy(cap->card, btv->video_dev.name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info),
> -		 "PCI:%s", pci_name(btv->c.pci));
>  	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
>  			    V4L2_CAP_STREAMING | V4L2_CAP_DEVICE_CAPS;
>  	if (no_overlay <= 0)
> diff --git a/drivers/media/pci/cx18/cx18-ioctl.c b/drivers/media/pci/cx18/cx18-ioctl.c
> index ce3f0141f94e..c8ba7841c720 100644
> --- a/drivers/media/pci/cx18/cx18-ioctl.c
> +++ b/drivers/media/pci/cx18/cx18-ioctl.c
> @@ -389,8 +389,6 @@ static int cx18_querycap(struct file *file, void *fh,
>  
>  	strscpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
>  	strscpy(vcap->card, cx->card_name, sizeof(vcap->card));
> -	snprintf(vcap->bus_info, sizeof(vcap->bus_info),
> -		 "PCI:%s", pci_name(cx->pci_dev));
>  	vcap->capabilities = cx->v4l2_cap | V4L2_CAP_DEVICE_CAPS;
>  	return 0;
>  }
> diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
> index d5da3bd5695d..c1b41a9283c1 100644
> --- a/drivers/media/pci/cx88/cx88-blackbird.c
> +++ b/drivers/media/pci/cx88/cx88-blackbird.c
> @@ -796,7 +796,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	struct cx88_core *core = dev->core;
>  
>  	strscpy(cap->driver, "cx88_blackbird", sizeof(cap->driver));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	return cx88_querycap(file, core, cap);
>  }
>  
> diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
> index c17ad9f7d822..d3729be89252 100644
> --- a/drivers/media/pci/cx88/cx88-video.c
> +++ b/drivers/media/pci/cx88/cx88-video.c
> @@ -808,7 +808,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	struct cx88_core *core = dev->core;
>  
>  	strscpy(cap->driver, "cx8800", sizeof(cap->driver));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	return cx88_querycap(file, core, cap);
>  }
>  
> diff --git a/drivers/media/pci/dt3155/dt3155.c b/drivers/media/pci/dt3155/dt3155.c
> index 961f844de99c..3ad72a53f2a5 100644
> --- a/drivers/media/pci/dt3155/dt3155.c
> +++ b/drivers/media/pci/dt3155/dt3155.c
> @@ -296,7 +296,6 @@ static int dt3155_querycap(struct file *filp, void *p,
>  
>  	strscpy(cap->driver, DT3155_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, DT3155_NAME " frame grabber", sizeof(cap->card));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(pd->pdev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> index b15fac775e14..de8cbacba793 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
> @@ -1050,8 +1050,6 @@ static int cio2_v4l2_querycap(struct file *file, void *fh,
>  
>  	strscpy(cap->driver, CIO2_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, CIO2_DEVICE_NAME, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info),
> -		 "PCI:%s", pci_name(cio2->pci_dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/pci/ivtv/ivtv-ioctl.c b/drivers/media/pci/ivtv/ivtv-ioctl.c
> index 0cdf6b3210c2..e5bc581ee464 100644
> --- a/drivers/media/pci/ivtv/ivtv-ioctl.c
> +++ b/drivers/media/pci/ivtv/ivtv-ioctl.c
> @@ -732,7 +732,6 @@ static int ivtv_querycap(struct file *file, void *fh, struct v4l2_capability *vc
>  
>  	strscpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
>  	strscpy(vcap->card, itv->card_name, sizeof(vcap->card));
> -	snprintf(vcap->bus_info, sizeof(vcap->bus_info), "PCI:%s", pci_name(itv->pdev));
>  	vcap->capabilities = itv->v4l2_cap | V4L2_CAP_DEVICE_CAPS;
>  	return 0;
>  }
> diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
> index 8944e4bd4638..5d87efd9b95c 100644
> --- a/drivers/media/pci/meye/meye.c
> +++ b/drivers/media/pci/meye/meye.c
> @@ -1012,7 +1012,6 @@ static int vidioc_querycap(struct file *file, void *fh,
>  {
>  	strscpy(cap->driver, "meye", sizeof(cap->driver));
>  	strscpy(cap->card, "meye", sizeof(cap->card));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/saa7134/saa7134-go7007.c b/drivers/media/pci/saa7134/saa7134-go7007.c
> index da83893ffee9..c0985ae2a05b 100644
> --- a/drivers/media/pci/saa7134/saa7134-go7007.c
> +++ b/drivers/media/pci/saa7134/saa7134-go7007.c
> @@ -421,7 +421,6 @@ static int saa7134_go7007_init(struct saa7134_dev *dev)
>  	}
>  
>  	go->board_id = GO7007_BOARDID_PCI_VOYAGER;
> -	snprintf(go->bus_info, sizeof(go->bus_info), "PCI:%s", pci_name(dev->pci));
>  	strscpy(go->name, saa7134_boards[dev->board].name, sizeof(go->name));
>  	go->hpi_ops = &saa7134_go7007_hpi_ops;
>  	go->hpi_context = saa;
> diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
> index 374c8e1087de..013314d6d78b 100644
> --- a/drivers/media/pci/saa7134/saa7134-video.c
> +++ b/drivers/media/pci/saa7134/saa7134-video.c
> @@ -1478,7 +1478,6 @@ int saa7134_querycap(struct file *file, void *priv,
>  	strscpy(cap->driver, "saa7134", sizeof(cap->driver));
>  	strscpy(cap->card, saa7134_boards[dev->board].name,
>  		sizeof(cap->card));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING |
>  			    V4L2_CAP_RADIO | V4L2_CAP_VIDEO_CAPTURE |
>  			    V4L2_CAP_VBI_CAPTURE | V4L2_CAP_DEVICE_CAPS;
> diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
> index 1d1d32e043f1..c1b6a0596801 100644
> --- a/drivers/media/pci/saa7164/saa7164-encoder.c
> +++ b/drivers/media/pci/saa7164/saa7164-encoder.c
> @@ -490,7 +490,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	strscpy(cap->driver, dev->name, sizeof(cap->driver));
>  	strscpy(cap->card, saa7164_boards[dev->board].name,
>  		sizeof(cap->card));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
>  			    V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE |
>  			    V4L2_CAP_DEVICE_CAPS;
> diff --git a/drivers/media/pci/saa7164/saa7164-vbi.c b/drivers/media/pci/saa7164/saa7164-vbi.c
> index cb2e09f0841d..a6738baab688 100644
> --- a/drivers/media/pci/saa7164/saa7164-vbi.c
> +++ b/drivers/media/pci/saa7164/saa7164-vbi.c
> @@ -201,7 +201,6 @@ static int vidioc_querycap(struct file *file, void  *priv,
>  	strscpy(cap->driver, dev->name, sizeof(cap->driver));
>  	strscpy(cap->card, saa7164_boards[dev->board].name,
>  		sizeof(cap->card));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
>  			    V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE |
>  			    V4L2_CAP_DEVICE_CAPS;
> diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> index 7766cadb73ea..956b2bbe9b71 100644
> --- a/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c
> @@ -769,8 +769,6 @@ static int solo_enc_querycap(struct file *file, void  *priv,
>  	strscpy(cap->driver, SOLO6X10_NAME, sizeof(cap->driver));
>  	snprintf(cap->card, sizeof(cap->card), "Softlogic 6x10 Enc %d",
>  		 solo_enc->ch);
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
> -		 pci_name(solo_dev->pdev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/solo6x10/solo6x10-v4l2.c b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
> index 24ef0c446bef..f0c0e66a9d58 100644
> --- a/drivers/media/pci/solo6x10/solo6x10-v4l2.c
> +++ b/drivers/media/pci/solo6x10/solo6x10-v4l2.c
> @@ -376,8 +376,6 @@ static int solo_querycap(struct file *file, void  *priv,
>  
>  	strscpy(cap->driver, SOLO6X10_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, "Softlogic 6x10", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
> -		 pci_name(solo_dev->pdev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/sta2x11/sta2x11_vip.c b/drivers/media/pci/sta2x11/sta2x11_vip.c
> index 524912f20d9f..9365ffd271c2 100644
> --- a/drivers/media/pci/sta2x11/sta2x11_vip.c
> +++ b/drivers/media/pci/sta2x11/sta2x11_vip.c
> @@ -405,8 +405,6 @@ static int vidioc_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
>  	strscpy(cap->card, KBUILD_MODNAME, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
> -		 pci_name(vip->pdev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
> index 9131265c2b87..197ed8978102 100644
> --- a/drivers/media/pci/tw5864/tw5864-video.c
> +++ b/drivers/media/pci/tw5864/tw5864-video.c
> @@ -604,7 +604,6 @@ static int tw5864_querycap(struct file *file, void *priv,
>  	strscpy(cap->driver, "tw5864", sizeof(cap->driver));
>  	snprintf(cap->card, sizeof(cap->card), "TW5864 Encoder %d",
>  		 input->nr);
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(input->root->pci));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
> index fe94944d0531..6013ff4f33ac 100644
> --- a/drivers/media/pci/tw68/tw68-video.c
> +++ b/drivers/media/pci/tw68/tw68-video.c
> @@ -717,7 +717,6 @@ static int tw68_querycap(struct file *file, void  *priv,
>  	strscpy(cap->driver, "tw68", sizeof(cap->driver));
>  	strscpy(cap->card, "Techwell Capture Card",
>  		sizeof(cap->card));
> -	sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
> index b227e9e78ebd..6344a479119f 100644
> --- a/drivers/media/pci/tw686x/tw686x-video.c
> +++ b/drivers/media/pci/tw686x/tw686x-video.c
> @@ -762,8 +762,6 @@ static int tw686x_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, "tw686x", sizeof(cap->driver));
>  	strscpy(cap->card, dev->name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info),
> -		 "PCI:%s", pci_name(dev->pci_dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
> index 4a3d06c70e34..b023a38c0ff4 100644
> --- a/drivers/media/platform/allegro-dvt/allegro-core.c
> +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
> @@ -3254,8 +3254,6 @@ static int allegro_querycap(struct file *file, void *fh,
>  
>  	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
>  	strscpy(cap->card, "Allegro DVT Video Encoder", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(&dev->plat_dev->dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c
> index bf3c3e76b921..9ea70817538e 100644
> --- a/drivers/media/platform/davinci/vpbe_display.c
> +++ b/drivers/media/platform/davinci/vpbe_display.c
> @@ -630,8 +630,6 @@ static int vpbe_display_querycap(struct file *file, void  *priv,
>  
>  	snprintf(cap->driver, sizeof(cap->driver), "%s",
>  		dev_name(vpbe_dev->pdev));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(vpbe_dev->pdev));
>  	strscpy(cap->card, vpbe_dev->cfg->module_name, sizeof(cap->card));
>  
>  	return 0;
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index 8fe55374c5a3..d4def719b71b 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1067,8 +1067,6 @@ static int vpif_querycap(struct file *file, void  *priv,
>  	struct vpif_capture_config *config = vpif_dev->platform_data;
>  
>  	strscpy(cap->driver, VPIF_DRIVER_NAME, sizeof(cap->driver));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(vpif_dev));
>  	strscpy(cap->card, config->card_name, sizeof(cap->card));
>  
>  	return 0;
> diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
> index 59f6b782e104..dfd4693ce67f 100644
> --- a/drivers/media/platform/davinci/vpif_display.c
> +++ b/drivers/media/platform/davinci/vpif_display.c
> @@ -585,8 +585,6 @@ static int vpif_querycap(struct file *file, void  *priv,
>  	struct vpif_display_config *config = vpif_dev->platform_data;
>  
>  	strscpy(cap->driver, VPIF_DRIVER_NAME, sizeof(cap->driver));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(vpif_dev));
>  	strscpy(cap->card, config->card_name, sizeof(cap->card));
>  
>  	return 0;
> diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c
> index f1cf847d1cc2..b6f54a513256 100644
> --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c
> +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c
> @@ -290,8 +290,6 @@ static int gsc_m2m_querycap(struct file *file, void *fh,
>  
>  	strscpy(cap->driver, GSC_MODULE_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, GSC_MODULE_NAME " gscaler", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(&gsc->pdev->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/exynos4-is/common.c b/drivers/media/platform/exynos4-is/common.c
> index 944b224eb621..cc1dc620d758 100644
> --- a/drivers/media/platform/exynos4-is/common.c
> +++ b/drivers/media/platform/exynos4-is/common.c
> @@ -38,8 +38,6 @@ void __fimc_vidioc_querycap(struct device *dev, struct v4l2_capability *cap)
>  {
>  	strscpy(cap->driver, dev->driver->name, sizeof(cap->driver));
>  	strscpy(cap->card, dev->driver->name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info),
> -				"platform:%s", dev_name(dev));
>  }
>  EXPORT_SYMBOL(__fimc_vidioc_querycap);
>  
> diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
> index aaa3af0493ce..d077e2e2f1f3 100644
> --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> @@ -650,8 +650,6 @@ static int fimc_lite_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, FIMC_LITE_DRV_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, FIMC_LITE_DRV_NAME, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -					dev_name(&fimc->pdev->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
> index 4ca96cf9def7..812bfa79df27 100644
> --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c
> +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c
> @@ -1531,8 +1531,6 @@ static int mxc_jpeg_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, MXC_JPEG_NAME " codec", sizeof(cap->driver));
>  	strscpy(cap->card, MXC_JPEG_NAME " codec", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(mxc_jpeg->dev));
>  	cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
>  	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
>  
> diff --git a/drivers/media/platform/marvell-ccic/cafe-driver.c b/drivers/media/platform/marvell-ccic/cafe-driver.c
> index 03dcf8bf705e..ae97ce4ead98 100644
> --- a/drivers/media/platform/marvell-ccic/cafe-driver.c
> +++ b/drivers/media/platform/marvell-ccic/cafe-driver.c
> @@ -497,7 +497,6 @@ static int cafe_pci_probe(struct pci_dev *pdev,
>  	mcam->plat_power_up = cafe_ctlr_power_up;
>  	mcam->plat_power_down = cafe_ctlr_power_down;
>  	mcam->dev = &pdev->dev;
> -	snprintf(mcam->bus_info, sizeof(mcam->bus_info), "PCI:%s", pci_name(pdev));
>  	/*
>  	 * Vmalloc mode for buffers is traditional with this driver.
>  	 * We *might* be able to run DMA_contig, especially on a system
> diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> index f332beb06d51..97afa57a165e 100644
> --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
> @@ -138,8 +138,6 @@ static int mtk_jpeg_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, jpeg->variant->dev_name, sizeof(cap->driver));
>  	strscpy(cap->card, jpeg->variant->dev_name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(jpeg->dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c
> index f282275af626..a1dc4d9c7215 100644
> --- a/drivers/media/platform/qcom/camss/camss-video.c
> +++ b/drivers/media/platform/qcom/camss/camss-video.c
> @@ -578,8 +578,6 @@ static int video_querycap(struct file *file, void *fh,
>  
>  	strscpy(cap->driver, "qcom-camss", sizeof(cap->driver));
>  	strscpy(cap->card, "Qualcomm Camera Subsystem", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(video->camss->dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index 2e60b9fce03b..4be2aff89d40 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -311,8 +311,6 @@ static int rvin_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
>  	strscpy(cap->card, "R_Car_VIN", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(vin->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
> index 56bb464629ed..776e21491506 100644
> --- a/drivers/media/platform/rcar_jpu.c
> +++ b/drivers/media/platform/rcar_jpu.c
> @@ -670,8 +670,6 @@ static int jpu_querycap(struct file *file, void *priv,
>  		strscpy(cap->card, DRV_NAME " decoder", sizeof(cap->card));
>  
>  	strscpy(cap->driver, DRV_NAME, sizeof(cap->driver));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(ctx->jpu->dev));
>  	memset(cap->reserved, 0, sizeof(cap->reserved));
>  
>  	return 0;
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index a8d9159d5ed8..73d05bc904f2 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -1257,8 +1257,6 @@ static int s5p_jpeg_querycap(struct file *file, void *priv,
>  		strscpy(cap->card, S5P_JPEG_M2M_NAME " decoder",
>  			sizeof(cap->card));
>  	}
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(ctx->jpeg->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> index c1d3bda8385b..2f41feb07902 100644
> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c
> @@ -270,8 +270,6 @@ static int vidioc_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, S5P_MFC_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, dev->vfd_dec->name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(&dev->plat_dev->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
> index 1fad99edb091..6678d551ae37 100644
> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
> @@ -1309,8 +1309,6 @@ static int vidioc_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, S5P_MFC_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, dev->vfd_enc->name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(&dev->plat_dev->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
> index 3872027ed2fa..adffedce5e4b 100644
> --- a/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
> +++ b/drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c
> @@ -57,8 +57,6 @@ static int sun4i_csi_querycap(struct file *file, void *priv,
>  
>  	strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver));
>  	strscpy(cap->card, "sun4i-csi", sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(csi->dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti-vpe/cal-video.c
> index 7799da1cc261..2efb1ba97695 100644
> --- a/drivers/media/platform/ti-vpe/cal-video.c
> +++ b/drivers/media/platform/ti-vpe/cal-video.c
> @@ -52,8 +52,6 @@ static int cal_querycap(struct file *file, void *priv,
>  	strscpy(cap->driver, CAL_MODULE_NAME, sizeof(cap->driver));
>  	strscpy(cap->card, CAL_MODULE_NAME, sizeof(cap->card));
>  
> -	snprintf(cap->bus_info, sizeof(cap->bus_info),
> -		 "platform:%s", dev_name(ctx->cal->dev));
>  	return 0;
>  }
>  
> diff --git a/drivers/media/platform/vsp1/vsp1_histo.c b/drivers/media/platform/vsp1/vsp1_histo.c
> index 5e5013d2cd2a..f22449dd654c 100644
> --- a/drivers/media/platform/vsp1/vsp1_histo.c
> +++ b/drivers/media/platform/vsp1/vsp1_histo.c
> @@ -434,8 +434,6 @@ static int histo_v4l2_querycap(struct file *file, void *fh,
>  
>  	strscpy(cap->driver, "vsp1", sizeof(cap->driver));
>  	strscpy(cap->card, histo->video.name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(histo->entity.vsp1->dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
> index 044eb5778820..497f352e9f8c 100644
> --- a/drivers/media/platform/vsp1/vsp1_video.c
> +++ b/drivers/media/platform/vsp1/vsp1_video.c
> @@ -959,8 +959,6 @@ vsp1_video_querycap(struct file *file, void *fh, struct v4l2_capability *cap)
>  
>  	strscpy(cap->driver, "vsp1", sizeof(cap->driver));
>  	strscpy(cap->card, video->video.name, sizeof(cap->card));
> -	snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> -		 dev_name(video->vsp1->dev));
>  
>  	return 0;
>  }
> diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
> index de107e2cbcd6..1a5dbae24ef4 100644
> --- a/drivers/media/radio/radio-maxiradio.c
> +++ b/drivers/media/radio/radio-maxiradio.c
> @@ -144,8 +144,6 @@ static int maxiradio_probe(struct pci_dev *pdev,
>  	dev->tea.v4l2_dev = v4l2_dev;
>  	dev->tea.radio_nr = radio_nr;
>  	strscpy(dev->tea.card, "Maxi Radio FM2000", sizeof(dev->tea.card));
> -	snprintf(dev->tea.bus_info, sizeof(dev->tea.bus_info),
> -			"PCI:%s", pci_name(pdev));
>  
>  	retval = -ENODEV;
>  
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index 642cb90f457c..81ebf6cca522 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -18,6 +18,7 @@
>  
>  #include <linux/videodev2.h>
>  
> +#include <media/media-device.h> /* for media_set_bus_info() */
>  #include <media/v4l2-common.h>
>  #include <media/v4l2-ioctl.h>
>  #include <media/v4l2-ctrls.h>
> @@ -1069,6 +1070,8 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
>  	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
>  	cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
>  
> +	media_set_bus_info(cap->bus_info, vfd->dev_parent);
> +

Shouldn't you do this before calling the driver operation, if you want
to allow driver overrides ?

>  	return ret;
>  }
>  

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 1/3] media: Provide a helper for setting bus_info field
  2022-01-22 23:44   ` Laurent Pinchart
@ 2022-01-24 15:55     ` Sakari Ailus
  0 siblings, 0 replies; 15+ messages in thread
From: Sakari Ailus @ 2022-01-24 15:55 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, hverkuil

Hi Laurent,

Thanks for the review.

On Sun, Jan 23, 2022 at 01:44:02AM +0200, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Sat, Jan 22, 2022 at 06:36:54PM +0200, Sakari Ailus wrote:
> > The bus_info or a similar field exists in a lot of structs, yet drivers
> > tend to set the value of that field by themselves in a determinable way.
> > Thus provide a helper for doing this. To be used in subsequent patches.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  include/media/media-device.h | 30 +++++++++++++++++++++++++++---
> >  1 file changed, 27 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/media/media-device.h b/include/media/media-device.h
> > index 1345e6da688a..9f0458068196 100644
> > --- a/include/media/media-device.h
> > +++ b/include/media/media-device.h
> > @@ -13,12 +13,13 @@
> >  
> >  #include <linux/list.h>
> >  #include <linux/mutex.h>
> > +#include <linux/pci.h>
> > +#include <linux/platform_device.h>
> >  
> >  #include <media/media-devnode.h>
> >  #include <media/media-entity.h>
> >  
> >  struct ida;
> > -struct device;
> >  struct media_device;
> >  
> >  /**
> > @@ -181,8 +182,7 @@ struct media_device {
> >  	atomic_t request_id;
> >  };
> >  
> > -/* We don't need to include pci.h or usb.h here */
> > -struct pci_dev;
> > +/* We don't need to include usb.h here */
> >  struct usb_device;
> >  
> >  #ifdef CONFIG_MEDIA_CONTROLLER
> > @@ -496,4 +496,28 @@ static inline void __media_device_usb_init(struct media_device *mdev,
> >  #define media_device_usb_init(mdev, udev, name) \
> >  	__media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
> >  
> > +static inline void
> > +__media_set_bus_info(char *bus_info, size_t bus_info_size, struct device *dev)
> > +{
> > +	if (!dev || *bus_info)
> > +		return;
> > +
> > +	if (dev_is_platform(dev))
> > +		snprintf(bus_info, bus_info_size, "platform:%s", dev_name(dev));
> > +	else if (dev_is_pci(dev))
> > +		snprintf(bus_info, bus_info_size, "PCI:%s", dev_name(dev));
> > +}
> 
> Does this have to be inline ?

Not necessarily. But we'll need a new module if it isn't --- this code will
be needed in both MC and V4L2 separately.

> 
> > +
> > +/**
> > + * media_set_bus_info() - Conditionally set bus_info
> > + *
> > + * @bus_info:	Variable where to write the bus info (char array)
> > + * @dev:	Related struct device
> > + *
> > + * Sets bus information based on device conditionally, if the first character of
> > + * &bus_info is not '\0' and dev is non-NULL.
> > + */
> > +#define media_set_bus_info(bus_info, dev) \
> > +	__media_set_bus_info(bus_info, sizeof(bus_info), dev)
> 
> I like the idea, but if the bus_info passed to the macro is a char *
> instead of a char[], I think this will still compile, with
> sizeof(bus_info) not giving the expected value. Could we either get a
> compilation failure in that case, of maybe turn this into two inline
> functions, one for media_device and the other one for v4l2_capability,
> that would both call __media_set_bus_info() ? The latter may be better.

The latter, yes. There will be so few users that's entirely fine.

-- 
Kind regards,

Sakari Ailus

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

* Re: [PATCH 2/3] media: Set bus_info in media_device_init()
  2022-01-22 23:48   ` Laurent Pinchart
@ 2022-01-24 15:59     ` Sakari Ailus
  2022-01-24 16:21       ` Laurent Pinchart
  0 siblings, 1 reply; 15+ messages in thread
From: Sakari Ailus @ 2022-01-24 15:59 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, hverkuil

Hi Laurent,

On Sun, Jan 23, 2022 at 01:48:16AM +0200, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thank you for the patch.
> 
> On Sat, Jan 22, 2022 at 06:36:55PM +0200, Sakari Ailus wrote:
> > Set bus_info field based on struct device in media_device_init(). Also
> > remove corresponding code from drivers.
> 
> This looks fine to me, but the documentation should be updated to
> explain that bus_info will be set by media_device_init(), and that
> driver may then override the value if desired (and probably also list
> the rules under which such an override is allowed).

We haven't really documented that for other fields either and rather relied
more on examples. I can add that if you still think so though.

-- 
Sakari Ailus

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

* Re: [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap()
  2022-01-22 23:51   ` Laurent Pinchart
@ 2022-01-24 16:02     ` Sakari Ailus
  2022-01-24 16:23       ` Laurent Pinchart
  0 siblings, 1 reply; 15+ messages in thread
From: Sakari Ailus @ 2022-01-24 16:02 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, hverkuil

Hi Laurent,

On Sun, Jan 23, 2022 at 01:51:10AM +0200, Laurent Pinchart wrote:

...

> > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > index 642cb90f457c..81ebf6cca522 100644
> > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > @@ -18,6 +18,7 @@
> >  
> >  #include <linux/videodev2.h>
> >  
> > +#include <media/media-device.h> /* for media_set_bus_info() */
> >  #include <media/v4l2-common.h>
> >  #include <media/v4l2-ioctl.h>
> >  #include <media/v4l2-ctrls.h>
> > @@ -1069,6 +1070,8 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
> >  	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
> >  	cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
> >  
> > +	media_set_bus_info(cap->bus_info, vfd->dev_parent);
> > +
> 
> Shouldn't you do this before calling the driver operation, if you want
> to allow driver overrides ?

This is done conditionally based on the value of the first byte.

-- 
Sakari Ailus

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

* Re: [PATCH 2/3] media: Set bus_info in media_device_init()
  2022-01-24 15:59     ` Sakari Ailus
@ 2022-01-24 16:21       ` Laurent Pinchart
  0 siblings, 0 replies; 15+ messages in thread
From: Laurent Pinchart @ 2022-01-24 16:21 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-media, hverkuil

Hi Sakari,

On Mon, Jan 24, 2022 at 05:59:32PM +0200, Sakari Ailus wrote:
> On Sun, Jan 23, 2022 at 01:48:16AM +0200, Laurent Pinchart wrote:
> > On Sat, Jan 22, 2022 at 06:36:55PM +0200, Sakari Ailus wrote:
> > > Set bus_info field based on struct device in media_device_init(). Also
> > > remove corresponding code from drivers.
> > 
> > This looks fine to me, but the documentation should be updated to
> > explain that bus_info will be set by media_device_init(), and that
> > driver may then override the value if desired (and probably also list
> > the rules under which such an override is allowed).
> 
> We haven't really documented that for other fields either and rather relied
> more on examples. I can add that if you still think so though.

There's sooooo much cargo-cult in V4L2 that adding a bit more may not
make a big difference, but on the other hand, now is as good as ever to
start and address this :-)

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap()
  2022-01-24 16:02     ` Sakari Ailus
@ 2022-01-24 16:23       ` Laurent Pinchart
  2022-01-24 16:47         ` Sakari Ailus
  0 siblings, 1 reply; 15+ messages in thread
From: Laurent Pinchart @ 2022-01-24 16:23 UTC (permalink / raw)
  To: Sakari Ailus; +Cc: linux-media, hverkuil

On Mon, Jan 24, 2022 at 06:02:59PM +0200, Sakari Ailus wrote:
> Hi Laurent,
> 
> On Sun, Jan 23, 2022 at 01:51:10AM +0200, Laurent Pinchart wrote:
> 
> ...
> 
> > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > index 642cb90f457c..81ebf6cca522 100644
> > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > @@ -18,6 +18,7 @@
> > >  
> > >  #include <linux/videodev2.h>
> > >  
> > > +#include <media/media-device.h> /* for media_set_bus_info() */
> > >  #include <media/v4l2-common.h>
> > >  #include <media/v4l2-ioctl.h>
> > >  #include <media/v4l2-ctrls.h>
> > > @@ -1069,6 +1070,8 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
> > >  	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
> > >  	cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
> > >  
> > > +	media_set_bus_info(cap->bus_info, vfd->dev_parent);
> > > +
> > 
> > Shouldn't you do this before calling the driver operation, if you want
> > to allow driver overrides ?
> 
> This is done conditionally based on the value of the first byte.

I had missed that.

Isn't it still better to call media_set_bus_info() first, instead of
checking the first byte ?

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap()
  2022-01-24 16:23       ` Laurent Pinchart
@ 2022-01-24 16:47         ` Sakari Ailus
  0 siblings, 0 replies; 15+ messages in thread
From: Sakari Ailus @ 2022-01-24 16:47 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-media, hverkuil

On Mon, Jan 24, 2022 at 06:23:12PM +0200, Laurent Pinchart wrote:
> On Mon, Jan 24, 2022 at 06:02:59PM +0200, Sakari Ailus wrote:
> > Hi Laurent,
> > 
> > On Sun, Jan 23, 2022 at 01:51:10AM +0200, Laurent Pinchart wrote:
> > 
> > ...
> > 
> > > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > > index 642cb90f457c..81ebf6cca522 100644
> > > > --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> > > > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> > > > @@ -18,6 +18,7 @@
> > > >  
> > > >  #include <linux/videodev2.h>
> > > >  
> > > > +#include <media/media-device.h> /* for media_set_bus_info() */
> > > >  #include <media/v4l2-common.h>
> > > >  #include <media/v4l2-ioctl.h>
> > > >  #include <media/v4l2-ctrls.h>
> > > > @@ -1069,6 +1070,8 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
> > > >  	cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
> > > >  	cap->device_caps |= V4L2_CAP_EXT_PIX_FORMAT;
> > > >  
> > > > +	media_set_bus_info(cap->bus_info, vfd->dev_parent);
> > > > +
> > > 
> > > Shouldn't you do this before calling the driver operation, if you want
> > > to allow driver overrides ?
> > 
> > This is done conditionally based on the value of the first byte.
> 
> I had missed that.
> 
> Isn't it still better to call media_set_bus_info() first, instead of
> checking the first byte ?

The result would be no different although it's easier to see what's going
on. This approach would work for querycap but not for media device init.

I'll take this into account in v2.

-- 
Sakari Ailus

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

* Re: [PATCH 1/3] media: Provide a helper for setting bus_info field
  2022-01-22 16:36 ` [PATCH 1/3] media: Provide a helper for setting bus_info field Sakari Ailus
  2022-01-22 23:44   ` Laurent Pinchart
@ 2022-01-25 12:54   ` Hans Verkuil
  2022-01-26 16:07     ` Sakari Ailus
  1 sibling, 1 reply; 15+ messages in thread
From: Hans Verkuil @ 2022-01-25 12:54 UTC (permalink / raw)
  To: Sakari Ailus, linux-media; +Cc: laurent.pinchart

Hi Sakari,

On 22/01/2022 17:36, Sakari Ailus wrote:
> The bus_info or a similar field exists in a lot of structs, yet drivers
> tend to set the value of that field by themselves in a determinable way.
> Thus provide a helper for doing this. To be used in subsequent patches.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  include/media/media-device.h | 30 +++++++++++++++++++++++++++---
>  1 file changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/include/media/media-device.h b/include/media/media-device.h
> index 1345e6da688a..9f0458068196 100644
> --- a/include/media/media-device.h
> +++ b/include/media/media-device.h
> @@ -13,12 +13,13 @@
>  
>  #include <linux/list.h>
>  #include <linux/mutex.h>
> +#include <linux/pci.h>
> +#include <linux/platform_device.h>
>  
>  #include <media/media-devnode.h>
>  #include <media/media-entity.h>
>  
>  struct ida;
> -struct device;
>  struct media_device;
>  
>  /**
> @@ -181,8 +182,7 @@ struct media_device {
>  	atomic_t request_id;
>  };
>  
> -/* We don't need to include pci.h or usb.h here */
> -struct pci_dev;
> +/* We don't need to include usb.h here */
>  struct usb_device;
>  
>  #ifdef CONFIG_MEDIA_CONTROLLER
> @@ -496,4 +496,28 @@ static inline void __media_device_usb_init(struct media_device *mdev,
>  #define media_device_usb_init(mdev, udev, name) \
>  	__media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
>  
> +static inline void
> +__media_set_bus_info(char *bus_info, size_t bus_info_size, struct device *dev)
> +{
> +	if (!dev || *bus_info)
> +		return;
> +
> +	if (dev_is_platform(dev))
> +		snprintf(bus_info, bus_info_size, "platform:%s", dev_name(dev));
> +	else if (dev_is_pci(dev))
> +		snprintf(bus_info, bus_info_size, "PCI:%s", dev_name(dev));
> +}
> +
> +/**
> + * media_set_bus_info() - Conditionally set bus_info
> + *
> + * @bus_info:	Variable where to write the bus info (char array)
> + * @dev:	Related struct device
> + *
> + * Sets bus information based on device conditionally, if the first character of
> + * &bus_info is not '\0' and dev is non-NULL.
> + */
> +#define media_set_bus_info(bus_info, dev) \
> +	__media_set_bus_info(bus_info, sizeof(bus_info), dev)

Wouldn't it be simpler to make two #defines:

#define media_set_bus_info(mdev, dev) \
	__media_set_bus_info(mdev->bus_info, sizeof(mdev->bus_info), dev)

and:

#define v4l2_cap_set_bus_info(cap, dev) \
	__media_set_bus_info(cap->bus_info, sizeof(cap->bus_info), dev)

That way the sizeof() always works correctly.

This could also be static inlines to have better type checking, of course.

Another option is:

#define media_set_bus_info(s, dev) \
	__media_set_bus_info((s)->bus_info, sizeof((s)->bus_info), dev)

That's more generic, but it does make the assumption that the struct s
has a field bus_info. Which is a reasonable assumption IMHO.

I do like the idea of this series.

Regards,

	Hans

> +
>  #endif


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

* Re: [PATCH 1/3] media: Provide a helper for setting bus_info field
  2022-01-25 12:54   ` Hans Verkuil
@ 2022-01-26 16:07     ` Sakari Ailus
  0 siblings, 0 replies; 15+ messages in thread
From: Sakari Ailus @ 2022-01-26 16:07 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, laurent.pinchart

Hi Hans,

On Tue, Jan 25, 2022 at 01:54:45PM +0100, Hans Verkuil wrote:
> Hi Sakari,
> 
> On 22/01/2022 17:36, Sakari Ailus wrote:
> > The bus_info or a similar field exists in a lot of structs, yet drivers
> > tend to set the value of that field by themselves in a determinable way.
> > Thus provide a helper for doing this. To be used in subsequent patches.
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  include/media/media-device.h | 30 +++++++++++++++++++++++++++---
> >  1 file changed, 27 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/media/media-device.h b/include/media/media-device.h
> > index 1345e6da688a..9f0458068196 100644
> > --- a/include/media/media-device.h
> > +++ b/include/media/media-device.h
> > @@ -13,12 +13,13 @@
> >  
> >  #include <linux/list.h>
> >  #include <linux/mutex.h>
> > +#include <linux/pci.h>
> > +#include <linux/platform_device.h>
> >  
> >  #include <media/media-devnode.h>
> >  #include <media/media-entity.h>
> >  
> >  struct ida;
> > -struct device;
> >  struct media_device;
> >  
> >  /**
> > @@ -181,8 +182,7 @@ struct media_device {
> >  	atomic_t request_id;
> >  };
> >  
> > -/* We don't need to include pci.h or usb.h here */
> > -struct pci_dev;
> > +/* We don't need to include usb.h here */
> >  struct usb_device;
> >  
> >  #ifdef CONFIG_MEDIA_CONTROLLER
> > @@ -496,4 +496,28 @@ static inline void __media_device_usb_init(struct media_device *mdev,
> >  #define media_device_usb_init(mdev, udev, name) \
> >  	__media_device_usb_init(mdev, udev, name, KBUILD_MODNAME)
> >  
> > +static inline void
> > +__media_set_bus_info(char *bus_info, size_t bus_info_size, struct device *dev)
> > +{
> > +	if (!dev || *bus_info)
> > +		return;
> > +
> > +	if (dev_is_platform(dev))
> > +		snprintf(bus_info, bus_info_size, "platform:%s", dev_name(dev));
> > +	else if (dev_is_pci(dev))
> > +		snprintf(bus_info, bus_info_size, "PCI:%s", dev_name(dev));
> > +}
> > +
> > +/**
> > + * media_set_bus_info() - Conditionally set bus_info
> > + *
> > + * @bus_info:	Variable where to write the bus info (char array)
> > + * @dev:	Related struct device
> > + *
> > + * Sets bus information based on device conditionally, if the first character of
> > + * &bus_info is not '\0' and dev is non-NULL.
> > + */
> > +#define media_set_bus_info(bus_info, dev) \
> > +	__media_set_bus_info(bus_info, sizeof(bus_info), dev)
> 
> Wouldn't it be simpler to make two #defines:
> 
> #define media_set_bus_info(mdev, dev) \
> 	__media_set_bus_info(mdev->bus_info, sizeof(mdev->bus_info), dev)
> 
> and:
> 
> #define v4l2_cap_set_bus_info(cap, dev) \
> 	__media_set_bus_info(cap->bus_info, sizeof(cap->bus_info), dev)
> 
> That way the sizeof() always works correctly.
> 
> This could also be static inlines to have better type checking, of course.
> 
> Another option is:
> 
> #define media_set_bus_info(s, dev) \
> 	__media_set_bus_info((s)->bus_info, sizeof((s)->bus_info), dev)
> 
> That's more generic, but it does make the assumption that the struct s
> has a field bus_info. Which is a reasonable assumption IMHO.
> 
> I do like the idea of this series.

Thanks for the comments.

I prefer Laurent's suggestion of removing the macro and simply using
sizeof() in the caller. Note that there will be a very small number of
these calls and so far none in the drivers (nor there should be any).

-- 
Kind regards,

Sakari Ailus

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

end of thread, other threads:[~2022-01-26 16:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-22 16:36 [PATCH 0/3] Set bus_info field in framework Sakari Ailus
2022-01-22 16:36 ` [PATCH 1/3] media: Provide a helper for setting bus_info field Sakari Ailus
2022-01-22 23:44   ` Laurent Pinchart
2022-01-24 15:55     ` Sakari Ailus
2022-01-25 12:54   ` Hans Verkuil
2022-01-26 16:07     ` Sakari Ailus
2022-01-22 16:36 ` [PATCH 2/3] media: Set bus_info in media_device_init() Sakari Ailus
2022-01-22 23:48   ` Laurent Pinchart
2022-01-24 15:59     ` Sakari Ailus
2022-01-24 16:21       ` Laurent Pinchart
2022-01-22 16:36 ` [PATCH 3/3] v4l: ioctl: Set bus_info in v4l_querycap() Sakari Ailus
2022-01-22 23:51   ` Laurent Pinchart
2022-01-24 16:02     ` Sakari Ailus
2022-01-24 16:23       ` Laurent Pinchart
2022-01-24 16:47         ` Sakari Ailus

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).