[media] allow overriding the driver name
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 11 Feb 2016 16:24:23 +0000 (14:24 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 16 Feb 2016 10:41:10 +0000 (08:41 -0200)
On USB drivers, the dev struct is usually filled with the USB
device. That would mean that the name of the driver specified
by media_device.dev.driver.name would be "usb", instead of the
name of the actual driver that created the media entity.

Add an optional field at the internal struct to allow drivers
to override the driver name.

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/media-device.c
include/media/media-device.h

index 4d1c13de494bfb9f7a4957311225211250480b5d..5ebb3cd3134568a4b6768cdbfdeec041cf669034 100644 (file)
@@ -55,7 +55,11 @@ static int media_device_get_info(struct media_device *dev,
 
        memset(&info, 0, sizeof(info));
 
-       strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
+       if (dev->driver_name[0])
+               strlcpy(info.driver, dev->driver_name, sizeof(info.driver));
+       else
+               strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
+
        strlcpy(info.model, dev->model, sizeof(info.model));
        strlcpy(info.serial, dev->serial, sizeof(info.serial));
        strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info));
index d3855898c3fc6767fe7f7fb30895173845e8548f..165451bc3985334737ff0f2cbddff184a4c5f568 100644 (file)
@@ -268,6 +268,10 @@ struct device;
  * struct media_device - Media device
  * @dev:       Parent device
  * @devnode:   Media device node
+ * @driver_name: Optional device driver name. If not set, calls to
+ *             %MEDIA_IOC_DEVICE_INFO will return dev->driver->name.
+ *             This is needed for USB drivers for example, as otherwise
+ *             they'll all appear as if the driver name was "usb".
  * @model:     Device model name
  * @serial:    Device serial number (optional)
  * @bus_info:  Unique and stable device location identifier
@@ -303,6 +307,7 @@ struct media_device {
        struct media_devnode devnode;
 
        char model[32];
+       char driver_name[32];
        char serial[40];
        char bus_info[32];
        u32 hw_revision;
This page took 0.0269509999999999 seconds and 5 git commands to generate.