{
struct wacom *wacom = input_get_drvdata(dev);
- hid_hw_close(wacom->hdev);
+ /*
+ * wacom->hdev should never be null, but surprisingly, I had the case
+ * once while unplugging the Wacom Wireless Receiver.
+ */
+ if (wacom->hdev)
+ hid_hw_close(wacom->hdev);
}
/*
struct hid_device *hdev = wacom->hdev;
struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
- input_dev = input_allocate_device();
+ input_dev = devm_input_allocate_device(&hdev->dev);
if (!input_dev)
return NULL;
wacom_wac->pen_input = wacom_allocate_input(wacom);
wacom_wac->touch_input = wacom_allocate_input(wacom);
wacom_wac->pad_input = wacom_allocate_input(wacom);
- if (!wacom_wac->pen_input || !wacom_wac->touch_input || !wacom_wac->pad_input) {
- wacom_clean_inputs(wacom);
+ if (!wacom_wac->pen_input ||
+ !wacom_wac->touch_input ||
+ !wacom_wac->pad_input)
return -ENOMEM;
- }
wacom_wac->pen_input->name = wacom_wac->pen_name;
wacom_wac->touch_input->name = wacom_wac->touch_name;
} else {
error = input_register_device(pen_input_dev);
if (error)
- goto fail_register_pen_input;
+ goto fail;
wacom_wac->pen_registered = true;
}
} else {
error = input_register_device(touch_input_dev);
if (error)
- goto fail_register_touch_input;
+ goto fail;
wacom_wac->touch_registered = true;
}
} else {
error = input_register_device(pad_input_dev);
if (error)
- goto fail_register_pad_input;
+ goto fail;
wacom_wac->pad_registered = true;
}
return 0;
-fail_register_pad_input:
- if (touch_input_dev)
- input_unregister_device(touch_input_dev);
+fail:
+ wacom_wac->pad_input = NULL;
+ wacom_wac->pad_registered = false;
wacom_wac->touch_input = NULL;
wacom_wac->touch_registered = false;
-fail_register_touch_input:
- if (pen_input_dev)
- input_unregister_device(pen_input_dev);
wacom_wac->pen_input = NULL;
wacom_wac->pen_registered = false;
-fail_register_pen_input:
return error;
}
fail_remote:
wacom_destroy_leds(wacom);
fail_leds:
- wacom_clean_inputs(wacom);
fail_register_inputs:
fail_battery:
wacom_remove_shared_data(wacom);
fail_shared_data:
fail_parsed:
fail_allocate_inputs:
- wacom_clean_inputs(wacom);
return error;
}
cancel_work_sync(&wacom->battery_work);
kobject_put(wacom->remote_dir);
wacom_destroy_leds(wacom);
- wacom_clean_inputs(wacom);
if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_remove_shared_data(wacom);