Commit 4b208f8b authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] siano: register media controller earlier

We need to initialize the media controller earlier, as the core
will call the smsdvb hotplug during register time. Ok, this is
an async operation, so, when the module is not loaded, the media
controller works.

However, if the module is already loaded, nothing will be
registered at the media controller, as it will load too late.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent fb372a43
...@@ -653,7 +653,8 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer, ...@@ -653,7 +653,8 @@ smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
* @return 0 on success, <0 on error. * @return 0 on success, <0 on error.
*/ */
int smscore_register_device(struct smsdevice_params_t *params, 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; struct smscore_device_t *dev;
u8 *buffer; u8 *buffer;
...@@ -662,6 +663,10 @@ int smscore_register_device(struct smsdevice_params_t *params, ...@@ -662,6 +663,10 @@ int smscore_register_device(struct smsdevice_params_t *params,
if (!dev) if (!dev)
return -ENOMEM; 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 entry so it could be safe in smscore_unregister_device */
INIT_LIST_HEAD(&dev->entry); INIT_LIST_HEAD(&dev->entry);
......
...@@ -1123,7 +1123,8 @@ extern int smscore_register_hotplug(hotplug_t hotplug); ...@@ -1123,7 +1123,8 @@ extern int smscore_register_hotplug(hotplug_t hotplug);
extern void smscore_unregister_hotplug(hotplug_t hotplug); extern void smscore_unregister_hotplug(hotplug_t hotplug);
extern int smscore_register_device(struct smsdevice_params_t *params, 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 void smscore_unregister_device(struct smscore_device_t *coredev);
extern int smscore_start_device(struct smscore_device_t *coredev); extern int smscore_start_device(struct smscore_device_t *coredev);
......
...@@ -279,7 +279,7 @@ static int smssdio_probe(struct sdio_func *func, ...@@ -279,7 +279,7 @@ static int smssdio_probe(struct sdio_func *func,
goto free; goto free;
} }
ret = smscore_register_device(&params, &smsdev->coredev); ret = smscore_register_device(&params, &smsdev->coredev, NULL);
if (ret < 0) if (ret < 0)
goto free; goto free;
......
...@@ -340,18 +340,18 @@ static void smsusb_term_device(struct usb_interface *intf) ...@@ -340,18 +340,18 @@ static void smsusb_term_device(struct usb_interface *intf)
usb_set_intfdata(intf, NULL); 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 #ifdef CONFIG_MEDIA_CONTROLLER_DVB
struct media_device *mdev; struct media_device *mdev;
struct usb_device *udev = dev->udev; struct usb_device *udev = dev->udev;
int board_id = smscore_get_board_id(dev->coredev);
struct sms_board *board = sms_get_board(board_id); struct sms_board *board = sms_get_board(board_id);
int ret; int ret;
mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
if (!mdev) if (!mdev)
return; return NULL;
mdev->dev = &udev->dev; mdev->dev = &udev->dev;
strlcpy(mdev->model, board->name, sizeof(mdev->model)); strlcpy(mdev->model, board->name, sizeof(mdev->model));
...@@ -366,13 +366,14 @@ static void siano_media_device_register(struct smsusb_device_t *dev) ...@@ -366,13 +366,14 @@ static void siano_media_device_register(struct smsusb_device_t *dev)
pr_err("Couldn't create a media device. Error: %d\n", pr_err("Couldn't create a media device. Error: %d\n",
ret); ret);
kfree(mdev); kfree(mdev);
return; return NULL;
} }
dev->coredev->media_dev = mdev;
pr_info("media controller created\n"); pr_info("media controller created\n");
return mdev;
#else
return NULL;
#endif #endif
} }
...@@ -380,6 +381,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) ...@@ -380,6 +381,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
{ {
struct smsdevice_params_t params; struct smsdevice_params_t params;
struct smsusb_device_t *dev; struct smsusb_device_t *dev;
void *mdev;
int i, rc; int i, rc;
/* create device object */ /* create device object */
...@@ -431,11 +433,15 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) ...@@ -431,11 +433,15 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
params.context = dev; params.context = dev;
usb_make_path(dev->udev, params.devpath, sizeof(params.devpath)); usb_make_path(dev->udev, params.devpath, sizeof(params.devpath));
mdev = siano_media_device_register(dev, board_id);
/* register in smscore */ /* register in smscore */
rc = smscore_register_device(&params, &dev->coredev); rc = smscore_register_device(&params, &dev->coredev, mdev);
if (rc < 0) { if (rc < 0) {
pr_err("smscore_register_device(...) failed, rc %d\n", rc); pr_err("smscore_register_device(...) failed, rc %d\n", rc);
smsusb_term_device(intf); smsusb_term_device(intf);
media_device_unregister(mdev);
kfree(mdev);
return rc; return rc;
} }
...@@ -467,7 +473,6 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id) ...@@ -467,7 +473,6 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
} }
pr_debug("device 0x%p created\n", dev); pr_debug("device 0x%p created\n", dev);
siano_media_device_register(dev);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment