From patchwork Wed Feb 28 18:43:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Rivas Costa X-Patchwork-Id: 10249333 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 94ED560211 for ; Wed, 28 Feb 2018 18:44:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 887ED28E17 for ; Wed, 28 Feb 2018 18:44:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BE8428E31; Wed, 28 Feb 2018 18:44:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2941028E17 for ; Wed, 28 Feb 2018 18:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933280AbeB1Sol (ORCPT ); Wed, 28 Feb 2018 13:44:41 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:44970 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933123AbeB1Snr (ORCPT ); Wed, 28 Feb 2018 13:43:47 -0500 Received: by mail-wr0-f196.google.com with SMTP id v65so3486164wrc.11; Wed, 28 Feb 2018 10:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Q9V3jmaT7R7M6N9Z3zHdY04lsE2FlreElKlmtuYPLM=; b=I4nodc68GWN5YMykHYAgIDMGD4i2JPNwYRTrmk6RTBAWQsVUFQz/vFH+ju2TUukTR1 3aaYbXhTLjtOKt+yRFb3sFYLYTIszTOyh6lkC/j8Xj1bB3+9P8NLJQroiNnc80WehZaO B+n2/7nbhwQ3jhofnykym32mDux+ligro8CzpjowlhYRPe2Xk4iUyNd1sJb511V61RTl FGe2A/xrwZbt/GmJUIf/gagzcxcpZisnN6mqFTHXoAq599qk5XFYONNvJolywYr4uD5h wp+6B4ZSWAoO6SEAM4N/YAUADHe53jRFJJBpDSf3v2dGD96hVzWg30eFoUUhSDKFk/sc FOBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Q9V3jmaT7R7M6N9Z3zHdY04lsE2FlreElKlmtuYPLM=; b=Hu/pWgugsYVMDpRdLC8SDrzzS/rgMqwstA8ho38DWMpTqYe+czhlarI8tRJxuMiXNo bUNrqgo6Rt3b8UZ2JCmCv710TrxiePAA0w8mT2Y/JqyVmqehMzoYDbnU2F2VJ5kGPFuX EOgXyz9fTMSFJ5lnPFO7M7+A5F7qYne+V0GziVNm0di4bdJ/9o6I4p4dvOW5fpgJhu3a CPCl1jrosiXCfeyELPflBjWnXkBMcjl36lqZIPlD/pA3LGtHlZRfTY4CFt6oOlbmySUu n04taxWU60Fpmemdwc0IZWoK0H6kKvb2gGfDmEW7WgfK/kkIq8CBmnlWlq2UuGup+ojJ Tvig== X-Gm-Message-State: APf1xPC0DzfA2Hotngr6LR6OSr4n7QEiy2NNwjXCBSWlAfCrYyqqvDbm b7rbrYiTCydJy0v1Vp4Acjg= X-Google-Smtp-Source: AH8x225AD6wb14/V1PiXm6r9vQc9RgabX9yzY9p5k1NIsqQiwDSBqHul/BnVWBcWHEoYBNNwrd9nxQ== X-Received: by 10.223.147.227 with SMTP id 90mr16825727wrp.230.1519843426373; Wed, 28 Feb 2018 10:43:46 -0800 (PST) Received: from localhost.localdomain ([2a01:c50e:5126:7a00:65e2:8463:c9d0:ead9]) by smtp.gmail.com with ESMTPSA id r136sm2766864wmf.18.2018.02.28.10.43.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 10:43:45 -0800 (PST) From: Rodrigo Rivas Costa To: Jiri Kosina , Benjamin Tissoires , "Pierre-Loup A. Griffais" , Cameron Gutman , =?UTF-8?q?Cl=C3=A9ment=20VUCHENER?= , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Cc: Rodrigo Rivas Costa Subject: [PATCH v4 3/4] HID: steam: command to check wireless connection Date: Wed, 28 Feb 2018 19:43:21 +0100 Message-Id: <20180228184322.29636-4-rodrigorivascosta@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180228184322.29636-1-rodrigorivascosta@gmail.com> References: <20180228184322.29636-1-rodrigorivascosta@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The wireless adaptor does not tell if a device is already connected when steam_probe() is run. Use a command to request the connection status. Signed-off-by: Rodrigo Rivas Costa --- drivers/hid/hid-steam.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c index 9e4b1f640bef..894b678685d3 100644 --- a/drivers/hid/hid-steam.c +++ b/drivers/hid/hid-steam.c @@ -114,6 +114,11 @@ static int steam_send_report(struct steam_device *steam, return ret; } +static inline int steam_send_report_byte(struct steam_device *steam, u8 cmd) +{ + return steam_send_report(steam, &cmd, 1); +} + static int steam_get_serial(struct steam_device *steam) { /* @@ -135,6 +140,16 @@ static int steam_get_serial(struct steam_device *steam) return 0; } +/* + * This command requests the wireless adaptor to post an event + * with the connection status. Useful if this driver is loaded when + * the controller is already connected. + */ +static inline int steam_request_conn_status(struct steam_device *steam) +{ + return steam_send_report_byte(steam, 0xb4); +} + static int steam_input_open(struct input_dev *dev) { struct steam_device *steam = input_get_drvdata(dev); @@ -363,6 +378,7 @@ static int steam_probe(struct hid_device *hdev, goto hid_hw_open_fail; } hid_info(hdev, "Steam wireless receiver connected"); + steam_request_conn_status(steam); } else { ret = steam_register(steam); if (ret) {