Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp234435lqp; Thu, 4 Apr 2024 11:31:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUx5aCuPvcp2m3KBx1A5I4gnGY6FITc+7kHBVoQ07LmtMp2nP4N42hK+YYQD80wTUOL5/7OKlwYUVbNWqiLNCFGx+//E3kEIT4EMy5Qyg== X-Google-Smtp-Source: AGHT+IFa/1V9bTwRV4zA3farwndfdcnHmUp0oQc/qCz/gax0d2SaCOeNArKGt7W/9nk5XuO+23AC X-Received: by 2002:a17:902:e802:b0:1dd:a33f:5913 with SMTP id u2-20020a170902e80200b001dda33f5913mr3856404plg.30.1712255471249; Thu, 04 Apr 2024 11:31:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712255471; cv=pass; d=google.com; s=arc-20160816; b=1EfmQjW7bqU8YC7mLuFUnFqcNSeZlPsX/iN1BORMs9m91YkuokyvSuQt4i/hW4rwxw JHNRXG8CaVfrSssL8nRihnVMXJnOyEmCbjnWeDhB1gXLCBgk9Ez564iKDMZ/ZX05NLWY FYIawVaB8QXbimBOPhFashSNUqd/Qp/1FGZ16fSS7QdYPCVg6CwgiLI9lxxeN03bw2qE 1m+8aldiZvoMQQ3266B+/biES1pH3eyS2MpZ1138v7+6qFwEcwHGOrdXMsCKej2jjcYb gcyYRQrf8N5LafytgDOOWK38QguiScudlz782wMFs6Hwjya3tb7iuo0IPkAv1nDZV2pj MqsA== 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:cc:to:from:dkim-signature; bh=t7XAs1oVmXtPQ69chZaMcCwOGj6flcaWL3dZ95DHy9k=; fh=QvLe9xSQ7zlfGAr+dqnfPkt50uL0YuAdQlMdBJrVoy4=; b=rTsgsQk8/9q4T1WaKoS/8LJDBXWlA2bj1tdz9JT1YHf92HOPe8cTnDRzUQJjL4uOiY n7ysfGnRi1EbMbLB5lbV18HlsoKQyDLTDr1mAOo5HHnEc7IRajiwoisot14xGMAaZj0z ++0l+6hEL8p3IkQVKjqmRWztuGKZR7OmfSOrWrL2qrF5y8n5tz359LrM1FRl7nJPe+2s qvH5XN9JL7SiY2coKxIIiBN4asvSF6h+ahY2VRcdIo8KMziNQOnCkcx1vAvIc+WBZ50O /dz5Msu5KxO4DUzhJVNwuOln75ND50wfAoBdohpXXywLPcOK8UzQac+ljazLd/y2593C Viig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eFmqb62r; 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-3226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3226-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 me13-20020a170902fc4d00b001e2c4ff586fsi330386plb.48.2024.04.04.11.31.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 11:31:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-3226-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=eFmqb62r; 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-3226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-3226-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 5181B283452 for ; Thu, 4 Apr 2024 18:31:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C585312D775; Thu, 4 Apr 2024 18:31:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eFmqb62r" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (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 D71941391 for ; Thu, 4 Apr 2024 18:31:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712255467; cv=none; b=SeiDaqO62juqtK0Y7WdqYI0GqFqdEDyVowS1P8nIX/n83snYAq5Qd1VKwvMg4q2AjHftzmAZlekBri6CyTMs4JZswU/sdNuIs5XQCVEmTw9Doms1KBFd3FksFUplazW3mPhWkVGuu/1wpYqBNrZLr9gKHlgKWyxsrXsa4/UZM+M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712255467; c=relaxed/simple; bh=5MvbRHUxpUjnrTvwTr4K/d9h/+BsRGepOTHTB/QAmSc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3c0fzpczp2gYARu0cYXfh2yaCaXHRk3IGfYx9AQ7ZFt3WOa3obmS9vV9MtYMPDOZAWCKK55zpKvSjIhozR7/nltIPzoARPZVGRoBLF2S8mFunYUCUpf1DbJ3HXLrfG2pteBfnzirP5168ao6TkPrTcEv0GejEAeOz6zje+wjWM= 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=eFmqb62r; arc=none smtp.client-ip=209.85.210.195 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-pf1-f195.google.com with SMTP id d2e1a72fcca58-6e6b6f86975so979416b3a.1 for ; Thu, 04 Apr 2024 11:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712255464; x=1712860264; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t7XAs1oVmXtPQ69chZaMcCwOGj6flcaWL3dZ95DHy9k=; b=eFmqb62rsVv2zX7UKFxkRNMy0HjanY0wxIvAoj2facXhd5aCHGfl+AEZdoZOK/E3Qa OYFvtNib0H9SwLNLnGk22qU5kISkwtdQQnNs2g9nBO6pWVmQCOoflpw//jdxFqNNFwkL AxJm8jXOvbOiBJ6UE2xZbGy7P/P8/ydOoZtVidnFeTFm6fFgi4a2WFzsuiha52s9WpMp asTUsNniAGCIICfs+ohg2JPEqXUrU8EHgYMAeNj+dR9hqqPkMvrB6wTlqc1hYKatmxFY ToiNn6ooBN0uZGdFgL6ambZ0rHexSfboWtgZlRM8aB3+e2OuAbn8OSEHh9yGCFekYeGh C9nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712255464; x=1712860264; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t7XAs1oVmXtPQ69chZaMcCwOGj6flcaWL3dZ95DHy9k=; b=ZTgp0iDDsiEfoehsfHmFg8FpBYekzgyhwnWSEs8HGkRVvsWhlaO72f2wHSizmY7N2Q aiIexIPAvvdco1e6fyZCKbYdc20EZZZS0iu+2bFC5fmMUIJVh8d4eR8gAG6WQjrmpF0o Oid+t6uQqD7o7WifUUbl6KUqoR7Ay4qjKwh4j73xyKqgWwSAooLiqekZSMcq381Q1kj0 R5Zw/Q2wib2+Uv4DAOGoYK/LZu+P+SHbn0H6ElCvfkGzPwFlwQmXRqLcbhbtJsDLoMPz jSAcJnLQlYsEuF6m3Vkcpj43hq9h0uf07gV9a/SJ8exu6trdbm01uuW53osvXgzrBzF3 6Jkg== X-Gm-Message-State: AOJu0YwWm5iPuMth3YGFvwKo8h9wHudfncxhBNbH/Y/Ie7FJ7twLQkN1 eWllw3ajqRk7pVW86MkqJkrLEeXrZ0lVhetbGBHuoDp9k4nlmkmZNWMBuOzIgdOrbe2q X-Received: by 2002:a05:6a00:4609:b0:6ea:e2d8:487 with SMTP id ko9-20020a056a00460900b006eae2d80487mr3572368pfb.17.1712255464407; Thu, 04 Apr 2024 11:31:04 -0700 (PDT) Received: from angua.lan ([2600:3c0a:e002:7f00::1001]) by smtp.gmail.com with ESMTPSA id n12-20020a056a000d4c00b006ea8c030c1esm806239pfv.211.2024.04.04.11.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 11:31:04 -0700 (PDT) From: Dimitris To: linux-bluetooth@vger.kernel.org Cc: Dimitris Subject: [PATCH BlueZ 1/1] refactor bearer connected test Date: Thu, 4 Apr 2024 11:30:50 -0700 Message-ID: <20240404183050.334414-2-dimitris.on.linux@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404183050.334414-1-dimitris.on.linux@gmail.com> References: <20240404183050.334414-1-dimitris.on.linux@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 --- src/adapter.c | 2 +- src/device.c | 7 ++++++- src/device.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 4bcc464de..017e60233 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7486,7 +7486,7 @@ static void adapter_remove_connection(struct btd_adapter *adapter, device_cancel_authentication(device, TRUE); /* If another bearer is still connected */ - if (btd_device_is_connected(device)) + if (btd_device_bearer_is_connected(device)) return; adapter->connections = g_slist_remove(adapter->connections, device); diff --git a/src/device.c b/src/device.c index 5e74633c6..74dd67a09 100644 --- a/src/device.c +++ b/src/device.c @@ -3273,13 +3273,18 @@ uint8_t btd_device_get_bdaddr_type(struct btd_device *dev) bool btd_device_is_connected(struct btd_device *dev) { - if (dev->bredr_state.connected || dev->le_state.connected) + if (btd_device_bearer_is_connected(dev)) return true; return find_service_with_state(dev->services, BTD_SERVICE_STATE_CONNECTED); } +bool btd_device_bearer_is_connected(struct btd_device *dev) +{ + return dev->bredr_state.connected || dev->le_state.connected; +} + static void clear_temporary_timer(struct btd_device *dev) { if (dev->temporary_timer) { diff --git a/src/device.h b/src/device.h index d4e70b7ef..5722ca9ca 100644 --- a/src/device.h +++ b/src/device.h @@ -104,6 +104,7 @@ void device_set_rssi(struct btd_device *device, int8_t rssi); void device_set_tx_power(struct btd_device *device, int8_t tx_power); void device_set_flags(struct btd_device *device, uint8_t flags); bool btd_device_is_connected(struct btd_device *dev); +bool btd_device_bearer_is_connected(struct btd_device *dev); uint8_t btd_device_get_bdaddr_type(struct btd_device *dev); bool device_is_retrying(struct btd_device *device); void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type, -- 2.44.0