Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1804211rdb; Mon, 8 Jan 2024 10:40:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHV0n+nf8vcxmVp9WESzVsFaHql4txd0siP8aCWMxttgim8CiKsuIqCdc3vtaOXVt863G9P X-Received: by 2002:a2e:8509:0:b0:2cd:dfe:74c7 with SMTP id j9-20020a2e8509000000b002cd0dfe74c7mr1912865lji.21.1704739238603; Mon, 08 Jan 2024 10:40:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704739238; cv=none; d=google.com; s=arc-20160816; b=ilTCo1O5x9Wnu5jLDgTM4KUGI+lYs5EiSRbaw+XcY+lWyexCsU9TcTf6rRkBL4OoDe wf/PL3AnIevf/BQsH9TdzyxgL80+4a1HpWrCJJdp1WGRD0ASc6473TrG/ZMXt9J+IlCC okN+coddBKLNNaV2ajw7PeHL+YMnDVSsYrIooMVVamUB4pf6PS1jg8K8hTEiwW0HxjUu +PdjfqsNveeQjrjwde5g0/2Ro35RrC5+WEQ7k3VeTp+GnzZ1IEnFW+gpc5LrwWrctTuy PYxqYxtaQjRBJGynlna55kPfegegF1SKftnJGZ1ast4s8BE2emH2/CcQ1J8YuzE2iE98 9MIQ== 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=GO3E86crEJ1aYvFIwv/TH2Mmeyx20SSpkVLfTpGtLETeQDfFmqFny9hrLnz3WhZhml TMw+YD1+aI5W1Wu6sJRGERS4bXHN16kd4VGE3iErzCfyjk99McjIgQvehWGJYoxD6JFj nG0sMNnQ1qqhmF+aJMuKgjDYquMql3rkES/J07VioHWY9kfNRMVtzVIGcSQwpADozBuh sGtGmxTqQFhAkICOe54lYjgVAdAMWUXndD70anoSuGiv6oYudXFq0i4Wo2bRQIitjpLE 6KFtG5Jjt+KdgruFf9gTYEfDeLwqd3HXARywv9PMqqJumUkhLFm+CZQ0aL2WbK6DE6Fa ICVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth+bounces-961-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-961-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cw21-20020a056402229500b00552346b02f5si92034edb.501.2024.01.08.10.40.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 10:40:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-961-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth+bounces-961-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-961-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 583071F23C43 for ; Mon, 8 Jan 2024 18:40:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55E5454BEB; Mon, 8 Jan 2024 18:39:58 +0000 (UTC) X-Original-To: linux-bluetooth@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=20Dre=C3=9Fler?= To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: =?UTF-8?q?Jonas=20Dre=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-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4T82st3W37z9scT 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 -- 2.43.0