Received: by 10.213.65.16 with SMTP id m16csp24900imf; Sun, 11 Mar 2018 13:01:09 -0700 (PDT) X-Google-Smtp-Source: AG47ELv+Qhdqw5E+eXSoQ4KNNycQu+OZ0Hbs4Y4fDRKiPXpM6G8lxK0tzvbTQfUpb1Ck9PbGY4o7 X-Received: by 2002:a17:902:7787:: with SMTP id o7-v6mr190670pll.75.1520798469021; Sun, 11 Mar 2018 13:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520798468; cv=none; d=google.com; s=arc-20160816; b=z2WV8PuLoMMTqb8cCmd4ruKAVddGcj2f9HeJC7NMKkvMGvrSWJUBe1z0uXqc1oSuPi Y9U5h1C0MWaW+beakQUunGEzYMNJe3sK8Vw8xUHPOmNeb6EzWGholJzKfsR4plZkbeMu 00cpIaw5hU9Tg862cfMavGwpi64e6y/2tdKcrkudGV+e/rxwN7O1RziNF5R91GkpJLd8 fdBMWnEaIbreDyMiCF9jctPVpEHnTFx2TZBhIxanVcP1Kgx9sYySoEUbN7vo5/J7YNFU K8AzvUutoXE3fzAnkPZ2IN0/4TI0zaEp+PGqfmgWUkZc3eyK5WOVvisgohYvCd4X5eKn EBpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=MGCLCq+D+5VxT4uuPzxVW44rKf96QtdrD/lGdwdzHE0=; b=z5PKCBNc3ouoi41IafSNaXtErhw+aUqhzczDgp0WEVeBlNckN6lYjcxWvuH8EAVHrf gYwPBUxtNc2auRNwTVmRS6jm8bB7NQ+MX9aCmruaylYwFA+Qv9jUcu0VWzLOyZWQAlwr W1zikFQ1JRCiPPp2yCmxjfJ5fCV5yniINIdkYG/PyitB91RUr9CEVs1lcrB7jN+DRXuh cflKeSxh3RJOk1qKDE3Cy+TTr9avKZRDFKXlNAsgu+U3wr1W9wQr0IAIogT44MXd6y3Q whhfIQR5ZYHM3O+HnkFimTYAImWI54v6vP6QpJkDo2OnTx+NE+o+g//oEpG5nK65QeM8 XEmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QN1uYxoz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34-v6si4804032pld.513.2018.03.11.13.00.54; Sun, 11 Mar 2018 13:01:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QN1uYxoz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932420AbeCKT7n (ORCPT + 99 others); Sun, 11 Mar 2018 15:59:43 -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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.16.2