From: Adrian M. <ad...@mc...> - 2002-03-13 23:45:05
|
This should allow true hog plugging of the PPP --- /home/Adrian/sounddc/purupuru.c Wed Mar 13 23:39:57 2002 +++ ./purupuru.c Wed Mar 13 23:37:41 2002 @@ -19,8 +19,11 @@ /* * First posted 18 Feburary 2002 * - * Multiple device support fixed 7 March 2003 - */ + * Multiple device support fixed 7 March 2002 + * + * Hot plugging bug fixed 13 March 2002 + * +*/ #include <linux/kernel.h> #include <linux/slab.h> @@ -38,7 +41,7 @@ #define PURU_MINOR_BASE 64 #define PPP_VERSION 1 -/*#define _DEBUG_ */ +/*#define _DEBUG_*/ #ifdef _DEBUG_ #define DEBGM(fmt, args...) (printk(KERN_ERR fmt, ##args)) @@ -111,7 +114,7 @@ puru->dev.event = NULL; puru->dev.idbus = BUS_MAPLE; input_register_device(&puru->dev); - input_register_handler(&purupuru_handler); + return 0; @@ -121,9 +124,7 @@ { struct dc_purupuru *puru = d->private_data; input_unregister_device(&puru->dev); - /* Remove this device from list */ - list_del(&puru->list); - kfree(puru); + DEBGM("In dc_purupuru_disconnect\n"); } @@ -410,13 +411,17 @@ /* tasklet_enable(&switchoff_tasklet); */ /* Is this a Puru Puru device? */ - if (dev->open != dc_puru_open) + if (dev->open != dc_puru_open) { + DEBGM("Attempted to connect non-PP device\n"); return NULL; + } /* Have we already added this device? */ list_for_each(lst, &devices_list) { device = list_entry(lst, struct dc_purupuru, list); if (device->minor == (PURU_MINOR_BASE + dev->number)) { - return NULL; + DEBGM + ("Attempting to connect already connected PP\n"); + return device->dev.handle; } } @@ -454,13 +459,15 @@ list_for_each_safe(ptr, nxt, &devices_list) { device = list_entry(ptr, struct dc_purupuru, list); if (device->minor == handle->handler->minor) { + DEBGM("Disconnection: removing from list\n"); list_del(&device->list); - kfree(device); } } input_close_device(handle); kfree(handle); + kfree(device); + } static struct input_handler purupuru_handler = { @@ -475,9 +482,9 @@ { maple_register_driver(&dc_purupuru_driver); - printk("Puru Puru Pack driver for Dreamcast Linux version 0.1\n"); + printk("Puru Puru Pack driver for Dreamcast Linux version 0.2\n"); /* tasklet_disable(&switchoff_tasklet); */ - + input_register_handler(&purupuru_handler); return 0; } |