* @return 0 on success, <0 on error.
*/
int smscore_register_device(struct smsdevice_params_t *params,
- struct smscore_device_t **coredev)
+ struct smscore_device_t **coredev,
+ void *mdev)
{
struct smscore_device_t *dev;
u8 *buffer;
if (!dev)
return -ENOMEM;
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+ dev->media_dev = mdev;
+#endif
+
/* init list entry so it could be safe in smscore_unregister_device */
INIT_LIST_HEAD(&dev->entry);
extern void smscore_unregister_hotplug(hotplug_t hotplug);
extern int smscore_register_device(struct smsdevice_params_t *params,
- struct smscore_device_t **coredev);
+ struct smscore_device_t **coredev,
+ void *mdev);
extern void smscore_unregister_device(struct smscore_device_t *coredev);
extern int smscore_start_device(struct smscore_device_t *coredev);
usb_set_intfdata(intf, NULL);
}
-static void siano_media_device_register(struct smsusb_device_t *dev)
+static void *siano_media_device_register(struct smsusb_device_t *dev,
+ int board_id)
{
#ifdef CONFIG_MEDIA_CONTROLLER_DVB
struct media_device *mdev;
struct usb_device *udev = dev->udev;
- int board_id = smscore_get_board_id(dev->coredev);
struct sms_board *board = sms_get_board(board_id);
int ret;
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev)
- return;
+ return NULL;
mdev->dev = &udev->dev;
strlcpy(mdev->model, board->name, sizeof(mdev->model));
pr_err("Couldn't create a media device. Error: %d\n",
ret);
kfree(mdev);
- return;
+ return NULL;
}
- dev->coredev->media_dev = mdev;
-
pr_info("media controller created\n");
+ return mdev;
+#else
+ return NULL;
#endif
}
{
struct smsdevice_params_t params;
struct smsusb_device_t *dev;
+ void *mdev;
int i, rc;
/* create device object */
params.context = dev;
usb_make_path(dev->udev, params.devpath, sizeof(params.devpath));
+ mdev = siano_media_device_register(dev, board_id);
+
/* register in smscore */
- rc = smscore_register_device(¶ms, &dev->coredev);
+ rc = smscore_register_device(¶ms, &dev->coredev, mdev);
if (rc < 0) {
pr_err("smscore_register_device(...) failed, rc %d\n", rc);
smsusb_term_device(intf);
+ media_device_unregister(mdev);
+ kfree(mdev);
return rc;
}
}
pr_debug("device 0x%p created\n", dev);
- siano_media_device_register(dev);
return rc;
}