[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>
This commit is contained in:
@@ -755,16 +755,11 @@ 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)
|
||||
void media_device_pci_init(struct media_device *mdev,
|
||||
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)
|
||||
@@ -780,25 +775,16 @@ struct media_device *media_device_pci_init(struct pci_dev *pci_dev,
|
||||
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)
|
||||
void __media_device_usb_init(struct media_device *mdev,
|
||||
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)
|
||||
@@ -818,10 +804,6 @@ struct media_device *__media_device_usb_init(struct usb_device *udev,
|
||||
mdev->driver_version = LINUX_VERSION_CODE;
|
||||
|
||||
media_device_init(mdev);
|
||||
|
||||
return mdev;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__media_device_usb_init);
|
||||
|
Reference in New Issue
Block a user