Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2205221ybh; Sun, 15 Mar 2020 21:51:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtPtZmJVndfyKopj17jjTobpQq+ML7+1m2NAUCQHuIy34S4eWeBHLnjffaA/bQTJ3w5Z6YO X-Received: by 2002:a54:448c:: with SMTP id v12mr16478810oiv.107.1584334263068; Sun, 15 Mar 2020 21:51:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584334263; cv=none; d=google.com; s=arc-20160816; b=Yb/2MABsnGMCz+5ONvVvi/iVvGC5Oe4J4eWFZJ2hzdCqEdWhTpq+Ln8ZGSDtUrzS+Z tK86QoBMH5+TOQu0xLV4IOOKicg8Tt2uj3KM3hEbwuKdCcnGB0vuKUUgwE9cmKmG9MdX mddnzdaES5rywRqYhERhU0LzOkLXOOreU1eFPUKTAlX4/IU0dOG13wC8PSEtKbJVtuD/ jprqUif2+mSgB5wplN2Vw33YtFfih59MBPCWE5+QMjXHkhvH1xdiMTzaU/xNQgCXiQMj qyEs8kJ4UHXchOd48Qs0PJOxpmCVqWG1zkq2niqjgYLIrXzigT/P94a2oJ/dk2zg7QmX jzOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=v7tr4/51ZhVaf3hAH5Qkss1fDCY9uT+81FCkJvhXir8=; b=w8PiWr3eDqhPjq2kjRcFJp6HVkc4ekKUMUKyV24czg8VHrUETqldi9GAd4Ro1fySvn X6KtrIeDgoC/h3jrS6XmUZZaoXCB9z0u2JnhnrGBvQIdzbgdW8WSa7RHncFv8k9LClNf UhEjv6u2I2No1lHB0jwISH22xC/PlPW3Of7ynC2c9Q6YQscTQgwDdMf18HqqlDbKjYqv 4T7pvCBKGZ2xdySvIrRhfhcmuUggpYdn2azeygdxcODibQC3H3tFMrhB2765gSOBEzj1 szwn4WDsdMHQX3Loo8QCcKpOcj9pSO8SeN+NQ9XC6aES/01G2j55JrDog1rpRSzJ6nsm DL7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=QBcbjio0; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x189si9398186oia.270.2020.03.15.21.50.24; Sun, 15 Mar 2020 21:51:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-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=@google.com header.s=20161025 header.b=QBcbjio0; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729423AbgCPEkZ (ORCPT + 99 others); Mon, 16 Mar 2020 00:40:25 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:46171 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727626AbgCPEkZ (ORCPT ); Mon, 16 Mar 2020 00:40:25 -0400 Received: by mail-vk1-f202.google.com with SMTP id f10so1399476vkl.13 for ; Sun, 15 Mar 2020 21:40:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=v7tr4/51ZhVaf3hAH5Qkss1fDCY9uT+81FCkJvhXir8=; b=QBcbjio0BE56VpkcLvwCC8EBrdzZYFQFSOyFTVSUdLKtCdnmYbpnauIPASMgMBf+6i IUQ+MFr5ih49HOB3pTVdb2RORplZukIw0Qp7srwQ43IZMi96hlan5lnnT0/+tuX/xBC7 mJrjjOa4QzXaKSspIRiCR/oyq0n0A/NFezHPOhVzvnQL0WTVrBydHQWuJTVysew81PU4 IDJMYCv1DbkwrUjFAyhz1y9vNQjdpjNXp8pENGd2abmCsXSHYjRoFf2ilRtHHaKcQBsh 8Zrh0vzF31k8UFDwiwJPuoSizZYN+ZtIocBCYG2diagNxo98JUuc9FPwbmY8ww8+p51c yA7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=v7tr4/51ZhVaf3hAH5Qkss1fDCY9uT+81FCkJvhXir8=; b=noQPKSEh/ntTeOI//vabBwn0AWPDhLG6aNf2NVvbAniXsWIf6CUdxLon84qJT+/gwo iJp2n2ooNEhwco4QWGsYuuZF7jtvTe5TqUArqUynj5rDggNqEXymeFfAbImlFR9Fxx0m Z2mjJq5C/fp9YtmlNq0O8dz9+hl3KiOw7zVz8AjWYNLSxStyegDpU9O9rcwNTNpkuxHb bOgswURhoci4obvJ9unAkWK9GTBf8q7XLyB91lFwlxgZ6UAu52G+EAmUiPYCSkMCofWM qjirs9hGxIc6wYC6knMU6KUZQB/6i4xDl64RiTKOLVoCvrrrEhFsdfMstSHdNGFhm3ao 4g9g== X-Gm-Message-State: ANhLgQ1WKhut+Vi9hD/mQzGj1mbktvS61PfZr0ma/ixRxgR741Cof4TQ KTsQyY16gOq4hYMIySBZzt+zb+QrzSFEjo4H/kQilVXZSWT/3Na/S3b6dWqXS2WYX951P1ElIfo X2jYLnwv6qYnb4wP7krKHXddae1OJ7X1Kh5X1ujUSPRkAz4QtA2HCXVSWe5n+0jTAdVPJ31i0E6 Br X-Received: by 2002:a05:6102:2250:: with SMTP id e16mr16254918vsb.130.1584333624125; Sun, 15 Mar 2020 21:40:24 -0700 (PDT) Date: Mon, 16 Mar 2020 12:40:05 +0800 Message-Id: <20200316123914.Bluez.v1.1.I2c83372de789a015c1ee506690bb795ee0b0b0d9@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.481.gfbce0eb801-goog Subject: [Bluez PATCH v1] input: disconnect intr channel before ctrl channel From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: Archie Pusaka Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka According to bluetooth HID Profile spec Ver 1.0, section 7.2.2, A host or device shall always complete the disconnection of the interrupt channel before disconnecting the control channel. However, the current implementation disconnects them both simultaneously. This patch postpone the disconnection of control channel to the callback of interrupt watch, which shall be called upon receiving interrupt channel disconnection response. --- profiles/input/device.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/profiles/input/device.c b/profiles/input/device.c index 8ada1b4ff..8ef3714c9 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1010,14 +1010,19 @@ static bool is_connected(struct input_device *idev) static int connection_disconnect(struct input_device *idev, uint32_t flags) { + int sock; + if (!is_connected(idev)) return -ENOTCONN; - /* Standard HID disconnect */ - if (idev->intr_io) - g_io_channel_shutdown(idev->intr_io, TRUE, NULL); - if (idev->ctrl_io) - g_io_channel_shutdown(idev->ctrl_io, TRUE, NULL); + /* Standard HID disconnect + * Intr channel must be disconnected before ctrl channel, so only + * disconnect intr here, ctrl is disconnected in intr_watch_cb. + */ + if (idev->intr_io) { + sock = g_io_channel_unix_get_fd(idev->intr_io); + shutdown(sock, SHUT_RDWR); + } if (idev->uhid) return 0; -- 2.25.1.481.gfbce0eb801-goog