From dc6ef6fae0d64433f3f38cfa52588016ac53bf31 Mon Sep 17 00:00:00 2001 From: Nirenjan Krishnan Date: Sat, 6 Oct 2012 23:21:21 -0700 Subject: [PATCH] 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. --- driver/x52joy.c | 4 ++++ driver/x52joy_common.h | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/driver/x52joy.c b/driver/x52joy.c index 8f32d41..13abb94 100644 --- a/driver/x52joy.c +++ b/driver/x52joy.c @@ -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"); } diff --git a/driver/x52joy_common.h b/driver/x52joy_common.h index 39fbc2b..af1ae4d 100644 --- a/driver/x52joy_common.h +++ b/driver/x52joy_common.h @@ -14,6 +14,8 @@ #include +#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;