Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1611824pxb; Wed, 10 Feb 2021 12:23:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0LP/CdIKdjmKV7pxphjqhMSDAmOL54jpexaaENato6/yMw5mFQYn39X8iRL90ugfWz5+s X-Received: by 2002:a17:906:27d8:: with SMTP id k24mr4598677ejc.339.1612988601144; Wed, 10 Feb 2021 12:23:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612988601; cv=none; d=google.com; s=arc-20160816; b=m6KYDKf0zKt29EiHBIJigtH+cN14idHIERKoyTseVZxplBThyO3Ta4i7jRyflY6GyX 4joSVzBfLrGzYxPj3qcviJBymDGerFTweRvh1eBz4aIu/zok34gft/HTzLd6NwkhBWAw +P6CHRqeAtX3+wSeIHJk6uNzTO3lAz+fqjKN3QUTFethn7GsL116S342mudq8B7mFL9f FMUmBmeCdRHrwytWhCsJl0UDfQL939K0Z9/l/0z12qdC6MptxRkHIRGooD+nXviOKbzA d2vuVrk7i4OyLIy8oNGQthU1UP6s85rLlkIMBLyjqoXn+T1Hnb0IBF8qy8ut4KNpULWX r7Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=uBCUmG0HC+H/OmutPSoFa4PAmtJW1vZ8PYZ2ygMWdyA=; b=iusNussMiVsiQYRb9+MBm1/0MSck1G0E1u4gnP3nXdxe58QpMmSn+/E1oWHQ5hrOGD 3YnhC4Xwik6Arnf60mEe1rDHLy8Pp1rUEhhhQofRjlDcFJKOABLqIqStGyg14Nq+IOBH itpN/Tynv0ouliHJ3P00/wBNIJvFFZWsSTIaEaO6ChoMXHsEhbspsm9GgbycvwlL03nC 4gzoB8yhhmEXhSfgs0Nn6qfvqi564y34qIPt16UUZy3uGillUAMPqlQQ68F3nhO3yL12 OGsuhgZ/8pM8IOqUAusEK6mKlAcRAZs4tg4frzUM4EWj8TqpoaTlsGNLA8KADS0zsjqV gW3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UjAht1HL; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd22si2092751ejb.105.2021.02.10.12.22.56; Wed, 10 Feb 2021 12:23:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UjAht1HL; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233225AbhBJUUJ (ORCPT + 99 others); Wed, 10 Feb 2021 15:20:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233244AbhBJUTg (ORCPT ); Wed, 10 Feb 2021 15:19:36 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5F3C061786 for ; Wed, 10 Feb 2021 12:18:56 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id t11so1963327pgu.8 for ; Wed, 10 Feb 2021 12:18:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=uBCUmG0HC+H/OmutPSoFa4PAmtJW1vZ8PYZ2ygMWdyA=; b=UjAht1HLbECXLOrjgLdfA4PZsB8Qa9SSxOFJVOJRB8iSTk9+ojjIwyh6sP6KUhy23S 0j9tM+DK7p7lknuu8dxIx5Q4WS3cSkdMk557OJUKONTaN+ZJvrB944b1gkquxF6c/0QV Tbxde6ZZB4OMEhUi5Nf7oH1nQELgP0sCH/ZgcnuAouticP70ileCrbMqGCDUnkyr/3bP GjN3yEistIZ/vHkW86muVK74KHL6pzWiautE8DaEybOEUijJ/hYAqxqGFv1hSMHVieoF dr3zIg1agVl+IK7KlFMPVZCl9FOgmHRYYuwxTZcB7wl8Fla79+DATNjq2AAFEAd305v4 sYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uBCUmG0HC+H/OmutPSoFa4PAmtJW1vZ8PYZ2ygMWdyA=; b=IDRdvcXlKWbmyOFR/ip26lZzdZ8ut0l3QJLzy+tVdqYSF2F+i1ws/fUGFfBzPJsYPh 1qrO30v2sfdivznC3UfFG3OEoDjQIojeKhLLmBdmzoynFfMzq7ILBzP2+IR1GUaUgGqS TszissPw20qNzwvzuE5/ObU+xt/vESncRdZzeB34TWv2DG7qN8szayaqZlWo2/La+l7a +kmIFSBRadcDKRZIdhUa8AHux1t4+ajx/fH6P6/ggzqPuyU1rZy4+4/3CIJ0/jEk/7TO XpPlhzdS3pfpZszBKOXQXDbZTJ9AWi3CfCt6Ovw4lSAbu5OBkHWHxbiOsntgD+BVDRU7 a7ew== X-Gm-Message-State: AOAM533ZJdyQ8HdvcPiSOVvQ/IEfa6x9upiG2jpsovYliexM3oT5UL8w gMoMTBROyNbAK9+PLsb/HxWk1MRribOf8g== X-Received: by 2002:a63:fb18:: with SMTP id o24mr4604878pgh.55.1612988335866; Wed, 10 Feb 2021 12:18:55 -0800 (PST) Received: from localhost.localdomain (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id cu5sm3124696pjb.27.2021.02.10.12.18.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Feb 2021 12:18:55 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v6 4/6] Bluetooth: btintel: Consolidate intel_version parsing Date: Wed, 10 Feb 2021 12:18:50 -0800 Message-Id: <20210210201852.2246985-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210210201852.2246985-1-luiz.dentz@gmail.com> References: <20210210201852.2246985-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This moves checks version checks of intel_version to btintel_version_info. Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/btintel.c | 36 ++++++++++++++++++++++++++++++++++-- drivers/bluetooth/btintel.h | 2 +- drivers/bluetooth/btusb.c | 12 ++++-------- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index c907a4d6b37c..452233a06aaa 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -216,10 +216,39 @@ void btintel_hw_error(struct hci_dev *hdev, u8 code) } EXPORT_SYMBOL_GPL(btintel_hw_error); -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) +int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) { const char *variant; + /* The hardware platform number has a fixed value of 0x37 and + * for now only accept this single value. + */ + if (ver->hw_platform != 0x37) { + bt_dev_err(hdev, "Unsupported Intel hardware platform (%u)", + ver->hw_platform); + return -EINVAL; + } + + /* Check for supported iBT hardware variants of this firmware + * loading method. + * + * This check has been put in place to ensure correct forward + * compatibility options when newer hardware variants come along. + */ + switch (ver->hw_variant) { + case 0x0b: /* SfP */ + case 0x0c: /* WsP */ + case 0x11: /* JfP */ + case 0x12: /* ThP */ + case 0x13: /* HrP */ + case 0x14: /* CcP */ + break; + default: + bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)", + ver->hw_variant); + return -EINVAL; + } + switch (ver->fw_variant) { case 0x06: variant = "Bootloader"; @@ -228,13 +257,16 @@ void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver) variant = "Firmware"; break; default: - return; + bt_dev_err(hdev, "Unsupported firmware variant(%02x)", ver->fw_variant); + return -EINVAL; } bt_dev_info(hdev, "%s revision %u.%u build %u week %u %u", variant, ver->fw_revision >> 4, ver->fw_revision & 0x0f, ver->fw_build_num, ver->fw_build_ww, 2000 + ver->fw_build_yy); + + return 0; } EXPORT_SYMBOL_GPL(btintel_version_info); diff --git a/drivers/bluetooth/btintel.h b/drivers/bluetooth/btintel.h index 94a63e898826..7163170410a8 100644 --- a/drivers/bluetooth/btintel.h +++ b/drivers/bluetooth/btintel.h @@ -148,7 +148,7 @@ int btintel_set_diag(struct hci_dev *hdev, bool enable); int btintel_set_diag_mfg(struct hci_dev *hdev, bool enable); void btintel_hw_error(struct hci_dev *hdev, u8 code); -void btintel_version_info(struct hci_dev *hdev, struct intel_version *ver); +int btintel_version_info(struct hci_dev *hdev, struct intel_version *ver); int btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *version); int btintel_secure_send(struct hci_dev *hdev, u8 fragment_type, u32 plen, const void *param); diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 169e7d0739d1..e80f66825697 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2474,12 +2474,6 @@ static int btusb_setup_intel_new_get_fw_name(struct intel_version *ver, char *fw_name, size_t len, const char *suffix) { - /* The hardware platform number has a fixed value of 0x37 and - * for now only accept this single value. - */ - if (ver->hw_platform != 0x37) - return -EINVAL; - switch (ver->hw_variant) { case 0x0b: /* SfP */ case 0x0c: /* WsP */ @@ -2658,8 +2652,6 @@ static int btusb_intel_download_firmware(struct hci_dev *hdev, if (!ver || !params) return -EINVAL; - btintel_version_info(hdev, ver); - /* The firmware variant determines if the device is in bootloader * mode or is running operational firmware. The value 0x06 identifies * the bootloader and the value 0x23 identifies the operational @@ -2847,6 +2839,10 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) return err; } + err = btintel_version_info(hdev, &ver); + if (err) + return err; + err = btusb_intel_download_firmware(hdev, &ver, ¶ms, &boot_param); if (err) return err; -- 2.26.2