From patchwork Thu Aug 26 18:53:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460495 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 93BC6C432BE for ; Thu, 26 Aug 2021 18:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7318D61037 for ; Thu, 26 Aug 2021 18:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243330AbhHZS7K (ORCPT ); Thu, 26 Aug 2021 14:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243300AbhHZS7J (ORCPT ); Thu, 26 Aug 2021 14:59:09 -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 20983C061757 for ; Thu, 26 Aug 2021 11:58:22 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id h13so6660557wrp.1 for ; Thu, 26 Aug 2021 11:58:22 -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=uCZOJy2EcDvwg3qkhxmtCMGfx1QF7c5X+D3+7xaUKBg=; b=uFeelsFHKrWg12PiaBmHSXX4R6ia7fo8QuplJKXDDPJ6AgNcSYFJxdXfkInlzQRmY+ 6v8r0JrMj8GhiGORsyRjG2AMbP5dbesexA5qlXb+r3+MBoXHE2tbK0/YNbg1TS6bZ4ra 5RPkWKW3HerSsUqnM6TM6g10W96siyLZKIZ+HfgT2+AH8zCP5nYLVKClwVbricOcVqCc LSVVOINdTIv2QEnpS4mwk6IzbbhSa2L1kJqyBJJd78WfWqROzbq7eW/9UoV6yXQZ78eL CbcHO6XdBDRcr+VD+hrojN/2BDd1FnnNFriMsRL7istZkGsR5fl6YuWXrLwtIKAPbnJS i2pA== 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=uCZOJy2EcDvwg3qkhxmtCMGfx1QF7c5X+D3+7xaUKBg=; b=HKa6dIlRwntCyAWrw/AxNWUqh7a20n1Y5nQ1kRRmQxPR4pmWC4a/OxZNHUcruCZBjP stQ6DMIBooEp/M6wwrQxb/UCS8e0CVSdYP1/+7GQ8uLEcJQIXHlaNSzwdHh2PM3Sp8bf qGkpnLJ+28DLxapr0mgEYbKT1FdyP+xcS2q2GLnhIuB+uyapo/9Q9Oy+eKLellJh0XtJ veRKXhuyK59XGh4qesoBnvcDM2fC+Fo3j8P1pmoOvUNeZLyVqy8Qpi7/sASsgF1px7ZW Yc5k1C5FZY0cyIM06c8V8go9wZCnROk8eRxTYLQapkpa64jsoQrxqsm+KG+tJlw6jnab 6MfQ== X-Gm-Message-State: AOAM532P6iTHybWGVVj0nvheQ7OyETxYIdRSF9tz6ChKUodaJwPuTn34 EgDRxRUe3zj/9mJwlrSlnRLYxf2+IdjB4g== X-Google-Smtp-Source: ABdhPJxd9rBPQ2070/NJ7peZnXbguSRGNWufOsrVGmV1/8OPC0+3r3cwRsXWNtir83nHMoTftljeUg== X-Received: by 2002:adf:906c:: with SMTP id h99mr1268761wrh.8.1630004300429; Thu, 26 Aug 2021 11:58:20 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id p11sm3623512wma.16.2021.08.26.11.58.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:19 -0700 (PDT) Subject: [PATCH 1/7] PCI/VPD: Stop exporting pci_vpd_find_tag() From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: <71131eca-0502-7878-365f-30b6614161cf@gmail.com> Date: Thu, 26 Aug 2021 20:53:42 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that the last users have been migrated to pci_vpd_find_ro_keyword() we can stop exporting this function. It's still used in VPD core code. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 3 +-- include/linux/pci.h | 11 ----------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 01e575947..5726fbb7a 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -296,7 +296,7 @@ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size) } EXPORT_SYMBOL_GPL(pci_vpd_alloc); -int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) +static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) { int i = 0; @@ -310,7 +310,6 @@ int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) return -ENOENT; } -EXPORT_SYMBOL_GPL(pci_vpd_find_tag); int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, unsigned int len, const char *kw) diff --git a/include/linux/pci.h b/include/linux/pci.h index 76e3a9254..2c0260884 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2350,17 +2350,6 @@ static inline u8 pci_vpd_info_field_size(const u8 *info_field) */ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size); -/** - * pci_vpd_find_tag - Locates the Resource Data Type tag provided - * @buf: Pointer to buffered vpd data - * @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 len, u8 rdt); - /** * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD * @buf: Pointer to buffered vpd data From patchwork Thu Aug 26 18:54:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460497 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 29B87C432BE for ; Thu, 26 Aug 2021 18:58:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13D3461037 for ; Thu, 26 Aug 2021 18:58:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243359AbhHZS7N (ORCPT ); Thu, 26 Aug 2021 14:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243319AbhHZS7N (ORCPT ); Thu, 26 Aug 2021 14:59:13 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63EFEC061757 for ; Thu, 26 Aug 2021 11:58:25 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so2820225wml.3 for ; Thu, 26 Aug 2021 11:58:25 -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=89DC8UIwgUAhYfezfzSWjndtlwDLSH0xk/3M1k/C10k=; b=op8JGbpIkaULBEiDKqmih0ZG4ySkHJANbjWCUU1leEbThFo2cEEy/+EG/81y4Eus6v Wc7uBQrpk4aunFeQTvJKgZZxo3nVJJkhM7L5qYjRPwLVcrolPQvqLgfdTAWnno1N7z2b QkswVDgW6AeEnCSI4sfZmQx4r2BGsP6DZ9R7qguTlWOTmoX9RdOb21hYwn1GQc9BVEQy HV+3BULmufnZpw4VAzU01IfVxckUQ7CW2gXNdMC/3d7epwZoUMoLfCDIf/FTlzD9CeL7 OhK98dq/ejOFQIh3opmqdua5M6scVcnEUIXuIt4zr8sCcwNMM/aZdpugU1i3cC+mQ1eP 6DSQ== 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=89DC8UIwgUAhYfezfzSWjndtlwDLSH0xk/3M1k/C10k=; b=Uhjov/KsNEec0DD1LYhnNpCAXxrRyovxze9YUxH4jn2+HpNMaZFC34zTJPXlUghDru R05u8eY4EMZRNcZnnEM6uEWBHES+XpNk7tqFQlGnvZAq7wBHsZHqr0PFyDIUhsjZ5BaD xVn5+j41zeev55o+DRfJVG2kdD9BTITteln0HaC3+IjAV1E6ofZVjiQhkHdC18pu9JDU CmsMnLB47UwWhCHEtuYSk2oSfMgtUZSWotZAN+65292hMco2RSJKoWRUXn5XsocSsWmo 4///yR4X/xPAXj3MYgbiIeje2fmlzfIsbldcSR9TCKtaWCoO+RRvRSgUB70wMK6CYxg0 9r9A== X-Gm-Message-State: AOAM532wsnPmze8oPDKa2J+/gPwF7WZqrbpBbX77M4gFvwmlHmtNDExD 33VPd7RzjvOL71oD0KVavHKJ/kshzYd/Yw== X-Google-Smtp-Source: ABdhPJzcpA4cJIbg9HIKDhyEE46cx/cJeJzTYqymm0mLTGBjYOOfY9BLmRQq5kQVyhsJVIl5v2o7cw== X-Received: by 2002:a05:600c:3795:: with SMTP id o21mr13881774wmr.130.1630004303767; Thu, 26 Aug 2021 11:58:23 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id e2sm4652060wrq.56.2021.08.26.11.58.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:23 -0700 (PDT) Subject: [PATCH 2/7] PCI/VPD: Stop exporting pci_vpd_find_info_keyword() From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: <96ca2a56-383e-9b61-9cba-4f1e5611dc15@gmail.com> Date: Thu, 26 Aug 2021 20:54:23 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now that the last users have been migrated to pci_vpd_find_ro_keyword() we can stop exporting this function. It's still used in VPD core code. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 3 +-- include/linux/pci.h | 13 ------------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 5726fbb7a..0e7a5e8a8 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -311,7 +311,7 @@ static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) return -ENOENT; } -int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, +static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, unsigned int len, const char *kw) { int i; @@ -327,7 +327,6 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, return -ENOENT; } -EXPORT_SYMBOL_GPL(pci_vpd_find_info_keyword); /** * pci_read_vpd - Read one entry from Vital Product Data diff --git a/include/linux/pci.h b/include/linux/pci.h index 2c0260884..0d6c45b1b 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2350,19 +2350,6 @@ static inline u8 pci_vpd_info_field_size(const u8 *info_field) */ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size); -/** - * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD - * @buf: Pointer to buffered vpd data - * @off: The offset into the buffer at which to begin the search - * @len: The length of the buffer area, relative to off, in which to search - * @kw: The keyword to search for - * - * Returns the index where the information field keyword was found or - * -ENOENT otherwise. - */ -int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, - unsigned int len, const char *kw); - /** * pci_vpd_find_ro_info_keyword - Locate info field keyword in VPD RO section * @buf: Pointer to buffered VPD data From patchwork Thu Aug 26 18:55:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460499 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 8E6F4C432BE for ; Thu, 26 Aug 2021 18:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 76F0A61052 for ; Thu, 26 Aug 2021 18:58:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243300AbhHZS7U (ORCPT ); Thu, 26 Aug 2021 14:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243409AbhHZS7Q (ORCPT ); Thu, 26 Aug 2021 14:59:16 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B068DC061757 for ; Thu, 26 Aug 2021 11:58:28 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id l7-20020a1c2507000000b002e6be5d86b3so2820299wml.3 for ; Thu, 26 Aug 2021 11:58:28 -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=yaTVSk0QhQ6Q3ONwqkunR+ld3cwrqWOmizyChyPBFII=; b=tsPjGzAFLWYbqWizpcH1yoD5Dpefts9e9RGZTGryEiRHVyy2k9NRomV098jjPgtfSR vWWEGIx9plSpLk1DhBsd1DiO+ZMoNcr1LFqV7VcdM/aBKWIXbKeF71gyFnib4eewTV6A gXp2d0tFJohtvNZBSQX2dgJkzIHfxw01cMKp34B0mbNSSOrOnmmubg5newyIWSjxux+Y jRstsWSCGjn2ABmKNOeCmMXTevO08Sdhb/A3wa6CENu0y1veMNUqPfpa3SSbqt1CIdMs LXacSM2fK9lNvQRfxB//NcR/gRDDn6+s1gSdJ3s8oQso92zHFknpxoZDc7IavfUNvI3R rckA== 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=yaTVSk0QhQ6Q3ONwqkunR+ld3cwrqWOmizyChyPBFII=; b=QL/8fDX++OGLS/npsTRW8ulu/gqw6ITEULMdjUpxicnFrMuCm1l6nuToWj7miVasxt a95J5RG9dlMZ1WJP9vIIrsxX1so1/wdQ+NxrW8KKmfdMdrOHTcikKIFuW3UvLRwP1cVD iJGWFPKHsg+/czpbM3GXGET4YodulYUJFWega3zBou/qExM0/daItjX4NLxn71syQfH5 LlJRVKN2LXXE4E8VdJRjVos9D9J7w6z7yPjpCNT7WpKvjdmgpWCh8v0T+tfhg8/usQ2S qxzD1DVFeGRDzfMdTbzugp4O2v1ucUKTEzcLGBxMcQN6VEjE5Z8hrMTeBiRUkKsJoPX4 8B3w== X-Gm-Message-State: AOAM530ikwIxyEQiGg4c1fSMvfUmleMq2nRBZi815gfSIdofCAXIQahg DQRlnqEWOR5QDCRX03rRtANpWyZc2iqQGA== X-Google-Smtp-Source: ABdhPJy5SATVXejtebcdAHyUIxrVx+lZhEgH1TUTSkdIPPrq2xzFuUIkzbmUAEOctC/EelRcZs920g== X-Received: by 2002:a1c:491:: with SMTP id 139mr6366079wme.137.1630004307056; Thu, 26 Aug 2021 11:58:27 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id n4sm3773167wri.78.2021.08.26.11.58.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:26 -0700 (PDT) Subject: [PATCH 3/7] PCI/VPD: Include post-processing in pci_vpd_find_tag() From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: Date: Thu, 26 Aug 2021 20:55:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Move pci_vpd_find_tag() post-processing from pci_vpd_find_ro_info_keyword() to pci_vpd_find_tag(). This simplifies function pci_vpd_find_id_string() that will be added in a subsequent patch. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 0e7a5e8a8..b7bf014cc 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -296,16 +296,25 @@ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size) } EXPORT_SYMBOL_GPL(pci_vpd_alloc); -static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt) +static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt, unsigned int *size) { int i = 0; /* 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) + unsigned int lrdt_len = pci_vpd_lrdt_size(buf + i); + u8 tag = buf[i]; + + i += PCI_VPD_LRDT_TAG_SIZE; + if (tag == rdt) { + if (i + lrdt_len > len) + lrdt_len = len - i; + if (size) + *size = lrdt_len; return i; + } - i += PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(buf + i); + i += lrdt_len; } return -ENOENT; @@ -384,16 +393,10 @@ int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len, int ro_start, infokw_start; unsigned int ro_len, infokw_size; - ro_start = pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_RO_DATA); + ro_start = pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_RO_DATA, &ro_len); if (ro_start < 0) return ro_start; - ro_len = pci_vpd_lrdt_size(buf + ro_start); - ro_start += PCI_VPD_LRDT_TAG_SIZE; - - if (ro_start + ro_len > len) - ro_len = len - ro_start; - infokw_start = pci_vpd_find_info_keyword(buf, ro_start, ro_len, kw); if (infokw_start < 0) return infokw_start; From patchwork Thu Aug 26 18:55:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460503 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 47947C4320A for ; Thu, 26 Aug 2021 18:58:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2777B61076 for ; Thu, 26 Aug 2021 18:58:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243493AbhHZS7Y (ORCPT ); Thu, 26 Aug 2021 14:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243375AbhHZS7U (ORCPT ); Thu, 26 Aug 2021 14:59:20 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDF26C061757 for ; Thu, 26 Aug 2021 11:58:31 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id m25-20020a7bcb99000000b002e751bcb5dbso2810632wmi.5 for ; Thu, 26 Aug 2021 11:58:31 -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=vd7UE3cNG2/03UusJReOeDxQVP6H5yBoJiW9RmSgRZ0=; b=LQ+TmbWtes8/SZiNxTsXNJxacRL1mRzXBoUMDG3/86TbzEbYYZFenyMFGaS3KW12Rd BrETvALFTdZrtoKImaxvtgl9w90lFPAHSZhvhD2JtmcOwaP4gdD5VUB0Zqxdb6xPs6RC RdEAdw7qE4zhjq8hnxv3nlUhDUyclw6YTMWF4jxCTWGaBpVyJYQU8M46bUD05lK00zUC cSetpN2MMx6ATJh0A/bTWUz4+8kZXNJs997wiRDj76t1paibylq1/fffFRH9yyn68kjO oR3JZ+gF+vFwN653Db06gZu0xkzbDabDZjaKetPL23puxCtPrC+38SBjLXxO3yyFjbuh 7MzQ== 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=vd7UE3cNG2/03UusJReOeDxQVP6H5yBoJiW9RmSgRZ0=; b=toYsAffYBiOD8pS1Iyg5nCV3gckdDB4ELvxfKiJdBqYhQvUcH+ZecmfqT7sf4o+dhH vYZOT974q2UkJYAR4kjx4MRxgfKeFTskn/0DYjeBSRe+/vV69089bfJ7YDpZC3qP5HSB jkAs1vTlOMoZhW3iOYG44qxZxsM+8dc6vGPUkhg2gtCF7mwYy1w5oOufF78aZrovk6z3 yIs/h0cy2K5eqKjcFLwPOn1HLo/UdS50F94wXaEknQHu1fCdLZBDwxdBkK1vHnTBN4Gy 9A8F0di+GiN5rMSGeRnzyrmKbi5khHDn5l4RYKbWM8abAWomS3275V9xRv1Pyc/dDqq/ WWeg== X-Gm-Message-State: AOAM531+eFlsTpxpys7nmSRk65f/McGv4YgQ1bGg39Y73qXF/bH6LabG yBNkfnTok2YEoctmcVJrM6r/joknEbNcGg== X-Google-Smtp-Source: ABdhPJzOwBnhdaa6jSK+0tBE8mRQyjwIpjy0hx0LEZBjOz3DPS/FxGyLpTS/61b7FLZjB2m9rxzoqg== X-Received: by 2002:a05:600c:4309:: with SMTP id p9mr5146111wme.174.1630004310271; Thu, 26 Aug 2021 11:58:30 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id b15sm4506359wru.1.2021.08.26.11.58.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:29 -0700 (PDT) Subject: [PATCH 4/7] PCI/VPD: Add pci_vpd_find_id_string() From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: Date: Thu, 26 Aug 2021 20:55:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Similar to pci_vpd_find_ro_info_keyword() provide an API function to retrieve the ID string from VPD. This way callers don't have to deal with low-level function pci_vpd_lrdt_size() any longer that can be made private to the VPD core in a subsequent patch. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 6 ++++++ include/linux/pci.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index b7bf014cc..79712b3d1 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -320,6 +320,12 @@ static int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt, unsigned in return -ENOENT; } +int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size) +{ + return pci_vpd_find_tag(buf, len, PCI_VPD_LRDT_ID_STRING, size); +} +EXPORT_SYMBOL_GPL(pci_vpd_find_id_string); + static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off, unsigned int len, const char *kw) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 0d6c45b1b..f83930562 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2350,6 +2350,16 @@ static inline u8 pci_vpd_info_field_size(const u8 *info_field) */ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size); +/** + * pci_vpd_find_id_string - Locate id string in VPD + * @buf: Pointer to buffered VPD data + * @len: The length of the buffer area in which to search + * @size: Pointer to field where length of id string is returned + * + * Returns the index of the id string or -ENOENT if not found. + */ +int pci_vpd_find_id_string(const u8 *buf, unsigned int len, unsigned int *size); + /** * pci_vpd_find_ro_info_keyword - Locate info field keyword in VPD RO section * @buf: Pointer to buffered VPD data From patchwork Thu Aug 26 18:56:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460501 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 5A906C4320E for ; Thu, 26 Aug 2021 18:58:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4001561040 for ; Thu, 26 Aug 2021 18:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243340AbhHZS7X (ORCPT ); Thu, 26 Aug 2021 14:59:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243488AbhHZS7X (ORCPT ); Thu, 26 Aug 2021 14:59:23 -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 4684FC0613CF; Thu, 26 Aug 2021 11:58:35 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id g138so2405674wmg.4; Thu, 26 Aug 2021 11:58:35 -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=A+DG0W5+2eklf4TtXNvnExlRa/zaKSRLzk5O/0U5K0w=; b=NhIehY5x0I1crqrN8X/OvkFkmhiGAEGNPVzzb1TTCJsZpj/NCdbuz4dtjGwo7BFF0U 01ogskY0N4lf5MraG/rPsWF6o81Iujt9KOiYkFTVFlgTnp9ifMUa1hA4/c88NxwLfmn/ W2bW7L6xgV9ojPXzbLvHSXEXZU/pPJrAtQmpU41pYRauvIQWxmyzM1rYHqWNUKLnA6fp 0oXHCMjL9bpWEujJ1R0fiv/ZI97YtJw5xPZ/gkLrL+HWmdJzJ7iLJWBSX7vxkbY/0cjP UPrmiktgPwz4/ZXRsje/jcCAs/NmXNMfYQ0O/9jZ53ASQZMcHSvq9i3ZjeznqdexJEkx 2nsg== 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=A+DG0W5+2eklf4TtXNvnExlRa/zaKSRLzk5O/0U5K0w=; b=ntxjUS//jsX2GlJA6Y/T3yZfcTgxULDV6kcG2n13OzpiuBckcKV9NT1+AmntroV0Uo 74w2vuZEesYXP8tCoPsZfYhn1Ae6aC8nLaJoY97J3MamrHbsZ1A4cr3IMEvtlNVW5ubh UF7yiFIoT1cOkHkU1pxcJVXnK2/6gEYVg92MJNj654nOK6y8KZLbFo8mnspdzkIwdoM0 8YGX5pxiZ+ueodVTjKAMpELL8k9At4/sOwdgvlps336AVdUyUO4rWU9nND1KtXuPRnAd QYJ04DQ2VBisI2J6XoYc6hUi0Q8EZeiORE4m7doSOvqHNAlyxy2qTtKnfQf1vGzHHIdU VgVw== X-Gm-Message-State: AOAM5338H4q/hMfsGR9YaxbIpBc4/v+ZOR1Oy1oGMbO1BYtHbztyzBhA 2+e+IFg1kkJ5awtzbk1YqmVHoLx9Y3HeNQ== X-Google-Smtp-Source: ABdhPJyzhanBtGemLIKksbfa5mBbVLTxY1yOPby8E/bgSyo4RyYV8xu0zGQ5ruG7kD9PVI7DLA6+Jw== X-Received: by 2002:a7b:c927:: with SMTP id h7mr5124646wml.154.1630004313599; Thu, 26 Aug 2021 11:58:33 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id b15sm4506476wru.1.2021.08.26.11.58.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:33 -0700 (PDT) Subject: [PATCH 5/7] cxgb4: Use pci_vpd_find_id_string() to find VPD id string From: Heiner Kallweit To: Raju Rangoju , Bjorn Helgaas , Jakub Kicinski , David Miller Cc: "linux-pci@vger.kernel.org" , "netdev@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: <19ea2e9b-6e94-288a-6612-88db01b1b417@gmail.com> Date: Thu, 26 Aug 2021 20:56:22 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use new VPD API function pci_vpd_find_id_string() for finding the VPD id string. This simplifies the code and avoids using VPD low-level function pci_vpd_lrdt_size(). Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 5e8ac42ac..64144b617 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -2744,7 +2744,7 @@ int t4_seeprom_wp(struct adapter *adapter, bool enable) int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) { unsigned int id_len, pn_len, sn_len, na_len; - int sn, pn, na, addr, ret = 0; + int id, sn, pn, na, addr, ret = 0; u8 *vpd, base_val = 0; vpd = vmalloc(VPD_LEN); @@ -2764,13 +2764,10 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) if (ret < 0) goto out; - if (vpd[0] != PCI_VPD_LRDT_ID_STRING) { - dev_err(adapter->pdev_dev, "missing VPD ID string\n"); - ret = -EINVAL; + ret = pci_vpd_find_id_string(vpd, VPD_LEN, &id_len); + if (ret < 0) goto out; - } - - id_len = pci_vpd_lrdt_size(vpd); + id = ret; ret = pci_vpd_check_csum(vpd, VPD_LEN); if (ret) { @@ -2796,7 +2793,7 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p) goto out; na = ret; - memcpy(p->id, vpd + PCI_VPD_LRDT_TAG_SIZE, min_t(int, id_len, ID_LEN)); + memcpy(p->id, vpd + id, min_t(int, id_len, ID_LEN)); strim(p->id); memcpy(p->sn, vpd + sn, min_t(int, sn_len, SERNUM_LEN)); strim(p->sn); From patchwork Thu Aug 26 18:57:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460505 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 12167C4320E for ; Thu, 26 Aug 2021 18:58:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E945A61037 for ; Thu, 26 Aug 2021 18:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243488AbhHZS70 (ORCPT ); Thu, 26 Aug 2021 14:59:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243409AbhHZS70 (ORCPT ); Thu, 26 Aug 2021 14:59:26 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 862EFC061757 for ; Thu, 26 Aug 2021 11:58:38 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id j17-20020a05600c1c1100b002e754875260so2810492wms.4 for ; Thu, 26 Aug 2021 11:58:38 -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=ugqNyqO4ZaYf6LRNQ26pXfGl/Wn1pUnTjjCEE2HWxhA=; b=qyilxcZcPDHYU77TYVNUeDtH4I1KaGQipwVaxj8Gwuu1x28h0eYyoelG+UUdqMqhdA W6fbUWNe/i14xCSxeNg+CmiQ92RostdsfTy754X2+wRTgm42MIQlVYmj+TvchclsLQv9 cP+FgXcFKY6/2oLrODHruL7n5jFKvOhurdfprd7WSDnmdL17H3Oj4GfvzWDERXiHy7eP Azblnd+oe4B4c5EZL43ZeBNDHXWyBIUztGzMT6EV73Oy0Fg+pk/jaKgJF69fbuOkaaNh Jd2eSXwsunaQ5p83Hx2HwJHxvYtomyTAf6jIy1RfPcvfGHTxrjDlzzyu2uxBCIH68Rzg R7nw== 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=ugqNyqO4ZaYf6LRNQ26pXfGl/Wn1pUnTjjCEE2HWxhA=; b=n5p4e3lUdI9GNBig95l92mkniO30Zx8KpgVgvOwdfb0RUNt3ygL2H22iQydxA5agJh DEqTaUHjdOonptFPUFhW5EXO3arDtj/Q+Csoww2gLm2VWLI+nU4wPjgMVSlPxzxyhSJT IUl4X7RnGC6H1jPJyZEjq+QohHamQefgOWpME0kNcYC0/C4EqeV4+PiuGnkz49QfIZcp OhF1oir11FzdAZu5eQgb57DLxMh6XKOnrD+xW2HdyBWg+Zl2nDmYpeW5SW7obkB32FMQ HeUkPtZu0+5LRK3mc6L08AeCOcXXSeAZrVDzu6cxE5DkT2FX6dWjX5kTWvbdHPTSebtG c0Sw== X-Gm-Message-State: AOAM532GDeReCZI2/n1BGnaUgXahbqr9RgLfIy/aJHE3ZYl8HJxB5PD+ c4eY9XX0IUQ+40M7lvOQH6MUd4XzKFiUMQ== X-Google-Smtp-Source: ABdhPJybT1h/OzeepzWee9ulPTXZXgvuuamn3RUCHvAYMfQC5+9lw6v+y79I5kegM2fQHb5gXDrHdA== X-Received: by 2002:a05:600c:4309:: with SMTP id p9mr5146395wme.174.1630004316857; Thu, 26 Aug 2021 11:58:36 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id w14sm3862769wrt.23.2021.08.26.11.58.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:36 -0700 (PDT) Subject: [PATCH 6/7] PCI/VPD: Clean up public VPD defines and inline functions From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: Date: Thu, 26 Aug 2021 20:57:01 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org After recent introduction of new VPD API functions and user migration these defines and inline functions aren't used outside VPD core any longer. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 26 +++++++++++++++++ include/linux/pci.h | 69 --------------------------------------------- 2 files changed, 26 insertions(+), 69 deletions(-) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index 79712b3d1..ff600dff4 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -11,6 +11,32 @@ #include #include "pci.h" +#define PCI_VPD_LRDT_TAG_SIZE 3 +#define PCI_VPD_SRDT_LEN_MASK 0x07 +#define PCI_VPD_SRDT_TAG_SIZE 1 +#define PCI_VPD_STIN_END 0x0f +#define PCI_VPD_INFO_FLD_HDR_SIZE 3 + +static u16 pci_vpd_lrdt_size(const u8 *lrdt) +{ + return (u16)lrdt[1] + ((u16)lrdt[2] << 8); +} + +static u8 pci_vpd_srdt_tag(const u8 *srdt) +{ + return *srdt >> 3; +} + +static u8 pci_vpd_srdt_size(const u8 *srdt) +{ + return *srdt & PCI_VPD_SRDT_LEN_MASK; +} + +static u8 pci_vpd_info_field_size(const u8 *info_field) +{ + return info_field[2]; +} + /* VPD access through PCI 2.2+ VPD capability */ static struct pci_dev *pci_get_func0_dev(struct pci_dev *dev) diff --git a/include/linux/pci.h b/include/linux/pci.h index f83930562..2106bfd0a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2266,81 +2266,12 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask); #define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA) #define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA) -/* Small Resource Data Type Tag Item Names */ -#define PCI_VPD_STIN_END 0x0f /* End */ - -#define PCI_VPD_SRDT_END (PCI_VPD_STIN_END << 3) - -#define PCI_VPD_SRDT_TIN_MASK 0x78 -#define PCI_VPD_SRDT_LEN_MASK 0x07 -#define PCI_VPD_LRDT_TIN_MASK 0x7f - -#define PCI_VPD_LRDT_TAG_SIZE 3 -#define PCI_VPD_SRDT_TAG_SIZE 1 - -#define PCI_VPD_INFO_FLD_HDR_SIZE 3 - #define PCI_VPD_RO_KEYWORD_PARTNO "PN" #define PCI_VPD_RO_KEYWORD_SERIALNO "SN" #define PCI_VPD_RO_KEYWORD_MFR_ID "MN" #define PCI_VPD_RO_KEYWORD_VENDOR0 "V0" #define PCI_VPD_RO_KEYWORD_CHKSUM "RV" -/** - * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length - * @lrdt: Pointer to the beginning of the Large Resource Data Type tag - * - * Returns the extracted Large Resource Data Type length. - */ -static inline u16 pci_vpd_lrdt_size(const u8 *lrdt) -{ - return (u16)lrdt[1] + ((u16)lrdt[2] << 8); -} - -/** - * pci_vpd_lrdt_tag - Extracts the Large Resource Data Type Tag Item - * @lrdt: Pointer to the beginning of the Large Resource Data Type tag - * - * Returns the extracted Large Resource Data Type Tag item. - */ -static inline u16 pci_vpd_lrdt_tag(const u8 *lrdt) -{ - return (u16)(lrdt[0] & PCI_VPD_LRDT_TIN_MASK); -} - -/** - * pci_vpd_srdt_size - Extracts the Small Resource Data Type length - * @srdt: Pointer to the beginning of the Small Resource Data Type tag - * - * Returns the extracted Small Resource Data Type length. - */ -static inline u8 pci_vpd_srdt_size(const u8 *srdt) -{ - return (*srdt) & PCI_VPD_SRDT_LEN_MASK; -} - -/** - * pci_vpd_srdt_tag - Extracts the Small Resource Data Type Tag Item - * @srdt: Pointer to the beginning of the Small Resource Data Type tag - * - * Returns the extracted Small Resource Data Type Tag Item. - */ -static inline u8 pci_vpd_srdt_tag(const u8 *srdt) -{ - return ((*srdt) & PCI_VPD_SRDT_TIN_MASK) >> 3; -} - -/** - * pci_vpd_info_field_size - Extracts the information field length - * @info_field: Pointer to the beginning of an information field header - * - * Returns the extracted information field length. - */ -static inline u8 pci_vpd_info_field_size(const u8 *info_field) -{ - return info_field[2]; -} - /** * pci_vpd_alloc - Allocate buffer and read VPD into it * @dev: PCI device From patchwork Thu Aug 26 18:58:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12460507 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 1415DC432BE for ; Thu, 26 Aug 2021 18:58:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6CA361040 for ; Thu, 26 Aug 2021 18:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243409AbhHZS73 (ORCPT ); Thu, 26 Aug 2021 14:59:29 -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 S243432AbhHZS73 (ORCPT ); Thu, 26 Aug 2021 14:59:29 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C1BC061757 for ; Thu, 26 Aug 2021 11:58:41 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id u15so2428762wmj.1 for ; Thu, 26 Aug 2021 11:58:41 -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=13raq/fbB+++wadaSwIhFLoGvj1KRluAlpxJAjLJwn4=; b=ESVmdVVo2Xa6EHSkdCQwchiqtzPI4YunfVaLz8qFr1se8hh2O8LYcWc+SSrvtd5apj 7qD6gSBsX5M8Y6e/H5Qk58nd+Z3eaSKUAbAGYakVqyZii0HroKuStWrAmus5erRBcekK KLGVu8d5cZub5u+O+yJ4JDSw+S5nelctuL8J1i9FWHx+EjhffIujgQsAUd+97069n1Qc /WMRbGtWQaWBF/sD+wbDpyEnxkbAGFQdPsNzURgZdbaHttWy+7iW9or7MwMIxgTUSTQD iervk3Ftq6YaYCgDL/5nrbTjGv5M/E81IcqfljmCLm7HTrCj87CopNiInt4PNCPtCZkN 8J3Q== 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=13raq/fbB+++wadaSwIhFLoGvj1KRluAlpxJAjLJwn4=; b=ZSuCl6ZW3GjSGNi3mvsYGA8ByOTL0c1cj+4+eo2/mAXxhG51mgRJpC3TJ7guCuBT9H gRmWNOPUEz8mlhaOCYDRJRhBCcSvmuzp4iB+otWbWZ+Fw6YiTLU4kY0viIKkFF8NIuGN iz8V7LvYfkCTdxd45Ov9lh5wMuB/tIHp91B+W1fEm+HHygy5QdDASuz4mg7aaCmtJ8uW TxdF1bS9QOx+C+Rt2bcgkXgpHUy5dC06l4nN/0YvjtzStlodcTJxePqrJerp3JOGFDEn uvRz7snXTvGzA+kACvjlH4xecg9gbJh4B7QaNNsPLArETm0eFc40A3d7s4YCNztHzHnc CfEw== X-Gm-Message-State: AOAM530C3C8ogBeIT6biD5R/OlDh+MBbs2bYH0uYMIfprnQnriOEIEi4 zslqYbyU35oB37o1zPD4R2z66bHGrDxH+w== X-Google-Smtp-Source: ABdhPJx2IJdgYg+m9iLF9oXwy2X7eQHtLvcUOQsPEmcRIJ/fLbnKqxCzRJons+DY1PHx5zF7N90yHw== X-Received: by 2002:a05:600c:1551:: with SMTP id f17mr15611235wmg.44.1630004320082; Thu, 26 Aug 2021 11:58:40 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2? (p200300ea8f084500b5d8a3dcf88fcae2.dip0.t-ipconnect.de. [2003:ea:8f08:4500:b5d8:a3dc:f88f:cae2]) by smtp.googlemail.com with ESMTPSA id d4sm4065613wrz.35.2021.08.26.11.58.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:58:39 -0700 (PDT) Subject: [PATCH 7/7] PCI/VPD: Use unaligned access helpers From: Heiner Kallweit To: Bjorn Helgaas Cc: "linux-pci@vger.kernel.org" References: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Message-ID: <0f1c7e21-5330-72ab-139d-f5ce3c65f04a@gmail.com> Date: Thu, 26 Aug 2021 20:58:07 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <5fa6578d-1515-20d3-be5f-9e7dc7db4424@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Use unaligned access helpers to simplify the code. Signed-off-by: Heiner Kallweit --- drivers/pci/vpd.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c index ff600dff4..25557b272 100644 --- a/drivers/pci/vpd.c +++ b/drivers/pci/vpd.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "pci.h" #define PCI_VPD_LRDT_TAG_SIZE 3 @@ -19,7 +20,7 @@ static u16 pci_vpd_lrdt_size(const u8 *lrdt) { - return (u16)lrdt[1] + ((u16)lrdt[2] << 8); + return get_unaligned_le16(lrdt + 1); } static u8 pci_vpd_srdt_tag(const u8 *srdt) @@ -218,14 +219,8 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count, return -EINTR; while (pos < end) { - u32 val; - - val = *buf++; - val |= *buf++ << 8; - val |= *buf++ << 16; - val |= *buf++ << 24; - - ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA, val); + ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA, + get_unaligned_le32(buf)); if (ret < 0) break; ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR, @@ -237,6 +232,7 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count, if (ret < 0) break; + buf += sizeof(u32); pos += sizeof(u32); }