Prevent rmmod while joystick is plugged in

Earlier versions of the module could be rmmod'ed while the X52 joystick
was still plugged in and running. Unplugging the joystick after the
module was removed resulted in a kernel crash.
pull/3/head
Nirenjan Krishnan 2012-10-06 23:21:21 -07:00
parent ce53d65021
commit dc6ef6fae0
2 changed files with 13 additions and 1 deletions

View File

@ -415,6 +415,8 @@ static int x52_probe(struct usb_interface *intf,
device_create_file(&intf->dev, &dev_attr_led_blink);
try_module_get(THIS_MODULE);
dev_info(&intf->dev, "X52 device now attached\n");
return 0;
@ -463,6 +465,8 @@ static void x52_disconnect(struct usb_interface *intf)
usb_put_dev(joy->udev);
kfree(joy);
module_put(THIS_MODULE);
dev_info(&intf->dev, "X52 device now disconnected\n");
}

View File

@ -14,6 +14,8 @@
#include <linux/usb.h>
#include "x52joy_map.h"
/*
* The X52 MFD supports the following:
* - 3 lines of 16 characters each
@ -68,7 +70,13 @@ struct x52_joy {
u8 shift_ind:1;
u8 blink_led:1;
u8 :6;
u8 clutch_mode:1;
u8 shift_state_enabled:1;
u8 clock_enabled:1;
u8 clutch_enabled:1;
u8 clutch_latched:1;
u8 :1;
u8 feat_mfd:1;
u8 feat_led:1;