Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6342328rwb; Mon, 5 Dec 2022 10:55:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf5lQAWMVx9YVXQuzyhaRpJYCNqXQnrJ8INVZMNglx+dcZ2H49rQfZDrfg//DfDhpLThcM/H X-Received: by 2002:a17:906:6703:b0:7ae:5dd6:e62d with SMTP id a3-20020a170906670300b007ae5dd6e62dmr60214972ejp.518.1670266544783; Mon, 05 Dec 2022 10:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670266544; cv=none; d=google.com; s=arc-20160816; b=jtFoh/c+KvR0o80eIPuZDtfMGFczvHS6w4c9mPhBJHynkLUVqcWdyO5SCk80WTScYl 1PdSx+80AG/qYqQiuSDXUuIN+yZuKXVp6HQ31SOdmIOLbCYraUmhXIEOEFZ+hmMTuRQI L4lJQR9luwcJ1U9vQXGXAFGeHQdOiy9TpQMpMJDL2ZQRpea18QuDFoxNjCCGySHjN9sj g5gKagQBdMSG04rGG1hSWJjbqxuDIYmhcx/8liEw4P83EfXXwqRHaxI0k1f4SGVkI+sO 1IE3W2DYBrF9pkt95oGzMP5ujSy7OE+nDEOrcDJkR3hWtaSuS8u2jeymQOr9wX3DsaXk rk7g== 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 :message-id:date:subject:to:from:dkim-signature; bh=oiQ7kqQcZglR2eF387n2myjsQOhqcKBThxzbTBU0Vwo=; b=hpdDMPa3QXXHzKr2oy2PSEidEdiXYdjXXaM5luV008gyXsxo9brvGZnLi8U/K1Xgjg RbzJIroxcIkwfjcK84lozXnxRklUm3S9P7stwmu4AOx0pSk7S4BAewF3yqkc1x9PG2SZ YjEWgXrPoOIk/t2k46z5Ldxs/3hJKQtGdiopEdIoUvlGgTbo92wksWDLmIQH29ILjnjl Sosoq7C9oRL50E94Lcd0FgcaJU1lxW0/61n4DUp0y3Kj9wP/h6SlJ4tN6Qvj93Z0lhQ8 5F9Mr5re6RLic1bn03pJC1N9lLnk6xkK+tch8N6Fzsox5NMXF3HCJOv+2EP94wJuehNf JYRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=juFvt0pq; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf34-20020a1709077f2200b007af0ca23299si1188768ejc.841.2022.12.05.10.55.12; Mon, 05 Dec 2022 10:55:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=juFvt0pq; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232918AbiLESj0 (ORCPT + 99 others); Mon, 5 Dec 2022 13:39:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232839AbiLESjH (ORCPT ); Mon, 5 Dec 2022 13:39:07 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E45BCA for ; Mon, 5 Dec 2022 10:32:44 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id q15so11031889pja.0 for ; Mon, 05 Dec 2022 10:32:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=oiQ7kqQcZglR2eF387n2myjsQOhqcKBThxzbTBU0Vwo=; b=juFvt0pqMtEIIumZntfjK5LJvV1QKekoyzqEfNB7/5+UgS55rWeaC6XmMFeZFksxML P3zZrtcL2MZyUlNcKWf/JRIt2Ee47841bVdJbtkubZPeFy29ZXR8Xpf5XBXTznslBZyW 3HsYCTyeyuakUo5ViPgp35ltmqaUuqX1oBDwj0DZCJfcNlrK+iqXo1SWM3WSPVwJtoHm qDdIMeirSWfQwAOdL6/faq+lN79eGQ7TrhHHleWzfLsSiPk9HQjuinWGEGFTl7omeGgP uP1Q3kJK9+WKD2P8ZJO42x7q1sTrl8cTCGqtojs5XAcPmB61UnXPXu3Vm3lTC9PVH+l7 laEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oiQ7kqQcZglR2eF387n2myjsQOhqcKBThxzbTBU0Vwo=; b=lja4Hje3i5nPHmcsegKoS78OWmu7sDJMmKKnUgMuv1m4s3f/0XAveHb1P5bxdvRAGf 9xpG6eryDidxPmKQgobJYqUpvB4RXAgG0sDiPch069E3sqgZVngie5f98reAk7NcdEC7 fhw9SBenqtaHpe31060RnJYeSSL9NdqdkGnbmBxj9HUPqkzoFJin3A+E/8owVVi46VW4 9cezYIWv2T2MDsz+5UXaMFs2q/0HwBuzb61pWuvKiGij93k2mEi1cGSggkUqpaUTMfoV 3GxbEfc2xezp1l60CnRu+lqNV5TgzS4UTaLlcYDliWmjI8hdvBVxtD9C2k1rQEz+3Hk/ cm0A== X-Gm-Message-State: ANoB5plTrwIyS7W5OlJR8wIwJjNcBZzGKL39DfgauotHAEs75UECkwZd IfzrMU0Cj6t+c23mcs4nElhOE3UIinr8znFT X-Received: by 2002:a17:90b:2642:b0:219:55d5:f30a with SMTP id pa2-20020a17090b264200b0021955d5f30amr32929451pjb.23.1670265163311; Mon, 05 Dec 2022 10:32:43 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id l124-20020a622582000000b00573eb4a9a66sm10204079pfl.2.2022.12.05.10.32.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 10:32:42 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 1/3] Bluetooth: btusb: Fix new sparce warnings Date: Mon, 5 Dec 2022 10:32:34 -0800 Message-Id: <20221205183236.3460924-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This fix the following warnings detect with make W=1 C=1: drivers/bluetooth/btusb.c:2212:9: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2212:9: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2245:18: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2249:18: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2253:18: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2257:18: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2261:18: warning: cast to restricted __le16 drivers/bluetooth/btusb.c:2267:18: warning: cast to restricted __le16 Signed-off-by: Luiz Augusto von Dentz --- drivers/bluetooth/btusb.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index d57571cc82d4..422c878a9500 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -2201,18 +2201,19 @@ static int btusb_setup_csr(struct hci_dev *hdev) return err; } - if (skb->len != sizeof(struct hci_rp_read_local_version)) { + rp = skb_pull_data(skb, sizeof(*rp)); + if (!rp) { bt_dev_err(hdev, "CSR: Local version length mismatch"); kfree_skb(skb); return -EIO; } - rp = (struct hci_rp_read_local_version *)skb->data; + bt_dev_info(hdev, "CSR: Setting up dongle with HCI ver=%u rev=%04x", + rp->hci_ver, le16_to_cpu(rp->hci_rev)); - bt_dev_info(hdev, "CSR: Setting up dongle with HCI ver=%u rev=%04x; LMP ver=%u subver=%04x; manufacturer=%u", - le16_to_cpu(rp->hci_ver), le16_to_cpu(rp->hci_rev), - le16_to_cpu(rp->lmp_ver), le16_to_cpu(rp->lmp_subver), - le16_to_cpu(rp->manufacturer)); + bt_dev_info(hdev, "LMP ver=%u subver=%04x; manufacturer=%u", + rp->lmp_ver, le16_to_cpu(rp->lmp_subver), + le16_to_cpu(rp->manufacturer)); /* Detect a wide host of Chinese controllers that aren't CSR. * @@ -2242,29 +2243,29 @@ static int btusb_setup_csr(struct hci_dev *hdev) * third-party BT 4.0 dongle reuses it. */ else if (le16_to_cpu(rp->lmp_subver) <= 0x034e && - le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_1) + rp->hci_ver > BLUETOOTH_VER_1_1) is_fake = true; else if (le16_to_cpu(rp->lmp_subver) <= 0x0529 && - le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_1_2) + rp->hci_ver > BLUETOOTH_VER_1_2) is_fake = true; else if (le16_to_cpu(rp->lmp_subver) <= 0x0c5c && - le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_0) + rp->hci_ver > BLUETOOTH_VER_2_0) is_fake = true; else if (le16_to_cpu(rp->lmp_subver) <= 0x1899 && - le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_2_1) + rp->hci_ver > BLUETOOTH_VER_2_1) is_fake = true; else if (le16_to_cpu(rp->lmp_subver) <= 0x22bb && - le16_to_cpu(rp->hci_ver) > BLUETOOTH_VER_4_0) + rp->hci_ver > BLUETOOTH_VER_4_0) is_fake = true; /* Other clones which beat all the above checks */ else if (bcdDevice == 0x0134 && le16_to_cpu(rp->lmp_subver) == 0x0c5c && - le16_to_cpu(rp->hci_ver) == BLUETOOTH_VER_2_0) + rp->hci_ver == BLUETOOTH_VER_2_0) is_fake = true; if (is_fake) { -- 2.37.3