Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2629581lqo; Mon, 20 May 2024 11:14:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW1uM54ea2AIDlNEp5YCQVHyCPTCQ22/3veTclSm87wx1mMkxv7G2PLjYQF1EFaX8gdDvqnmRdgQ5oJzN1YC4H76Smsq1L/U8jjrEuVcQ== X-Google-Smtp-Source: AGHT+IE7+f4NP9rsDOYydBdEIy2iStV60a1jhTmzYofQx7KPwRn+BuO9XkuvJuyMRnC5UHLwPlW+ X-Received: by 2002:a17:902:cf11:b0:1f2:fb28:9d2c with SMTP id d9443c01a7336-1f2fb28a0eamr53815315ad.44.1716228897484; Mon, 20 May 2024 11:14:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716228897; cv=pass; d=google.com; s=arc-20160816; b=wN0nPbB5DGsAhmJgTv30pqO6uP1MbFHrPCZNgFvdb96YZ8KGTgaCIV1OMFVAZnVzIx HdjCLuULVP9y+A8uFhMPnz13hUA+NgJliPXOnEg98fElOWU1dxvF7C/JKyX1QiEDV0Pd l3BAamW9srycq/LfBGD1XmQaEMcjMq4uEp6zC8z8fYOAJZe8aRNlk+8Av6HNhq/35bJk xow5z9PKs9VZ+pLLcYyUC0Qzae9Bd+ussdMwDTZwA5KDJCzHORNPL8apuBS1BX6+0H9t dggz9Uebx2YPGbB6u7spjiC/gz5fQE918tTVvvcbK4jSGUXpllcaRq5poHnCsJVqNzet SpYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=yxItAwRiuLRgNwYlc5PmmODJU6saxMWdAp9zjjn/Nhg=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=JUGIXj9hnGxaAbnjnMtgQgWwB7DO7Z05x+f+TfjwM1GuByla9dDSKKRTz4jqAvhqaQ IK9pMk93x4RuaGwo6jPhS7JqOO+D9QwnO1+683OkRGddxbZ0r35+kNdiSZMRcSi7f3pE gRtnyGaNevycO7ZXSkru61pkG+AcSlzXIgCdW3Mk7sW+FE+EoRZWT4IYV/lWQhnNnEzO LMBL3JfRUXu8bE2hizJlhpJa3oJWNwtgm/voDNJBhsO6wOdnULV+BSPhH/gfVZvtnivy y2Hh8Ms12OEG2MKtLl9JdhZN3KLSKCw6DRT28NsaHeISajznuHQO3ybWKKTwdln9JO6u 8wNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M3E1eABs; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f2fb9ab2casi28472925ad.278.2024.05.20.11.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 11:14:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=M3E1eABs; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4815-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4815-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 22455282A5E for ; Mon, 20 May 2024 18:14:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEF50137C32; Mon, 20 May 2024 18:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M3E1eABs" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7298137C49 for ; Mon, 20 May 2024 18:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716228888; cv=none; b=RQ87hLoWIQ0FgnZ5yWyFNl9hzJ+2esODJi92Q5SdxTn5f5fgOgwak5a6AT4T+APApKVDFShOjNuZznv3EFpbw4CkEedvBZPG/KDt7zAwL+isSYde6ZZ+DtyLxeoAR106iEGS271PZXtX0KUmHfiWfakIontz8JpblcADr1A76fE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716228888; c=relaxed/simple; bh=xcPq72idBxazIW/Hj7WW5ABxhBL97UTnV46Sv/VZtA4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m+M60N09Gt3IFa08OYfKkxBldNSMudeu22eKpDcKDbkCQlrfKV8FEHaLDVCidbDgQcRbbbV+a6opejPDRj8T99bTFx0bp+tQLupZTFXP7+sHX+IDMs38gP/3L0vg0WG2Wb3xvEcI2GPUxqAdSmK0j2Knw4Fnkx9woLDXraiDKv0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M3E1eABs; arc=none smtp.client-ip=209.85.217.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-4820c2dd6d7so328832137.3 for ; Mon, 20 May 2024 11:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716228884; x=1716833684; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=yxItAwRiuLRgNwYlc5PmmODJU6saxMWdAp9zjjn/Nhg=; b=M3E1eABs+ll9Kl4rfpmZ7h73x7o5L5NkPFvqfN5ugsxZa/hlFJqaR/6gQde0JFeDfq S4sShGFHp+k0L7RfB6Q1uy5Juc732bxRrxJU4+qFfAdtkDOinP7/8BSyKcOMXHP4iTA0 Ryo+B8EZDOQoFJIEy9q3rVmm7RZpf0hKJTvILMcpOB1NOUYqK6+JtBsnhQPFCiXe/Zms r0jeRfG0JQA4wZ/iICqb5RL01FgrSHeXzq5HY8RtNeEH72AeQUasvqz1UFDQumgH5kuc aH3oYkwBbd5gz42nkSPtmGDmZZNK2yx6C1fMJwnf0AbGbcgNlwr80rRkUtTlLkdaKhKB +IGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716228884; x=1716833684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yxItAwRiuLRgNwYlc5PmmODJU6saxMWdAp9zjjn/Nhg=; b=XVmRpNqpbgp1miTlzyk8BSioQgL6GXihJ4Y33P7TxslAhe1c4ygiCQZX4YSF7Cb0kE BK1IHiqSUHdaHzdeHZHc+myg7e8yBnPNutZwXsybeiaCwmFp6oOP8cFprnYnv4+37a0V GIgFeQmymD4B7zJpfsa5x/vplCp+JTfFi1Y2//TfKSxIqVGnuSX0xRtAGXSdGYeEr0dw ob0GKNJwih1/4l6qyTmk5OzAGhOtcvMI1yk1GJxn/HI/7CSQQO1ckA0vAna//Xc68MFc 1aNe+wRdZeXCpkIEl1xocaUUs+WHw8mgksT9HwxhX+PKZ1dw6adQ5jQVstcdtNkqUdx9 Bxgw== X-Gm-Message-State: AOJu0YzQSzlJkyF+pdriWU3KusydX1a8qsruIeKEV5SPR5HU1FUTCMOj +F7yhCAIcK1HYVqRHjvFq6ysK45i5AUKfobBK16utPDX41sn4EBlRLsb0g== X-Received: by 2002:a05:6102:3e0e:b0:486:11ff:65b2 with SMTP id ada2fe7eead31-48611ff67b1mr13836802137.29.1716228882385; Mon, 20 May 2024 11:14:42 -0700 (PDT) Received: from lvondent-mobl4.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-7f9000e33fesm3232549241.39.2024.05.20.11.14.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 11:14:41 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 2/3] hog-lib: Add force parameter to bt_hog_detach Date: Mon, 20 May 2024 14:14:38 -0400 Message-ID: <20240520181439.1407634-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240520181439.1407634-1-luiz.dentz@gmail.com> References: <20240520181439.1407634-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz This adds force parameter to bt_hog_detach which indicates if the bt_uhid_destroy shall be called. --- android/hidhost.c | 2 +- profiles/input/hog-lib.c | 9 ++++++--- profiles/input/hog-lib.h | 2 +- profiles/input/hog.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/android/hidhost.c b/android/hidhost.c index b4e5c527fafc..e0e3ecf92676 100644 --- a/android/hidhost.c +++ b/android/hidhost.c @@ -796,7 +796,7 @@ static void hog_conn_cb(const bdaddr_t *addr, int err, void *attrib) if (dev->hog) { bt_hid_notify_state(dev, HAL_HIDHOST_STATE_DISCONNECTED); - bt_hog_detach(dev->hog); + bt_hog_detach(dev->hog, true); return; } goto fail; diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c index 2d8d0f359e57..964acc716041 100644 --- a/profiles/input/hog-lib.c +++ b/profiles/input/hog-lib.c @@ -1232,7 +1232,7 @@ static void hog_free(void *data) { struct bt_hog *hog = data; - bt_hog_detach(hog); + bt_hog_detach(hog, true); uhid_destroy(hog); queue_destroy(hog->bas, (void *) bt_bas_unref); @@ -1747,7 +1747,7 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt) return true; } -void bt_hog_detach(struct bt_hog *hog) +void bt_hog_detach(struct bt_hog *hog, bool force) { GSList *l; @@ -1759,7 +1759,7 @@ void bt_hog_detach(struct bt_hog *hog) for (l = hog->instances; l; l = l->next) { struct bt_hog *instance = l->data; - bt_hog_detach(instance); + bt_hog_detach(instance, force); } for (l = hog->reports; l; l = l->next) { @@ -1780,6 +1780,9 @@ void bt_hog_detach(struct bt_hog *hog) queue_remove_all(hog->gatt_op, cancel_gatt_req, hog, destroy_gatt_req); g_attrib_unref(hog->attrib); hog->attrib = NULL; + + if (force) + uhid_destroy(hog); } int bt_hog_set_control_point(struct bt_hog *hog, bool suspend) diff --git a/profiles/input/hog-lib.h b/profiles/input/hog-lib.h index a79648976e79..abca829bee92 100644 --- a/profiles/input/hog-lib.h +++ b/profiles/input/hog-lib.h @@ -22,7 +22,7 @@ struct bt_hog *bt_hog_ref(struct bt_hog *hog); void bt_hog_unref(struct bt_hog *hog); bool bt_hog_attach(struct bt_hog *hog, void *gatt); -void bt_hog_detach(struct bt_hog *hog); +void bt_hog_detach(struct bt_hog *hog, bool force); int bt_hog_set_control_point(struct bt_hog *hog, bool suspend); int bt_hog_send_report(struct bt_hog *hog, void *data, size_t size, int type); diff --git a/profiles/input/hog.c b/profiles/input/hog.c index d50b823213b5..2db52d1a2fcb 100644 --- a/profiles/input/hog.c +++ b/profiles/input/hog.c @@ -206,7 +206,7 @@ static int hog_disconnect(struct btd_service *service) { struct hog_device *dev = btd_service_get_user_data(service); - bt_hog_detach(dev->hog); + bt_hog_detach(dev->hog, false); btd_service_disconnecting_complete(service, 0); -- 2.45.1