Commit eae55660 authored by Steven Toth's avatar Steven Toth Committed by Mauro Carvalho Chehab

V4L/DVB (8268): sms1xxx: usb cleanup

Signed-off-by: default avatarSteven Toth <stoth@hauppauge.com>
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 159ed4bb
...@@ -1104,6 +1104,12 @@ int smscore_module_init(void) ...@@ -1104,6 +1104,12 @@ int smscore_module_init(void)
INIT_LIST_HEAD(&g_smscore_registry); INIT_LIST_HEAD(&g_smscore_registry);
kmutex_init(&g_smscore_registrylock); kmutex_init(&g_smscore_registrylock);
/* USB Register */
rc = smsusb_register();
/* DVB Register */
rc = smsdvb_register();
printk(KERN_INFO "%s, rc %d\n", __FUNCTION__, rc); printk(KERN_INFO "%s, rc %d\n", __FUNCTION__, rc);
return rc; return rc;
...@@ -1111,6 +1117,7 @@ int smscore_module_init(void) ...@@ -1111,6 +1117,7 @@ int smscore_module_init(void)
void smscore_module_exit(void) void smscore_module_exit(void)
{ {
kmutex_lock(&g_smscore_deviceslock); kmutex_lock(&g_smscore_deviceslock);
while (!list_empty(&g_smscore_notifyees)) while (!list_empty(&g_smscore_notifyees))
{ {
...@@ -1131,6 +1138,12 @@ void smscore_module_exit(void) ...@@ -1131,6 +1138,12 @@ void smscore_module_exit(void)
} }
kmutex_unlock(&g_smscore_registrylock); kmutex_unlock(&g_smscore_registrylock);
/* DVB UnRegister */
smsdvb_unregister();
/* Unregister USB */
smsusb_unregister();
printk(KERN_INFO "%s\n", __FUNCTION__); printk(KERN_INFO "%s\n", __FUNCTION__);
} }
......
...@@ -508,7 +508,11 @@ extern smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev); ...@@ -508,7 +508,11 @@ extern smscore_buffer_t *smscore_getbuffer(smscore_device_t *coredev);
extern void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb); extern void smscore_putbuffer(smscore_device_t *coredev, smscore_buffer_t *cb);
/* smsdvb.c */ /* smsdvb.c */
int smsdvb_hotplug(smscore_device_t *coredev, struct device* device, int arrival); int smsdvb_register(void);
void smsdvb_unregister_client(smsdvb_client_t* client); void smsdvb_unregister(void);
/* smsusb.c */
int smsusb_register(void);
void smsusb_unregister(void);
#endif // __smscoreapi_h__ #endif // __smscoreapi_h__
...@@ -375,3 +375,30 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device* device, int arrival ...@@ -375,3 +375,30 @@ int smsdvb_hotplug(smscore_device_t *coredev, struct device* device, int arrival
return rc; return rc;
} }
int smsdvb_register(void)
{
int rc;
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;
}
void smsdvb_unregister(void)
{
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);
}
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/firmware.h> #include <linux/firmware.h>
...@@ -401,46 +400,21 @@ static struct usb_driver smsusb_driver = { ...@@ -401,46 +400,21 @@ static struct usb_driver smsusb_driver = {
.id_table = smsusb_id_table, .id_table = smsusb_id_table,
}; };
extern struct list_head g_smsdvb_clients; int smsusb_register(void)
kmutex_t g_smsdvb_clientslock;
int smsusb_module_init(void)
{ {
int rc = usb_register(&smsusb_driver); int rc = usb_register(&smsusb_driver);
if (rc) if (rc)
printk(KERN_INFO "usb_register failed. Error number %d\n", 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__); printk(KERN_INFO "%s\n", __FUNCTION__);
return rc; return rc;
} }
void smsusb_module_exit(void) void smsusb_unregister(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 */ /* Regular USB Cleanup */
usb_deregister(&smsusb_driver); usb_deregister(&smsusb_driver);
printk(KERN_INFO "%s\n", __FUNCTION__); printk(KERN_INFO "%s\n", __FUNCTION__);
} }
module_init(smsusb_module_init);
module_exit(smsusb_module_exit);
MODULE_DESCRIPTION("smsusb");
MODULE_AUTHOR("Anatoly Greenblatt,,, (anatolyg@siano-ms.com)");
MODULE_LICENSE("GPL");
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