From patchwork Tue Jan 2 18:59:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonas_Dre=C3=9Fler?= X-Patchwork-Id: 184433 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4629961dyb; Tue, 2 Jan 2024 11:01:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEd41MZnWUHFWa9OZ9dYedk0fvmy65qKJAIF/HpDspvtA6oZ0xNws2gqEnrELy6eIrl/NX+ X-Received: by 2002:a05:6a20:3a91:b0:196:a56b:4e92 with SMTP id d17-20020a056a203a9100b00196a56b4e92mr2246431pzh.81.1704222067073; Tue, 02 Jan 2024 11:01:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704222067; cv=none; d=google.com; s=arc-20160816; b=IGcmYIncBYada1JTqXhOH3zYcFj+ZSM7dels1bZLPWE24SUI7Ab4ueqqTwd8ZjV+Yo DQWvBZqW30U7ctuz8LzE65K0d4IPqnOmrErjM/eUzDThkrH7c3EKZppELwUcaCvi59HR rjyhQeCXxH54y0bLqyXeQYCExyxwEycp7fyRa1s9K6qk0Lmnln+VSaKL1D5Uk/dwGU7k XMjP5wryP47X737iQxjYKf3vOTh19hVZJoMqlhaOPIJp6OvYh92SIK4NZU+MMHCVFFww NgrO5//8FGQz6wL5yYMoj0Xe+8Rj4jGjq95NTYbm2HZYPEiD98vhH8VF0Q/LxnT6YybB wYkw== ARC-Message-Signature: i=1; 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; bh=Sz1KVDSy6RfcWKbVdd4pVfTOMN76sxIKW3uTgVzJ+q8=; fh=3AqDzvZy8BuFcn015+g5AB3sGQnZc/edyFwniXfpO+U=; b=y5pBX9cD3txO+K4atqPcdXNHPSfsd6iFPDJfCqrBvrJU9BupRrCVqV1vycnkpDfaMq hcqlr+mSZMuE3R/n0JbTn0A1UnhvyNB6V6VSq+T0LsBclaJdAM3WwLLmh78mP/e4gNNy rM6DtieTD6X+M3Dvwkx00tzp61qDORrBvIa7vT7oc37F3RfhlW9NlVhv3H4HxAn7yI+3 HuBoaPtGFqMnEnT8sXRuDtrElwx+MacCrRuKOYSwXT9Iq5tl4vykt/DVAAnbzv0l//+A KZOK2IGDXPSpEdc3luYeWV8N6fcrbPp8E++wHEpUL7LtBfkZoTGpUh6RcshUAGMKJsMB t6nA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14752-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14752-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u8-20020a056a00098800b006d9c8639c70si13150815pfg.354.2024.01.02.11.01.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 11:01:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14752-ouuuleilei=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; spf=pass (google.com: domain of linux-kernel+bounces-14752-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14752-ouuuleilei=gmail.com@vger.kernel.org" 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 C33FE280CFD for ; Tue, 2 Jan 2024 19:01:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8F80168DD; Tue, 2 Jan 2024 18:59:46 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41C2D15E97; Tue, 2 Jan 2024 18:59:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=v0yd.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=v0yd.nl Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4T4Mbb1SQzz9sq5; Tue, 2 Jan 2024 19:59:39 +0100 (CET) From: =?utf-8?q?Jonas_Dre=C3=9Fler?= To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: =?utf-8?q?Jonas_Dre=C3=9Fler?= , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 2/5] Bluetooth: hci_event: Use HCI error defines instead of magic values Date: Tue, 2 Jan 2024 19:59:29 +0100 Message-ID: <20240102185933.64179-3-verdre@v0yd.nl> In-Reply-To: <20240102185933.64179-1-verdre@v0yd.nl> References: <20240102185933.64179-1-verdre@v0yd.nl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787006358195185340 X-GMAIL-MSGID: 1787006358195185340 Signed-off-by: Jonas Dreßler --- include/net/bluetooth/hci.h | 2 ++ net/bluetooth/hci_event.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 111e8f8e5..fef723afd 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -641,6 +641,7 @@ enum { #define HCI_ERROR_PIN_OR_KEY_MISSING 0x06 #define HCI_ERROR_MEMORY_EXCEEDED 0x07 #define HCI_ERROR_CONNECTION_TIMEOUT 0x08 +#define HCI_ERROR_COMMAND_DISALLOWED 0x0c #define HCI_ERROR_REJ_LIMITED_RESOURCES 0x0d #define HCI_ERROR_REJ_BAD_ADDR 0x0f #define HCI_ERROR_INVALID_PARAMETERS 0x12 @@ -649,6 +650,7 @@ enum { #define HCI_ERROR_REMOTE_POWER_OFF 0x15 #define HCI_ERROR_LOCAL_HOST_TERM 0x16 #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 +#define HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE 0x1e #define HCI_ERROR_INVALID_LL_PARAMS 0x1e #define HCI_ERROR_UNSPECIFIED 0x1f #define HCI_ERROR_ADVERTISING_TIMEOUT 0x3c diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 13396329f..e8b4a0126 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -92,11 +92,11 @@ static u8 hci_cc_inquiry_cancel(struct hci_dev *hdev, void *data, /* It is possible that we receive Inquiry Complete event right * before we receive Inquiry Cancel Command Complete event, in * which case the latter event should have status of Command - * Disallowed (0x0c). This should not be treated as error, since + * Disallowed. This should not be treated as error, since * we actually achieve what Inquiry Cancel wants to achieve, * which is to end the last Inquiry session. */ - if (rp->status == 0x0c && !test_bit(HCI_INQUIRY, &hdev->flags)) { + if (rp->status == HCI_ERROR_COMMAND_DISALLOWED && !test_bit(HCI_INQUIRY, &hdev->flags)) { bt_dev_warn(hdev, "Ignoring error of Inquiry Cancel command"); rp->status = 0x00; } @@ -2323,7 +2323,7 @@ static void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) if (status) { if (conn && conn->state == BT_CONNECT) { - if (status != 0x0c || conn->attempt > 2) { + if (status != HCI_ERROR_COMMAND_DISALLOWED || conn->attempt > 2) { conn->state = BT_CLOSED; hci_connect_cfm(conn, status); hci_conn_del(conn); @@ -6578,7 +6578,7 @@ static void hci_le_remote_feat_complete_evt(struct hci_dev *hdev, void *data, * transition into connected state and mark it as * successful. */ - if (!conn->out && ev->status == 0x1a && + if (!conn->out && ev->status == HCI_ERROR_UNSUPPORTED_REMOTE_FEATURE && (hdev->le_features[0] & HCI_LE_PERIPHERAL_FEATURES)) status = 0x00; else