From patchwork Mon Jan 8 22:46:07 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: 186149 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp1315370dyq; Mon, 8 Jan 2024 14:47:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7wDAISxW95g7EDQemUfTyJ/C5IZ4C46XlpEr0P+ZffQiUQlG9/hKRDUUk9xPX+C74L0tR X-Received: by 2002:a05:6a20:c519:b0:199:a2a9:4159 with SMTP id gm25-20020a056a20c51900b00199a2a94159mr2584432pzb.109.1704754063538; Mon, 08 Jan 2024 14:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704754063; cv=none; d=google.com; s=arc-20160816; b=ny3IjYfmSVDZQHfUnJ2T++ceqBU5HvyTYSsOj9Kl0ALhorM0mxNTYug9tvRsZshapq rg5e9B5srOqMyzNL+iqULms6C62uQhr3fqPf1bN4EUdKT9P17lGIzSICfqbT1sIsSIlh rM/9vhjilfo6lveF+e6wXtZiDIc/MUtlDFC+gnkhZQ4AJbCvvlae5B0tgA+eVnLh5hXv SaNJgsF5FH/A7rE1ex4dFd1/jYF2jOBV+XQrPzAFnvsmDDz7uRvxaNST0E2GJKlMLbcU xiRoK/xDLDnDhbgVhN+Xkm/HOqCgd6tqFGPlY9HJ2kZyGkX0w8NHZvpdG1UvsDvKHB4H lVGQ== 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=b4UkFMx240jn6WjIAxqmBs/yAZe5umDjmXYJPY6CaHY=; fh=3AqDzvZy8BuFcn015+g5AB3sGQnZc/edyFwniXfpO+U=; b=BsC1DR2IGi7plUOaiGJwBqN6FVdFuBGRILPWODXdUHhPU0cz3sNlnZwjv+Y8USHJKE k5U+URsCFUyXqw5jo5MXvHr5KawS1Vlrd1nqAHlBRD9GCxoqGiQufc/El1QTlhUVR0od PSjhIZNs7SqCxxaAx08de7ohF5zXaK7kjEk/lbSpkE8Dpz1FqOlvtLQD55Qd0Bfn5dpU VCfwWorZ36OM5n8lUylXMN7Vkk1pBh/+evdIVhrB8AEW0/ghXlI31Vjz9T1E1ZjUVXr3 oaiI6WGRiCggCMa48SCN1GeoxrqJgEW0y4I9qVoQDePpiAEeiUXteybq+lcOOWVhr1f3 UrAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-20160-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20160-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ay4-20020a056a00300400b006d9b895e00bsi466650pfb.311.2024.01.08.14.47.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 14:47:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20160-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-20160-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20160-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 43F56285006 for ; Mon, 8 Jan 2024 22:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F24356B85; Mon, 8 Jan 2024 22:46:34 +0000 (UTC) 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 C29B15647A; Mon, 8 Jan 2024 22:46:30 +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 smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (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 4T88LW06kWz9srv; Mon, 8 Jan 2024 23:46:27 +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 v3 2/4] Bluetooth: hci_event: Use HCI error defines instead of magic values Date: Mon, 8 Jan 2024 23:46:07 +0100 Message-ID: <20240108224614.56900-3-verdre@v0yd.nl> In-Reply-To: <20240108224614.56900-1-verdre@v0yd.nl> References: <20240108224614.56900-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: 4T88LW06kWz9srv X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787564197251310354 X-GMAIL-MSGID: 1787564197251310354 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 87d92accc..63f84e185 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -652,6 +652,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 @@ -660,6 +661,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 9423394f6..dcbba1521 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -95,11 +95,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; } @@ -2326,7 +2326,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); @@ -6682,7 +6682,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