}
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)
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)
mdev->driver_version = LINUX_VERSION_CODE;
media_device_init(mdev);
-
- return mdev;
-#else
- return NULL;
#endif
}
EXPORT_SYMBOL_GPL(__media_device_usb_init);
sprintf(dev->name, "saa%x[%d]", pci_dev->device, dev->nr);
#ifdef CONFIG_MEDIA_CONTROLLER
- dev->media_dev = media_device_pci_init(pci_dev, dev->name);
+ dev->media_dev = kzalloc(sizeof(*dev->media_dev), GFP_KERNEL);
if (!dev->media_dev) {
err = -ENOMEM;
goto fail0;
}
+ media_device_pci_init(dev->media_dev, pci_dev, dev->name);
dev->v4l2_dev.mdev = dev->media_dev;
#endif
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- if (!dev->board.name)
- mdev = media_device_usb_init(udev, "unknown au0828");
- else
- mdev = media_device_usb_init(udev, dev->board.name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ if (!dev->board.name)
+ media_device_usb_init(mdev, udev, "unknown au0828");
+ else
+ media_device_usb_init(mdev, udev, dev->board.name);
+
dev->media_dev = mdev;
#endif
return 0;
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- mdev = media_device_usb_init(udev, dev->board.name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ media_device_usb_init(mdev, udev, dev->board.name);
+
dev->media_dev = mdev;
#endif
return 0;
struct dvb_usb_device *d = adap_to_d(adap);
struct usb_device *udev = d->udev;
- mdev = media_device_usb_init(udev, d->name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ media_device_usb_init(mdev, udev, d->name);
+
dvb_register_media_controller(&adap->dvb_adap, mdev);
dev_info(&d->udev->dev, "media controller created\n");
struct dvb_usb_device *d = adap->dev;
struct usb_device *udev = d->udev;
- mdev = media_device_usb_init(udev, d->desc->name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+ if (!mdev)
+ return -ENOMEM;
+
+ media_device_usb_init(mdev, udev, d->desc->name);
dvb_register_media_controller(&adap->dvb_adap, mdev);
#ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev;
- if (udev->product) {
- mdev = media_device_usb_init(udev, udev->product);
- } else if (udev->manufacturer) {
- mdev = media_device_usb_init(udev, udev->manufacturer);
- } else {
- mdev = media_device_usb_init(udev, dev->name);
- }
-
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return -ENOMEM;
+ if (udev->product)
+ media_device_usb_init(mdev, udev, udev->product);
+ else if (udev->manufacturer)
+ media_device_usb_init(mdev, udev, udev->manufacturer);
+ else
+ media_device_usb_init(mdev, udev, dev->name);
+
dev->media_dev = mdev;
#endif
return 0;
struct sms_board *board = sms_get_board(board_id);
int ret;
- mdev = media_device_usb_init(udev, board->name);
+ mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
return NULL;
+ media_device_usb_init(mdev, udev, board->name);
+
ret = media_device_register(mdev);
if (ret) {
media_device_cleanup(mdev);
* 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.
* 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)
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