V4L/DVB (8266): sms1xxx: merge modules

Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/mdtv/smsusb.c b/drivers/media/mdtv/smsusb.c
index 1da0209..11c471a 100644
--- a/drivers/media/mdtv/smsusb.c
+++ b/drivers/media/mdtv/smsusb.c
@@ -401,12 +401,21 @@
 	.id_table		= smsusb_id_table,
 };
 
+extern struct list_head g_smsdvb_clients;
+kmutex_t g_smsdvb_clientslock;
+
 int smsusb_module_init(void)
 {
 	int rc = usb_register(&smsusb_driver);
 	if (rc)
 		printk(KERN_INFO "usb_register failed. Error number %d\n", rc);
 
+	/* Bring up the dvb componenets */
+	INIT_LIST_HEAD(&g_smsdvb_clients);
+	kmutex_init(&g_smsdvb_clientslock);
+
+	rc = smscore_register_hotplug(smsdvb_hotplug);
+
 	printk(KERN_INFO "%s\n", __FUNCTION__);
 
 	return rc;
@@ -414,6 +423,17 @@
 
 void smsusb_module_exit(void)
 {
+	/* Tear down the DVB components */
+	smscore_unregister_hotplug(smsdvb_hotplug);
+
+	kmutex_lock(&g_smsdvb_clientslock);
+
+	while (!list_empty(&g_smsdvb_clients))
+		smsdvb_unregister_client((smsdvb_client_t*) g_smsdvb_clients.next);
+
+	kmutex_unlock(&g_smsdvb_clientslock);
+
+	/* Regular USB Cleanup */
 	usb_deregister(&smsusb_driver);
 	printk(KERN_INFO "%s\n", __FUNCTION__);
 }