aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_sys.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-07-24 15:51:26 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-07-25 21:53:49 -0400
commit008f4d9e3cd666c1c4f97b53c102a868a6041f64 (patch)
tree776341a9cf7049d8285c15efd5c13fdb14e4eefa /drivers/input/tablet/wacom_sys.c
parent3813810c7103f90eb2a0ec43fbd637265360c618 (diff)
Input: wacom - split out the pad device for the wireless receiver
The Wireless Receiver should also behave in the same way than regular USB devices. To simplify the unregistering of the different devices, wacom_unregister_inputs() is introduced. For consistency, the function wacom_register_input() is renamed into wacom_register_inputs(). Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Ping Cheng <pingc@wacom.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r--drivers/input/tablet/wacom_sys.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index b25848581fc1..dd0dbc250c94 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -1142,7 +1142,17 @@ static struct input_dev *wacom_allocate_input(struct wacom *wacom)
1142 return input_dev; 1142 return input_dev;
1143} 1143}
1144 1144
1145static int wacom_register_input(struct wacom *wacom) 1145static void wacom_unregister_inputs(struct wacom *wacom)
1146{
1147 if (wacom->wacom_wac.input)
1148 input_unregister_device(wacom->wacom_wac.input);
1149 if (wacom->wacom_wac.pad_input)
1150 input_unregister_device(wacom->wacom_wac.pad_input);
1151 wacom->wacom_wac.input = NULL;
1152 wacom->wacom_wac.pad_input = NULL;
1153}
1154
1155static int wacom_register_inputs(struct wacom *wacom)
1146{ 1156{
1147 struct input_dev *input_dev, *pad_input_dev; 1157 struct input_dev *input_dev, *pad_input_dev;
1148 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1158 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
@@ -1214,16 +1224,12 @@ static void wacom_wireless_work(struct work_struct *work)
1214 /* Stylus interface */ 1224 /* Stylus interface */
1215 wacom1 = usb_get_intfdata(usbdev->config->interface[1]); 1225 wacom1 = usb_get_intfdata(usbdev->config->interface[1]);
1216 wacom_wac1 = &(wacom1->wacom_wac); 1226 wacom_wac1 = &(wacom1->wacom_wac);
1217 if (wacom_wac1->input) 1227 wacom_unregister_inputs(wacom1);
1218 input_unregister_device(wacom_wac1->input);
1219 wacom_wac1->input = NULL;
1220 1228
1221 /* Touch interface */ 1229 /* Touch interface */
1222 wacom2 = usb_get_intfdata(usbdev->config->interface[2]); 1230 wacom2 = usb_get_intfdata(usbdev->config->interface[2]);
1223 wacom_wac2 = &(wacom2->wacom_wac); 1231 wacom_wac2 = &(wacom2->wacom_wac);
1224 if (wacom_wac2->input) 1232 wacom_unregister_inputs(wacom2);
1225 input_unregister_device(wacom_wac2->input);
1226 wacom_wac2->input = NULL;
1227 1233
1228 if (wacom_wac->pid == 0) { 1234 if (wacom_wac->pid == 0) {
1229 dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); 1235 dev_info(&wacom->intf->dev, "wireless tablet disconnected\n");
@@ -1253,9 +1259,11 @@ static void wacom_wireless_work(struct work_struct *work)
1253 wacom_wac1->features.device_type = BTN_TOOL_PEN; 1259 wacom_wac1->features.device_type = BTN_TOOL_PEN;
1254 snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", 1260 snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen",
1255 wacom_wac1->features.name); 1261 wacom_wac1->features.name);
1262 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1263 wacom_wac1->features.name);
1256 wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max; 1264 wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max;
1257 wacom_wac1->shared->type = wacom_wac1->features.type; 1265 wacom_wac1->shared->type = wacom_wac1->features.type;
1258 error = wacom_register_input(wacom1); 1266 error = wacom_register_inputs(wacom1);
1259 if (error) 1267 if (error)
1260 goto fail; 1268 goto fail;
1261 1269
@@ -1273,7 +1281,9 @@ static void wacom_wireless_work(struct work_struct *work)
1273 else 1281 else
1274 snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1282 snprintf(wacom_wac2->name, WACOM_NAME_MAX,
1275 "%s (WL) Pad",wacom_wac2->features.name); 1283 "%s (WL) Pad",wacom_wac2->features.name);
1276 error = wacom_register_input(wacom2); 1284 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1285 "%s (WL) Pad", wacom_wac2->features.name);
1286 error = wacom_register_inputs(wacom2);
1277 if (error) 1287 if (error)
1278 goto fail; 1288 goto fail;
1279 1289
@@ -1290,15 +1300,8 @@ static void wacom_wireless_work(struct work_struct *work)
1290 return; 1300 return;
1291 1301
1292fail: 1302fail:
1293 if (wacom_wac2->input) { 1303 wacom_unregister_inputs(wacom1);
1294 input_unregister_device(wacom_wac2->input); 1304 wacom_unregister_inputs(wacom2);
1295 wacom_wac2->input = NULL;
1296 }
1297
1298 if (wacom_wac1->input) {
1299 input_unregister_device(wacom_wac1->input);
1300 wacom_wac1->input = NULL;
1301 }
1302 return; 1305 return;
1303} 1306}
1304 1307
@@ -1444,7 +1447,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1444 goto fail4; 1447 goto fail4;
1445 1448
1446 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { 1449 if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
1447 error = wacom_register_input(wacom); 1450 error = wacom_register_inputs(wacom);
1448 if (error) 1451 if (error)
1449 goto fail5; 1452 goto fail5;
1450 } 1453 }
@@ -1484,10 +1487,7 @@ static void wacom_disconnect(struct usb_interface *intf)
1484 1487
1485 usb_kill_urb(wacom->irq); 1488 usb_kill_urb(wacom->irq);
1486 cancel_work_sync(&wacom->work); 1489 cancel_work_sync(&wacom->work);
1487 if (wacom->wacom_wac.input) 1490 wacom_unregister_inputs(wacom);
1488 input_unregister_device(wacom->wacom_wac.input);
1489 if (wacom->wacom_wac.pad_input)
1490 input_unregister_device(wacom->wacom_wac.pad_input);
1491 wacom_destroy_battery(wacom); 1491 wacom_destroy_battery(wacom);
1492 wacom_destroy_leds(wacom); 1492 wacom_destroy_leds(wacom);
1493 usb_free_urb(wacom->irq); 1493 usb_free_urb(wacom->irq);