Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5431831pxu; Thu, 22 Oct 2020 02:02:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFLRB09QijTbbtltWYo8ccdqrTtyKiApfX8dS0Zv9unMNqDbDvC3n6nEFsSyKfidXSkb+P X-Received: by 2002:a17:906:364d:: with SMTP id r13mr1192632ejb.521.1603357332264; Thu, 22 Oct 2020 02:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603357332; cv=none; d=google.com; s=arc-20160816; b=bFmio/Z27iq7uVszmdrXLZ76f7tIbcua3gF35CvzX2nzaJF+ezP0lRo1KYUTlQ2Etf 6ZuKlWEF50QHI1Ws3JCPkSkmtAtsJxXKjEd9IkEjj40FRBoy8lBdZi4MBktzKyTXdMIP 5EI1+Ypq9WArsa1PUNLJeTKbClyJo+PA5e1mJy53n2EEylNNYjeGDsdbvgyawIpRyikD nCkA7u3YZ4ld3X/8gyF9tfrsANod1HeJghVOhRCelmTMWi9ztu0myAFXw5gJ0Ut5ON/+ ZAq1YZtvyjKT8FUhPwdaMI8oMuQ9pywTz1xIwTSnO6gceC+mxxOeKOl1oQUYjZEXPKNU oLsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=8KtUk2kpQBYZMeYj1ttnbvvxz0iE7tmEcQp0BtrQMwE=; b=wLOo21Ix0JeDvN9DDkraUcdxCjRI5820syLU5mU+h6uKBsfnW6erzo+r/F0wLjHQ/5 weEFN91Sct2KQ1yBxY5tqTnVkOeV9fNOGM4WI0kUXYqV9BgdJE05rt1c24T08fwRzxyz ZZ3I99IuoP/8pv5PmrFMJjqhajd6Y/xnqvil/UQOZzLDeai4uKNv7EfaWUb++rR+ch11 wQOPSNHvlsgPLpbN2cq/azhCvWv2dj6fUi5mFluF5sMw27VSXHpgMtL/+8pkarfCmn2Y o/aTFdJQBa6d9UzdbhP6m9u1JGcqxCaBSEPcGsGWEYcRRfMVpYaluJBF0eNDduLOkTVR zk2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ckfR5Pes; 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 b6si702572edu.343.2020.10.22.02.01.39; Thu, 22 Oct 2020 02:02:12 -0700 (PDT) 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=ckfR5Pes; 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 S2894827AbgJVITL (ORCPT + 99 others); Thu, 22 Oct 2020 04:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443979AbgJVITK (ORCPT ); Thu, 22 Oct 2020 04:19:10 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504EAC0613CE for ; Thu, 22 Oct 2020 01:19:10 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id e15so673526pfh.6 for ; Thu, 22 Oct 2020 01:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8KtUk2kpQBYZMeYj1ttnbvvxz0iE7tmEcQp0BtrQMwE=; b=ckfR5Pes2q9avYh0mft+9TKeu11CRpJQrxPnAJmAft2gx37eVFn+i+rA3dWrw+llZY BuypZ8kt8XjUWUwaEbk6EcIVeDFw5zz6tNoosUIMwivOcaUzOTS4OTsO7vLDj4U1Ovs7 +8QT4eZco7716tBtlQ6kwCwjBHIfR05cFL7dWSkI74a3+SIahVT29im8PHB0XFeb59x0 gkqlkgg/hcA4NV7ZPG8h0dCNRnc39waB8GmeEsKWGPLtuHJipcsKiNOpKadCRX93XIV+ wbZPaULQ0vT/9MDZG19l/JCwH5BhK1FhaUEe9626rIHdYExIGMuPiX/+/vzHfKBF9Qrt 2EVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8KtUk2kpQBYZMeYj1ttnbvvxz0iE7tmEcQp0BtrQMwE=; b=B5McAXODpqrXe2iBmFy8qaDAnCkT5u/7oASUs+2RfmDuXhaSQWX52i8s9Km2hH7zRy 6BJgwlN4Wv6yWMBwae1J/HcJVI6mA9LE29+al0t2nx6H2G4AOwOO/SEyhmZ0YMZnP2V6 PyRv+MpN0h1dw1oBLXHa5hMBdQB2gCoX69nA9JF7Oy1bZPJ8FqXILMtaGqtnf3Ujmxv9 Nngin30XSBo3mT/btEkY64z6CIV9KHVFJiCQvbfAAG74cy6edrHClGui3OGZRTlLem2U X8iCxSjNacN9/OhEI/lq2+rNsrqd6Yy4f+9HywoNf9uPx1GulDcgB+sK5Cb3VK59ryQK r6rQ== X-Gm-Message-State: AOAM530IkLRHpetHLrk/iRE2rJ0VYU9kOEQjAZG0DSoiQSnZNwO1YJN3 KDUrhylAjrkMzjIwMWP2wJwVj/4UJqLChcaI X-Received: by 2002:a62:b417:0:b029:142:2501:35dc with SMTP id h23-20020a62b4170000b0290142250135dcmr1519045pfn.60.1603354749670; Thu, 22 Oct 2020 01:19:09 -0700 (PDT) Received: from nsathish-Latitude-7480.iind.intel.com ([134.134.137.79]) by smtp.gmail.com with ESMTPSA id j5sm1179514pjb.56.2020.10.22.01.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Oct 2020 01:19:09 -0700 (PDT) From: Sathish Narasimman X-Google-Original-From: Sathish Narasimman To: linux-bluetooth@vger.kernel.org Cc: chethan.tumkur.narayan@intel.com, ravishankar.srivatsa@intel.com, kiran.k@intel.com, Sathish Narasimman Subject: [PATCH 1/3] Bluetooth: btintel: seperated TLV parsing as new function Date: Thu, 22 Oct 2020 13:54:33 +0530 Message-Id: <20201022082435.31831-2-sathish.narasimman@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201022082435.31831-1-sathish.narasimman@intel.com> References: <20201022082435.31831-1-sathish.narasimman@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Create a seperate TLV parse function to read btintel TLV structure. Signed-off-by: Sathish Narasimman --- drivers/bluetooth/btintel.c | 54 ++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index 88ce5f0ffc4b..cc8e6c4e3205 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -401,31 +401,9 @@ void btintel_version_info_tlv(struct hci_dev *hdev, struct intel_version_tlv *ve } EXPORT_SYMBOL_GPL(btintel_version_info_tlv); -int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) +static void btintel_parse_tlv(struct sk_buff *skb, + struct intel_version_tlv *version) { - struct sk_buff *skb; - const u8 param[1] = { 0xFF }; - - if (!version) - return -EINVAL; - - skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); - if (IS_ERR(skb)) { - bt_dev_err(hdev, "Reading Intel version information failed (%ld)", - PTR_ERR(skb)); - return PTR_ERR(skb); - } - - if (skb->data[0]) { - bt_dev_err(hdev, "Intel Read Version command failed (%02x)", - skb->data[0]); - kfree_skb(skb); - return -EIO; - } - - /* Consume Command Complete Status field */ - skb_pull(skb, 1); - /* Event parameters contatin multiple TLVs. Read each of them * and only keep the required data. Also, it use existing legacy * version field like hw_platform, hw_variant, and fw_variant @@ -496,6 +474,34 @@ int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *ver /* consume the current tlv and move to next*/ skb_pull(skb, tlv->len + sizeof(*tlv)); } +} + +int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version) +{ + struct sk_buff *skb; + const u8 param[1] = { 0xFF }; + + if (!version) + return -EINVAL; + + skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT); + if (IS_ERR(skb)) { + bt_dev_err(hdev, "Reading Intel version information failed (%ld)", + PTR_ERR(skb)); + return PTR_ERR(skb); + } + + if (skb->data[0]) { + bt_dev_err(hdev, "Intel Read Version command failed (%02x)", + skb->data[0]); + kfree_skb(skb); + return -EIO; + } + + /* Consume Command Complete Status field */ + skb_pull(skb, 1); + + btintel_parse_tlv(skb, version); kfree_skb(skb); return 0; -- 2.17.1