aboutsummaryrefslogtreecommitdiff
path: root/drivers/hid/hid-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r--drivers/hid/hid-input.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index dd332f28e08..0b27da7d749 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -297,7 +297,7 @@ static struct hid_usage *hidinput_find_key(struct hid_device *hid,
static int hidinput_getkeycode(struct input_dev *dev, int scancode,
int *keycode)
{
- struct hid_device *hid = dev->private;
+ struct hid_device *hid = input_get_drvdata(dev);
struct hid_usage *usage;
usage = hidinput_find_key(hid, scancode, 0);
@@ -311,7 +311,7 @@ static int hidinput_getkeycode(struct input_dev *dev, int scancode,
static int hidinput_setkeycode(struct input_dev *dev, int scancode,
int keycode)
{
- struct hid_device *hid = dev->private;
+ struct hid_device *hid = input_get_drvdata(dev);
struct hid_usage *usage;
int old_keycode;
@@ -1152,7 +1152,7 @@ int hidinput_connect(struct hid_device *hid)
kfree(hidinput);
input_free_device(input_dev);
err_hid("Out of memory during hid input probe");
- return -1;
+ goto out_unwind;
}
input_set_drvdata(input_dev, hid);
@@ -1186,15 +1186,25 @@ int hidinput_connect(struct hid_device *hid)
* UGCI) cram a lot of unrelated inputs into the
* same interface. */
hidinput->report = report;
- input_register_device(hidinput->input);
+ if (input_register_device(hidinput->input))
+ goto out_cleanup;
hidinput = NULL;
}
}
- if (hidinput)
- input_register_device(hidinput->input);
+ if (hidinput && input_register_device(hidinput->input))
+ goto out_cleanup;
return 0;
+
+out_cleanup:
+ input_free_device(hidinput->input);
+ kfree(hidinput);
+out_unwind:
+ /* unwind the ones we already registered */
+ hidinput_disconnect(hid);
+
+ return -1;
}
EXPORT_SYMBOL_GPL(hidinput_connect);