From patchwork Thu Apr 1 16:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12179145 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3D86C43461 for ; Thu, 1 Apr 2021 18:23:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2511601FC for ; Thu, 1 Apr 2021 18:23:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237286AbhDASW6 (ORCPT ); Thu, 1 Apr 2021 14:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236948AbhDASLl (ORCPT ); Thu, 1 Apr 2021 14:11:41 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B801C03114D for ; Thu, 1 Apr 2021 09:44:30 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id e18so2460592wrt.6 for ; Thu, 01 Apr 2021 09:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=YSnhs+QugQX12bb4GkY/AXYl7X1tCBk+JT0tdjERlBo=; b=Wcd3lEvvpTNi2r3myGrKY/G9gxpe497zxepnIBDzVdUXV/f6CXhN8lkS+XuU/awnzT CS1WdiHekcKHkBbcZA7WrGO6G/cJAU4kliOSdUFb3MasyMHr3uEn4VPIOmvV8gAC8drP rk69xX45ifNRXYL5IKAsLD4Sw5xFo1RHXWO+a3602LE8peUDpYSMJyO28EIZAESjoiXL TMAMwtBVlV4xpMXicr+3+1EeDx+3rB8DqgWhrOKFPazE80HmDgCdpwiMDOoSoYOXUg1V 9d3o6cVvVFjf0s7oP2bqik3zTRY/69RgGNrjT70HCIh70my0rAMJIf+IjpKt1THSBUAF TGCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YSnhs+QugQX12bb4GkY/AXYl7X1tCBk+JT0tdjERlBo=; b=MTrmYWf0EC/SYffAXYwntVZmcjKwNDS/KZzXvHipqDGnc5c+ev8/9NOehL2jfAPOMf ZZ/q1U7F0m2bdPUgkqG5SQJLlXa4aa4ZCEe97u3SpbPWep/iEFPYXfCbwb6bEXO8riyW nxhVtazhqq2/rQesJaDzNB7iHkyzrZiNwu6E+iDpp9hI0+kC9QghsoSJcTQ8Mz3B9jz1 iwdVg7hSt+zb06esM/HL18dXqzeCNS5lwaqhy1xRfceVqEdtAfTq+9mSMJ5Naj/kdLGB TBzTr4TC2efREqkao9kP8bDLCHKGyl5IoDCHU7EjoOVs6acfAMZiJLXIvxBLigjGiERE Ls7A== X-Gm-Message-State: AOAM530bSnrm1WNeryBPGGW1TePKn0R+JhOwf+Sbl53zFq5agUv5NbuM HlV+V5sbhVkDAs1EH9WjC6sbonFU7mS8Zg== X-Google-Smtp-Source: ABdhPJwaGgPmDPMmXXEY+GmlIa8Z5vaCpSw6GR8dpI4krTiFjJI4LWV4pE8+CCfAJei+hc5CmugbFA== X-Received: by 2002:a5d:554b:: with SMTP id g11mr10492913wrw.411.1617295468920; Thu, 01 Apr 2021 09:44:28 -0700 (PDT) Received: from ?IPv6:2003:ea:8f1f:bb00:5544:e633:d47e:4b76? (p200300ea8f1fbb005544e633d47e4b76.dip0.t-ipconnect.de. [2003:ea:8f1f:bb00:5544:e633:d47e:4b76]) by smtp.googlemail.com with ESMTPSA id a13sm10148732wrp.31.2021.04.01.09.44.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Apr 2021 09:44:28 -0700 (PDT) Subject: [PATCH 1/3] PCI/VPD: Change pci_vpd_init return type to void From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com> Message-ID: <663ec440-8375-1459-ddb4-98ea76e75917@gmail.com> Date: Thu, 1 Apr 2021 18:37:47 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pci_init_capabilities() is the only caller and doesn't use the return value. So let's change the return type to void. Signed-off-by: Heiner Kallweit --- drivers/pci/pci.h | 2 +- drivers/pci/vpd.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index bbbc55965..ff0f4aeef 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -141,7 +141,7 @@ static inline bool pcie_downstream_port(const struct pci_dev *dev) type == PCI_EXP_TYPE_PCIE_BRIDGE; } -int pci_vpd_init(struct pci_dev *dev); +void pci_vpd_init(struct pci_dev *dev); void pci_vpd_release(struct pci_dev *dev); /* PCI Virtual Channel */ diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 48f4a9ae8..85889718a 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -337,18 +337,18 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = { .write = pci_vpd_f0_write, }; -int pci_vpd_init(struct pci_dev *dev) +void pci_vpd_init(struct pci_dev *dev) { struct pci_vpd *vpd; u8 cap; cap = pci_find_capability(dev, PCI_CAP_ID_VPD); if (!cap) - return -ENODEV; + return; vpd = kzalloc(sizeof(*vpd), GFP_ATOMIC); if (!vpd) - return -ENOMEM; + return; vpd->len = PCI_VPD_MAX_SIZE; if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) @@ -360,7 +360,6 @@ int pci_vpd_init(struct pci_dev *dev) vpd->busy = 0; vpd->valid = 0; dev->vpd = vpd; - return 0; } void pci_vpd_release(struct pci_dev *dev) From patchwork Thu Apr 1 16:43:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12179149 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04668C433ED for ; Thu, 1 Apr 2021 18:23:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D842F60201 for ; Thu, 1 Apr 2021 18:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237440AbhDASXE (ORCPT ); Thu, 1 Apr 2021 14:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237284AbhDASTE (ORCPT ); Thu, 1 Apr 2021 14:19:04 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAADCC03114E; Thu, 1 Apr 2021 09:44:36 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id d191so1362600wmd.2; Thu, 01 Apr 2021 09:44:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:references:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=dsZYTG5YjRYIylzLECh8VUqy5Nq7ENfTH8PmA/1aukE=; b=SEp0n4y/wxztrOXia6Y2ncc4SWEsVWT0v7PfduwVzHDoszXd3cSTsNhzauJy9QheWF 2QcGmVSNCcLLEoY0Mo42isZ1onV2bDIwLw51pQr7Zlc+nompdU7A7QKXUbV55bakOgwI pW0wzL8f0ZWA+B4RSHKBhLOzyE4hZRgGz3YXNg0yk0uUUkGGjc95Uuo5fZ4qhkKOAFDl Kc5XvNr4Q+3Izlj8gn1qsP5bDIkWOSIf8jn7kQ1KwBQUaeaAwldb8bDx2dr3qcB1yR8l TncTSn09jqv36lKcdrTmcUs1DspNnPomDa5iaC5247OJKiBPa+/vdmjssyY/OkeL4qSx W0hg== 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:references:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dsZYTG5YjRYIylzLECh8VUqy5Nq7ENfTH8PmA/1aukE=; b=U9DV6qPf6wRrVDxmZOiv1hsAWyTe66GQKAdzZq5Y1ZGEC3KMsq16WRYNVl+aF3A+ru 3RMIZyFJxzzVBnPUU1BO6RfYpZEDLDJQyGMqQl+qRem1B0HHzlfO0Q7R+QqfZf8T8LyP NyqhBN9q8J8OxS63KzLZhPXdIR3/hmuzoQgrBYzNfRc9uiJ/7exqCb9R3TIVhn8OV9RE FSp5sVtQb9CaCU8ciMW6dm+w1/5kk2G83SaWFqppCP4fIYDiEcUmaX+8fwkxhE6xi8a7 CpJJFTWs2Z36pWRYZ0ceTd5sql/qBSF8Pp71Ki0ylcmldOvPvmjhHG9K6/YuAlSUVcaX uRXA== X-Gm-Message-State: AOAM532xK4RQ14JfLjLF39wjac4BVWIHDFCwidsWQIhQ+76EA21EuDYJ 5UBEdmTGR4nOXilRnd8wbz3QG42FC6c49A== X-Google-Smtp-Source: ABdhPJzuWtuDjAu1sovzH17Gr8k8/fS+vntCAbg4BsS+EF8kjJ/UPRNArdTs1HXXEGzifhnk4+3qvg== X-Received: by 2002:a05:600c:ac2:: with SMTP id c2mr8394938wmr.23.1617295474784; Thu, 01 Apr 2021 09:44:34 -0700 (PDT) Received: from ?IPv6:2003:ea:8f1f:bb00:5544:e633:d47e:4b76? (p200300ea8f1fbb005544e633d47e4b76.dip0.t-ipconnect.de. [2003:ea:8f1f:bb00:5544:e633:d47e:4b76]) by smtp.googlemail.com with ESMTPSA id c8sm8863953wmb.34.2021.04.01.09.44.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Apr 2021 09:44:32 -0700 (PDT) From: Heiner Kallweit To: Bjorn Helgaas , Rasesh Mody , GR-Linux-NIC-Dev@marvell.com, David Miller , Jakub Kicinski , Ariel Elior , Sudarsana Kalluru , GR-everest-linux-l2@marvell.com, Michael Chan , Siva Reddy Kallam , Prashant Sreedharan , Raju Rangoju , Edward Cree , Martin Habets , "Manoj N. Kumar" , "Matthew R. Ochs" , Uma Krishnan , "James E.J. Bottomley" , "Martin K. Petersen" Cc: "linux-pci@vger.kernel.org" , "netdev@vger.kernel.org" , SCSI development list References: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com> Subject: [PATCH 2/3] PCI/VPD: Remove argument off from pci_vpd_find_tag Message-ID: Date: Thu, 1 Apr 2021 18:43:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org All callers pass 0 as offset. Therefore remove the parameter and use a fixed offset 0 in pci_vpd_find_tag(). Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/broadcom/bnx2.c | 2 +- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 +-- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/tg3.c | 4 ++-- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 2 +- drivers/net/ethernet/sfc/efx.c | 2 +- drivers/net/ethernet/sfc/falcon/efx.c | 2 +- drivers/pci/vpd.c | 4 ++-- drivers/scsi/cxlflash/main.c | 3 +-- include/linux/pci.h | 3 +-- 10 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 3e8a179f3..c0986096c 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c @@ -8057,7 +8057,7 @@ bnx2_read_vpd_fw_ver(struct bnx2 *bp) data[i + 3] = data[i + BNX2_VPD_LEN]; } - i = pci_vpd_find_tag(data, 0, BNX2_VPD_LEN, PCI_VPD_LRDT_RO_DATA); + i = pci_vpd_find_tag(data, BNX2_VPD_LEN, PCI_VPD_LRDT_RO_DATA); if (i < 0) goto vpd_done; diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 568013875..281b1c2e0 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -12206,8 +12206,7 @@ static void bnx2x_read_fwinfo(struct bnx2x *bp) /* VPD RO tag should be first tag after identifier string, hence * we should be able to find it in first BNX2X_VPD_LEN chars */ - i = pci_vpd_find_tag(vpd_start, 0, BNX2X_VPD_LEN, - PCI_VPD_LRDT_RO_DATA); + i = pci_vpd_find_tag(vpd_start, BNX2X_VPD_LEN, PCI_VPD_LRDT_RO_DATA); if (i < 0) goto out_not_found; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 6f1364212..4c517fe70 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -12719,7 +12719,7 @@ static void bnxt_vpd_read_info(struct bnxt *bp) goto exit; } - i = pci_vpd_find_tag(vpd_data, 0, vpd_size, PCI_VPD_LRDT_RO_DATA); + i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); if (i < 0) { netdev_err(bp->dev, "VPD READ-Only not found\n"); goto exit; diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index d23819299..b0e49643f 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -13016,7 +13016,7 @@ static int tg3_test_nvram(struct tg3 *tp) if (!buf) return -ENOMEM; - i = pci_vpd_find_tag((u8 *)buf, 0, len, PCI_VPD_LRDT_RO_DATA); + i = pci_vpd_find_tag((u8 *)buf, len, PCI_VPD_LRDT_RO_DATA); if (i > 0) { j = pci_vpd_lrdt_size(&((u8 *)buf)[i]); if (j < 0) @@ -15629,7 +15629,7 @@ static void tg3_read_vpd(struct tg3 *tp) if (!vpd_data) goto out_no_vpd; - i = pci_vpd_find_tag(vpd_data, 0, vpdlen, PCI_VPD_LRDT_RO_DATA); + i = pci_vpd_find_tag(vpd_data, vpdlen, PCI_VPD_LRDT_RO_DATA); if (i < 0) goto out_not_found; diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 98829e482..ef5d10e1c 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -2774,7 +2774,7 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) if (id_len > ID_LEN) id_len = ID_LEN; - i = pci_vpd_find_tag(vpd, 0, VPD_LEN, PCI_VPD_LRDT_RO_DATA); + i = pci_vpd_find_tag(vpd, VPD_LEN, PCI_VPD_LRDT_RO_DATA); if (i < 0) { dev_err(adapter->pdev_dev, "missing VPD-R section\n"); ret = -EINVAL; diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 36c8625a6..c746ca723 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -920,7 +920,7 @@ static void efx_probe_vpd_strings(struct efx_nic *efx) } /* Get the Read only section */ - ro_start = pci_vpd_find_tag(vpd_data, 0, vpd_size, PCI_VPD_LRDT_RO_DATA); + ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); if (ro_start < 0) { netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); return; diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c index f89799919..5e7a57b68 100644 --- a/drivers/net/ethernet/sfc/falcon/efx.c +++ b/drivers/net/ethernet/sfc/falcon/efx.c @@ -2800,7 +2800,7 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) } /* Get the Read only section */ - ro_start = pci_vpd_find_tag(vpd_data, 0, vpd_size, PCI_VPD_LRDT_RO_DATA); + ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); if (ro_start < 0) { netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); return; diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 85889718a..5b80db02d 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -367,11 +367,11 @@ void pci_vpd_release(struct pci_dev *dev) kfree(dev->vpd); } -int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt) +int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) { int i; - for (i = off; i < len; ) { + for (i = 0; i < len; ) { u8 val = buf[i]; if (val & PCI_VPD_LRDT) { diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index dc36531d5..222593bc2 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c @@ -1649,8 +1649,7 @@ static int read_vpd(struct cxlflash_cfg *cfg, u64 wwpn[]) } /* Get the read only section offset */ - ro_start = pci_vpd_find_tag(vpd_data, 0, vpd_size, - PCI_VPD_LRDT_RO_DATA); + ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); if (unlikely(ro_start < 0)) { dev_err(dev, "%s: VPD Read-only data not found\n", __func__); rc = -ENODEV; diff --git a/include/linux/pci.h b/include/linux/pci.h index 51660ab67..56125397f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2311,14 +2311,13 @@ static inline u8 pci_vpd_info_field_size(const u8 *info_field) /** * pci_vpd_find_tag - Locates the Resource Data Type tag provided * @buf: Pointer to buffered vpd data - * @off: The offset into the buffer at which to begin the search * @len: The length of the vpd buffer * @rdt: The Resource Data Type to search for * * Returns the index where the Resource Data Type was found or * -ENOENT otherwise. */ -int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt); +int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt); /** * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD From patchwork Thu Apr 1 16:44:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12179147 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFD51C433ED for ; Thu, 1 Apr 2021 18:23:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE39B601FC for ; Thu, 1 Apr 2021 18:23:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237366AbhDASXA (ORCPT ); Thu, 1 Apr 2021 14:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239232AbhDASPs (ORCPT ); Thu, 1 Apr 2021 14:15:48 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16006C03114F for ; Thu, 1 Apr 2021 09:44:40 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id j7so2483707wrd.1 for ; Thu, 01 Apr 2021 09:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=bgXjFPEoVaKS4YN67IbL3DtnNePGHAFX/A1y+wQ+Nhw=; b=je19boQ1u0Vem3uvE5ckt396JTGv5v1CMLlH4c0OnvUrEftWESjKcJSLueNIMCMNmp 92iOA4MnavdJpmP1GjsCBELLAoxftCVSIweIHq6IG+SUmP7TUJN5MzxaNlc8IcepOpR6 Drtv2d0txSKaaiMG3d9egeDF+RViJitEWtm7wken0Fo+E3zvJAUS3W1VKTqK9mcMIf8y MFJYM0u2fVOzULMiTQyMvwgysqkk24LHRmxB742JoCkb4ZNLUu9v+D9vlPaZY1e4GvwA tu+Seh1OHL8E4N3xjk194iuTPTkWwBUxJNeJyo2tD308A51ukRSosd1F9MgjjAsVuCp/ R4gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bgXjFPEoVaKS4YN67IbL3DtnNePGHAFX/A1y+wQ+Nhw=; b=MHFwsR/5KwOIfg5WMbvbnYRQVzu60HmW3MzGog3ViUVS7miW8pqMjwAx1hHrgdstXz /DSF8CeUlNoKc483NeVVxLza/qxilLBeSwl9cUTKI/r7rG3o87S3+xUlPlsMg2wGqtLu oZs6TBsPe7lwyo/bwDdqMdkSjwALVdYP5/1Lbs8Y2hu8XY9e7g4EbcnEn1Nnbp0xn1nD aq+f/e6LMP5BxyEao8okOkE/ddXuZChN0QfOVConVAGG0EvOHX2w2447eWkqTP6PC8vf WkRQvYDgwWG+ibeH4NIBvXBQ043mOlUH8SCJ4smu8mncF1J2sL+ycgdxVvtPJMNQGqFv eUPA== X-Gm-Message-State: AOAM532cMhRt5fQKiqCXdQ+yvX5AxlvT5lAz1l/Wxi9x6NY0YCAMsXBa 2fDZpJ6lS7cwvqlGwVh1pog7rgMsUIIrWg== X-Google-Smtp-Source: ABdhPJxhGXXHDJNl/7F6ep81YKiWZmX5kPbn1VqqRG2VKNzfx+SJ6yMRaMnvW+N1bfijOpJxef09qA== X-Received: by 2002:adf:e481:: with SMTP id i1mr11165085wrm.63.1617295478442; Thu, 01 Apr 2021 09:44:38 -0700 (PDT) Received: from ?IPv6:2003:ea:8f1f:bb00:5544:e633:d47e:4b76? (p200300ea8f1fbb005544e633d47e4b76.dip0.t-ipconnect.de. [2003:ea:8f1f:bb00:5544:e633:d47e:4b76]) by smtp.googlemail.com with ESMTPSA id p12sm10524126wrx.28.2021.04.01.09.44.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Apr 2021 09:44:37 -0700 (PDT) Subject: [PATCH 3/3] PCI/VPD: Improve and simplify pci_vpd_find_tag From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com> Message-ID: <3f63f06f-734f-8fff-9518-27fe1faf903d@gmail.com> Date: Thu, 1 Apr 2021 18:44:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Only SRDT tag is the end tag, and no caller is interested in it. This allows to remove all SRDT tag handling. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 5b80db02d..45f1d73f8 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -369,33 +369,14 @@ void pci_vpd_release(struct pci_dev *dev) int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) { - int i; - - for (i = 0; i < len; ) { - u8 val = buf[i]; - - if (val & PCI_VPD_LRDT) { - /* Don't return success of the tag isn't complete */ - if (i + PCI_VPD_LRDT_TAG_SIZE > len) - break; + int i = 0; - if (val == rdt) - return i; - - i += PCI_VPD_LRDT_TAG_SIZE + - pci_vpd_lrdt_size(&buf[i]); - } else { - u8 tag = val & ~PCI_VPD_SRDT_LEN_MASK; - - if (tag == rdt) - return i; - - if (tag == PCI_VPD_SRDT_END) - break; + /* look for LRDT tags only, end tag is the only SRDT tag */ + while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) { + if (buf[i] == rdt) + return i; - i += PCI_VPD_SRDT_TAG_SIZE + - pci_vpd_srdt_size(&buf[i]); - } + i += PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(buf + i); } return -ENOENT;