diff options
| author | Chris Bagwell <chris@cnpbagwell.com> | 2012-06-12 03:25:23 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-06-12 03:40:07 -0400 |
| commit | b7af2bb84cea328c766c615aac45cdd498c50bc6 (patch) | |
| tree | d9c4632eb89bc09ec5ed61fac0164698c32746a0 /drivers/input | |
| parent | ac173837cd4b268a538235a1699b91457551a9a9 (diff) | |
Input: wacom - battery reporting improvements
Do not register battery device until connected to a tablet.
This prevents an empty battery icon from being shown when tablet is
connected using USB cable.
Also, call power_supply_powers() for apps that can make use of that
info.
And stop ignoring input registration failures.
Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Reviewed-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/tablet/wacom_sys.c | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 79b5cfbc1bc4..a48fcb76bb83 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c | |||
| @@ -963,6 +963,10 @@ static int wacom_initialize_battery(struct wacom *wacom) | |||
| 963 | 963 | ||
| 964 | error = power_supply_register(&wacom->usbdev->dev, | 964 | error = power_supply_register(&wacom->usbdev->dev, |
| 965 | &wacom->battery); | 965 | &wacom->battery); |
| 966 | |||
| 967 | if (!error) | ||
| 968 | power_supply_powers(&wacom->battery, | ||
| 969 | &wacom->usbdev->dev); | ||
| 966 | } | 970 | } |
| 967 | 971 | ||
| 968 | return error; | 972 | return error; |
| @@ -970,8 +974,11 @@ static int wacom_initialize_battery(struct wacom *wacom) | |||
| 970 | 974 | ||
| 971 | static void wacom_destroy_battery(struct wacom *wacom) | 975 | static void wacom_destroy_battery(struct wacom *wacom) |
| 972 | { | 976 | { |
| 973 | if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR) | 977 | if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_MONITOR && |
| 978 | wacom->battery.dev) { | ||
| 974 | power_supply_unregister(&wacom->battery); | 979 | power_supply_unregister(&wacom->battery); |
| 980 | wacom->battery.dev = NULL; | ||
| 981 | } | ||
| 975 | } | 982 | } |
| 976 | 983 | ||
| 977 | static int wacom_register_input(struct wacom *wacom) | 984 | static int wacom_register_input(struct wacom *wacom) |
| @@ -1018,23 +1025,30 @@ static void wacom_wireless_work(struct work_struct *work) | |||
| 1018 | struct wacom *wacom = container_of(work, struct wacom, work); | 1025 | struct wacom *wacom = container_of(work, struct wacom, work); |
| 1019 | struct usb_device *usbdev = wacom->usbdev; | 1026 | struct usb_device *usbdev = wacom->usbdev; |
| 1020 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; | 1027 | struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 1028 | struct wacom *wacom1, *wacom2; | ||
| 1029 | struct wacom_wac *wacom_wac1, *wacom_wac2; | ||
| 1030 | int error; | ||
| 1021 | 1031 | ||
| 1022 | /* | 1032 | /* |
| 1023 | * Regardless if this is a disconnect or a new tablet, | 1033 | * Regardless if this is a disconnect or a new tablet, |
| 1024 | * remove any existing input devices. | 1034 | * remove any existing input and battery devices. |
| 1025 | */ | 1035 | */ |
| 1026 | 1036 | ||
| 1037 | wacom_destroy_battery(wacom); | ||
| 1038 | |||
| 1027 | /* Stylus interface */ | 1039 | /* Stylus interface */ |
| 1028 | wacom = usb_get_intfdata(usbdev->config->interface[1]); | 1040 | wacom1 = usb_get_intfdata(usbdev->config->interface[1]); |
| 1029 | if (wacom->wacom_wac.input) | 1041 | wacom_wac1 = &(wacom1->wacom_wac); |
| 1030 | input_unregister_device(wacom->wacom_wac.input); | 1042 | if (wacom_wac1->input) |
| 1031 | wacom->wacom_wac.input = NULL; | 1043 | input_unregister_device(wacom_wac1->input); |
| 1044 | wacom_wac1->input = NULL; | ||
| 1032 | 1045 | ||
| 1033 | /* Touch interface */ | 1046 | /* Touch interface */ |
| 1034 | wacom = usb_get_intfdata(usbdev->config->interface[2]); | 1047 | wacom2 = usb_get_intfdata(usbdev->config->interface[2]); |
| 1035 | if (wacom->wacom_wac.input) | 1048 | wacom_wac2 = &(wacom2->wacom_wac); |
| 1036 | input_unregister_device(wacom->wacom_wac.input); | 1049 | if (wacom_wac2->input) |
| 1037 | wacom->wacom_wac.input = NULL; | 1050 | input_unregister_device(wacom_wac2->input); |
| 1051 | wacom_wac2->input = NULL; | ||
| 1038 | 1052 | ||
| 1039 | if (wacom_wac->pid == 0) { | 1053 | if (wacom_wac->pid == 0) { |
| 1040 | dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); | 1054 | dev_info(&wacom->intf->dev, "wireless tablet disconnected\n"); |
| @@ -1059,24 +1073,39 @@ static void wacom_wireless_work(struct work_struct *work) | |||
| 1059 | } | 1073 | } |
| 1060 | 1074 | ||
| 1061 | /* Stylus interface */ | 1075 | /* Stylus interface */ |
| 1062 | wacom = usb_get_intfdata(usbdev->config->interface[1]); | 1076 | wacom_wac1->features = |
| 1063 | wacom_wac = &wacom->wacom_wac; | ||
| 1064 | wacom_wac->features = | ||
| 1065 | *((struct wacom_features *)id->driver_info); | 1077 | *((struct wacom_features *)id->driver_info); |
| 1066 | wacom_wac->features.device_type = BTN_TOOL_PEN; | 1078 | wacom_wac1->features.device_type = BTN_TOOL_PEN; |
| 1067 | wacom_register_input(wacom); | 1079 | error = wacom_register_input(wacom1); |
| 1080 | if (error) | ||
| 1081 | goto fail1; | ||
| 1068 | 1082 | ||
| 1069 | /* Touch interface */ | 1083 | /* Touch interface */ |
| 1070 | wacom = usb_get_intfdata(usbdev->config->interface[2]); | 1084 | wacom_wac2->features = |
| 1071 | wacom_wac = &wacom->wacom_wac; | ||
| 1072 | wacom_wac->features = | ||
| 1073 | *((struct wacom_features *)id->driver_info); | 1085 | *((struct wacom_features *)id->driver_info); |
| 1074 | wacom_wac->features.pktlen = WACOM_PKGLEN_BBTOUCH3; | 1086 | wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; |
| 1075 | wacom_wac->features.device_type = BTN_TOOL_FINGER; | 1087 | wacom_wac2->features.device_type = BTN_TOOL_FINGER; |
| 1076 | wacom_set_phy_from_res(&wacom_wac->features); | 1088 | wacom_set_phy_from_res(&wacom_wac2->features); |
| 1077 | wacom_wac->features.x_max = wacom_wac->features.y_max = 4096; | 1089 | wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; |
| 1078 | wacom_register_input(wacom); | 1090 | error = wacom_register_input(wacom2); |
| 1091 | if (error) | ||
| 1092 | goto fail2; | ||
| 1093 | |||
| 1094 | error = wacom_initialize_battery(wacom); | ||
| 1095 | if (error) | ||
| 1096 | goto fail3; | ||
| 1079 | } | 1097 | } |
| 1098 | |||
| 1099 | return; | ||
| 1100 | |||
| 1101 | fail3: | ||
| 1102 | input_unregister_device(wacom_wac2->input); | ||
| 1103 | wacom_wac2->input = NULL; | ||
| 1104 | fail2: | ||
| 1105 | input_unregister_device(wacom_wac1->input); | ||
| 1106 | wacom_wac1->input = NULL; | ||
| 1107 | fail1: | ||
| 1108 | return; | ||
| 1080 | } | 1109 | } |
| 1081 | 1110 | ||
| 1082 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) | 1111 | static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) |
| @@ -1179,14 +1208,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 1179 | if (error) | 1208 | if (error) |
| 1180 | goto fail4; | 1209 | goto fail4; |
| 1181 | 1210 | ||
| 1182 | error = wacom_initialize_battery(wacom); | ||
| 1183 | if (error) | ||
| 1184 | goto fail5; | ||
| 1185 | |||
| 1186 | if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { | 1211 | if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { |
| 1187 | error = wacom_register_input(wacom); | 1212 | error = wacom_register_input(wacom); |
| 1188 | if (error) | 1213 | if (error) |
| 1189 | goto fail6; | 1214 | goto fail5; |
| 1190 | } | 1215 | } |
| 1191 | 1216 | ||
| 1192 | /* Note that if query fails it is not a hard failure */ | 1217 | /* Note that if query fails it is not a hard failure */ |
| @@ -1201,7 +1226,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 1201 | 1226 | ||
| 1202 | return 0; | 1227 | return 0; |
| 1203 | 1228 | ||
| 1204 | fail6: wacom_destroy_battery(wacom); | ||
| 1205 | fail5: wacom_destroy_leds(wacom); | 1229 | fail5: wacom_destroy_leds(wacom); |
| 1206 | fail4: wacom_remove_shared_data(wacom_wac); | 1230 | fail4: wacom_remove_shared_data(wacom_wac); |
| 1207 | fail3: usb_free_urb(wacom->irq); | 1231 | fail3: usb_free_urb(wacom->irq); |
