From 6cf5dad17e913fce1ccb0c38e199eff15b0f03cc Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 22 Feb 2016 12:10:49 -0300 Subject: [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 --- include/media/media-device.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'include/media') diff --git a/include/media/media-device.h b/include/media/media-device.h index 2d144fed936e..49dda6c7e664 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -550,16 +550,19 @@ struct media_device *media_device_find_devres(struct device *dev); * media_device_pci_init() - create and initialize a * struct &media_device from a PCI device. * + * @mdev: pointer to struct &media_device * @pci_dev: pointer to struct pci_dev * @name: media device name. If %NULL, the routine will use the default * name for the pci device, given by pci_name() macro. */ -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); /** * __media_device_usb_init() - create and initialize a * struct &media_device from a PCI device. * + * @mdev: pointer to struct &media_device * @udev: pointer to struct usb_device * @board_name: media device name. If %NULL, the routine will use the usb * product name, if available. @@ -570,9 +573,10 @@ struct media_device *media_device_pci_init(struct pci_dev *pci_dev, * NOTE: It is better to call media_device_usb_init() instead, as * such macro fills driver_name with %KBUILD_MODNAME. */ -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); #else static inline int media_device_register(struct media_device *mdev) @@ -599,24 +603,24 @@ static inline struct media_device *media_device_find_devres(struct device *dev) return NULL; } -static inline -struct media_device *media_device_pci_init(struct pci_dev *pci_dev, - char *name) +static inline void media_device_pci_init(struct media_device *mdev, + struct pci_dev *pci_dev, + char *name) { return NULL; } -static inline -struct media_device *__media_device_usb_init(struct usb_device *udev, - char *board_name, - char *driver_name) +static inline void __media_device_usb_init(struct media_device *mdev, + struct usb_device *udev, + char *board_name, + char *driver_name) { return NULL; } #endif /* CONFIG_MEDIA_CONTROLLER */ -#define media_device_usb_init(udev, name) \ - __media_device_usb_init(udev, name, KBUILD_MODNAME) +#define media_device_usb_init(mdev, udev, name) \ + __media_device_usb_init(mdev, udev, name, KBUILD_MODNAME) #endif -- cgit v1.2.3