summaryrefslogtreecommitdiffstats
path: root/drivers/media/media-device.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-22 10:10:49 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-23 05:19:39 -0500
commit6cf5dad17e913fce1ccb0c38e199eff15b0f03cc (patch)
treeb039fae16d8290e8d54e4e614a1a0fb3dfd7e34a /drivers/media/media-device.c
parent41b44e35ba9b34e50a65c05ecf7642c07bd3e8aa (diff)
[media] media_device: move allocation out of media_device_*_init
Right now, media_device_pci_init and media_device_usb_init does media_device allocation internaly. That preents its usage when the media_device struct is embedded on some other structure. Move memory allocation outside it, to make it more generic. 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.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index fe376b6b5244..6613723f5eb8 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -755,16 +755,11 @@ struct media_device *media_device_find_devres(struct device *dev)
755} 755}
756EXPORT_SYMBOL_GPL(media_device_find_devres); 756EXPORT_SYMBOL_GPL(media_device_find_devres);
757 757
758struct media_device *media_device_pci_init(struct pci_dev *pci_dev, 758void media_device_pci_init(struct media_device *mdev,
759 const char *name) 759 struct pci_dev *pci_dev,
760 const char *name)
760{ 761{
761#ifdef CONFIG_PCI 762#ifdef CONFIG_PCI
762 struct media_device *mdev;
763
764 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
765 if (!mdev)
766 return NULL;
767
768 mdev->dev = &pci_dev->dev; 763 mdev->dev = &pci_dev->dev;
769 764
770 if (name) 765 if (name)
@@ -780,25 +775,16 @@ struct media_device *media_device_pci_init(struct pci_dev *pci_dev,
780 mdev->driver_version = LINUX_VERSION_CODE; 775 mdev->driver_version = LINUX_VERSION_CODE;
781 776
782 media_device_init(mdev); 777 media_device_init(mdev);
783
784 return mdev;
785#else
786 return NULL;
787#endif 778#endif
788} 779}
789EXPORT_SYMBOL_GPL(media_device_pci_init); 780EXPORT_SYMBOL_GPL(media_device_pci_init);
790 781
791struct media_device *__media_device_usb_init(struct usb_device *udev, 782void __media_device_usb_init(struct media_device *mdev,
792 const char *board_name, 783 struct usb_device *udev,
793 const char *driver_name) 784 const char *board_name,
785 const char *driver_name)
794{ 786{
795#ifdef CONFIG_USB 787#ifdef CONFIG_USB
796 struct media_device *mdev;
797
798 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
799 if (!mdev)
800 return NULL;
801
802 mdev->dev = &udev->dev; 788 mdev->dev = &udev->dev;
803 789
804 if (driver_name) 790 if (driver_name)
@@ -818,10 +804,6 @@ struct media_device *__media_device_usb_init(struct usb_device *udev,
818 mdev->driver_version = LINUX_VERSION_CODE; 804 mdev->driver_version = LINUX_VERSION_CODE;
819 805
820 media_device_init(mdev); 806 media_device_init(mdev);
821
822 return mdev;
823#else
824 return NULL;
825#endif 807#endif
826} 808}
827EXPORT_SYMBOL_GPL(__media_device_usb_init); 809EXPORT_SYMBOL_GPL(__media_device_usb_init);