aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2017-03-27 10:59:28 -0400
committerJiri Kosina <jkosina@suse.cz>2017-04-06 08:36:37 -0400
commit2936836f919af8d766a23fdf2bb945a0d74fa534 (patch)
tree66b327b33fe735c8bc5f16e80cca92eac668faa9
parent187f2bba93816a300018ad7fb0d79175af0643d3 (diff)
HID: logitech-hidpp: rework hidpp_connect_event()
Looks like all users don't care about a disconnect. Simplify the various variant_connect() and put the connect state check at the beginning. For delayed input devices, make sure we go through all other connect values (protocol, battery) before bailing out. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Tested-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-logitech-hidpp.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index b0d2fea7ec56..81ebded3c8e8 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -1884,9 +1884,6 @@ static int wtp_connect(struct hid_device *hdev, bool connected)
1884 struct wtp_data *wd = hidpp->private_data; 1884 struct wtp_data *wd = hidpp->private_data;
1885 int ret; 1885 int ret;
1886 1886
1887 if (!connected)
1888 return 0;
1889
1890 if (!wd->x_size) { 1887 if (!wd->x_size) {
1891 ret = wtp_get_config(hidpp); 1888 ret = wtp_get_config(hidpp);
1892 if (ret) { 1889 if (ret) {
@@ -1954,9 +1951,6 @@ static int m560_send_config_command(struct hid_device *hdev, bool connected)
1954 1951
1955 hidpp_dev = hid_get_drvdata(hdev); 1952 hidpp_dev = hid_get_drvdata(hdev);
1956 1953
1957 if (!connected)
1958 return -ENODEV;
1959
1960 return hidpp_send_rap_command_sync( 1954 return hidpp_send_rap_command_sync(
1961 hidpp_dev, 1955 hidpp_dev,
1962 REPORT_ID_HIDPP_SHORT, 1956 REPORT_ID_HIDPP_SHORT,
@@ -2160,9 +2154,6 @@ static int k400_connect(struct hid_device *hdev, bool connected)
2160{ 2154{
2161 struct hidpp_device *hidpp = hid_get_drvdata(hdev); 2155 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
2162 2156
2163 if (!connected)
2164 return 0;
2165
2166 if (!disable_tap_to_click) 2157 if (!disable_tap_to_click)
2167 return 0; 2158 return 0;
2168 2159
@@ -2414,6 +2405,9 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
2414 struct input_dev *input; 2405 struct input_dev *input;
2415 char *name, *devm_name; 2406 char *name, *devm_name;
2416 2407
2408 if (!connected)
2409 return;
2410
2417 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { 2411 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
2418 ret = wtp_connect(hdev, connected); 2412 ret = wtp_connect(hdev, connected);
2419 if (ret) 2413 if (ret)
@@ -2428,9 +2422,6 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
2428 return; 2422 return;
2429 } 2423 }
2430 2424
2431 if (!connected || hidpp->delayed_input)
2432 return;
2433
2434 /* the device is already connected, we can ask for its name and 2425 /* the device is already connected, we can ask for its name and
2435 * protocol */ 2426 * protocol */
2436 if (!hidpp->protocol_major) { 2427 if (!hidpp->protocol_major) {
@@ -2461,8 +2452,8 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
2461 2452
2462 hidpp_initialize_battery(hidpp); 2453 hidpp_initialize_battery(hidpp);
2463 2454
2464 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT)) 2455 if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input)
2465 /* if HID created the input nodes for us, we can stop now */ 2456 /* if the input nodes are already created, we can stop now */
2466 return; 2457 return;
2467 2458
2468 input = hidpp_allocate_input(hdev); 2459 input = hidpp_allocate_input(hdev);