From patchwork Sun Mar 11 19:58:41 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: 10274905 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 52FBE602C2 for ; Sun, 11 Mar 2018 19:59:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4210228474 for ; Sun, 11 Mar 2018 19:59:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 352F7289AC; Sun, 11 Mar 2018 19:59:55 +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 D968028474 for ; Sun, 11 Mar 2018 19:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932410AbeCKT7m (ORCPT ); Sun, 11 Mar 2018 15:59:42 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36925 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932235AbeCKT66 (ORCPT ); Sun, 11 Mar 2018 15:58:58 -0400 Received: by mail-wm0-f67.google.com with SMTP id 139so12381764wmn.2; Sun, 11 Mar 2018 12:58:57 -0700 (PDT) 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=MGCLCq+D+5VxT4uuPzxVW44rKf96QtdrD/lGdwdzHE0=; b=QN1uYxoz73Dm7lTPV+pZGEc1NKkrFQM8CHgkKFeMBg7lq9g0iAHNMK/1MhHdseDLHV aMHWlkRImuSQ9USMwDjxdsMgZnSKQGI+QbgjTsE0Zxp3ajUMxVEMWavKyshuSxBJxfAd /6JBaKK9mBWUpjPkdXBg3iyptswCRW/h2C2ZVWvMlqGEyEpFz+IPV6BaMSaWdw0BiCao dj8Nu5wcdN3wE7gZ5myaBDt176GxSLNnydJ1JIdLGzC2EzKFGYZVUtNm8IaJHuzGKB1Q tTa2/hnbxDzx1IJA2xv81qS47r50EZXLNgK/2j9EdhmNQ9udNvCH8HrT49JFZFzqIOI8 ZL3A== 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=MGCLCq+D+5VxT4uuPzxVW44rKf96QtdrD/lGdwdzHE0=; b=NVwljFVme8aOP3XtWkmNrLCNeJj6xg0FooHFjc6bpcosRGh5fM7bM4LFiOR2moywfy Xijf2aUFURv6sa/t5wBJxBVE/4daf0ApHIrNBhYz7cNnPq1U8E6gPNjRHQEaFxGtrcSq MV4LcLI+HSBRrGSRkVRyQi9Okhs5eybP4IibDj1E/bvdimQnsRRYUhu34LtkcUcCWPwS oLxO12kNaaB8TNe2B/agFeqzW3cukCrdDU2XY0/FkH0YjqfYnXe0JY4Ztuw/4nIQ9GeO oysSMlKDwS2OfGT/Tvsd8fHd17DUeAoPZzf5ajYzBsid4IN5JjCpmSemOZsHCvVyObDV T69w== X-Gm-Message-State: AElRT7HpJVyWRQtRfmCh4es688Y6E3wRtK8KUsKcl+hgj6qcHy4RxuXZ 6AIVMENGpDdS9C6vjjNbzf9a2r2lrow= X-Google-Smtp-Source: AG47ELuvqempIF62fFahQkaP0SyxRZ5oBfT9HtZOI3ygwXcGEwzN4LzGHUjTQBR7uUVwWIKbdFccHA== X-Received: by 10.28.85.7 with SMTP id j7mr3426380wmb.38.1520798337154; Sun, 11 Mar 2018 12:58:57 -0700 (PDT) Received: from localhost.localdomain ([2a01:c50e:5126:7a00:b895:42e2:2236:5d86]) by smtp.gmail.com with ESMTPSA id 8sm4900473wmf.13.2018.03.11.12.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Mar 2018 12:58:56 -0700 (PDT) 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 v5 3/4] HID: steam: command to check wireless connection Date: Sun, 11 Mar 2018 20:58:41 +0100 Message-Id: <20180311195842.5551-4-rodrigorivascosta@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180311195842.5551-1-rodrigorivascosta@gmail.com> References: <20180311195842.5551-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 03eebc4c28ba..3d34716ae55f 100644 --- a/drivers/hid/hid-steam.c +++ b/drivers/hid/hid-steam.c @@ -118,6 +118,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) { /* @@ -139,6 +144,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); @@ -360,6 +375,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) {