Commit a97ac104 authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina

HID: wacom: store the hid_device pointers of the sibling devices

The Bamboo PAD in debug mode needs to re-route events from the debug
interface to the Pen interface. This can be easily done with
hid_input_report(), but that means that we need to keep a reference to
the various hid_devices.

There should be only one touch and one pen interface per physical tablet,
so there is no need to keep a list of hid-devices, plain pointers are
sufficient.
Tested-by: default avatarJosep Sanchez Ferreres <josep.sanchez.ferreres@est.fib.upc.edu>
Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: default avatarPing Cheng <pingc@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent eef23a84
...@@ -524,6 +524,11 @@ static int wacom_add_shared_data(struct hid_device *hdev) ...@@ -524,6 +524,11 @@ static int wacom_add_shared_data(struct hid_device *hdev)
wacom_wac->shared = &data->shared; wacom_wac->shared = &data->shared;
if (wacom_wac->features.device_type == BTN_TOOL_FINGER)
wacom_wac->shared->touch = hdev;
else if (wacom_wac->features.device_type == BTN_TOOL_PEN)
wacom_wac->shared->pen = hdev;
out: out:
mutex_unlock(&wacom_udev_list_lock); mutex_unlock(&wacom_udev_list_lock);
return retval; return retval;
...@@ -541,14 +546,22 @@ static void wacom_release_shared_data(struct kref *kref) ...@@ -541,14 +546,22 @@ static void wacom_release_shared_data(struct kref *kref)
kfree(data); kfree(data);
} }
static void wacom_remove_shared_data(struct wacom_wac *wacom) static void wacom_remove_shared_data(struct wacom *wacom)
{ {
struct wacom_hdev_data *data; struct wacom_hdev_data *data;
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
if (wacom_wac->shared) {
data = container_of(wacom_wac->shared, struct wacom_hdev_data,
shared);
if (wacom_wac->shared->touch == wacom->hdev)
wacom_wac->shared->touch = NULL;
else if (wacom_wac->shared->pen == wacom->hdev)
wacom_wac->shared->pen = NULL;
if (wacom->shared) {
data = container_of(wacom->shared, struct wacom_hdev_data, shared);
kref_put(&data->kref, wacom_release_shared_data); kref_put(&data->kref, wacom_release_shared_data);
wacom->shared = NULL; wacom_wac->shared = NULL;
} }
} }
...@@ -1527,7 +1540,7 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -1527,7 +1540,7 @@ static int wacom_probe(struct hid_device *hdev,
wacom_clean_inputs(wacom); wacom_clean_inputs(wacom);
wacom_destroy_battery(wacom); wacom_destroy_battery(wacom);
fail_battery: fail_battery:
wacom_remove_shared_data(wacom_wac); wacom_remove_shared_data(wacom);
fail_shared_data: fail_shared_data:
wacom_clean_inputs(wacom); wacom_clean_inputs(wacom);
fail_allocate_inputs: fail_allocate_inputs:
...@@ -1550,7 +1563,7 @@ static void wacom_remove(struct hid_device *hdev) ...@@ -1550,7 +1563,7 @@ static void wacom_remove(struct hid_device *hdev)
if (hdev->bus == BUS_BLUETOOTH) if (hdev->bus == BUS_BLUETOOTH)
device_remove_file(&hdev->dev, &dev_attr_speed); device_remove_file(&hdev->dev, &dev_attr_speed);
wacom_destroy_battery(wacom); wacom_destroy_battery(wacom);
wacom_remove_shared_data(&wacom->wacom_wac); wacom_remove_shared_data(wacom);
hid_set_drvdata(hdev, NULL); hid_set_drvdata(hdev, NULL);
kfree(wacom); kfree(wacom);
......
...@@ -169,6 +169,8 @@ struct wacom_shared { ...@@ -169,6 +169,8 @@ struct wacom_shared {
unsigned touch_max; unsigned touch_max;
int type; int type;
struct input_dev *touch_input; struct input_dev *touch_input;
struct hid_device *pen;
struct hid_device *touch;
}; };
struct hid_data { struct hid_data {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment