diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2012-07-30 07:28:18 -0400 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2012-09-19 13:50:20 -0400 |
commit | 9ebf3d7687192923e3d44fdbcd8d9f8375053fb8 (patch) | |
tree | 6973ce11e93dc97c3d5766bbc8f8b45814c0688e | |
parent | 22739293402966db7ca3eb0148632d986fe30465 (diff) |
HID: Add an input configured notification callback
A hid device may create several input devices, and a driver may need
to prepare or finalize the configuration per input device. Currently,
there is no sane way for a driver to know when a device has been
configured. This patch adds a callback providing that information.
Reviewed-and-tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Tested-by: Ping Cheng <pingc@wacom.com>
Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r-- | drivers/hid/hid-input.c | 11 | ||||
-rw-r--r-- | include/linux/hid.h | 3 |
2 files changed, 12 insertions, 2 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 811bfad64609..d917c0d53685 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -1154,6 +1154,7 @@ static void report_features(struct hid_device *hid) | |||
1154 | 1154 | ||
1155 | int hidinput_connect(struct hid_device *hid, unsigned int force) | 1155 | int hidinput_connect(struct hid_device *hid, unsigned int force) |
1156 | { | 1156 | { |
1157 | struct hid_driver *drv = hid->driver; | ||
1157 | struct hid_report *report; | 1158 | struct hid_report *report; |
1158 | struct hid_input *hidinput = NULL; | 1159 | struct hid_input *hidinput = NULL; |
1159 | struct input_dev *input_dev; | 1160 | struct input_dev *input_dev; |
@@ -1228,6 +1229,8 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
1228 | * UGCI) cram a lot of unrelated inputs into the | 1229 | * UGCI) cram a lot of unrelated inputs into the |
1229 | * same interface. */ | 1230 | * same interface. */ |
1230 | hidinput->report = report; | 1231 | hidinput->report = report; |
1232 | if (drv->input_configured) | ||
1233 | drv->input_configured(hid, hidinput); | ||
1231 | if (input_register_device(hidinput->input)) | 1234 | if (input_register_device(hidinput->input)) |
1232 | goto out_cleanup; | 1235 | goto out_cleanup; |
1233 | hidinput = NULL; | 1236 | hidinput = NULL; |
@@ -1235,8 +1238,12 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
1235 | } | 1238 | } |
1236 | } | 1239 | } |
1237 | 1240 | ||
1238 | if (hidinput && input_register_device(hidinput->input)) | 1241 | if (hidinput) { |
1239 | goto out_cleanup; | 1242 | if (drv->input_configured) |
1243 | drv->input_configured(hid, hidinput); | ||
1244 | if (input_register_device(hidinput->input)) | ||
1245 | goto out_cleanup; | ||
1246 | } | ||
1240 | 1247 | ||
1241 | return 0; | 1248 | return 0; |
1242 | 1249 | ||
diff --git a/include/linux/hid.h b/include/linux/hid.h index 42970de1b40c..f37da2803005 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
@@ -626,6 +626,7 @@ struct hid_usage_id { | |||
626 | * @report_fixup: called before report descriptor parsing (NULL means nop) | 626 | * @report_fixup: called before report descriptor parsing (NULL means nop) |
627 | * @input_mapping: invoked on input registering before mapping an usage | 627 | * @input_mapping: invoked on input registering before mapping an usage |
628 | * @input_mapped: invoked on input registering after mapping an usage | 628 | * @input_mapped: invoked on input registering after mapping an usage |
629 | * @input_configured: invoked just before the device is registered | ||
629 | * @feature_mapping: invoked on feature registering | 630 | * @feature_mapping: invoked on feature registering |
630 | * @suspend: invoked on suspend (NULL means nop) | 631 | * @suspend: invoked on suspend (NULL means nop) |
631 | * @resume: invoked on resume if device was not reset (NULL means nop) | 632 | * @resume: invoked on resume if device was not reset (NULL means nop) |
@@ -670,6 +671,8 @@ struct hid_driver { | |||
670 | int (*input_mapped)(struct hid_device *hdev, | 671 | int (*input_mapped)(struct hid_device *hdev, |
671 | struct hid_input *hidinput, struct hid_field *field, | 672 | struct hid_input *hidinput, struct hid_field *field, |
672 | struct hid_usage *usage, unsigned long **bit, int *max); | 673 | struct hid_usage *usage, unsigned long **bit, int *max); |
674 | void (*input_configured)(struct hid_device *hdev, | ||
675 | struct hid_input *hidinput); | ||
673 | void (*feature_mapping)(struct hid_device *hdev, | 676 | void (*feature_mapping)(struct hid_device *hdev, |
674 | struct hid_field *field, | 677 | struct hid_field *field, |
675 | struct hid_usage *usage); | 678 | struct hid_usage *usage); |