From patchwork Mon Jan 8 18:39:34 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: 186100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1205814dyq; Mon, 8 Jan 2024 10:40:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLmwR5utTeVxgcpPvEuYYP8pgT9t4LGwdtVidGALBB0sk+vAmvMa4vZoq8vr2s7ncOnjjY X-Received: by 2002:a0d:d8d8:0:b0:5ec:8d7f:3509 with SMTP id a207-20020a0dd8d8000000b005ec8d7f3509mr2419696ywe.9.1704739259533; Mon, 08 Jan 2024 10:40:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704739259; cv=none; d=google.com; s=arc-20160816; b=hTQzHNydPI7FLJVquV67CeOfEvi7f2CA+wSGHI0286fIEUiBnC27q1mHZ/fZRNl4oM 0Gx1mPTZd/ifDCClOSVJ9mMtpocbcBaCEek0deALHZaosiYBtGO2TpBgaUr7HkOjp4o2 0uBfnHpoFyNF09l3xqD8Ic1CuYXEXPD86MTi/W5I7PCTg16vnThXmAE1ZSO5gK9yolO2 xeESriuFIjEUKfNE2HWtvBwhYyDXA2J2BLLEZ5sU6/PQR51RMsm0wZw9LmAtyTLG0kcm EQSS5X6z0G4Ckw4n2Sw8aAOXHIE+yBexMloZ0euTJO5HCdJVHsI2E+xWcFmU/aM8rxqj iiJA== 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=/mRH7uIDoL7EQ29xDkhsozKxe10rot3JsZTe8qYsvNc=; fh=3AqDzvZy8BuFcn015+g5AB3sGQnZc/edyFwniXfpO+U=; b=HQUJ/9DR3IK4D/QwJyXjBFx5jPcZ+Q4xWeRlOD6HbsXvc62IVxdap+YfFu9saEPRJy l0ZvSz5ku83bRRQKvqNHXUYXKTJNjE5v3URCD6HKr6iaqCPJp2MKNEA1gGTBGcch3SYa EygkWvjmUANCvrIAav5+UTtOiubLZBP9YKETVa+LSx6k/QDSW2bTNWTnQNbNAHfZ7JKJ DadD84KVqlS67bAXbTnf/XwKkk41bwS2x7QLX2q2wtxvagYKUHZZOe7UFeWzk0MAguY1 v/BcdkG97R85wlkl8etZTE4Y5YglFSBca4832H7LDT+lhcGkLqawh08SIV4h+FTDT9Hw 1olg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19982-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19982-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t13-20020a0cb38d000000b0067f33dcc95bsi416238qve.469.2024.01.08.10.40.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:40:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19982-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19982-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19982-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 52E931C2125F for ; Mon, 8 Jan 2024 18:40:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9092255C1F; Mon, 8 Jan 2024 18:39:59 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 C3D5954F83; Mon, 8 Jan 2024 18:39:55 +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 smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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-102.mailbox.org (Postfix) with ESMTPS id 4T82st3W37z9scT; Mon, 8 Jan 2024 19:39:46 +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 v2 2/4] Bluetooth: hci_event: Use HCI error defines instead of magic values Date: Mon, 8 Jan 2024 19:39:34 +0100 Message-ID: <20240108183938.468426-3-verdre@v0yd.nl> In-Reply-To: <20240108183938.468426-1-verdre@v0yd.nl> References: <20240108183938.468426-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-Rspamd-Queue-Id: 4T82st3W37z9scT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787548674093624433 X-GMAIL-MSGID: 1787548674093624433 We have error defines already, so let's use them. 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