PCI/VPD: Some improvements
Subsystems (10)
cover PCI/VPD: Some improvements
This series includes some improvements. No functional change intended.
Heiner Kallweit (3):
PCI/VPD: Change pci_vpd_init return type to void PCI/VPD: Remove argument off from pci_vpd_find_tag PCI/VPD: Improve and simplify pci_vpd_find_tag
drivers/net/ethernet/broadcom/bnx2.c | 2 +- .../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/pci.h | 2 +- drivers/pci/vpd.c | 40 +++++-------------- drivers/scsi/cxlflash/main.c | 3 +- include/linux/pci.h | 3 +- 11 files changed, 21 insertions(+), 44 deletions(-)
Signature · 1 line
2.31.1
Quoted 7 lines · Heiner Kallweit
This series includes some improvements. No functional change intended.
Heiner Kallweit (3):
PCI/VPD: Changepci_vpd_initreturn type to void PCI/VPD: Remove argument off frompci_vpd_find_tagPCI/VPD: Improve and simplifypci_vpd_find_tag
Quoted 13 lines
drivers/net/ethernet/broadcom/bnx2.c | 2 +- .../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/pci.h | 2 +- drivers/pci/vpd.c | 40 +++++-------------- drivers/scsi/cxlflash/main.c | 3 +- include/linux/pci.h | 3 +- 11 files changed, 21 insertions(+), 44 deletions(-)
Forgot to say: This series is based on the pci/vpd branch.
PATCH 1/3 PCI/VPD: Change pci_vpd_init return type to void
In reply to Heiner Kallweitpci_init_capabilities() is the only caller and doesn't use the return value. So let's change the return type to void.
--- drivers/pci/pci.h | 2 +- drivers/pci/vpd.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/pci/pci.h +1 -1
@@ -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 */
drivers/pci/vpd.c +3 -4
@@ -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)
Signature · 1 line
2.31.1
PATCH 2/3 PCI/VPD: Remove argument off from pci_vpd_find_tag
In reply to Heiner KallweitAll callers pass 0 as offset. Therefore remove the parameter and use a fixed offset 0 in pci_vpd_find_tag().
--- 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(-)
drivers/net/ethernet/broadcom/bnx2.c +1 -1
@@ -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;
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +1 -2
@@ -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;
drivers/net/ethernet/broadcom/bnxt/bnxt.c +1 -1
@@ -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;
drivers/net/ethernet/broadcom/tg3.c +2 -2
@@ -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;
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +1 -1
@@ -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 ;
drivers/net/ethernet/sfc/efx.c +1 -1
@@ -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 ;
drivers/net/ethernet/sfc/falcon/efx.c +1 -1
@@ -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 ;
drivers/pci/vpd.c +2 -2
@@ -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 ) {
drivers/scsi/cxlflash/main.c +1 -2
@@ -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 ;
include/linux/pci.h +1 -2
@@ -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
Signature · 1 line
2.31.1
PATCH 3/3 PCI/VPD: Improve and simplify pci_vpd_find_tag
In reply to Heiner KallweitOnly SRDT tag is the end tag, and no caller is interested in it. This allows to remove all SRDT tag handling.
--- drivers/pci/vpd.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-)
drivers/pci/vpd.c +6 -25
@@ -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 ;
Signature · 1 line
2.31.1
Bjorn Helgaas
AppliedQuoted 7 lines · Heiner Kallweit
This series includes some improvements. No functional change intended.
Heiner Kallweit (3):
PCI/VPD: Changepci_vpd_initreturn type to void PCI/VPD: Remove argument off frompci_vpd_find_tagPCI/VPD: Improve and simplifypci_vpd_find_tag
Quoted 12 lines
drivers/net/ethernet/broadcom/bnx2.c | 2 +- .../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/pci.h | 2 +- drivers/pci/vpd.c | 40 +++++-------------- drivers/scsi/cxlflash/main.c | 3 +- include/linux/pci.h | 3 +- 11 files changed, 21 insertions(+), 44 deletions(-)
Applied to pci/vpd for v5.13, thanks!