diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-02-22 11:42:04 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-02-23 07:18:45 -0300 |
commit | 41b44e35ba9b34e50a65c05ecf7642c07bd3e8aa (patch) | |
tree | 32743771d16d1b18d305600dc66d0f4828fecbde /drivers/media/media-device.c | |
parent | 2ddf22eec4b88ab0d4235a140db8243eaaab5128 (diff) | |
download | linux-41b44e35ba9b34e50a65c05ecf7642c07bd3e8aa.tar.bz2 |
[media] media-device: move PCI/USB helper functions from v4l2-mc
Those ancillary functions could be called even when compiled
without V4L2 support, as warned by ktest build robot:
All errors (new ones prefixed by >>):
>> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/dvb-usb/dvb-usb.ko] undefined!
>> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/dvb-usb-v2/dvb_usb_v2.ko] undefined!
>> ERROR: "__v4l2_mc_usb_media_device_init" [drivers/media/usb/au0828/au0828.ko] undefined!
Also, there's nothing there that are specific to V4L2. So, move
those ancillary functions to MC core.
No functional changes. Just function rename.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r-- | drivers/media/media-device.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 5ebb3cd31345..fe376b6b5244 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -27,6 +27,8 @@ #include <linux/media.h> #include <linux/slab.h> #include <linux/types.h> +#include <linux/pci.h> +#include <linux/usb.h> #include <media/media-device.h> #include <media/media-devnode.h> @@ -753,4 +755,76 @@ struct media_device *media_device_find_devres(struct device *dev) } EXPORT_SYMBOL_GPL(media_device_find_devres); +struct media_device *media_device_pci_init(struct pci_dev *pci_dev, + const char *name) +{ +#ifdef CONFIG_PCI + struct media_device *mdev; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return NULL; + + mdev->dev = &pci_dev->dev; + + if (name) + strlcpy(mdev->model, name, sizeof(mdev->model)); + else + strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model)); + + sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev)); + + mdev->hw_revision = (pci_dev->subsystem_vendor << 16) + | pci_dev->subsystem_device; + + mdev->driver_version = LINUX_VERSION_CODE; + + media_device_init(mdev); + + return mdev; +#else + return NULL; +#endif +} +EXPORT_SYMBOL_GPL(media_device_pci_init); + +struct media_device *__media_device_usb_init(struct usb_device *udev, + const char *board_name, + const char *driver_name) +{ +#ifdef CONFIG_USB + struct media_device *mdev; + + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); + if (!mdev) + return NULL; + + mdev->dev = &udev->dev; + + if (driver_name) + strlcpy(mdev->driver_name, driver_name, + sizeof(mdev->driver_name)); + + if (board_name) + strlcpy(mdev->model, board_name, sizeof(mdev->model)); + else if (udev->product) + strlcpy(mdev->model, udev->product, sizeof(mdev->model)); + else + strlcpy(mdev->model, "unknown model", sizeof(mdev->model)); + if (udev->serial) + strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial)); + usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info)); + mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); + mdev->driver_version = LINUX_VERSION_CODE; + + media_device_init(mdev); + + return mdev; +#else + return NULL; +#endif +} +EXPORT_SYMBOL_GPL(__media_device_usb_init); + + #endif /* CONFIG_MEDIA_CONTROLLER */ |