Move all PCIBIOS* definitions into arch/x86
Subsystems (55)
cover Move all PCIBIOS* definitions into arch/x86
This goal of these series is to move the definition of *all* PCIBIOS* from include/linux/pci.h to arch/x86 and limit their use within there. All other tree specific definition will be left for intact. Maybe they can be renamed.
PCIBIOS* is an x86 concept as defined by the PCI spec. The returned error codes of PCIBIOS* are positive values and this introduces some complexities which other archs need not incur.
PLAN:
1. [PATCH v0 1-36] Replace all PCIBIOS_SUCCESSFUL with 0
2a. Audit all functions returning PCIBIOS_* error values directly or
indirectly and prevent possible bug coming in (2b)
2b. Make all functions returning PCIBIOS_* error values call
pcibios_err_to_errno(). *This will change their behaviour, for good.*
3. Clone a pcibios_err_to_errno() into arch/x86/pci/pcbios.c as _v2.
This handles the positive error codes directly and will not use any PCIBIOS* definitions. So calls to it have no outside dependence.
4. Make all x86 codes that needs to convert to -E* values call the
cloned version - pcibios_err_to_errno_v2()
5. Assign PCIBIOS_* errors values directly to generic -E* errors
6. Refactor pcibios_err_to_errno() and mark it deprecated
7. Replace all calls to pcibios_err_to_errno() with the proper -E* value
or 0.
8. Remove all PCIBIOS* definitions in include/linux/pci.h and
pcibios_err_to_errno() too.
9. Redefine all PCIBIOS* definitions with original values inside
arch/x86/pci/pcbios.c
10. Redefine pcibios_err_to_errno() inside arch/x86/pci/pcbios.c
11. Replace pcibios_err_to_errno_v2() calls with pcibios_err_to_errno()
12. Remove pcibios_err_to_errno_v2()
Bolarinwa Olayemi Saheed (35):
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Fix Style ERROR: assignment in if condition
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
Change PCIBIOS_SUCCESSFUL to 0
Tidy Success/Failure checks
arch/alpha/kernel/core_apecs.c | 4 +-- arch/alpha/kernel/core_cia.c | 4 +-- arch/alpha/kernel/core_irongate.c | 4 +-- arch/alpha/kernel/core_lca.c | 4 +-- arch/alpha/kernel/core_marvel.c | 4 +-- arch/alpha/kernel/core_mcpcia.c | 4 +-- arch/alpha/kernel/core_polaris.c | 4 +-- arch/alpha/kernel/core_t2.c | 4 +-- arch/alpha/kernel/core_titan.c | 4 +-- arch/alpha/kernel/core_tsunami.c | 4 +-- arch/alpha/kernel/core_wildfire.c | 4 +-- arch/alpha/kernel/sys_miata.c | 2 +- arch/arm/common/it8152.c | 4 +-- arch/arm/mach-cns3xxx/pcie.c | 2 +- arch/arm/mach-footbridge/dc21285.c | 4 +-- arch/arm/mach-iop32x/pci.c | 6 ++-- arch/arm/mach-ixp4xx/common-pci.c | 8 ++--- arch/arm/mach-orion5x/pci.c | 4 +-- arch/arm/plat-orion/pcie.c | 8 ++--- arch/m68k/coldfire/pci.c | 8 ++--- arch/microblaze/pci/indirect_pci.c | 4 +-- arch/mips/pci/fixup-ath79.c | 2 +- arch/mips/pci/ops-bcm63xx.c | 14 ++++---- arch/mips/pci/ops-bonito64.c | 4 +-- arch/mips/pci/ops-gt64xxx_pci0.c | 4 +-- arch/mips/pci/ops-lantiq.c | 4 +-- arch/mips/pci/ops-loongson2.c | 4 +-- arch/mips/pci/ops-mace.c | 4 +-- arch/mips/pci/ops-msc.c | 4 +-- arch/mips/pci/ops-rc32434.c | 6 ++-- arch/mips/pci/ops-sni.c | 4 +-- arch/mips/pci/ops-tx3927.c | 2 +- arch/mips/pci/ops-tx4927.c | 2 +- arch/mips/pci/ops-vr41xx.c | 4 +-- arch/mips/pci/pci-alchemy.c | 6 ++-- arch/mips/pci/pci-ar2315.c | 5 ++- arch/mips/pci/pci-ar71xx.c | 4 +-- arch/mips/pci/pci-ar724x.c | 6 ++-- arch/mips/pci/pci-bcm1480.c | 4 +-- arch/mips/pci/pci-bcm1480ht.c | 4 +-- arch/mips/pci/pci-mt7620.c | 4 +-- arch/mips/pci/pci-octeon.c | 12 +++---- arch/mips/pci/pci-rt2880.c | 4 +-- arch/mips/pci/pci-rt3883.c | 4 +-- arch/mips/pci/pci-sb1250.c | 4 +-- arch/mips/pci/pci-virtio-guest.c | 4 +-- arch/mips/pci/pci-xlp.c | 4 +-- arch/mips/pci/pci-xlr.c | 4 +-- arch/mips/pci/pci-xtalk-bridge.c | 14 ++++---- arch/mips/pci/pcie-octeon.c | 4 +-- arch/mips/txx9/generic/pci.c | 5 ++- arch/powerpc/kernel/rtas_pci.c | 4 +-- arch/powerpc/platforms/4xx/pci.c | 4 +-- arch/powerpc/platforms/52xx/efika.c | 4 +-- arch/powerpc/platforms/52xx/mpc52xx_pci.c | 4 +-- arch/powerpc/platforms/82xx/pq2.c | 2 +- arch/powerpc/platforms/85xx/mpc85xx_cds.c | 2 +- arch/powerpc/platforms/85xx/mpc85xx_ds.c | 2 +- arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 2 +- arch/powerpc/platforms/chrp/pci.c | 8 ++--- arch/powerpc/platforms/embedded6xx/holly.c | 2 +- .../platforms/embedded6xx/mpc7448_hpc2.c | 2 +- arch/powerpc/platforms/fsl_uli1575.c | 2 +- arch/powerpc/platforms/maple/pci.c | 18 +++++----- arch/powerpc/platforms/pasemi/pci.c | 6 ++-- arch/powerpc/platforms/powermac/pci.c | 8 ++--- arch/powerpc/platforms/powernv/eeh-powernv.c | 4 +-- arch/powerpc/platforms/powernv/pci.c | 4 +-- arch/powerpc/platforms/pseries/eeh_pseries.c | 4 +-- arch/powerpc/sysdev/fsl_pci.c | 2 +- arch/powerpc/sysdev/indirect_pci.c | 4 +-- arch/powerpc/sysdev/tsi108_pci.c | 4 +-- arch/sh/drivers/pci/common.c | 3 +- arch/sh/drivers/pci/ops-dreamcast.c | 4 +-- arch/sh/drivers/pci/ops-sh4.c | 4 +-- arch/sh/drivers/pci/ops-sh7786.c | 8 ++--- arch/sh/drivers/pci/pci.c | 2 +- arch/sparc/kernel/pci_common.c | 28 +++++++-------- arch/unicore32/kernel/pci.c | 4 +-- drivers/atm/iphase.c | 20 ++++++----- drivers/atm/lanai.c | 8 ++--- drivers/bcma/driver_pci_host.c | 4 +-- drivers/hwmon/sis5595.c | 13 +++---- drivers/hwmon/via686a.c | 13 +++---- drivers/hwmon/vt8231.c | 13 +++---- drivers/i2c/busses/i2c-ali15x3.c | 5 ++- drivers/i2c/busses/i2c-nforce2.c | 3 +- drivers/i2c/busses/i2c-sis5595.c | 15 +++----- drivers/misc/cxl/vphb.c | 4 +-- drivers/net/ethernet/realtek/r8169_main.c | 2 +- drivers/nvme/host/pci.c | 2 +- drivers/pci/access.c | 14 ++++---- drivers/pci/controller/dwc/pci-meson.c | 4 +-- .../pci/controller/dwc/pcie-designware-host.c | 2 +- drivers/pci/controller/dwc/pcie-designware.c | 4 +-- drivers/pci/controller/dwc/pcie-hisi.c | 4 +-- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +-- .../pci/controller/mobiveil/pcie-mobiveil.c | 4 +-- drivers/pci/controller/pci-aardvark.c | 4 +-- drivers/pci/controller/pci-ftpci100.c | 4 +-- drivers/pci/controller/pci-hyperv.c | 8 ++--- drivers/pci/controller/pci-mvebu.c | 4 +-- drivers/pci/controller/pci-thunder-ecam.c | 36 +++++++++---------- drivers/pci/controller/pci-thunder-pem.c | 4 +-- drivers/pci/controller/pci-xgene.c | 5 ++- drivers/pci/controller/pcie-altera.c | 16 ++++----- drivers/pci/controller/pcie-iproc.c | 10 +++--- drivers/pci/controller/pcie-mediatek.c | 4 +-- drivers/pci/controller/pcie-rcar-host.c | 8 ++--- drivers/pci/controller/pcie-rockchip-host.c | 10 +++--- drivers/pci/pci-bridge-emul.c | 14 ++++---- drivers/pci/pci.c | 8 ++--- drivers/pci/pcie/bw_notification.c | 4 +-- drivers/pci/probe.c | 4 +-- drivers/pci/quirks.c | 4 +-- drivers/pci/syscall.c | 8 ++--- drivers/pci/xen-pcifront.c | 2 +- drivers/scsi/ipr.c | 16 ++++----- drivers/scsi/pmcraid.c | 6 ++-- drivers/ssb/driver_gige.c | 4 +-- drivers/ssb/driver_pcicore.c | 4 +-- drivers/xen/xen-pciback/conf_space.c | 2 +- 122 files changed, 347 insertions(+), 369 deletions(-)
Signature · 1 line
2.18.2
RFC PATCH 1/35 xen-pciback: Change PCIBIOS_SUCCESSFUL to 0
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/xen/xen-pciback/conf_space.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/xen/xen-pciback/conf_space.c +1 -1
@@ -130,7 +130,7 @@ static inline u32 merge_value(u32 val, u32 new_val, u32 new_val_mask,static int xen_pcibios_err_to_errno (int err) {switch (err) { -case PCIBIOS_SUCCESSFUL : +case 0 :return XEN_PCI_ERR_success;case PCIBIOS_DEVICE_NOT_FOUND :return XEN_PCI_ERR_dev_not_found;
Signature · 1 line
2.18.2
RFC PATCH 2/35 ssb: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/ssb/driver_gige.c | 4 ++-- drivers/ssb/driver_pcicore.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/ssb/driver_gige.c +2 -2
@@ -134,7 +134,7 @@ static int ssb_gige_pci_read_config(struct pci_bus *bus, unsigned int devfn, }spin_unlock_irqrestore (&dev->lock, flags); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -164,7 +164,7 @@ static int ssb_gige_pci_write_config(struct pci_bus *bus, unsigned int devfn, }spin_unlock_irqrestore (&dev->lock, flags); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int ssb_gige_probe(struct ssb_device *sdev,
drivers/ssb/driver_pcicore.c +2 -2
@@ -212,7 +212,7 @@ static int ssb_pcicore_read_config(struct pci_bus *bus, unsigned int devfn, PCI_FUNC(devfn), reg, val, size);spin_unlock_irqrestore (&cfgspace_lock, flags); -return err ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return err ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int ssb_pcicore_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -226,7 +226,7 @@ static int ssb_pcicore_write_config(struct pci_bus *bus, unsigned int devfn, PCI_FUNC(devfn), reg, &val, size);spin_unlock_irqrestore (&cfgspace_lock, flags); -return err ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return err ?PCIBIOS_DEVICE_NOT_FOUND :0 ; }static struct pci_ops ssb_pcicore_pciops = {
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [RFC PATCH 02/35] ssb: Change PCIBIOS_SUCCESSFUL to 0
Quoted 6 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>
Could you please tell me what difference this makes? It looks like source churn rather than a substantive change. The symbol is defined in pci.h and is used in many architures. Certainly, PCIBIOS_SUCCESSFUL indicates success even more clearly than 0 does.
Why is your name inside quotes in your s-o-b?
Larry
Re: [RFC PATCH 02/35] ssb: Change PCIBIOS_SUCCESSFUL to 0
Hello Larry,
Quoted 10 lines · Larry Finger
Quoted 6 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>Could you please tell me what difference this makes? It looks like source churn rather than a substantive change. The symbol is defined in
pci.hand is used in many architures. Certainly,PCIBIOS_SUCCESSFULindicates success even more clearly than 0 does.
It is a trivial first step towards a probably significant task. I explained in the Cover Letter, I can see it didn't get through but I Cc linux-wireless (properly this time). Probably, too many addresses.
I have resent it. It is here https://lore.kernel.org/linux-wireless/[email protected]/T/#u
Quoted 2 lines
Why is your name inside quotes in your s-o-b?
To keep me company before I get to know my way within the kernel.
I saw people with >2 names do it, so I did! Please let me know if it is odd.
Thank you.
- Saheed
Arnd Bergmann
maintainerRe: [RFC PATCH 02/35] ssb: Change PCIBIOS_SUCCESSFUL to 0
Quoted 7 lines · Saheed Bolarinwa
Quoted 2 lines · Larry Finger
Why is your name inside quotes in your s-o-b?
To keep me company before I get to know my way within the kernel.
I saw people with >2 names do it, so I did! Please let me know if it is odd.
It's required for a proper email header if you have a dor (.) in your cleartext name, but it is not required in a Signed-off-by tag, though a number of people still do it out of habit. I'm sure it's fine either way.
Arnd
Larry Finger
Acked-byRe: [RFC PATCH 02/35] ssb: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed BolarinwaQuoted 15 lines · Saheed Bolarinwa
Hello Larry,
Quoted 10 lines · Larry Finger
Quoted 6 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>Could you please tell me what difference this makes? It looks like source churn rather than a substantive change. The symbol is defined in
pci.hand is used in many architures. Certainly,PCIBIOS_SUCCESSFULindicates success even more clearly than 0 does.It is a trivial first step towards a probably significant task. I explained in the Cover Letter, I can see it didn't get through but I Cc linux-wireless (properly this time). Probably, too many addresses.
Quoted 9 lines
I have resent it. It is here https://lore.kernel.org/linux-wireless/[email protected]/T/#u
Quoted 2 lines
Why is your name inside quotes in your s-o-b?
To keep me company before I get to know my way within the kernel.
I saw people with >2 names do it, so I did! Please let me know if it is odd.
Thank you for the explanations. The cover letter did help.
For both SSB and BMCA changes,
Larry
RFC PATCH 3/35 scsi: ipr: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/scsi/ipr.c | 16 ++++++++-------- drivers/scsi/pmcraid.c | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-)
drivers/scsi/ipr.c +8 -8
@@ -775,7 +775,7 @@ static int ipr_save_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)return 0 ;if (pci_read_config_word (ioa_cfg->pdev, pcix_cmd_reg +PCI_X_CMD , - &ioa_cfg->saved_pcix_cmd_reg) !=PCIBIOS_SUCCESSFUL ) { + &ioa_cfg->saved_pcix_cmd_reg) !=0 ) {dev_err (&ioa_cfg->pdev->dev,"Failed to save PCI-X command register\n" );return -EIO ; }
@@ -797,7 +797,7 @@ static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)if (pcix_cmd_reg) {if (pci_write_config_word (ioa_cfg->pdev, pcix_cmd_reg +PCI_X_CMD , - ioa_cfg->saved_pcix_cmd_reg) !=PCIBIOS_SUCCESSFUL ) { + ioa_cfg->saved_pcix_cmd_reg) !=0 ) {dev_err (&ioa_cfg->pdev->dev,"Failed to setup PCI-X command register\n" );return -EIO ; }
@@ -8739,7 +8739,7 @@ static int ipr_reset_bist_done(struct ipr_cmnd *ipr_cmd)static int ipr_reset_start_bist (struct ipr_cmnd *ipr_cmd) {struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; -int rc =PCIBIOS_SUCCESSFUL ; +int rc =0 ;ENTER ;if (ioa_cfg->ipr_chip->bist_method ==IPR_MMIO )
@@ -8748,7 +8748,7 @@ static int ipr_reset_start_bist(struct ipr_cmnd *ipr_cmd)else rc =pci_write_config_byte (ioa_cfg->pdev,PCI_BIST ,PCI_BIST_START ); -if (rc ==PCIBIOS_SUCCESSFUL ) { +if (rc ==0 ) { ipr_cmd->job_step = ipr_reset_bist_done;ipr_reset_start_timer (ipr_cmd,IPR_WAIT_FOR_BIST_TIMEOUT ); rc =IPR_RC_JOB_RETURN ;
@@ -8946,7 +8946,7 @@ static int ipr_reset_alert(struct ipr_cmnd *ipr_cmd)ENTER ; rc =pci_read_config_word (ioa_cfg->pdev,PCI_COMMAND , &cmd_reg); -if ((rc ==PCIBIOS_SUCCESSFUL ) && (cmd_reg &PCI_COMMAND_MEMORY )) { +if ((rc ==0 ) && (cmd_reg &PCI_COMMAND_MEMORY )) {ipr_mask_and_clear_interrupts (ioa_cfg, ~0 );writel (IPR_UPROCI_RESET_ALERT , ioa_cfg->regs.set_uproc_interrupt_reg32); ipr_cmd->job_step = ipr_reset_wait_to_start_bist;
@@ -10154,7 +10154,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev,struct Scsi_Host *host;unsigned long ipr_regs_pci;void __iomem *ipr_regs; -int rc =PCIBIOS_SUCCESSFUL ; +int rc =0 ;volatile u32 mask, uproc, interrupts;unsigned long lock_flags, driver_lock_flags;unsigned int irq_flag;
@@ -10256,7 +10256,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev, rc =pci_write_config_byte (pdev,PCI_CACHE_LINE_SIZE , ioa_cfg->chip_cfg->cache_line_size); -if (rc !=PCIBIOS_SUCCESSFUL ) { +if (rc !=0 ) {dev_err (&pdev->dev,"Write of cache line size failed\n" );ipr_wait_for_pci_err_recovery (ioa_cfg); rc = -EIO ;
@@ -10337,7 +10337,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev,/* Save away PCI config space for use following IOA reset */ rc =pci_save_state (pdev); -if (rc !=PCIBIOS_SUCCESSFUL ) { +if (rc !=0 ) {dev_err (&pdev->dev,"Failed to save PCI config space\n" ); rc = -EIO ; goto cleanup_nolog;
drivers/scsi/pmcraid.c +3 -3
@@ -553,7 +553,7 @@ static void pmcraid_bist_done(struct timer_list *t) rc =pci_read_config_word (pinstance->pdev,PCI_COMMAND , &pci_reg);/* If PCI config space can't be accessed wait for another two secs */ -if ((rc !=PCIBIOS_SUCCESSFUL || (!(pci_reg &PCI_COMMAND_MEMORY ))) && +if ((rc !=0 || (!(pci_reg &PCI_COMMAND_MEMORY ))) && cmd->time_left >0 ) {pmcraid_info ("BIST not complete, waiting another 2 secs\n" ); cmd->timer.expires = jiffies + cmd->time_left;
@@ -649,7 +649,7 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd)* BIST or slot_reset */ rc =pci_read_config_word (pinstance->pdev,PCI_COMMAND , &pci_reg); -if ((rc ==PCIBIOS_SUCCESSFUL ) && (pci_reg &PCI_COMMAND_MEMORY )) { +if ((rc ==0 ) && (pci_reg &PCI_COMMAND_MEMORY )) {/* wait for IOA permission i.e until CRITICAL_OPERATION bit is * reset IOA doesn't generate any interrupts when CRITICAL
@@ -5651,7 +5651,7 @@ static int pmcraid_probe(struct pci_dev *pdev,struct pmcraid_instance *pinstance;struct Scsi_Host *host;void __iomem *mapped_pci_addr; -int rc =PCIBIOS_SUCCESSFUL ; +int rc =0 ;if (atomic_read (&pmcraid_adapter_count) >=PMCRAID_MAX_ADAPTERS ) { pmcraid_err
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 4/35 scsi: ipr: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 03/35
drivers/scsi/ipr.c | 12 ++++++------ drivers/scsi/pmcraid.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/scsi/ipr.c +6 -6
@@ -775,7 +775,7 @@ static int ipr_save_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)return 0 ;if (pci_read_config_word (ioa_cfg->pdev, pcix_cmd_reg +PCI_X_CMD , - &ioa_cfg->saved_pcix_cmd_reg) !=0 ) { + &ioa_cfg->saved_pcix_cmd_reg)) {dev_err (&ioa_cfg->pdev->dev,"Failed to save PCI-X command register\n" );return -EIO ; }
@@ -797,7 +797,7 @@ static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)if (pcix_cmd_reg) {if (pci_write_config_word (ioa_cfg->pdev, pcix_cmd_reg +PCI_X_CMD , - ioa_cfg->saved_pcix_cmd_reg) !=0 ) { + ioa_cfg->saved_pcix_cmd_reg)) {dev_err (&ioa_cfg->pdev->dev,"Failed to setup PCI-X command register\n" );return -EIO ; }
@@ -8748,7 +8748,7 @@ static int ipr_reset_start_bist(struct ipr_cmnd *ipr_cmd)else rc =pci_write_config_byte (ioa_cfg->pdev,PCI_BIST ,PCI_BIST_START ); -if (rc ==0 ) { +if (!rc) { ipr_cmd->job_step = ipr_reset_bist_done;ipr_reset_start_timer (ipr_cmd,IPR_WAIT_FOR_BIST_TIMEOUT ); rc =IPR_RC_JOB_RETURN ;
@@ -8946,7 +8946,7 @@ static int ipr_reset_alert(struct ipr_cmnd *ipr_cmd)ENTER ; rc =pci_read_config_word (ioa_cfg->pdev,PCI_COMMAND , &cmd_reg); -if ((rc ==0 ) && (cmd_reg &PCI_COMMAND_MEMORY )) { +if ((!rc) && (cmd_reg &PCI_COMMAND_MEMORY )) {ipr_mask_and_clear_interrupts (ioa_cfg, ~0 );writel (IPR_UPROCI_RESET_ALERT , ioa_cfg->regs.set_uproc_interrupt_reg32); ipr_cmd->job_step = ipr_reset_wait_to_start_bist;
@@ -10256,7 +10256,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev, rc =pci_write_config_byte (pdev,PCI_CACHE_LINE_SIZE , ioa_cfg->chip_cfg->cache_line_size); -if (rc !=0 ) { +if (rc) {dev_err (&pdev->dev,"Write of cache line size failed\n" );ipr_wait_for_pci_err_recovery (ioa_cfg); rc = -EIO ;
@@ -10337,7 +10337,7 @@ static int ipr_probe_ioa(struct pci_dev *pdev,/* Save away PCI config space for use following IOA reset */ rc =pci_save_state (pdev); -if (rc !=0 ) { +if (rc) {dev_err (&pdev->dev,"Failed to save PCI config space\n" ); rc = -EIO ; goto cleanup_nolog;
drivers/scsi/pmcraid.c +2 -2
@@ -553,7 +553,7 @@ static void pmcraid_bist_done(struct timer_list *t) rc =pci_read_config_word (pinstance->pdev,PCI_COMMAND , &pci_reg);/* If PCI config space can't be accessed wait for another two secs */ -if ((rc !=0 || (!(pci_reg &PCI_COMMAND_MEMORY ))) && +if ((rc || (!(pci_reg &PCI_COMMAND_MEMORY ))) && cmd->time_left >0 ) {pmcraid_info ("BIST not complete, waiting another 2 secs\n" ); cmd->timer.expires = jiffies + cmd->time_left;
@@ -649,7 +649,7 @@ static void pmcraid_reset_alert(struct pmcraid_cmd *cmd)* BIST or slot_reset */ rc =pci_read_config_word (pinstance->pdev,PCI_COMMAND , &pci_reg); -if ((rc ==0 ) && (pci_reg &PCI_COMMAND_MEMORY )) { +if ((!rc) && (pci_reg &PCI_COMMAND_MEMORY )) {/* wait for IOA permission i.e until CRITICAL_OPERATION bit is * reset IOA doesn't generate any interrupts when CRITICAL
Signature · 1 line
2.18.2
RFC PATCH 5/35 PCI: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/pci/controller/dwc/pci-meson.c | 4 +-- .../pci/controller/dwc/pcie-designware-host.c | 2 +- drivers/pci/controller/dwc/pcie-designware.c | 4 +-- drivers/pci/controller/dwc/pcie-hisi.c | 4 +-- drivers/pci/controller/dwc/pcie-tegra194.c | 4 +-- .../pci/controller/mobiveil/pcie-mobiveil.c | 4 +-- drivers/pci/controller/pci-aardvark.c | 4 +-- drivers/pci/controller/pci-ftpci100.c | 4 +-- drivers/pci/controller/pci-hyperv.c | 8 ++--- drivers/pci/controller/pci-mvebu.c | 4 +-- drivers/pci/controller/pci-thunder-ecam.c | 36 +++++++++---------- drivers/pci/controller/pci-thunder-pem.c | 4 +-- drivers/pci/controller/pci-xgene.c | 4 +-- drivers/pci/controller/pcie-altera.c | 16 ++++----- drivers/pci/controller/pcie-iproc.c | 10 +++--- drivers/pci/controller/pcie-mediatek.c | 4 +-- drivers/pci/controller/pcie-rcar-host.c | 8 ++--- drivers/pci/controller/pcie-rockchip-host.c | 10 +++--- 18 files changed, 67 insertions(+), 67 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +2 -2
@@ -390,7 +390,7 @@ static int meson_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,int ret; ret =dw_pcie_read (pci->dbi_base + where, size, val); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return ret;/*
@@ -407,7 +407,7 @@ static int meson_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,else if (where ==PCI_CLASS_DEVICE +1 && size ==1 ) *val = (PCI_CLASS_BRIDGE_PCI >>8 ) &0xff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int meson_pcie_wr_own_conf(struct pcie_port *pp, int where,
drivers/pci/controller/dwc/pcie-designware-host.c +1 -1
@@ -459,7 +459,7 @@ int dw_pcie_host_init(struct pcie_port *pp) } ret =dw_pcie_rd_own_conf (pp,PCI_HEADER_TYPE ,1 , &hdr_type); -if (ret !=PCIBIOS_SUCCESSFUL ) { +if (ret !=0 ) {dev_err (pci->dev,"Failed reading PCI_HEADER_TYPE cfg space reg (ret: 0x%x)\n" , ret); ret =pcibios_err_to_errno (ret);
drivers/pci/controller/dwc/pcie-designware.c +2 -2
@@ -113,7 +113,7 @@ int dw_pcie_read(void __iomem *addr, int size, u32 *val)return PCIBIOS_BAD_REGISTER_NUMBER ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }EXPORT_SYMBOL_GPL (dw_pcie_read);
@@ -131,7 +131,7 @@ int dw_pcie_write(void __iomem *addr, int size, u32 val)else return PCIBIOS_BAD_REGISTER_NUMBER ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }EXPORT_SYMBOL_GPL (dw_pcie_write);
drivers/pci/controller/dwc/pcie-hisi.c +2 -2
@@ -163,7 +163,7 @@ static int hisi_pcie_cfg_read(struct pcie_port *pp, int where, int size,else return PCIBIOS_BAD_REGISTER_NUMBER ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/* HipXX PCIe host only supports 32-bit config access */
@@ -190,7 +190,7 @@ static int hisi_pcie_cfg_write(struct pcie_port *pp, int where, int size, }else return PCIBIOS_BAD_REGISTER_NUMBER ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int hisi_pcie_link_up_hip05 (struct hisi_pcie *hisi_pcie)
drivers/pci/controller/dwc/pcie-tegra194.c +2 -2
@@ -581,7 +581,7 @@ static int tegra_pcie_dw_rd_own_conf(struct pcie_port *pp, int where, int size,*/ if (where ==PORT_LOGIC_MSIX_DOORBELL ) { *val =0x00000000 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }return dw_pcie_read (pci->dbi_base + where, size, val);
@@ -599,7 +599,7 @@ static int tegra_pcie_dw_wr_own_conf(struct pcie_port *pp, int where, int size,* So skip accessing it altogether */ if (where ==PORT_LOGIC_MSIX_DOORBELL ) -return PCIBIOS_SUCCESSFUL ; +return 0 ;return dw_pcie_write (pci->dbi_base + where, size, val); }
drivers/pci/controller/mobiveil/pcie-mobiveil.c +2 -2
@@ -71,7 +71,7 @@ static int mobiveil_pcie_read(void __iomem *addr, int size, u32 *val)return PCIBIOS_BAD_REGISTER_NUMBER ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int mobiveil_pcie_write (void __iomem *addr,int size,u32 val)
@@ -93,7 +93,7 @@ static int mobiveil_pcie_write(void __iomem *addr, int size, u32 val)return PCIBIOS_BAD_REGISTER_NUMBER ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }u32 mobiveil_csr_read (struct mobiveil_pcie *pcie,u32 off,size_t size)
drivers/pci/controller/pci-aardvark.c +2 -2
@@ -700,7 +700,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,else if (size ==2 ) *val = (*val >> (8 * (where &3 ))) &0xffff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
@@ -760,7 +760,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,advk_pcie_check_pio_status (pcie); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops advk_pcie_ops = {
drivers/pci/controller/pci-ftpci100.c +2 -2
@@ -204,7 +204,7 @@ static int faraday_raw_pci_read_config(struct faraday_pci *p, int bus_number,else if (size ==2 ) *value = (*value >> (8 * (config &3 ))) &0xFFFF ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int faraday_pci_read_config(struct pci_bus *bus, unsigned int fn,
@@ -223,7 +223,7 @@ static int faraday_raw_pci_write_config(struct faraday_pci *p, int bus_number, unsigned int fn, int config, int size, u32 value) { - int ret = PCIBIOS_SUCCESSFUL; + int ret = 0; writel(PCI_CONF_BUS(bus_number) | PCI_CONF_DEVICE(PCI_SLOT(fn)) |
drivers/pci/controller/pci-hyperv.c +4 -4
@@ -807,7 +807,7 @@ static void _hv_pcifront_write_config(struct hv_pci_dev *hpdev, int where,* @size: Byte/word/dword * @val: Value to be read * -* Return: PCIBIOS_SUCCESSFUL on success +* Return: 0 on success * PCIBIOS_DEVICE_NOT_FOUND on failure */ static int hv_pcifront_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -824,7 +824,7 @@ static int hv_pcifront_read_config(struct pci_bus *bus, unsigned int devfn,_hv_pcifront_read_config (hpdev, where, size, val);put_pcichild (hpdev); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/**
@@ -835,7 +835,7 @@ static int hv_pcifront_read_config(struct pci_bus *bus, unsigned int devfn,* @size: Byte/word/dword * @val: Value to be written to device * -* Return: PCIBIOS_SUCCESSFUL on success +* Return: 0 on success * PCIBIOS_DEVICE_NOT_FOUND on failure */ static int hv_pcifront_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -852,7 +852,7 @@ static int hv_pcifront_write_config(struct pci_bus *bus, unsigned int devfn,_hv_pcifront_write_config (hpdev, where, size, val);put_pcichild (hpdev); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/* PCIe operations */
drivers/pci/controller/pci-mvebu.c +2 -2
@@ -246,7 +246,7 @@ static int mvebu_pcie_hw_rd_conf(struct mvebu_pcie_port *port,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int mvebu_pcie_hw_wr_conf(struct mvebu_pcie_port *port,
@@ -272,7 +272,7 @@ static int mvebu_pcie_hw_wr_conf(struct mvebu_pcie_port *port,return PCIBIOS_BAD_REGISTER_NUMBER ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/*
drivers/pci/controller/pci-thunder-ecam.c +18 -18
@@ -37,7 +37,7 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus,if (where_a ==0 ) {set_val (e0, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0x4 ) { addr = bus->ops->map_bus (bus, devfn, bar);/* BAR 0 */
@@ -49,7 +49,7 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus, v &= ~0xf ; v |=2 ;/* EA entry-1. Base-L */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0x8 ) {u32 barl_orig;
@@ -68,7 +68,7 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus, v = ~barl_rb & ~3 ; v |=0xc ;/* EA entry-2. Offset-L */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xc ) { addr = bus->ops->map_bus (bus, devfn, bar +4 );/* BAR 1 */
@@ -78,7 +78,7 @@ static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus, } v =readl (addr);/* EA entry-3. Base-H */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }return PCIBIOS_DEVICE_NOT_FOUND ; }
@@ -121,7 +121,7 @@ static int thunder_ecam_p2_config_read(struct pci_bus *bus, unsigned int devfn, v |= node_bits;set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
@@ -172,7 +172,7 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn, (where >= 0x1a4 && where < 0x1bc))) {/* BAR or SR-IOV BAR */ *val =0 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } addr = bus->ops->map_bus (bus, devfn,0 );
@@ -207,7 +207,7 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,if (!has_msix && where_a ==0x70 ) { v |=0xbc00 ;/* next capability is EA at 0xbc */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xb0 ) { addr = bus->ops->map_bus (bus, devfn, where_a);
@@ -220,7 +220,7 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,pr_err ("Bad MSIX cap header: %08x\n" , v); v |=0xbc00 ;/* next capability is EA at 0xbc */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xbc ) {if (is_nic)
@@ -232,7 +232,7 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,else v =0x10014 ;/* EA last in chain, 1 entry */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a >=0xc0 && where_a <0xd0 )/* EA entry-0. PP=0, BAR0 Size:3 */
@@ -277,7 +277,7 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,pr_err ("Bad PCIe cap header: %08x\n" , v); v |=0xbc00 ;/* next capability is EA at 0xbc */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xbc ) {if (is_nic_bridge)
@@ -285,7 +285,7 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,else v =0x00014 ;/* EA last in chain, no entries */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xc0 ) {if (is_rsl_bridge || is_nic_bridge)
@@ -297,33 +297,33 @@ static int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,else if (is_dfa_bridge) v =0x0404 ;/* subordinate:secondary = 4:4 */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xc4 && is_nic_bridge) {/* Enabled, not-Write, SP=ff, PP=05, BEI=6, ES=4 */ v =0x80ff0564 ;set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xc8 && is_nic_bridge) { v =0x00000002 ;/* Base-L 64-bit */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xcc && is_nic_bridge) { v =0xfffffffe ;/* MaxOffset-L 64-bit */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xd0 && is_nic_bridge) { v =0x00008430 ;/* NIC Base-H */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (where_a ==0xd4 && is_nic_bridge) { v =0x0000000f ;/* MaxOffset-H */ set_val (v, where, size, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } } no_emulation:
@@ -340,7 +340,7 @@ static int thunder_ecam_config_write(struct pci_bus *bus, unsigned int devfn,if ((where >=0x10 && where <0x2c ) || (where >=0x1a4 && where <0x1bc ))/* BAR or SR-IOV BAR */ -return PCIBIOS_SUCCESSFUL ; +return 0 ;return pci_generic_config_write (bus, devfn, where, size, val); }
drivers/pci/controller/pci-thunder-pem.c +2 -2
@@ -123,7 +123,7 @@ static int thunder_pem_bridge_read(struct pci_bus *bus, unsigned int devfn,break ; } *val = read_val; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int thunder_pem_config_read(struct pci_bus *bus, unsigned int devfn,
@@ -272,7 +272,7 @@ static int thunder_pem_bridge_write(struct pci_bus *bus, unsigned int devfn,*/ write_val = (((u64 )val) <<32 ) | where_aligned;writeq (write_val, pem_pci->pem_reg_base +PEM_CFG_WR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int thunder_pem_config_write(struct pci_bus *bus, unsigned int devfn,
drivers/pci/controller/pci-xgene.c +2 -2
@@ -168,7 +168,7 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,struct xgene_pcie_port *port =pcie_bus_to_port (bus);if (pci_generic_config_read32 (bus, devfn, where & ~0x3 ,4 , val) != -PCIBIOS_SUCCESSFUL ) +0 )return PCIBIOS_DEVICE_NOT_FOUND ;/*
@@ -187,7 +187,7 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,if (size <=2 ) *val = (*val >> (8 * (where &3 ))) & ((1 << (size *8 )) -1 ); - return PCIBIOS_SUCCESSFUL; + return 0; }#endif
drivers/pci/controller/pcie-altera.c +8 -8
@@ -226,7 +226,7 @@ static int tlp_read_packet(struct altera_pcie *pcie, u32 *value)if (value) *value = reg0; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } }udelay (5 );
@@ -273,7 +273,7 @@ static int s10_tlp_read_packet(struct altera_pcie *pcie, u32 *value) count == 4) *value = dw[3 ]; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } }
@@ -367,7 +367,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn, value, false); ret = pcie->pcie_data->ops->tlp_read_pkt (pcie,NULL ); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return ret;/*
@@ -377,7 +377,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn,if ((bus == pcie->root_bus_nr) && (where ==PCI_PRIMARY_BUS )) pcie->root_bus_nr = (u8)(value); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int s10_rp_read_cfg(struct altera_pcie *pcie, int where,
@@ -397,7 +397,7 @@ static int s10_rp_read_cfg(struct altera_pcie *pcie, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int s10_rp_write_cfg(struct altera_pcie *pcie, u8 busno,
@@ -424,7 +424,7 @@ static int s10_rp_write_cfg(struct altera_pcie *pcie, u8 busno,if (busno == pcie->root_bus_nr && where ==PCI_PRIMARY_BUS ) pcie->root_bus_nr = value &0xff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int _altera_pcie_cfg_read(struct altera_pcie *pcie, u8 busno,
@@ -453,7 +453,7 @@ static int _altera_pcie_cfg_read(struct altera_pcie *pcie, u8 busno, ret =tlp_cfg_dword_read (pcie, busno, devfn, (where & ~DWORD_MASK ), byte_en, &data); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return ret;switch (size) {
@@ -468,7 +468,7 @@ static int _altera_pcie_cfg_read(struct altera_pcie *pcie, u8 busno,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int _altera_pcie_cfg_write(struct altera_pcie *pcie, u8 busno,
drivers/pci/controller/pcie-iproc.c +5 -5
@@ -584,7 +584,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn,/* root complex access */ if (busno ==0 ) { ret =pci_generic_config_read32 (bus, devfn, where, size, val); -if (ret ==PCIBIOS_SUCCESSFUL ) +if (ret ==0 )iproc_pcie_fix_cap (pcie, where, val);return ret;
@@ -620,7 +620,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn, (PCI_DEVICE_ID_NX2_57810 << DEVICE_ID_SHIFT))return PCIBIOS_FUNC_NOT_SUPPORTED ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/**
@@ -677,7 +677,7 @@ static int iproc_pci_raw_config_read32(struct iproc_pcie *pcie,if (size <=2 ) *val = (*val >> (8 * (where &3 ))) & ((1 << (size *8 )) -1 ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int iproc_pci_raw_config_write32(struct iproc_pcie *pcie,
@@ -693,7 +693,7 @@ static int iproc_pci_raw_config_write32(struct iproc_pcie *pcie,if (size ==4 ) {writel (val, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } mask = ~(((1 << (size *8 )) -1 ) << ((where &0x3 ) *8 ));
@@ -701,7 +701,7 @@ static int iproc_pci_raw_config_write32(struct iproc_pcie *pcie, tmp |= val << ((where &0x3 ) *8 );writel (tmp, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int iproc_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
drivers/pci/controller/pcie-mediatek.c +2 -2
@@ -274,7 +274,7 @@ static int mtk_pcie_check_cfg_cpld(struct mtk_pcie_port *port)if (readl (port->base +PCIE_APP_TLP_REQ ) &APP_CPL_STATUS )return PCIBIOS_SET_FAILED ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int mtk_pcie_hw_rd_cfg(struct mtk_pcie_port *port, u32 bus, u32 devfn,
@@ -306,7 +306,7 @@ static int mtk_pcie_hw_rd_cfg(struct mtk_pcie_port *port, u32 bus, u32 devfn,else if (size ==2 ) *val = (*val >> (8 * (where &3 ))) &0xffff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int mtk_pcie_hw_wr_cfg(struct mtk_pcie_port *port, u32 bus, u32 devfn,
drivers/pci/controller/pcie-rcar-host.c +4 -4
@@ -110,7 +110,7 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host,rcar_pci_write_reg (pcie, *data,PCICONF (index)); } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (host->root_bus_nr <0 )
@@ -146,7 +146,7 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host,/* Disable the configuration access */ rcar_pci_write_reg (pcie,0 ,PCIECCTLR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
@@ -157,7 +157,7 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, ret =rcar_pcie_config_access (host,RCAR_PCI_ACCESS_READ , bus, devfn, where, val); -if (ret !=PCIBIOS_SUCCESSFUL ) { +if (ret !=0 ) { *val =0xffffffff ;return ret; }
@@ -184,7 +184,7 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, ret =rcar_pcie_config_access (host,RCAR_PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return ret; dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n",
drivers/pci/controller/pcie-rockchip-host.c +5 -5
@@ -125,7 +125,7 @@ static int rockchip_pcie_rd_own_conf(struct rockchip_pcie *rockchip, *val =0 ;return PCIBIOS_BAD_REGISTER_NUMBER ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rockchip_pcie_wr_own_conf(struct rockchip_pcie *rockchip,
@@ -139,7 +139,7 @@ static int rockchip_pcie_wr_own_conf(struct rockchip_pcie *rockchip,if (size ==4 ) {writel (val, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } mask = ~(((1 << (size *8 )) -1 ) << ((where &0x3 ) *8 ));
@@ -153,7 +153,7 @@ static int rockchip_pcie_wr_own_conf(struct rockchip_pcie *rockchip, tmp |= val << ((where &0x3 ) *8 );writel (tmp, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip,
@@ -187,7 +187,7 @@ static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip, *val =0 ;return PCIBIOS_BAD_REGISTER_NUMBER ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rockchip_pcie_wr_other_conf(struct rockchip_pcie *rockchip,
@@ -217,7 +217,7 @@ static int rockchip_pcie_wr_other_conf(struct rockchip_pcie *rockchip,else return PCIBIOS_BAD_REGISTER_NUMBER ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rockchip_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 6/35 PCI: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 05/35
drivers/pci/controller/dwc/pci-meson.c | 2 +- drivers/pci/controller/dwc/pcie-designware-host.c | 2 +- drivers/pci/controller/pci-xgene.c | 3 +-- drivers/pci/controller/pcie-altera.c | 4 ++-- drivers/pci/controller/pcie-iproc.c | 2 +- drivers/pci/controller/pcie-rcar-host.c | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-)
drivers/pci/controller/dwc/pci-meson.c +1 -1
@@ -390,7 +390,7 @@ static int meson_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,int ret; ret =dw_pcie_read (pci->dbi_base + where, size, val); -if (ret !=0 ) +if (ret)return ret;/*
drivers/pci/controller/dwc/pcie-designware-host.c +1 -1
@@ -459,7 +459,7 @@ int dw_pcie_host_init(struct pcie_port *pp) } ret =dw_pcie_rd_own_conf (pp,PCI_HEADER_TYPE ,1 , &hdr_type); -if (ret !=0 ) { +if (ret) {dev_err (pci->dev,"Failed reading PCI_HEADER_TYPE cfg space reg (ret: 0x%x)\n" , ret); ret =pcibios_err_to_errno (ret);
drivers/pci/controller/pci-xgene.c +1 -2
@@ -167,8 +167,7 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, {struct xgene_pcie_port *port =pcie_bus_to_port (bus); -if (pci_generic_config_read32 (bus, devfn, where & ~0x3 ,4 , val) != -0 ) +if (pci_generic_config_read32 (bus, devfn, where & ~0x3 ,4 , val))return PCIBIOS_DEVICE_NOT_FOUND ;/*
drivers/pci/controller/pcie-altera.c +2 -2
@@ -367,7 +367,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn, value, false); ret = pcie->pcie_data->ops->tlp_read_pkt (pcie,NULL ); -if (ret !=0 ) +if (ret)return ret;/*
@@ -453,7 +453,7 @@ static int _altera_pcie_cfg_read(struct altera_pcie *pcie, u8 busno, ret =tlp_cfg_dword_read (pcie, busno, devfn, (where & ~DWORD_MASK ), byte_en, &data); -if (ret !=0 ) +if (ret)return ret;switch (size) {
drivers/pci/controller/pcie-iproc.c +1 -1
@@ -584,7 +584,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn,/* root complex access */ if (busno ==0 ) { ret =pci_generic_config_read32 (bus, devfn, where, size, val); -if (ret ==0 ) +if (!ret)iproc_pcie_fix_cap (pcie, where, val);return ret;
drivers/pci/controller/pcie-rcar-host.c +2 -2
@@ -157,7 +157,7 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, ret =rcar_pcie_config_access (host,RCAR_PCI_ACCESS_READ , bus, devfn, where, val); -if (ret !=0 ) { +if (ret) { *val =0xffffffff ;return ret; }
@@ -184,7 +184,7 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, ret =rcar_pcie_config_access (host,RCAR_PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=0 ) +if (ret)return ret; dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n",
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RE: [RFC PATCH 06/35] PCI: Tidy Success/Failure checks
Quoted 113 lines · Saheed O. Bolarinwa
Remove unnecessary check for 0.
Signed-off-by "Saheed O. Bolarinwa" <[email protected]>---
This patch depends on PATCH 05/35drivers/pci/controller/dwc/pci-meson.c | 2 +- drivers/pci/controller/dwc/pcie-designware-host.c | 2 +- drivers/pci/controller/pci-xgene.c | 3 +-- drivers/pci/controller/pcie-altera.c | 4 ++-- drivers/pci/controller/pcie-iproc.c | 2 +- drivers/pci/controller/pcie-rcar-host.c | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-)drivers/pci/controller/dwc/pci-meson.c +1
-1@@ -390,7 +390,7 @@ static int meson_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,int ret; ret =dw_pcie_read (pci->dbi_base + where, size, val); -if (ret !=0 ) +if (ret)return ret;/* drivers/pci/controller/dwc/pcie-designware-host.c +1
-1@@ -459,7 +459,7 @@ int dw_pcie_host_init(struct pcie_port *pp) } ret =dw_pcie_rd_own_conf (pp,PCI_HEADER_TYPE ,1 , &hdr_type); -if (ret !=0 ) { +if (ret) {dev_err (pci->dev,"Failed reading PCI_HEADER_TYPE cfg space reg (ret: 0x%x)\n" , ret); ret =pcibios_err_to_errno (ret);drivers/pci/controller/pci-xgene.c +1
-2@@ -167,8 +167,7 @@ static int xgene_pcie_config_read32(struct pci_bus *bus, unsigned int devfn, {struct xgene_pcie_port *port =pcie_bus_to_port (bus); -if (pci_generic_config_read32 (bus, devfn, where & ~0x3 ,4 , val) != -0 ) +if (pci_generic_config_read32 (bus, devfn, where & ~0x3 ,4 , val))return PCIBIOS_DEVICE_NOT_FOUND ;/* drivers/pci/controller/pcie-altera.c +2
-2@@ -367,7 +367,7 @@ static int tlp_cfg_dword_write(struct altera_pcie *pcie, u8 bus, u32 devfn, value, false); ret = pcie->pcie_data->ops->tlp_read_pkt (pcie,NULL ); -if (ret !=0 ) +if (ret)return ret;/* @@ -453,7 +453,7 @@ static int _altera_pcie_cfg_read(struct altera_pcie *pcie, u8 busno, ret =tlp_cfg_dword_read (pcie, busno, devfn, (where & ~DWORD_MASK ), byte_en, &data); -if (ret !=0 ) +if (ret)return ret;switch (size) {drivers/pci/controller/pcie-iproc.c +1
-1@@ -584,7 +584,7 @@ static int iproc_pcie_config_read(struct pci_bus *bus, unsigned int devfn,/* root complex access */ if (busno ==0 ) { ret =pci_generic_config_read32 (bus, devfn, where, size, val); -if (ret ==0 ) +if (!ret)iproc_pcie_fix_cap (pcie, where, val);return ret;drivers/pci/controller/pcie-rcar-host.c +2
-2@@ -157,7 +157,7 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn, ret =rcar_pcie_config_access (host,RCAR_PCI_ACCESS_READ , bus, devfn, where, val); -if (ret !=0 ) { +if (ret) { *val =0xffffffff ;return ret; }@@ -184,7 +184,7 @@ static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn, ret =rcar_pcie_config_access (host,RCAR_PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=0 ) +if (ret)return ret; dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08x\n",Signature · 1 line
2.18.2
Seems harmless to me.
RFC PATCH 7/35 PCI: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/pci/access.c | 14 +++++++------- drivers/pci/pci-bridge-emul.c | 14 +++++++------- drivers/pci/pci.c | 8 ++++---- drivers/pci/pcie/bw_notification.c | 4 ++-- drivers/pci/probe.c | 4 ++-- drivers/pci/quirks.c | 2 +- drivers/pci/syscall.c | 8 ++++---- drivers/pci/xen-pcifront.c | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-)
drivers/pci/access.c +7 -7
@@ -92,7 +92,7 @@ int pci_generic_config_read(struct pci_bus *bus, unsigned int devfn,else *val =readl (addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }EXPORT_SYMBOL_GPL (pci_generic_config_read);
@@ -112,7 +112,7 @@ int pci_generic_config_write(struct pci_bus *bus, unsigned int devfn,else writel (val, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }EXPORT_SYMBOL_GPL (pci_generic_config_write);
@@ -132,7 +132,7 @@ int pci_generic_config_read32(struct pci_bus *bus, unsigned int devfn,if (size <=2 ) *val = (*val >> (8 * (where &3 ))) & ((1 << (size *8 )) -1 ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }EXPORT_SYMBOL_GPL (pci_generic_config_read32);
@@ -148,7 +148,7 @@ int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn,if (size ==4 ) {writel (val, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/*
@@ -169,7 +169,7 @@ int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn, tmp |= val << ((where &0x3 ) *8 );writel (tmp, addr); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }EXPORT_SYMBOL_GPL (pci_generic_config_write32);
@@ -222,7 +222,7 @@ static noinline void pci_wait_cfg(struct pci_dev *dev) int pci_user_read_config_##size \ (struct pci_dev *dev, int pos, type *val) \ { \ - int ret = PCIBIOS_SUCCESSFUL; \ + int ret = 0; \ u32 data = -1; \ if (PCI_##size##_BAD) \ return -EINVAL; \
@@ -242,7 +242,7 @@ EXPORT_SYMBOL_GPL(pci_user_read_config_##size); int pci_user_write_config_##size \ (struct pci_dev *dev, int pos, type val) \ { \ - int ret = PCIBIOS_SUCCESSFUL; \ + int ret = 0; \ if (PCI_##size##_BAD) \ return -EINVAL; \ raw_spin_lock_irq(&pci_lock); \
drivers/pci/pci-bridge-emul.c +7 -7
@@ -323,12 +323,12 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where,if (bridge->has_pcie && reg >=PCI_CAP_PCIE_END ) { *value =0 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (!bridge->has_pcie && reg >=PCI_BRIDGE_CONF_END ) { *value =0 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }if (bridge->has_pcie && reg >=PCI_CAP_PCIE_START ) {
@@ -364,7 +364,7 @@ int pci_bridge_emul_conf_read(struct pci_bridge_emul *bridge, int where,else if (size !=4 )return PCIBIOS_BAD_REGISTER_NUMBER ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/*
@@ -383,10 +383,10 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,const struct pci_bridge_reg_behavior *behavior;if (bridge->has_pcie && reg >=PCI_CAP_PCIE_END ) -return PCIBIOS_SUCCESSFUL ; +return 0 ;if (!bridge->has_pcie && reg >=PCI_BRIDGE_CONF_END ) -return PCIBIOS_SUCCESSFUL ; +return 0 ; shift = (where &0x3 ) *8 ;
@@ -400,7 +400,7 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,return PCIBIOS_BAD_REGISTER_NUMBER ; ret =pci_bridge_emul_conf_read (bridge, reg,4 , &old); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return ret;if (bridge->has_pcie && reg >=PCI_CAP_PCIE_START ) {
@@ -428,5 +428,5 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,if (write_op)write_op (bridge, reg, old, new, mask); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
drivers/pci/pci.c +4 -4
@@ -185,7 +185,7 @@ int pci_status_get_and_clear_errors(struct pci_dev *pdev)int ret; ret =pci_read_config_word (pdev,PCI_STATUS , &status); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return -EIO ; status &=PCI_STATUS_ERROR_BITS ;
@@ -534,7 +534,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)if (start) pos = start; -if (pci_read_config_dword (dev, pos, &header) !=PCIBIOS_SUCCESSFUL ) +if (pci_read_config_dword (dev, pos, &header) !=0 )return 0 ;/*
@@ -552,7 +552,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)if (pos <PCI_CFG_SPACE_SIZE )break ; -if (pci_read_config_dword (dev, pos, &header) !=PCIBIOS_SUCCESSFUL ) +if (pci_read_config_dword (dev, pos, &header) !=0 )break ; }
@@ -628,7 +628,7 @@ static int __pci_find_next_ht_cap(struct pci_dev *dev, int pos, int ht_cap) PCI_CAP_ID_HT, &ttl);while (pos) { rc =pci_read_config_byte (dev, pos +3 , &cap); -if (rc !=PCIBIOS_SUCCESSFUL ) +if (rc !=0 )return 0 ;if ((cap & mask) == ht_cap)
drivers/pci/pcie/bw_notification.c +2 -2
@@ -23,7 +23,7 @@ static bool pcie_link_bandwidth_notification_supported(struct pci_dev *dev)u32 lnk_cap; ret =pcie_capability_read_dword (dev,PCI_EXP_LNKCAP , &lnk_cap); -return (ret ==PCIBIOS_SUCCESSFUL ) && (lnk_cap &PCI_EXP_LNKCAP_LBNC ); +return (ret ==0 ) && (lnk_cap &PCI_EXP_LNKCAP_LBNC ); }static void pcie_enable_link_bandwidth_notification (struct pci_dev *dev)
@@ -56,7 +56,7 @@ static irqreturn_t pcie_bw_notification_irq(int irq, void *context) ret =pcie_capability_read_word (port,PCI_EXP_LNKSTA , &link_status); events = link_status &PCI_EXP_LNKSTA_LBMS ; -if (ret !=PCIBIOS_SUCCESSFUL || !events) +if (ret !=0 || !events)return IRQ_NONE ;pcie_capability_write_word (port,PCI_EXP_LNKSTA , events);
drivers/pci/probe.c +2 -2
@@ -1582,7 +1582,7 @@ static bool pci_ext_cfg_is_aliased(struct pci_dev *dev)for (pos =PCI_CFG_SPACE_SIZE ; pos <PCI_CFG_SPACE_EXP_SIZE ; pos +=PCI_CFG_SPACE_SIZE ) { -if (pci_read_config_dword (dev, pos, &tmp) !=PCIBIOS_SUCCESSFUL +if (pci_read_config_dword (dev, pos, &tmp) !=0 || header != tmp)return false; }
@@ -1609,7 +1609,7 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev)u32 status;int pos =PCI_CFG_SPACE_SIZE ; -if (pci_read_config_dword (dev, pos, &status) !=PCIBIOS_SUCCESSFUL ) +if (pci_read_config_dword (dev, pos, &status) !=0 )return PCI_CFG_SPACE_SIZE ;if (status ==0xffffffff ||pci_ext_cfg_is_aliased (dev))return PCI_CFG_SPACE_SIZE ;
drivers/pci/quirks.c +1 -1
@@ -5117,7 +5117,7 @@ static void quirk_intel_qat_vf_cap(struct pci_dev *pdev) pdev->cfg_size =PCI_CFG_SPACE_EXP_SIZE ;if (pci_read_config_dword (pdev,PCI_CFG_SPACE_SIZE , &status) != -PCIBIOS_SUCCESSFUL || (status ==0xffffffff )) +0 || (status ==0xffffffff )) pdev->cfg_size =PCI_CFG_SPACE_SIZE ;if (pci_find_saved_cap (pdev,PCI_CAP_ID_EXP ))
drivers/pci/syscall.c +4 -4
@@ -46,7 +46,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, } err = -EIO ; -if (cfg_ret !=PCIBIOS_SUCCESSFUL ) +if (cfg_ret !=0 ) goto error;switch (len) {
@@ -105,7 +105,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_byte (dev, off, byte); -if (err !=PCIBIOS_SUCCESSFUL ) +if (err !=0 ) err = -EIO ;break ;
@@ -114,7 +114,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_word (dev, off, word); -if (err !=PCIBIOS_SUCCESSFUL ) +if (err !=0 ) err = -EIO ;break ;
@@ -123,7 +123,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_dword (dev, off, dword); -if (err !=PCIBIOS_SUCCESSFUL ) +if (err !=0 ) err = -EIO ;break ;
drivers/pci/xen-pcifront.c +1 -1
@@ -81,7 +81,7 @@ static int errno_to_pcibios_err(int errno) {switch (errno) {case XEN_PCI_ERR_success: -return PCIBIOS_SUCCESSFUL ; +return 0 ;case XEN_PCI_ERR_dev_not_found:return PCIBIOS_DEVICE_NOT_FOUND ;
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 8/35 PCI: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 07/35
drivers/pci/pci-bridge-emul.c | 2 +- drivers/pci/pci.c | 8 ++++---- drivers/pci/pcie/bw_notification.c | 4 ++-- drivers/pci/probe.c | 4 ++-- drivers/pci/quirks.c | 4 ++-- drivers/pci/syscall.c | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-)
drivers/pci/pci-bridge-emul.c +1 -1
@@ -400,7 +400,7 @@ int pci_bridge_emul_conf_write(struct pci_bridge_emul *bridge, int where,return PCIBIOS_BAD_REGISTER_NUMBER ; ret =pci_bridge_emul_conf_read (bridge, reg,4 , &old); -if (ret !=0 ) +if (ret)return ret;if (bridge->has_pcie && reg >=PCI_CAP_PCIE_START ) {
drivers/pci/pci.c +4 -4
@@ -185,7 +185,7 @@ int pci_status_get_and_clear_errors(struct pci_dev *pdev)int ret; ret =pci_read_config_word (pdev,PCI_STATUS , &status); -if (ret !=0 ) +if (ret)return -EIO ; status &=PCI_STATUS_ERROR_BITS ;
@@ -534,7 +534,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)if (start) pos = start; -if (pci_read_config_dword (dev, pos, &header) !=0 ) +if (pci_read_config_dword (dev, pos, &header))return 0 ;/*
@@ -552,7 +552,7 @@ int pci_find_next_ext_capability(struct pci_dev *dev, int start, int cap)if (pos <PCI_CFG_SPACE_SIZE )break ; -if (pci_read_config_dword (dev, pos, &header) !=0 ) +if (pci_read_config_dword (dev, pos, &header))break ; }
@@ -628,7 +628,7 @@ static int __pci_find_next_ht_cap(struct pci_dev *dev, int pos, int ht_cap) PCI_CAP_ID_HT, &ttl);while (pos) { rc =pci_read_config_byte (dev, pos +3 , &cap); -if (rc !=0 ) +if (rc)return 0 ;if ((cap & mask) == ht_cap)
drivers/pci/pcie/bw_notification.c +2 -2
@@ -23,7 +23,7 @@ static bool pcie_link_bandwidth_notification_supported(struct pci_dev *dev)u32 lnk_cap; ret =pcie_capability_read_dword (dev,PCI_EXP_LNKCAP , &lnk_cap); -return (ret ==0 ) && (lnk_cap &PCI_EXP_LNKCAP_LBNC ); +return (!ret) && (lnk_cap &PCI_EXP_LNKCAP_LBNC ); }static void pcie_enable_link_bandwidth_notification (struct pci_dev *dev)
@@ -56,7 +56,7 @@ static irqreturn_t pcie_bw_notification_irq(int irq, void *context) ret =pcie_capability_read_word (port,PCI_EXP_LNKSTA , &link_status); events = link_status &PCI_EXP_LNKSTA_LBMS ; -if (ret !=0 || !events) +if (ret || !events)return IRQ_NONE ;pcie_capability_write_word (port,PCI_EXP_LNKSTA , events);
drivers/pci/probe.c +2 -2
@@ -1582,7 +1582,7 @@ static bool pci_ext_cfg_is_aliased(struct pci_dev *dev)for (pos =PCI_CFG_SPACE_SIZE ; pos <PCI_CFG_SPACE_EXP_SIZE ; pos +=PCI_CFG_SPACE_SIZE ) { -if (pci_read_config_dword (dev, pos, &tmp) !=0 +if (pci_read_config_dword (dev, pos, &tmp) || header != tmp)return false; }
@@ -1609,7 +1609,7 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev)u32 status;int pos =PCI_CFG_SPACE_SIZE ; -if (pci_read_config_dword (dev, pos, &status) !=0 ) +if (pci_read_config_dword (dev, pos, &status))return PCI_CFG_SPACE_SIZE ;if (status ==0xffffffff ||pci_ext_cfg_is_aliased (dev))return PCI_CFG_SPACE_SIZE ;
drivers/pci/quirks.c +2 -2
@@ -5116,8 +5116,8 @@ static void quirk_intel_qat_vf_cap(struct pci_dev *pdev) pdev->pcie_mpss = reg16 &PCI_EXP_DEVCAP_PAYLOAD ; pdev->cfg_size =PCI_CFG_SPACE_EXP_SIZE ; -if (pci_read_config_dword (pdev,PCI_CFG_SPACE_SIZE , &status) != -0 || (status ==0xffffffff )) +if (pci_read_config_dword (pdev,PCI_CFG_SPACE_SIZE , &status) + || (status ==0xffffffff )) pdev->cfg_size =PCI_CFG_SPACE_SIZE ;if (pci_find_saved_cap (pdev,PCI_CAP_ID_EXP ))
drivers/pci/syscall.c +4 -4
@@ -46,7 +46,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, } err = -EIO ; -if (cfg_ret !=0 ) +if (cfg_ret) goto error;switch (len) {
@@ -105,7 +105,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_byte (dev, off, byte); -if (err !=0 ) +if (err) err = -EIO ;break ;
@@ -114,7 +114,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_word (dev, off, word); -if (err !=0 ) +if (err) err = -EIO ;break ;
@@ -123,7 +123,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,if (err)break ; err =pci_user_write_config_dword (dev, off, dword); -if (err !=0 ) +if (err) err = -EIO ;break ;
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 9/35 nvme-pci: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -1185,7 +1185,7 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts) result =pci_read_config_word (to_pci_dev (dev->dev),PCI_STATUS , &pci_status); -if (result ==PCIBIOS_SUCCESSFUL ) +if (result ==0 )dev_warn (dev->ctrl.device,"controller is down; will reset: CSTS=0x%x, PCI_STATUS=0x%hx\n" , csts, pci_status);
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [RFC PATCH 09/35] nvme-pci: Change PCIBIOS_SUCCESSFUL to 0
Hi,
Quoted 15 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/pci.c +0
-0
drivers/nvme/host/pci.c static void nvme_warn_reset(struct nvme_dev *dev, u32 csts) · line 1188
Quoted 5 lines
drivers/nvme/host/pci.c +1
-1@@ -1185,7 +1185,7 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts) result =pci_read_config_word (to_pci_dev (dev->dev),PCI_STATUS , &pci_status); -if (result ==PCIBIOS_SUCCESSFUL ) +if (result ==0 )
How about simplifying the check to if (!result)?
drivers/nvme/host/pci.c static void nvme_warn_reset(struct nvme_dev *dev, u32 csts) · line 1191
Quoted 3 lines
drivers/nvme/host/pci.c +0
-0dev_warn (dev->ctrl.device,"controller is down; will reset: CSTS=0x%x, PCI_STATUS=0x%hx\n" , csts, pci_status);
Thanks!
Revanth
Re: [RFC PATCH 09/35] nvme-pci: Change PCIBIOS_SUCCESSFUL to 0
Quoted 19 lines · Revanth
Hi,
Quoted 16 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/nvme/host/pci.c +0
-0@@ -1185,7 +1185,7 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)
Quoted 5 lines
drivers/nvme/host/pci.c static void nvme_warn_reset(struct nvme_dev *dev, u32 csts) · line 1188
Quoted 4 lines
drivers/nvme/host/pci.c +1
-1result =pci_read_config_word (to_pci_dev (dev->dev),PCI_STATUS , &pci_status); -if (result ==PCIBIOS_SUCCESSFUL ) +if (result ==0 )How about simplifying the check to if (!result)?
Thank you for the review. I did in PATCH 10/35. I will merge both.
I wanted to separate the goal from the fix but I see it's confusing.
- Saheed
RFC PATCH 10/35 nvme-pci: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 09/35
drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -1185,7 +1185,7 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts) result =pci_read_config_word (to_pci_dev (dev->dev),PCI_STATUS , &pci_status); -if (result ==0 ) +if (!result)dev_warn (dev->ctrl.device,"controller is down; will reset: CSTS=0x%x, PCI_STATUS=0x%hx\n" , csts, pci_status);
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 11/35 r8169: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -1
@@ -2656,7 +2656,7 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val)* first and if it fails fall back to CSI. */ if (pdev->cfg_size >0x070f && -pci_write_config_byte (pdev,0x070f , val) ==PCIBIOS_SUCCESSFUL ) +pci_write_config_byte (pdev,0x070f , val) ==0 )return ; netdev_notice_once(tp->dev,
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 12/35 r8169: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 11/35
drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -1
@@ -2656,7 +2656,7 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val)* first and if it fails fall back to CSI. */ if (pdev->cfg_size >0x070f && -pci_write_config_byte (pdev,0x070f , val) ==0 ) + !pci_write_config_byte (pdev,0x070f , val))return ; netdev_notice_once(tp->dev,
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Heiner Kallweit
maintainerRe: [RFC PATCH 12/35] r8169: Tidy Success/Failure checks
Quoted 15 lines · Saheed O. Bolarinwa
Remove unnecessary check for 0.
Signed-off-by "Saheed O. Bolarinwa" <[email protected]>---
This patch depends on PATCH 11/35drivers/net/ethernet/realtek/r8169_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/realtek/r8169_main.c +0
-0
drivers/net/ethernet/realtek/r8169_main.c static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val) · line 2662
Quoted 8 lines
drivers/net/ethernet/realtek/r8169_main.c +1
-1@@ -2656,7 +2656,7 @@ static void rtl_csi_access_enable(struct rtl8169_private *tp, u8 val)* first and if it fails fall back to CSI. */ if (pdev->cfg_size >0x070f && -pci_write_config_byte (pdev,0x070f , val) ==0 ) + !pci_write_config_byte (pdev,0x070f , val))return ; netdev_notice_once(tp->dev,
Patches 11 and 12 are both trivial, wouldn't it make sense to merge them? Apart from that: Acked-by: Heiner Kallweit <[email protected]>
Re: [RFC PATCH 12/35] r8169: Tidy Success/Failure checks
Thank you for the review.
Quoted 3 lines · Heiner Kallweit
Patches 11 and 12 are both trivial, wouldn't it make sense to merge them? Apart from that: Acked-by: Heiner Kallweit <[email protected]>
I separated them for easy review, I will merge them in the next version.
- Saheed
RFC PATCH 13/35 cxl: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. There scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/misc/cxl/vphb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/cxl/vphb.c +2 -2
@@ -150,7 +150,7 @@ static int cxl_pcie_read_config(struct pci_bus *bus, unsigned int devfn, out:cxl_afu_configured_put (afu); -return rc ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return rc ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int cxl_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -184,7 +184,7 @@ static int cxl_pcie_write_config(struct pci_bus *bus, unsigned int devfn, out:cxl_afu_configured_put (afu); -return rc ?PCIBIOS_SET_FAILED :PCIBIOS_SUCCESSFUL ; +return rc ?PCIBIOS_SET_FAILED :0 ; } static struct pci_ops cxl_pcie_pci_ops =
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 14/35 i2c/busses: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/i2c/busses/i2c-ali15x3.c | 4 ++-- drivers/i2c/busses/i2c-nforce2.c | 2 +- drivers/i2c/busses/i2c-sis5595.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-ali15x3.c +2 -2
@@ -167,11 +167,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)if (force_addr) {dev_info (&ALI15X3_dev->dev,"forcing ISA address 0x%04X\n" , ali15x3_smba); -if (PCIBIOS_SUCCESSFUL !=pci_write_config_word (ALI15X3_dev, +if (0 !=pci_write_config_word (ALI15X3_dev,SMBBA , ali15x3_smba)) goto error; -if (PCIBIOS_SUCCESSFUL !=pci_read_config_word (ALI15X3_dev, +if (0 !=pci_read_config_word (ALI15X3_dev,SMBBA , &a)) goto error;if ((a & ~(ALI15X3_SMB_IOSIZE -1 )) != ali15x3_smba) {
drivers/i2c/busses/i2c-nforce2.c +1 -1
@@ -328,7 +328,7 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,u16 iobase;if (pci_read_config_word (dev, alt_reg, &iobase) - !=PCIBIOS_SUCCESSFUL ) { + !=0 ) {dev_err (&dev->dev,"Error reading PCI config for %s\n" , name);return -EIO ;
drivers/i2c/busses/i2c-sis5595.c +5 -5
@@ -176,10 +176,10 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)if (force_addr) {dev_info (&SIS5595_dev->dev,"forcing ISA address 0x%04X\n" , sis5595_base);if (pci_write_config_word (SIS5595_dev,ACPI_BASE , sis5595_base) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if (pci_read_config_word (SIS5595_dev,ACPI_BASE , &a) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if ((a & ~(SIS5595_EXTENT -1 )) != sis5595_base) {/* doesn't work for some chips! */
@@ -189,15 +189,15 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) }if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if ((val &0x80 ) ==0 ) {dev_info (&SIS5595_dev->dev,"enabling ACPI\n" );if (pci_write_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , val |0x80 ) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if ((val &0x80 ) ==0 ) {/* doesn't work for some chips? */
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [RFC PATCH 14/35] i2c/busses: Change PCIBIOS_SUCCESSFUL to 0
Hi Saheed,
Quoted 2 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.
Which PCI specification are you talking about here. In my "PCI Local Bus Revision 2.3" specification (March 29, 2002), chapter 2 is about Signal Definition and has nothing to do with the BIOS.
Quoted 9 lines
Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>--- drivers/i2c/busses/i2c-ali15x3.c | 4 ++-- drivers/i2c/busses/i2c-nforce2.c | 2 +- drivers/i2c/busses/i2c-sis5595.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-)
Hmmm. That seems to be a lot of changes to solve an essentially theoretical problem (if a problem at all). I am not familiar enough with the PCI subsystem to claim that it is fundamentally wrong, but enough to say I'm skeptical.
PCI is a cross-architecture standard, and we can't possibly have the return value of core functions such as pci_write_config_word follow different conventions depending on the architecture, can we? Does pci_write_config_word() currently return PCIBIOS_SUCCESSFUL on success on x86 and 0 on success on other architectures? What about errors, do we return positive, "PCIBIOS-specific" error codes on x86 and negative, unix-like error codes on other architectures?
drivers/i2c/busses/i2c-ali15x3.c static int ali15x3_setup(struct pci_dev *ALI15X3_dev) · line 173
Quoted 13 lines
drivers/i2c/busses/i2c-ali15x3.c +1
-1@@ -167,11 +167,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)if (force_addr) {dev_info (&ALI15X3_dev->dev,"forcing ISA address 0x%04X\n" , ali15x3_smba); -if (PCIBIOS_SUCCESSFUL !=pci_write_config_word (ALI15X3_dev, +if (0 !=pci_write_config_word (ALI15X3_dev,SMBBA , ali15x3_smba)) goto error;
This leaves the code horribly aligned.
Quoted 54 lines
drivers/i2c/busses/i2c-ali15x3.c +1
-1-if (PCIBIOS_SUCCESSFUL !=pci_read_config_word (ALI15X3_dev, +if (0 !=pci_read_config_word (ALI15X3_dev,SMBBA , &a)) goto error;if ((a & ~(ALI15X3_SMB_IOSIZE -1 )) != ali15x3_smba) {drivers/i2c/busses/i2c-nforce2.c +1
-1@@ -328,7 +328,7 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,u16 iobase;if (pci_read_config_word (dev, alt_reg, &iobase) - !=PCIBIOS_SUCCESSFUL ) { + !=0 ) {dev_err (&dev->dev,"Error reading PCI config for %s\n" , name);return -EIO ;drivers/i2c/busses/i2c-sis5595.c +5
-5@@ -176,10 +176,10 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)if (force_addr) {dev_info (&SIS5595_dev->dev,"forcing ISA address 0x%04X\n" , sis5595_base);if (pci_write_config_word (SIS5595_dev,ACPI_BASE , sis5595_base) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if (pci_read_config_word (SIS5595_dev,ACPI_BASE , &a) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if ((a & ~(SIS5595_EXTENT -1 )) != sis5595_base) {/* doesn't work for some chips! */ @@ -189,15 +189,15 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) }if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if ((val &0x80 ) ==0 ) {dev_info (&SIS5595_dev->dev,"enabling ACPI\n" );if (pci_write_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , val |0x80 ) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=PCIBIOS_SUCCESSFUL ) + !=0 ) goto error;if ((val &0x80 ) ==0 ) {/* doesn't work for some chips? */
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [RFC PATCH 14/35] i2c/busses: Change PCIBIOS_SUCCESSFUL to 0
Quoted 3 lines · Jean Delvare
Which PCI specification are you talking about here. In my "PCI Local Bus Revision 2.3" specification (March 29, 2002), chapter 2 is about Signal Definition and has nothing to do with the BIOS.
http://read.pudn.com/downloads211/doc/comm/994029/pcifw_r3_0_updated.pdf
Quoted 13 lines
Quoted 8 lines
Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>--- drivers/i2c/busses/i2c-ali15x3.c | 4 ++-- drivers/i2c/busses/i2c-nforce2.c | 2 +- drivers/i2c/busses/i2c-sis5595.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-)Hmmm. That seems to be a lot of changes to solve an essentially theoretical problem (if a problem at all). I am not familiar enough with the PCI subsystem to claim that it is fundamentally wrong, but enough to say I'm skeptical.
Quoted 7 lines
PCI is a cross-architecture standard, and we can't possibly have the return value of core functions such as
pci_write_config_wordfollow different conventions depending on the architecture, can we? Doespci_write_config_word()currently returnPCIBIOS_SUCCESSFULon success on x86 and 0 on success on other architectures? What about errors, do we return positive, "PCIBIOS-specific" error codes on x86 and negative, unix-like error codes on other architectures?
Unfortunately, the cover letter did not go through. I have resent it now:
https://lore.kernel.org/linux-i2c/[email protected]/T/#u
Here is a discussion thread on it:
Quoted 6 lines
Quoted 6 lines
drivers/i2c/busses/i2c-ali15x3.c +0
-0@@ -167,11 +167,11 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)if (force_addr) {
Quoted 8 lines
drivers/i2c/busses/i2c-ali15x3.c static int ali15x3_setup(struct pci_dev *ALI15X3_dev) · line 173
Quoted 7 lines
drivers/i2c/busses/i2c-ali15x3.c +1
-1dev_info (&ALI15X3_dev->dev,"forcing ISA address 0x%04X\n" , ali15x3_smba); -if (PCIBIOS_SUCCESSFUL !=pci_write_config_word (ALI15X3_dev, +if (0 !=pci_write_config_word (ALI15X3_dev,SMBBA , ali15x3_smba)) goto error;This leaves the code horribly aligned.
Sorry about that, lessons learnt.
Thank you for the review.
- Saheed
Re: [RFC PATCH 14/35] i2c/busses: Change PCIBIOS_SUCCESSFUL to 0
Quoted 2 lines
Sorry about that, lessons learnt.
I'll mark the I2C patches as RFC for me. If you resend them, please mention if I should pick them or if the series shall go in via some other tree.
RFC PATCH 15/35 i2c/busses: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 15/35
drivers/i2c/busses/i2c-ali15x3.c | 5 ++--- drivers/i2c/busses/i2c-nforce2.c | 3 +-- drivers/i2c/busses/i2c-sis5595.c | 15 +++++---------- 3 files changed, 8 insertions(+), 15 deletions(-)
drivers/i2c/busses/i2c-ali15x3.c +2 -3
@@ -167,11 +167,10 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)if (force_addr) {dev_info (&ALI15X3_dev->dev,"forcing ISA address 0x%04X\n" , ali15x3_smba); -if (0 !=pci_write_config_word (ALI15X3_dev, -SMBBA , +if (pci_write_config_word (ALI15X3_dev,SMBBA , ali15x3_smba)) goto error; -if (0 !=pci_read_config_word (ALI15X3_dev, +if (pci_read_config_word (ALI15X3_dev,SMBBA , &a)) goto error;if ((a & ~(ALI15X3_SMB_IOSIZE -1 )) != ali15x3_smba) {
drivers/i2c/busses/i2c-nforce2.c +1 -2
@@ -327,8 +327,7 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,/* Older incarnations of the device used non-standard BARs */ u16 iobase; -if (pci_read_config_word (dev, alt_reg, &iobase) - !=0 ) { +if (pci_read_config_word (dev, alt_reg, &iobase)) {dev_err (&dev->dev,"Error reading PCI config for %s\n" , name);return -EIO ;
drivers/i2c/busses/i2c-sis5595.c +5 -10
@@ -175,11 +175,9 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)if (force_addr) {dev_info (&SIS5595_dev->dev,"forcing ISA address 0x%04X\n" , sis5595_base); -if (pci_write_config_word (SIS5595_dev,ACPI_BASE , sis5595_base) - !=0 ) +if (pci_write_config_word (SIS5595_dev,ACPI_BASE , sis5595_base)) goto error; -if (pci_read_config_word (SIS5595_dev,ACPI_BASE , &a) - !=0 ) +if (pci_read_config_word (SIS5595_dev,ACPI_BASE , &a)) goto error;if ((a & ~(SIS5595_EXTENT -1 )) != sis5595_base) {/* doesn't work for some chips! */
@@ -188,16 +186,13 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) } } -if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=0 ) +if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val)) goto error;if ((val &0x80 ) ==0 ) {dev_info (&SIS5595_dev->dev,"enabling ACPI\n" ); -if (pci_write_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , val |0x80 ) - !=0 ) +if (pci_write_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , val |0x80 )) goto error; -if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=0 ) +if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val)) goto error;if ((val &0x80 ) ==0 ) {/* doesn't work for some chips? */
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Re: [RFC PATCH 15/35] i2c/busses: Tidy Success/Failure checks
Quoted 3 lines · Saheed O. Bolarinwa
Signed-off-by "Saheed O. Bolarinwa" <[email protected]>---
This patch depends on PATCH 15/35
Not possible, as this *is* patch 15/35. Not really worth mentioning anyway, as it is expected that patches in a given series may depend on any earlier patch in the same series.
Quoted 11 lines
drivers/i2c/busses/i2c-ali15x3.c | 5 ++--- drivers/i2c/busses/i2c-nforce2.c | 3 +-- drivers/i2c/busses/i2c-sis5595.c | 15 +++++---------- 3 files changed, 8 insertions(+), 15 deletions(-)drivers/i2c/busses/i2c-ali15x3.c +0
-0
drivers/i2c/busses/i2c-ali15x3.c static int ali15x3_setup(struct pci_dev *ALI15X3_dev) · line 172
Quoted 8 lines
drivers/i2c/busses/i2c-ali15x3.c +1
-2@@ -167,11 +167,10 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)if (force_addr) {dev_info (&ALI15X3_dev->dev,"forcing ISA address 0x%04X\n" , ali15x3_smba); -if (0 !=pci_write_config_word (ALI15X3_dev, -SMBBA , +if (pci_write_config_word (ALI15X3_dev,SMBBA , ali15x3_smba)) goto error;
You can't possibly leave the code with such a ugly alignment and run away. The whole point of tidying patches it to have more readable code in the end, right?
Quoted 47 lines
drivers/i2c/busses/i2c-ali15x3.c +1
-1-if (0 !=pci_read_config_word (ALI15X3_dev, +if (pci_read_config_word (ALI15X3_dev,SMBBA , &a)) goto error;if ((a & ~(ALI15X3_SMB_IOSIZE -1 )) != ali15x3_smba) {drivers/i2c/busses/i2c-nforce2.c +1
-2@@ -327,8 +327,7 @@ static int nforce2_probe_smb(struct pci_dev *dev, int bar, int alt_reg,/* Older incarnations of the device used non-standard BARs */ u16 iobase; -if (pci_read_config_word (dev, alt_reg, &iobase) - !=0 ) { +if (pci_read_config_word (dev, alt_reg, &iobase)) {dev_err (&dev->dev,"Error reading PCI config for %s\n" , name);return -EIO ;drivers/i2c/busses/i2c-sis5595.c +3
-6@@ -175,11 +175,9 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)if (force_addr) {dev_info (&SIS5595_dev->dev,"forcing ISA address 0x%04X\n" , sis5595_base); -if (pci_write_config_word (SIS5595_dev,ACPI_BASE , sis5595_base) - !=0 ) +if (pci_write_config_word (SIS5595_dev,ACPI_BASE , sis5595_base)) goto error; -if (pci_read_config_word (SIS5595_dev,ACPI_BASE , &a) - !=0 ) +if (pci_read_config_word (SIS5595_dev,ACPI_BASE , &a)) goto error;if ((a & ~(SIS5595_EXTENT -1 )) != sis5595_base) {/* doesn't work for some chips! */ @@ -188,16 +186,13 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev) } } -if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=0 ) +if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val)) goto error;if ((val &0x80 ) ==0 ) {dev_info (&SIS5595_dev->dev,"enabling ACPI\n" );
drivers/i2c/busses/i2c-sis5595.c static int sis5595_setup(struct pci_dev *SIS5595_dev) · line 198
Quoted 10 lines
drivers/i2c/busses/i2c-sis5595.c +2
-4-if (pci_write_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , val |0x80 ) - !=0 ) +if (pci_write_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , val |0x80 )) goto error; -if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val) - !=0 ) +if (pci_read_config_byte (SIS5595_dev,SIS5595_ENABLE_REG , &val)) goto error;if ((val &0x80 ) ==0 ) {/* doesn't work for some chips? */
Overall I'd be happy to have a more consistent style for checking errors on PCI config registers access, so this seems to be going into the right direction.
Signature · 2 lines
Jean Delvare SUSE L3 Support
RFC PATCH 16/35 hwmon: (sis5595) Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/hwmon/sis5595.c | 8 ++++---- drivers/hwmon/via686a.c | 8 ++++---- drivers/hwmon/vt8231.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)
drivers/hwmon/sis5595.c +4 -4
@@ -825,7 +825,7 @@ static int sis5595_pci_probe(struct pci_dev *dev,pci_write_config_word (dev,SIS5595_BASE_REG , force_addr); } -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_read_config_word (dev,SIS5595_BASE_REG , &address)) {dev_err (&dev->dev,"Failed to read ISA address\n" );return -ENODEV ;
@@ -843,16 +843,16 @@ static int sis5595_pci_probe(struct pci_dev *dev,return -ENODEV ; } -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_read_config_byte (dev,SIS5595_ENABLE_REG , &enable)) {dev_err (&dev->dev,"Failed to read enable register\n" );return -ENODEV ; }if (!(enable &0x80 )) { -if ((PCIBIOS_SUCCESSFUL != +if ((0 !=pci_write_config_byte (dev,SIS5595_ENABLE_REG , enable |0x80 )) - || (PCIBIOS_SUCCESSFUL != + || (0 !=pci_read_config_byte (dev,SIS5595_ENABLE_REG , &enable)) || (!(enable &0x80 ))) {/* doesn't work for some chips! */
drivers/hwmon/via686a.c +4 -4
@@ -863,11 +863,11 @@ static int via686a_pci_probe(struct pci_dev *dev,if (force_addr) { address = force_addr & ~(VIA686A_EXTENT -1 );dev_warn (&dev->dev,"Forcing ISA address 0x%x\n" , address); -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_write_config_word (dev,VIA686A_BASE_REG , address |1 ))return -ENODEV ; } -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_read_config_word (dev,VIA686A_BASE_REG , &val))return -ENODEV ;
@@ -878,7 +878,7 @@ static int via686a_pci_probe(struct pci_dev *dev,return -ENODEV ; } -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_read_config_word (dev,VIA686A_ENABLE_REG , &val))return -ENODEV ;if (!(val &0x0001 )) {
@@ -890,7 +890,7 @@ static int via686a_pci_probe(struct pci_dev *dev, }dev_warn (&dev->dev,"Enabling sensors\n" ); -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_write_config_word (dev,VIA686A_ENABLE_REG , val |0x0001 ))return -ENODEV ;
drivers/hwmon/vt8231.c +4 -4
@@ -987,12 +987,12 @@ static int vt8231_pci_probe(struct pci_dev *dev,dev_warn (&dev->dev,"Forcing ISA address 0x%x\n" , address); -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_write_config_word (dev,VT8231_BASE_REG , address |1 ))return -ENODEV ; } -if (PCIBIOS_SUCCESSFUL !=pci_read_config_word (dev,VT8231_BASE_REG , +if (0 !=pci_read_config_word (dev,VT8231_BASE_REG , &val))return -ENODEV ;
@@ -1002,13 +1002,13 @@ static int vt8231_pci_probe(struct pci_dev *dev,return -ENODEV ; } -if (PCIBIOS_SUCCESSFUL !=pci_read_config_word (dev,VT8231_ENABLE_REG , +if (0 !=pci_read_config_word (dev,VT8231_ENABLE_REG , &val))return -ENODEV ;if (!(val &0x0001 )) {dev_warn (&dev->dev,"enabling sensors\n" ); -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_write_config_word (dev,VT8231_ENABLE_REG , val |0x0001 ))return -ENODEV ;
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Guenter Roeck
maintainerRe: [RFC PATCH 16/35] hwmon: (sis5595) Change PCIBIOS_SUCCESSFUL to 0
Quoted 17 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>--- drivers/hwmon/sis5595.c | 8 ++++---- drivers/hwmon/via686a.c | 8 ++++---- drivers/hwmon/vt8231.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)drivers/hwmon/sis5595.c +0
-0
drivers/hwmon/sis5595.c static int sis5595_pci_probe(struct pci_dev *dev, · line 829
Quoted 6 lines
drivers/hwmon/sis5595.c +1
-1@@ -825,7 +825,7 @@ static int sis5595_pci_probe(struct pci_dev *dev,pci_write_config_word (dev,SIS5595_BASE_REG , force_addr); } -if (PCIBIOS_SUCCESSFUL != +if (0 !=pci_read_config_word (dev,SIS5595_BASE_REG , &address)) {
Yoda programming already terrible is, but "0 !=" is even worse than that (and completely unnecessary). If you want to clean this up, do it right and drop those unnecessary comparisons.
Guenter
RFC PATCH 17/35 hwmon: (sis5595) Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 16/35
drivers/hwmon/sis5595.c | 13 ++++--------- drivers/hwmon/via686a.c | 13 ++++--------- drivers/hwmon/vt8231.c | 13 ++++--------- 3 files changed, 12 insertions(+), 27 deletions(-)
drivers/hwmon/sis5595.c +4 -9
@@ -825,8 +825,7 @@ static int sis5595_pci_probe(struct pci_dev *dev,pci_write_config_word (dev,SIS5595_BASE_REG , force_addr); } -if (0 != -pci_read_config_word (dev,SIS5595_BASE_REG , &address)) { +if (pci_read_config_word (dev,SIS5595_BASE_REG , &address)) {dev_err (&dev->dev,"Failed to read ISA address\n" );return -ENODEV ; }
@@ -843,17 +842,13 @@ static int sis5595_pci_probe(struct pci_dev *dev,return -ENODEV ; } -if (0 != -pci_read_config_byte (dev,SIS5595_ENABLE_REG , &enable)) { +if (pci_read_config_byte (dev,SIS5595_ENABLE_REG , &enable)) {dev_err (&dev->dev,"Failed to read enable register\n" );return -ENODEV ; }if (!(enable &0x80 )) { -if ((0 != -pci_write_config_byte (dev,SIS5595_ENABLE_REG , - enable |0x80 )) - || (0 != -pci_read_config_byte (dev,SIS5595_ENABLE_REG , &enable)) +if ((pci_write_config_byte (dev,SIS5595_ENABLE_REG , enable |0x80 )) + || (pci_read_config_byte (dev,SIS5595_ENABLE_REG , &enable)) || (!(enable &0x80 ))) {/* doesn't work for some chips! */ dev_err (&dev->dev,"Failed to enable HWM device\n" );
drivers/hwmon/via686a.c +4 -9
@@ -863,12 +863,10 @@ static int via686a_pci_probe(struct pci_dev *dev,if (force_addr) { address = force_addr & ~(VIA686A_EXTENT -1 );dev_warn (&dev->dev,"Forcing ISA address 0x%x\n" , address); -if (0 != -pci_write_config_word (dev,VIA686A_BASE_REG , address |1 )) +if (pci_write_config_word (dev,VIA686A_BASE_REG , address |1 ))return -ENODEV ; } -if (0 != -pci_read_config_word (dev,VIA686A_BASE_REG , &val)) +if (pci_read_config_word (dev,VIA686A_BASE_REG , &val))return -ENODEV ; address = val & ~(VIA686A_EXTENT -1 );
@@ -878,8 +876,7 @@ static int via686a_pci_probe(struct pci_dev *dev,return -ENODEV ; } -if (0 != -pci_read_config_word (dev,VIA686A_ENABLE_REG , &val)) +if (pci_read_config_word (dev,VIA686A_ENABLE_REG , &val))return -ENODEV ;if (!(val &0x0001 )) {if (!force_addr) {
@@ -890,9 +887,7 @@ static int via686a_pci_probe(struct pci_dev *dev, }dev_warn (&dev->dev,"Enabling sensors\n" ); -if (0 != -pci_write_config_word (dev,VIA686A_ENABLE_REG , - val |0x0001 )) +if (pci_write_config_word (dev,VIA686A_ENABLE_REG , val |0x0001 ))return -ENODEV ; }
drivers/hwmon/vt8231.c +4 -9
@@ -987,13 +987,11 @@ static int vt8231_pci_probe(struct pci_dev *dev,dev_warn (&dev->dev,"Forcing ISA address 0x%x\n" , address); -if (0 != -pci_write_config_word (dev,VT8231_BASE_REG , address |1 )) +if (pci_write_config_word (dev,VT8231_BASE_REG , address |1 ))return -ENODEV ; } -if (0 !=pci_read_config_word (dev,VT8231_BASE_REG , - &val)) +if (pci_read_config_word (dev,VT8231_BASE_REG , &val))return -ENODEV ; address = val & ~(VT8231_EXTENT -1 );
@@ -1002,15 +1000,12 @@ static int vt8231_pci_probe(struct pci_dev *dev,return -ENODEV ; } -if (0 !=pci_read_config_word (dev,VT8231_ENABLE_REG , - &val)) +if (pci_read_config_word (dev,VT8231_ENABLE_REG , &val))return -ENODEV ;if (!(val &0x0001 )) {dev_warn (&dev->dev,"enabling sensors\n" ); -if (0 != -pci_write_config_word (dev,VT8231_ENABLE_REG , - val |0x0001 )) +if (pci_write_config_word (dev,VT8231_ENABLE_REG , val |0x0001 ))return -ENODEV ; }
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Guenter Roeck
maintainerRe: [RFC PATCH 17/35] hwmon: (sis5595) Tidy Success/Failure checks
Quoted 16 lines · Saheed O. Bolarinwa
Remove unnecessary check for 0.
Signed-off-by "Saheed O. Bolarinwa" <[email protected]>---
This patch depends on PATCH 16/35drivers/hwmon/sis5595.c | 13 ++++--------- drivers/hwmon/via686a.c | 13 ++++--------- drivers/hwmon/vt8231.c | 13 ++++--------- 3 files changed, 12 insertions(+), 27 deletions(-)drivers/hwmon/sis5595.c +0
-0
drivers/hwmon/sis5595.c static int sis5595_pci_probe(struct pci_dev *dev, · line 828
Quoted 6 lines
drivers/hwmon/sis5595.c +1
-2@@ -825,8 +825,7 @@ static int sis5595_pci_probe(struct pci_dev *dev,pci_write_config_word (dev,SIS5595_BASE_REG , force_addr); } -if (0 != -pci_read_config_word (dev,SIS5595_BASE_REG , &address)) { +if (pci_read_config_word (dev,SIS5595_BASE_REG , &address)) {
Ah, there is is, and I see that others commented on it. Single patch, please.
Guenter
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 18/35 bcma: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/bcma/driver_pci_host.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bcma/driver_pci_host.c +2 -2
@@ -244,7 +244,7 @@ static int bcma_core_pci_hostmode_read_config(struct pci_bus *bus, PCI_FUNC(devfn), reg, val, size);spin_unlock_irqrestore (&pc_host->cfgspace_lock, flags); -return err ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return err ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus,
@@ -264,7 +264,7 @@ static int bcma_core_pci_hostmode_write_config(struct pci_bus *bus, PCI_FUNC(devfn), reg, &val, size);spin_unlock_irqrestore (&pc_host->cfgspace_lock, flags); -return err ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return err ?PCIBIOS_DEVICE_NOT_FOUND :0 ; }/* return cap_offset if requested capability exists in the PCI config space */
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 19/35 atm: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- drivers/atm/iphase.c | 4 ++-- drivers/atm/lanai.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/atm/iphase.c +2 -2
@@ -2296,12 +2296,12 @@ static int reset_sar(struct atm_dev *dev) iadev =INPH_IA_DEV (dev);for (i=0 ; i<64 ; i++)if ((error =pci_read_config_dword (iadev->pci, - i*4 , &pci[i])) !=PCIBIOS_SUCCESSFUL ) + i*4 , &pci[i])) !=0 )return error;writel (0 , iadev->reg+IPHASE5575_EXT_RESET );for (i=0 ; i<64 ; i++)if ((error =pci_write_config_dword (iadev->pci, - i*4 , pci[i])) !=PCIBIOS_SUCCESSFUL ) + i*4 , pci[i])) !=0 )return error;udelay (5 );return 0 ;
drivers/atm/lanai.c +3 -3
@@ -1098,7 +1098,7 @@ static void pcistatus_check(struct lanai_dev *lanai, int clearonly)u16 s;int result; result =pci_read_config_word (lanai->pci,PCI_STATUS , &s); -if (result !=PCIBIOS_SUCCESSFUL ) { +if (result !=0 ) { printk(KERN_ERR DEV_LABEL "(itf %d): can't read PCI_STATUS: " "%d\n", lanai->number, result);return ;
@@ -1109,7 +1109,7 @@ static void pcistatus_check(struct lanai_dev *lanai, int clearonly)if (s ==0 )return ; result =pci_write_config_word (lanai->pci,PCI_STATUS , s); -if (result !=PCIBIOS_SUCCESSFUL ) +if (result !=0 ) printk(KERN_ERR DEV_LABEL "(itf %d): can't write PCI_STATUS: ""%d\n" , lanai->number, result);if (clearonly)
@@ -1949,7 +1949,7 @@ static int lanai_pci_start(struct lanai_dev *lanai)return result;/* Set latency timer to zero as per lanai docs */ result =pci_write_config_byte (pci,PCI_LATENCY_TIMER ,0 ); -if (result !=PCIBIOS_SUCCESSFUL ) { +if (result !=0 ) { printk(KERN_ERR DEV_LABEL "(itf %d): can't write " "PCI_LATENCY_TIMER: %d\n", lanai->number, result);return -EINVAL ;
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 20/35 atm: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 19/35
drivers/atm/iphase.c | 10 ++++------ drivers/atm/lanai.c | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/atm/iphase.c +4 -6
@@ -2295,14 +2295,12 @@ static int reset_sar(struct atm_dev *dev) iadev =INPH_IA_DEV (dev);for (i=0 ; i<64 ; i++) -if ((error =pci_read_config_dword (iadev->pci, - i*4 , &pci[i])) !=0 ) -return error; +if ((error =pci_read_config_dword (iadev->pci, i*4 , &pci[i]))) +return error;writel (0 , iadev->reg+IPHASE5575_EXT_RESET );for (i=0 ; i<64 ; i++) -if ((error =pci_write_config_dword (iadev->pci, - i*4 , pci[i])) !=0 ) -return error; +if ((error =pci_write_config_dword (iadev->pci, i*4 , pci[i]))) +return error;udelay (5 );return 0 ; }
drivers/atm/lanai.c +3 -3
@@ -1098,7 +1098,7 @@ static void pcistatus_check(struct lanai_dev *lanai, int clearonly)u16 s;int result; result =pci_read_config_word (lanai->pci,PCI_STATUS , &s); -if (result !=0 ) { +if (result) { printk(KERN_ERR DEV_LABEL "(itf %d): can't read PCI_STATUS: " "%d\n", lanai->number, result);return ;
@@ -1109,7 +1109,7 @@ static void pcistatus_check(struct lanai_dev *lanai, int clearonly)if (s ==0 )return ; result =pci_write_config_word (lanai->pci,PCI_STATUS , s); -if (result !=0 ) +if (result) printk(KERN_ERR DEV_LABEL "(itf %d): can't write PCI_STATUS: ""%d\n" , lanai->number, result);if (clearonly)
@@ -1945,7 +1945,7 @@ static int lanai_pci_start(struct lanai_dev *lanai)return -EBUSY ; } result =check_board_id_and_rev ("PCI" , pci->subsystem_device,NULL ); -if (result !=0 ) +if (result)return result;/* Set latency timer to zero as per lanai docs */ result =pci_write_config_byte (pci,PCI_LATENCY_TIMER ,0 );
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 21/35 atm: Fix Style ERROR- assignment in if condition
In reply to Saheed O. BolarinwaMove assignment out of the if condition
Fix style issues in the for-loop
---
This patch depends on PATCH 20/35
drivers/atm/iphase.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/atm/iphase.c +10 -4
@@ -2294,13 +2294,19 @@ static int reset_sar(struct atm_dev *dev)unsigned int pci[64 ]; iadev =INPH_IA_DEV (dev); -for (i=0 ; i<64 ; i++) -if ((error =pci_read_config_dword (iadev->pci, i*4 , &pci[i]))) +for (i =0 ; i <64 ; i++) { + error =pci_read_config_dword (iadev->pci, i*4 , &pci[i]); +if (error)return error; + } +writel (0 , iadev->reg+IPHASE5575_EXT_RESET ); -for (i=0 ; i<64 ; i++) -if ((error =pci_write_config_dword (iadev->pci, i*4 , pci[i]))) +for (i =0 ; i <64 ; i++) { + error =pci_write_config_dword (iadev->pci, i*4 , pci[i]); +if (error)return error; + } +udelay (5 );return 0 ; }
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 22/35 unicore32: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/unicore32/kernel/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/unicore32/kernel/pci.c +2 -2
@@ -37,7 +37,7 @@ puv3_read_config(struct pci_bus *bus, unsigned int devfn, int where, *value =readl (PCICFG_DATA );break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -58,7 +58,7 @@ puv3_write_config(struct pci_bus *bus, unsigned int devfn, int where,writel (value,PCICFG_DATA );break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops pci_puv3_ops = {
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 23/35 sparc/PCI: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/sparc/kernel/pci_common.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
arch/sparc/kernel/pci_common.c +14 -14
@@ -59,7 +59,7 @@ static int sun4u_read_pci_cfg_host(struct pci_pbm_info *pbm, addr =sun4u_config_mkaddr (pbm, bus, devfn, where);if (!addr) -return PCIBIOS_SUCCESSFUL ; +return 0 ;switch (size) {case 1 :
@@ -102,7 +102,7 @@ static int sun4u_read_pci_cfg_host(struct pci_pbm_info *pbm, *value |= tmp32 <<16 ;break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
@@ -132,7 +132,7 @@ static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, addr =sun4u_config_mkaddr (pbm, bus, devfn, where);if (!addr) -return PCIBIOS_SUCCESSFUL ; +return 0 ;switch (size) {case 1 :
@@ -144,7 +144,7 @@ static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,if (where &0x01 ) {printk ("pci_read_config_word: misaligned reg [%x]\n" , where); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }pci_config_read16 ((u16 *)addr, &tmp16); *value = (u32 ) tmp16;
@@ -154,12 +154,12 @@ static int sun4u_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,if (where &0x03 ) {printk ("pci_read_config_dword: misaligned reg [%x]\n" , where); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }pci_config_read32 (addr, value);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sun4u_write_pci_cfg_host(struct pci_pbm_info *pbm,
@@ -170,7 +170,7 @@ static int sun4u_write_pci_cfg_host(struct pci_pbm_info *pbm, addr =sun4u_config_mkaddr (pbm, bus, devfn, where);if (!addr) -return PCIBIOS_SUCCESSFUL ; +return 0 ;switch (size) {case 1 :
@@ -206,7 +206,7 @@ static int sun4u_write_pci_cfg_host(struct pci_pbm_info *pbm, where + 2, 2, value >> 16);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
@@ -222,7 +222,7 @@ static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, addr =sun4u_config_mkaddr (pbm, bus, devfn, where);if (!addr) -return PCIBIOS_SUCCESSFUL ; +return 0 ;switch (size) {case 1 :
@@ -233,7 +233,7 @@ static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,if (where &0x01 ) {printk ("pci_write_config_word: misaligned reg [%x]\n" , where); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }pci_config_write16 ((u16 *)addr, value);break ;
@@ -242,11 +242,11 @@ static int sun4u_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,if (where &0x03 ) {printk ("pci_write_config_dword: misaligned reg [%x]\n" , where); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }pci_config_write32 (addr, value); } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops sun4u_pci_ops = {
@@ -284,7 +284,7 @@ static int sun4v_read_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn, } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sun4v_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,
@@ -307,7 +307,7 @@ static int sun4v_write_pci_cfg(struct pci_bus *bus_dev, unsigned int devfn,HV_PCI_DEVICE_BUILD (bus, device, func), where, size, value); } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops sun4v_pci_ops = {
Signature · 1 line
2.18.2
RFC PATCH 24/35 sh: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/sh/drivers/pci/common.c | 2 +- arch/sh/drivers/pci/ops-dreamcast.c | 4 ++-- arch/sh/drivers/pci/ops-sh4.c | 4 ++-- arch/sh/drivers/pci/ops-sh7786.c | 8 ++++---- arch/sh/drivers/pci/pci.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)
arch/sh/drivers/pci/common.c +1 -0
@@ -61,7 +61,7 @@ int __init pci_is_66mhz_capable(struct pci_channel *hose,continue ;if (early_read_config_word (hose, top_bus, current_bus, pci_devfn, PCI_VENDOR_ID, &vid) !- PCIBIOS_SUCCESSFUL) + 0)continue ;if (vid =0xffff )continue ;
arch/sh/drivers/pci/ops-dreamcast.c +2 -2
@@ -56,7 +56,7 @@ static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, intcase 4 : *val =inl (GAPSPCI_BBA_CONFIG +where);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int gapspci_write (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 val)
@@ -70,7 +70,7 @@ static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, intcase 4 :outl ((u32 )val,GAPSPCI_BBA_CONFIG +where);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops gapspci_pci_ops = {
arch/sh/drivers/pci/ops-sh4.c +2 -2
@@ -49,7 +49,7 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/*
@@ -90,7 +90,7 @@ static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn,pci_write_reg (chan, data,SH4_PCIPDR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops sh4_pci_ops = {
arch/sh/drivers/pci/ops-sh7786.c +4 -4
@@ -52,7 +52,7 @@ static int sh7786_pcie_config_access(unsigned char access_type,else pci_write_reg (chan, *data,PCI_REG (reg)); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }else if (dev >1 )return PCIBIOS_DEVICE_NOT_FOUND ; }
@@ -83,7 +83,7 @@ static int sh7786_pcie_config_access(unsigned char access_type,/* Disable the configuration access */ pci_write_reg (chan,0 ,SH4A_PCIEPCTLR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,
@@ -101,7 +101,7 @@ static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,raw_spin_lock_irqsave (&pci_config_lock, flags); ret =sh7786_pcie_config_access (PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=PCIBIOS_SUCCESSFUL ) { +if (ret !=0 ) { *val =0xffffffff ; goto out; }
@@ -137,7 +137,7 @@ static int sh7786_pcie_write(struct pci_bus *bus, unsigned int devfn,raw_spin_lock_irqsave (&pci_config_lock, flags); ret =sh7786_pcie_config_access (PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 ) goto out; dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x "
arch/sh/drivers/pci/pci.c +1 -1
@@ -204,7 +204,7 @@ pcibios_bus_report_status_early(struct pci_channel *hose,continue ; ret =early_read_config_word (hose, top_bus, current_bus, pci_devfn,PCI_STATUS , &status); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )continue ;if (status =0xffff )continue ;
Signature · 1 line
2.18.2
Re: [RFC PATCH 24/35] sh: Change PCIBIOS_SUCCESSFUL to 0
Quoted 125 lines · Saheed O. Bolarinwa
In reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within
arch/x86.Change all
PCIBIOS_SUCCESSFULto 0Signed-off-by "Saheed O. Bolarinwa" <[email protected]>--- arch/sh/drivers/pci/common.c | 2 +- arch/sh/drivers/pci/ops-dreamcast.c | 4 ++-- arch/sh/drivers/pci/ops-sh4.c | 4 ++-- arch/sh/drivers/pci/ops-sh7786.c | 8 ++++---- arch/sh/drivers/pci/pci.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)arch/sh/drivers/pci/common.c +1
-0@@ -61,7 +61,7 @@ int __init pci_is_66mhz_capable(struct pci_channel *hose,continue ;if (early_read_config_word (hose, top_bus, current_bus, pci_devfn, PCI_VENDOR_ID, &vid) !> - PCIBIOS_SUCCESSFUL) + 0)continue ;if (vid =0xffff )continue ;arch/sh/drivers/pci/ops-dreamcast.c +2
-2@@ -56,7 +56,7 @@ static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, intcase 4 : *val =inl (GAPSPCI_BBA_CONFIG +where);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int gapspci_write (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 val)@@ -70,7 +70,7 @@ static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, intcase 4 :outl ((u32 )val,GAPSPCI_BBA_CONFIG +where);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops gapspci_pci_ops = {arch/sh/drivers/pci/ops-sh4.c +2
-2@@ -49,7 +49,7 @@ static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/* @@ -90,7 +90,7 @@ static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn,pci_write_reg (chan, data,SH4_PCIPDR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops sh4_pci_ops = {arch/sh/drivers/pci/ops-sh7786.c +4
-4@@ -52,7 +52,7 @@ static int sh7786_pcie_config_access(unsigned char access_type,else pci_write_reg (chan, *data,PCI_REG (reg)); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }else if (dev >1 )return PCIBIOS_DEVICE_NOT_FOUND ; }@@ -83,7 +83,7 @@ static int sh7786_pcie_config_access(unsigned char access_type,/* Disable the configuration access */ pci_write_reg (chan,0 ,SH4A_PCIEPCTLR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,@@ -101,7 +101,7 @@ static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,raw_spin_lock_irqsave (&pci_config_lock, flags); ret =sh7786_pcie_config_access (PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=PCIBIOS_SUCCESSFUL ) { +if (ret !=0 ) { *val =0xffffffff ; goto out; }@@ -137,7 +137,7 @@ static int sh7786_pcie_write(struct pci_bus *bus, unsigned int devfn,raw_spin_lock_irqsave (&pci_config_lock, flags); ret =sh7786_pcie_config_access (PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 ) goto out; dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x "arch/sh/drivers/pci/pci.c +1
-1@@ -204,7 +204,7 @@ pcibios_bus_report_status_early(struct pci_channel *hose,continue ; ret =early_read_config_word (hose, top_bus, current_bus, pci_devfn,PCI_STATUS , &status); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )continue ;if (status =0xffff )continue ;Signature · 1 line
2.18.2
(for both this and the following one in the series)
RFC PATCH 25/35 sh: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 24/35
arch/sh/drivers/pci/common.c | 3 +-- arch/sh/drivers/pci/ops-sh7786.c | 4 ++-- arch/sh/drivers/pci/pci.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
arch/sh/drivers/pci/common.c +1 -1
@@ -60,8 +60,7 @@ int __init pci_is_66mhz_capable(struct pci_channel *hose,if (PCI_FUNC (pci_devfn))continue ;if (early_read_config_word (hose, top_bus, current_bus, - pci_devfn, PCI_VENDOR_ID, &vid) !- 0) + pci_devfn,PCI_VENDOR_ID , &vid))continue ;if (vid =0xffff )continue ;
arch/sh/drivers/pci/ops-sh7786.c +2 -2
@@ -101,7 +101,7 @@ static int sh7786_pcie_read(struct pci_bus *bus, unsigned int devfn,raw_spin_lock_irqsave (&pci_config_lock, flags); ret =sh7786_pcie_config_access (PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=0 ) { +if (ret) { *val =0xffffffff ; goto out; }
@@ -137,7 +137,7 @@ static int sh7786_pcie_write(struct pci_bus *bus, unsigned int devfn,raw_spin_lock_irqsave (&pci_config_lock, flags); ret =sh7786_pcie_config_access (PCI_ACCESS_READ , bus, devfn, where, &data); -if (ret !=0 ) +if (ret) goto out; dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x "
arch/sh/drivers/pci/pci.c +1 -1
@@ -204,7 +204,7 @@ pcibios_bus_report_status_early(struct pci_channel *hose,continue ; ret =early_read_config_word (hose, top_bus, current_bus, pci_devfn,PCI_STATUS , &status); -if (ret !=0 ) +if (ret)continue ;if (status =0xffff )continue ;
Signature · 1 line
2.18.2
RFC PATCH 26/35 powerpc: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/powerpc/kernel/rtas_pci.c | 4 ++-- arch/powerpc/platforms/4xx/pci.c | 4 ++-- arch/powerpc/platforms/52xx/efika.c | 4 ++-- arch/powerpc/platforms/52xx/mpc52xx_pci.c | 4 ++-- arch/powerpc/platforms/82xx/pq2.c | 2 +- arch/powerpc/platforms/85xx/mpc85xx_cds.c | 2 +- arch/powerpc/platforms/85xx/mpc85xx_ds.c | 2 +- arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 2 +- arch/powerpc/platforms/chrp/pci.c | 8 ++++---- arch/powerpc/platforms/embedded6xx/holly.c | 2 +- .../platforms/embedded6xx/mpc7448_hpc2.c | 2 +- arch/powerpc/platforms/fsl_uli1575.c | 2 +- arch/powerpc/platforms/maple/pci.c | 18 +++++++++--------- arch/powerpc/platforms/pasemi/pci.c | 6 +++--- arch/powerpc/platforms/powermac/pci.c | 8 ++++---- arch/powerpc/platforms/powernv/eeh-powernv.c | 4 ++-- arch/powerpc/platforms/powernv/pci.c | 4 ++-- arch/powerpc/platforms/pseries/eeh_pseries.c | 4 ++-- arch/powerpc/sysdev/fsl_pci.c | 2 +- arch/powerpc/sysdev/indirect_pci.c | 4 ++-- arch/powerpc/sysdev/tsi108_pci.c | 4 ++-- 21 files changed, 46 insertions(+), 46 deletions(-)
arch/powerpc/kernel/rtas_pci.c +2 -2
@@ -71,7 +71,7 @@ int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)if (ret)return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rtas_pci_read_config(struct pci_bus *bus,
@@ -121,7 +121,7 @@ int rtas_write_config(struct pci_dn *pdn, int where, int size, u32 val)if (ret)return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rtas_pci_write_config(struct pci_bus *bus,
arch/powerpc/platforms/4xx/pci.c +2 -2
@@ -1652,7 +1652,7 @@ static int ppc4xx_pciex_read_config(struct pci_bus *bus, unsigned int devfn,dcr_write (port->dcrs,DCRO_PEGPL_CFG , gpl_cfg); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int ppc4xx_pciex_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -1696,7 +1696,7 @@ static int ppc4xx_pciex_write_config(struct pci_bus *bus, unsigned int devfn,dcr_write (port->dcrs,DCRO_PEGPL_CFG , gpl_cfg); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops ppc4xx_pciex_pci_ops =
arch/powerpc/platforms/52xx/efika.c +2 -2
@@ -44,7 +44,7 @@ static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset, rval =rtas_call (rtas_token ("read-pci-config" ),2 ,2 , &ret, addr, len); *val = ret; -return rval ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return rval ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int rtas_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -58,7 +58,7 @@ static int rtas_write_config(struct pci_bus *bus, unsigned int devfn, rval =rtas_call (rtas_token ("write-pci-config" ),3 ,1 ,NULL , addr, len, val); -return rval ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return rval ?PCIBIOS_DEVICE_NOT_FOUND :0 ; }static struct pci_ops rtas_pci_ops = {
arch/powerpc/platforms/52xx/mpc52xx_pci.c +2 -2
@@ -157,7 +157,7 @@ mpc52xx_pci_read_config(struct pci_bus *bus, unsigned int devfn,out_be32 (hose->cfg_addr,0 );mb (); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -221,7 +221,7 @@ mpc52xx_pci_write_config(struct pci_bus *bus, unsigned int devfn,out_be32 (hose->cfg_addr,0 );mb (); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops mpc52xx_pci_ops = {
arch/powerpc/platforms/82xx/pq2.c +1 -1
@@ -40,7 +40,7 @@ static int pq2_pci_exclude_device(struct pci_controller *hose,if (bus ==0 &&PCI_SLOT (devfn) ==0 )return PCIBIOS_DEVICE_NOT_FOUND ;else -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static void __init pq2_pci_add_bridge (struct device_node *np)
arch/powerpc/platforms/85xx/mpc85xx_cds.c +1 -1
@@ -76,7 +76,7 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,if ((bus ==0 ) && (PCI_SLOT (devfn) ==ARCADIA_2ND_BRIDGE_IDSEL ))return PCIBIOS_DEVICE_NOT_FOUND ;else -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int mpc85xx_cds_restart(struct notifier_block *this,
arch/powerpc/platforms/85xx/mpc85xx_ds.c +1 -1
@@ -118,7 +118,7 @@ static int mpc85xx_exclude_device(struct pci_controller *hose,if (hose->dn == pci_with_uli)return uli_exclude_device (hose, bus, devfn); - return PCIBIOS_SUCCESSFUL; + return 0; }#endif /* CONFIG_PCI */
arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +1 -1
@@ -49,7 +49,7 @@ static int mpc86xx_exclude_device(struct pci_controller *hose,if (hose->dn == fsl_pci_primary)return uli_exclude_device (hose, bus, devfn); - return PCIBIOS_SUCCESSFUL; + return 0; }#endif /* CONFIG_PCI */
arch/powerpc/platforms/chrp/pci.c +4 -4
@@ -55,7 +55,7 @@ static int gg2_read_config(struct pci_bus *bus, unsigned int devfn, int off, *val =in_le32 (cfg_data);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int gg2_write_config(struct pci_bus *bus, unsigned int devfn, int off,
@@ -82,7 +82,7 @@ static int gg2_write_config(struct pci_bus *bus, unsigned int devfn, int off,out_le32 (cfg_data, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops gg2_pci_ops =
@@ -106,7 +106,7 @@ static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset, rval =rtas_call (rtas_token ("read-pci-config" ),2 ,2 , &ret, addr, len); *val = ret; -return rval?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return rval ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int rtas_write_config(struct pci_bus *bus, unsigned int devfn, int offset,
@@ -120,7 +120,7 @@ static int rtas_write_config(struct pci_bus *bus, unsigned int devfn, int offset rval =rtas_call (rtas_token ("write-pci-config" ),3 ,1 ,NULL , addr, len, val); -return rval?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return rval ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static struct pci_ops rtas_pci_ops =
arch/powerpc/platforms/embedded6xx/holly.c +1 -1
@@ -47,7 +47,7 @@ static int holly_exclude_device(struct pci_controller *hose, u_char bus,if (bus ==0 &&PCI_SLOT (devfn) ==0 )return PCIBIOS_DEVICE_NOT_FOUND ;else -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static void holly_remap_bridge (void )
arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c +1 -1
@@ -55,7 +55,7 @@ int mpc7448_hpc2_exclude_device(struct pci_controller *hose,if (bus ==0 &&PCI_SLOT (devfn) ==0 )return PCIBIOS_DEVICE_NOT_FOUND ;else -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static void __init mpc7448_hpc2_setup_arch (void )
arch/powerpc/platforms/fsl_uli1575.c +1 -1
@@ -353,5 +353,5 @@ int uli_exclude_device(struct pci_controller *hose,return PCIBIOS_DEVICE_NOT_FOUND ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
arch/powerpc/platforms/maple/pci.c +9 -9
@@ -142,7 +142,7 @@ static int u3_agp_read_config(struct pci_bus *bus, unsigned int devfn, *val =in_le32 (addr);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int u3_agp_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -173,7 +173,7 @@ static int u3_agp_write_config(struct pci_bus *bus, unsigned int devfn,out_le32 (addr, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops u3_agp_pci_ops =
@@ -223,7 +223,7 @@ static int u3_ht_root_read_config(struct pci_controller *hose, u8 offset,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int u3_ht_root_write_config(struct pci_controller *hose, u8 offset,
@@ -234,7 +234,7 @@ static int u3_ht_root_write_config(struct pci_controller *hose, u8 offset, addr = hose->cfg_addr + ((offset & ~3 ) <<2 ) + (4 - len - (offset &3 ));if (offset >=PCI_BASE_ADDRESS_0 && offset <PCI_CAPABILITY_LIST ) -return PCIBIOS_SUCCESSFUL ; +return 0 ;switch (len) {case 1 :
@@ -248,7 +248,7 @@ static int u3_ht_root_write_config(struct pci_controller *hose, u8 offset,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -286,7 +286,7 @@ static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, *val =in_le32 (addr);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -323,7 +323,7 @@ static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,out_le32 (addr, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops u3_ht_pci_ops =
@@ -397,7 +397,7 @@ static int u4_pcie_read_config(struct pci_bus *bus, unsigned int devfn, *val =in_le32 (addr);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int u4_pcie_write_config (struct pci_bus *bus,unsigned int devfn,int offset,int len,u32 val)
@@ -428,7 +428,7 @@ static int u4_pcie_write_config(struct pci_bus *bus, unsigned int devfn,out_le32 (addr, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops u4_pcie_pci_ops =
arch/powerpc/platforms/pasemi/pci.c +3 -3
@@ -166,7 +166,7 @@ static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn,return PCIBIOS_BAD_REGISTER_NUMBER ;if (workaround_5945 (bus, devfn, offset, len, val)) -return PCIBIOS_SUCCESSFUL ; +return 0 ; addr =pa_pxp_cfg_addr (hose, bus->number, devfn, offset);
@@ -188,7 +188,7 @@ static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -223,7 +223,7 @@ static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn,out_le32 (addr, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops pa_pxp_ops = {
arch/powerpc/platforms/powermac/pci.c +4 -4
@@ -307,7 +307,7 @@ static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,default : *val =0xfffffffful ;break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ;default :return PCIBIOS_DEVICE_NOT_FOUND ; }
@@ -327,7 +327,7 @@ static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, *val = swap ?in_le32 (addr) :in_be32 (addr);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -350,7 +350,7 @@ static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,case 0 :break ;case 1 : -return PCIBIOS_SUCCESSFUL ; +return 0 ;default :return PCIBIOS_DEVICE_NOT_FOUND ; }
@@ -370,7 +370,7 @@ static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn, swap ?out_le32 (addr, val) :out_be32 (addr, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops u3_ht_pci_ops =
arch/powerpc/platforms/powernv/eeh-powernv.c +2 -2
@@ -318,7 +318,7 @@ static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)if (!edev || !edev->pcie_cap)return 0 ; -if (pnv_pci_cfg_read (pdn, pos,4 , &header) !=PCIBIOS_SUCCESSFUL ) +if (pnv_pci_cfg_read (pdn, pos,4 , &header) !=0 )return 0 ;else if (!header)return 0 ;
@@ -331,7 +331,7 @@ static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)if (pos <256 )break ; -if (pnv_pci_cfg_read (pdn, pos,4 , &header) !=PCIBIOS_SUCCESSFUL ) +if (pnv_pci_cfg_read (pdn, pos,4 , &header) !=0 )break ; }
arch/powerpc/platforms/powernv/pci.c +2 -2
@@ -685,7 +685,7 @@ int pnv_pci_cfg_read(struct pci_dn *pdn,pr_devel ("%s: bus: %x devfn: %x +%x/%x -> %08x\n" , __func__, pdn->busno, pdn->devfn, where, size, *val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } int pnv_pci_cfg_write(struct pci_dn *pdn,
@@ -710,7 +710,7 @@ int pnv_pci_cfg_write(struct pci_dn *pdn,return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }#if CONFIG_EEH
arch/powerpc/platforms/pseries/eeh_pseries.c +2 -2
@@ -200,7 +200,7 @@ static int pseries_eeh_find_ecap(struct pci_dn *pdn, int cap)if (!edev || !edev->pcie_cap)return 0 ; -if (rtas_read_config (pdn, pos,4 , &header) !=PCIBIOS_SUCCESSFUL ) +if (rtas_read_config (pdn, pos,4 , &header) !=0 )return 0 ;else if (!header)return 0 ;
@@ -213,7 +213,7 @@ static int pseries_eeh_find_ecap(struct pci_dn *pdn, int cap)if (pos <256 )break ; -if (rtas_read_config (pdn, pos,4 , &header) !=PCIBIOS_SUCCESSFUL ) +if (rtas_read_config (pdn, pos,4 , &header) !=0 )break ; }
arch/powerpc/sysdev/fsl_pci.c +1 -1
@@ -697,7 +697,7 @@ static int mpc83xx_pcie_exclude_device(struct pci_bus *bus, unsigned int devfn)return PCIBIOS_DEVICE_NOT_FOUND ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static void __iomem *mpc83xx_pcie_remap_cfg(struct pci_bus *bus,
arch/powerpc/sysdev/indirect_pci.c +2 -2
@@ -70,7 +70,7 @@ int __indirect_read_config(struct pci_controller *hose, *val =in_le32 (cfg_data);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } int indirect_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -148,7 +148,7 @@ int indirect_write_config(struct pci_bus *bus, unsigned int devfn,out_le32 (cfg_data, val);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static struct pci_ops indirect_pci_ops =
arch/powerpc/sysdev/tsi108_pci.c +2 -2
@@ -78,7 +78,7 @@ tsi108_direct_write_config(struct pci_bus *bus, unsigned int devfunc,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }void tsi108_clear_pci_error (u32 pci_cfg_base)
@@ -167,7 +167,7 @@ tsi108_direct_read_config(struct pci_bus *bus, unsigned int devfn, int offset, printk("data = 0x%x\n", *val); }#endif -return PCIBIOS_SUCCESSFUL ; +return 0 ; }void tsi108_clear_pci_cfg_error (void )
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 27/35 powerpc: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 26/35
arch/powerpc/platforms/powernv/eeh-powernv.c | 4 ++-- arch/powerpc/platforms/pseries/eeh_pseries.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/eeh-powernv.c +2 -2
@@ -318,7 +318,7 @@ static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)if (!edev || !edev->pcie_cap)return 0 ; -if (pnv_pci_cfg_read (pdn, pos,4 , &header) !=0 ) +if (pnv_pci_cfg_read (pdn, pos,4 , &header))return 0 ;else if (!header)return 0 ;
@@ -331,7 +331,7 @@ static int pnv_eeh_find_ecap(struct pci_dn *pdn, int cap)if (pos <256 )break ; -if (pnv_pci_cfg_read (pdn, pos,4 , &header) !=0 ) +if (pnv_pci_cfg_read (pdn, pos,4 , &header))break ; }
arch/powerpc/platforms/pseries/eeh_pseries.c +2 -2
@@ -200,7 +200,7 @@ static int pseries_eeh_find_ecap(struct pci_dn *pdn, int cap)if (!edev || !edev->pcie_cap)return 0 ; -if (rtas_read_config (pdn, pos,4 , &header) !=0 ) +if (rtas_read_config (pdn, pos,4 , &header))return 0 ;else if (!header)return 0 ;
@@ -213,7 +213,7 @@ static int pseries_eeh_find_ecap(struct pci_dn *pdn, int cap)if (pos <256 )break ; -if (rtas_read_config (pdn, pos,4 , &header) !=0 ) +if (rtas_read_config (pdn, pos,4 , &header))break ; }
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 28/35 mips: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/mips/pci/fixup-ath79.c | 2 +- arch/mips/pci/ops-bcm63xx.c | 14 +++++++------- arch/mips/pci/ops-bonito64.c | 4 ++-- arch/mips/pci/ops-gt64xxx_pci0.c | 4 ++-- arch/mips/pci/ops-lantiq.c | 4 ++-- arch/mips/pci/ops-loongson2.c | 4 ++-- arch/mips/pci/ops-mace.c | 4 ++-- arch/mips/pci/ops-msc.c | 4 ++-- arch/mips/pci/ops-rc32434.c | 6 +++--- arch/mips/pci/ops-sni.c | 4 ++-- arch/mips/pci/ops-tx3927.c | 2 +- arch/mips/pci/ops-tx4927.c | 2 +- arch/mips/pci/ops-vr41xx.c | 4 ++-- arch/mips/pci/pci-alchemy.c | 6 +++--- arch/mips/pci/pci-ar2315.c | 4 ++-- arch/mips/pci/pci-ar71xx.c | 4 ++-- arch/mips/pci/pci-ar724x.c | 6 +++--- arch/mips/pci/pci-bcm1480.c | 4 ++-- arch/mips/pci/pci-bcm1480ht.c | 4 ++-- arch/mips/pci/pci-mt7620.c | 4 ++-- arch/mips/pci/pci-octeon.c | 12 ++++++------ arch/mips/pci/pci-rt2880.c | 4 ++-- arch/mips/pci/pci-rt3883.c | 4 ++-- arch/mips/pci/pci-sb1250.c | 4 ++-- arch/mips/pci/pci-virtio-guest.c | 4 ++-- arch/mips/pci/pci-xlp.c | 4 ++-- arch/mips/pci/pci-xlr.c | 4 ++-- arch/mips/pci/pci-xtalk-bridge.c | 14 +++++++------- arch/mips/pci/pcie-octeon.c | 4 ++-- arch/mips/txx9/generic/pci.c | 4 ++-- 30 files changed, 74 insertions(+), 74 deletions(-)
arch/mips/pci/fixup-ath79.c +1 -1
@@ -9,7 +9,7 @@int pcibios_plat_dev_init (struct pci_dev *dev) { -return PCIBIOS_SUCCESSFUL ; +return 0 ; }int pcibios_map_irq (const struct pci_dev *dev,u8 slot,u8 pin)
arch/mips/pci/ops-bcm63xx.c +7 -7
@@ -115,7 +115,7 @@ static int bcm63xx_do_cfg_read(int type, unsigned int busn, *val =postprocess_read (data, where, size); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int bcm63xx_do_cfg_write(int type, unsigned int busn,
@@ -141,7 +141,7 @@ static int bcm63xx_do_cfg_write(int type, unsigned int busn,/* restore IO space normal behaviour */ bcm_mpi_writel (0 ,MPI_L2PCFG_REG ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int bcm63xx_pci_read(struct pci_bus *bus, unsigned int devfn,
@@ -282,7 +282,7 @@ static int fake_cb_bridge_read(int where, int size, u32 *val) } *val =postprocess_read (data, where, size); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }/*
@@ -295,7 +295,7 @@ static int fake_cb_bridge_write(int where, int size, u32 val)int ret; ret =fake_cb_bridge_read ((where & ~0x3 ),4 , &data); -if (ret !=PCIBIOS_SUCCESSFUL ) +if (ret !=0 )return ret; data =preprocess_write (data, val, where, size);
@@ -356,7 +356,7 @@ static int fake_cb_bridge_write(int where, int size, u32 val)break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int bcm63xx_cb_read(struct pci_bus *bus, unsigned int devfn,
@@ -496,7 +496,7 @@ static int bcm63xx_pcie_read(struct pci_bus *bus, unsigned int devfn, *val =postprocess_read (data, where, size); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
@@ -518,7 +518,7 @@ static int bcm63xx_pcie_write(struct pci_bus *bus, unsigned int devfn, data =preprocess_write (data, val, where, size);bcm_pcie_writel (data, reg); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
arch/mips/pci/ops-bonito64.c +2 -2
@@ -107,7 +107,7 @@ static int bonito64_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int bonito64_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -139,7 +139,7 @@ static int bonito64_pcibios_write(struct pci_bus *bus, unsigned int devfn, &data))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops bonito64_pci_ops = {
arch/mips/pci/ops-gt64xxx_pci0.c +2 -2
@@ -104,7 +104,7 @@ static int gt64xxx_pci0_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int gt64xxx_pci0_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -131,7 +131,7 @@ static int gt64xxx_pci0_pcibios_write(struct pci_bus *bus, unsigned int devfn, where, &data))return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops gt64xxx_pci0_ops = {
arch/mips/pci/ops-lantiq.c +2 -2
@@ -83,7 +83,7 @@ int ltq_pci_read_config_dword(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } int ltq_pci_write_config_dword(struct pci_bus *bus, unsigned int devfn,
@@ -109,5 +109,5 @@ int ltq_pci_write_config_dword(struct pci_bus *bus, unsigned int devfn,if (ltq_pci_config_access (PCI_ACCESS_WRITE , bus, devfn, where, &data))return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
arch/mips/pci/ops-loongson2.c +2 -2
@@ -136,7 +136,7 @@ static int loongson_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int loongson_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -168,7 +168,7 @@ static int loongson_pcibios_write(struct pci_bus *bus, unsigned int devfn, &data))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops loongson_pci_ops = {
arch/mips/pci/ops-mace.c +2 -2
@@ -69,7 +69,7 @@ mace_pci_read_config(struct pci_bus *bus, unsigned int devfn,DPRINTK ("read%d: reg=%08x,val=%02x\n" , size *8 , reg, *val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -91,7 +91,7 @@ mace_pci_write_config(struct pci_bus *bus, unsigned int devfn,DPRINTK ("write%d: reg=%08x,val=%02x\n" , size *8 , reg, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops mace_pci_ops = {
arch/mips/pci/ops-msc.c +2 -2
@@ -93,7 +93,7 @@ static int msc_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int msc_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -125,7 +125,7 @@ static int msc_pcibios_write(struct pci_bus *bus, unsigned int devfn, &data))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops msc_pci_ops = {
arch/mips/pci/ops-rc32434.c +3 -3
@@ -140,7 +140,7 @@ write_config_byte(struct pci_bus *bus, unsigned int devfn, int where,if (config_access (PCI_ACCESS_WRITE , bus, devfn, where, &data))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
@@ -160,7 +160,7 @@ write_config_word(struct pci_bus *bus, unsigned int devfn, int where,return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
@@ -171,7 +171,7 @@ write_config_dword(struct pci_bus *bus, unsigned int devfn, int where,if (config_access (PCI_ACCESS_WRITE , bus, devfn, where, &val))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pci_config_read(struct pci_bus *bus, unsigned int devfn,
arch/mips/pci/ops-sni.c +2 -2
@@ -34,7 +34,7 @@ static int set_config_address(unsigned int busno, unsigned int devfn, int reg) ((devfn &0xff ) <<8 ) | (reg &0xfc ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pcimt_read(struct pci_bus *bus, unsigned int devfn, int reg,
@@ -94,7 +94,7 @@ static int pcit_set_config_address(unsigned int busno, unsigned int devfn, int rreturn PCIBIOS_BAD_REGISTER_NUMBER ;outl ((1 <<31 ) | ((busno &0xff ) <<16 ) | ((devfn &0xff ) <<8 ) | (reg &0xfc ),0xcf8 ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pcit_read(struct pci_bus *bus, unsigned int devfn, int reg,
arch/mips/pci/ops-tx3927.c +1 -1
@@ -70,7 +70,7 @@ static inline int check_abort(void)iob ();return PCIBIOS_DEVICE_NOT_FOUND ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int tx3927_pci_read_config(struct pci_bus *bus, unsigned int devfn,
arch/mips/pci/ops-tx4927.c +1 -1
@@ -74,7 +74,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where,static int check_abort (struct tx4927_pcic_reg __iomem *pcicptr) { -int code =PCIBIOS_SUCCESSFUL ; +int code =0 ;/* wait write cycle completion before checking error status */ while (__raw_readl (&pcicptr->pcicstatus) &TX4927_PCIC_PCICSTATUS_IWB )
arch/mips/pci/ops-vr41xx.c +2 -2
@@ -70,7 +70,7 @@ static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
@@ -104,7 +104,7 @@ static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,writel (data,PCICONFDREG ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops vr41xx_pci_ops = {
arch/mips/pci/pci-alchemy.c +3 -3
@@ -103,7 +103,7 @@ static int config_access(unsigned char access_type, struct pci_bus *bus,unsigned int device =PCI_SLOT (dev_fn);unsigned int function =PCI_FUNC (dev_fn);unsigned long offset, status, cfg_base, flags, entryLo0, entryLo1, r; -int error =PCIBIOS_SUCCESSFUL ; +int error =0 ;if (device >19 ) { *data =0xffffffff ;
@@ -231,7 +231,7 @@ static int write_config_byte(struct pci_bus *bus, unsigned int devfn,if (config_access (PCI_ACCESS_WRITE , bus, devfn, where, &data))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int write_config_word(struct pci_bus *bus, unsigned int devfn,
@@ -248,7 +248,7 @@ static int write_config_word(struct pci_bus *bus, unsigned int devfn,if (config_access (PCI_ACCESS_WRITE , bus, devfn, where, &data))return -1 ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int write_config_dword(struct pci_bus *bus, unsigned int devfn,
arch/mips/pci/pci-ar2315.c +2 -2
@@ -260,7 +260,7 @@ static int ar2315_pci_cfg_access(struct ar2315_pci_ctrl *apc, unsigned devfn, 0);return isr &AR2315_PCI_INT_ABORT ?PCIBIOS_DEVICE_NOT_FOUND : -PCIBIOS_SUCCESSFUL ; +0 ; } static inline int ar2315_pci_local_cfg_rd(struct ar2315_pci_ctrl *apc,
@@ -311,7 +311,7 @@ static int ar2315_pci_host_setup(struct ar2315_pci_ctrl *apc)u32 id; res =ar2315_pci_local_cfg_rd (apc, devfn,PCI_VENDOR_ID , &id); -if (res !=PCIBIOS_SUCCESSFUL || id !=AR2315_PCI_HOST_DEVID ) +if (res !=0 || id !=AR2315_PCI_HOST_DEVID )return -ENODEV ;/* Program MBARs */
arch/mips/pci/pci-ar71xx.c +2 -2
@@ -182,7 +182,7 @@ static int ar71xx_pci_read_config(struct pci_bus *bus, unsigned int devfn,int err;int ret; - ret =PCIBIOS_SUCCESSFUL ; + ret =0 ; data = ~0 ; err = ar71xx_pci_set_cfgaddr(bus, devfn, where, size,
@@ -206,7 +206,7 @@ static int ar71xx_pci_write_config(struct pci_bus *bus, unsigned int devfn,int ret; value = value << (8 * (where &3 )); - ret =PCIBIOS_SUCCESSFUL ; + ret =0 ; err =ar71xx_pci_set_cfgaddr (bus, devfn, where, size,AR71XX_PCI_CFG_CMD_WRITE );
arch/mips/pci/pci-ar724x.c +3 -3
@@ -107,7 +107,7 @@ static int ar724x_pci_local_write(struct ar724x_pci_controller *apc,/* flush write */ __raw_readl (base + (where & ~3 )); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where,
@@ -154,7 +154,7 @@ static int ar724x_pci_read(struct pci_bus *bus, unsigned int devfn, int where, *value = data; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,
@@ -218,7 +218,7 @@ static int ar724x_pci_write(struct pci_bus *bus, unsigned int devfn, int where,/* flush write */ __raw_readl (base + (where & ~3 )); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops ar724x_pci_ops = {
arch/mips/pci/pci-bcm1480.c +2 -2
@@ -126,7 +126,7 @@ static int bcm1480_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int bcm1480_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -156,7 +156,7 @@ static int bcm1480_pcibios_write(struct pci_bus *bus, unsigned int devfn,WRITECFG32 (cfgaddr, data); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops bcm1480_pci_ops = {
arch/mips/pci/pci-bcm1480ht.c +2 -2
@@ -115,7 +115,7 @@ static int bcm1480ht_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int bcm1480ht_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -145,7 +145,7 @@ static int bcm1480ht_pcibios_write(struct pci_bus *bus, unsigned int devfn,WRITECFG32 (cfgaddr, data); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int bcm1480ht_pcibios_get_busno (void )
arch/mips/pci/pci-mt7620.c +2 -2
@@ -162,7 +162,7 @@ static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
@@ -198,7 +198,7 @@ static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,bridge_w32 (data,RALINK_PCI_CONFIG_DATA_VIRT_REG ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops mt7620_pci_ops = {
arch/mips/pci/pci-octeon.c +6 -6
@@ -273,13 +273,13 @@ static int octeon_read_config(struct pci_bus *bus, unsigned int devfn,switch (size) {case 4 : *val =le32_to_cpu (cvmx_read64_uint32 (pci_addr.u64)); -return PCIBIOS_SUCCESSFUL ; +return 0 ;case 2 : *val =le16_to_cpu (cvmx_read64_uint16 (pci_addr.u64)); -return PCIBIOS_SUCCESSFUL ; +return 0 ;case 1 : *val =cvmx_read64_uint8 (pci_addr.u64); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }return PCIBIOS_FUNC_NOT_SUPPORTED ; }
@@ -307,13 +307,13 @@ static int octeon_write_config(struct pci_bus *bus, unsigned int devfn,switch (size) {case 4 :cvmx_write64_uint32 (pci_addr.u64,cpu_to_le32 (val)); -return PCIBIOS_SUCCESSFUL ; +return 0 ;case 2 :cvmx_write64_uint16 (pci_addr.u64,cpu_to_le16 (val)); -return PCIBIOS_SUCCESSFUL ; +return 0 ;case 1 :cvmx_write64_uint8 (pci_addr.u64, val); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }return PCIBIOS_FUNC_NOT_SUPPORTED ; }
arch/mips/pci/pci-rt2880.c +2 -2
@@ -87,7 +87,7 @@ static int rt2880_pci_config_read(struct pci_bus *bus, unsigned int devfn,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rt2880_pci_config_write(struct pci_bus *bus, unsigned int devfn,
@@ -121,7 +121,7 @@ static int rt2880_pci_config_write(struct pci_bus *bus, unsigned int devfn,rt2880_pci_reg_write (data,RT2880_PCI_REG_CONFIG_DATA );spin_unlock_irqrestore (&rt2880_pci_lock, flags); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops rt2880_pci_ops = {
arch/mips/pci/pci-rt3883.c +2 -2
@@ -256,7 +256,7 @@ static int rt3883_pci_config_read(struct pci_bus *bus, unsigned int devfn,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int rt3883_pci_config_write(struct pci_bus *bus, unsigned int devfn,
@@ -294,7 +294,7 @@ static int rt3883_pci_config_write(struct pci_bus *bus, unsigned int devfn,rt3883_pci_w32 (rpc, data,RT3883_PCI_REG_CFGDATA ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops rt3883_pci_ops = {
arch/mips/pci/pci-sb1250.c +2 -2
@@ -135,7 +135,7 @@ static int sb1250_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int sb1250_pcibios_write(struct pci_bus *bus, unsigned int devfn,
@@ -165,7 +165,7 @@ static int sb1250_pcibios_write(struct pci_bus *bus, unsigned int devfn,WRITECFG32 (cfgaddr, data); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops sb1250_pci_ops = {
arch/mips/pci/pci-virtio-guest.c +2 -2
@@ -70,7 +70,7 @@ static int pci_virtio_guest_write_config(struct pci_bus *bus,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pci_virtio_guest_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -89,7 +89,7 @@ static int pci_virtio_guest_read_config(struct pci_bus *bus, unsigned int devfn, *val =inl (PCI_CONFIG_DATA );break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops pci_virtio_guest_ops = {
arch/mips/pci/pci-xlp.c +2 -2
@@ -118,7 +118,7 @@ static int nlm_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
@@ -145,7 +145,7 @@ static int nlm_pcibios_write(struct pci_bus *bus, unsigned int devfn,pci_cfg_write_32bit (bus, devfn, where, data); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops nlm_pci_ops = {
arch/mips/pci/pci-xlr.c +2 -2
@@ -100,7 +100,7 @@ static int nlm_pcibios_read(struct pci_bus *bus, unsigned int devfn,else *val = data; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
@@ -127,7 +127,7 @@ static int nlm_pcibios_write(struct pci_bus *bus, unsigned int devfn,pci_cfg_write_32bit (bus, devfn, where, data); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops nlm_pci_ops = {
arch/mips/pci/pci-xtalk-bridge.c +7 -7
@@ -67,7 +67,7 @@ static int ioc3_cfg_rd(void *addr, int where, int size, u32 *value, u32 sid) mask =0xffffffffU >> ((4 - size) <<3 ); *value = (cf >> shift) & mask; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int ioc3_cfg_wr (void *addr,int where,int size,u32 value)
@@ -75,7 +75,7 @@ static int ioc3_cfg_wr(void *addr, int where, int size, u32 value)u32 cf, shift, mask, smask;if ((where >=0x14 && where <0x40 ) || (where >=0x48 )) -return PCIBIOS_SUCCESSFUL ; +return 0 ;if (get_dbe (cf, (u32 *)addr))return PCIBIOS_DEVICE_NOT_FOUND ;
@@ -88,7 +88,7 @@ static int ioc3_cfg_wr(void *addr, int where, int size, u32 value)if (put_dbe (cf, (u32 *)addr))return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static void bridge_disable_swapping (struct pci_dev *dev)
@@ -149,7 +149,7 @@ static int pci_conf0_read_config(struct pci_bus *bus, unsigned int devfn,else res =get_dbe (*value, (u32 *)addr); -return res ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return res ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -188,7 +188,7 @@ static int pci_conf1_read_config(struct pci_bus *bus, unsigned int devfn,else res =get_dbe (*value, (u32 *)addr); -return res ?PCIBIOS_DEVICE_NOT_FOUND :PCIBIOS_SUCCESSFUL ; +return res ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static int pci_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -236,7 +236,7 @@ static int pci_conf0_write_config(struct pci_bus *bus, unsigned int devfn,if (res)return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,
@@ -277,7 +277,7 @@ static int pci_conf1_write_config(struct pci_bus *bus, unsigned int devfn,if (res)return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int pci_write_config(struct pci_bus *bus, unsigned int devfn,
arch/mips/pci/pcie-octeon.c +2 -2
@@ -1703,7 +1703,7 @@ static int octeon_pcie_read_config(unsigned int pcie_port, struct pci_bus *bus,if (OCTEON_IS_MODEL (OCTEON_CN56XX_PASS1 ) ||OCTEON_IS_MODEL (OCTEON_CN56XX_PASS1_1 ))write_c0_cvmmemctl (cvmmemctl_save.u64); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int octeon_pcie0_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -1759,7 +1759,7 @@ static int octeon_pcie_write_config(unsigned int pcie_port, struct pci_bus *bus,default :return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int octeon_pcie0_write_config(struct pci_bus *bus, unsigned int devfn,
arch/mips/txx9/generic/pci.c +2 -2
@@ -62,7 +62,7 @@ int __init txx9_pci66_check(struct pci_controller *hose, int top_bus,continue ;if (early_read_config_word (hose, top_bus, current_bus, pci_devfn,PCI_VENDOR_ID , &vid) != -PCIBIOS_SUCCESSFUL ) +0 )continue ;if (vid ==0xffff )continue ;
@@ -346,7 +346,7 @@ static void final_fixup(struct pci_dev *dev)unsigned char bist;/* Do build-in self test */ -if (pci_read_config_byte (dev,PCI_BIST , &bist) ==PCIBIOS_SUCCESSFUL && +if (pci_read_config_byte (dev,PCI_BIST , &bist) ==0 && (bist &PCI_BIST_CAPABLE )) {unsigned long timeout;pci_set_power_state (dev,PCI_D0 );
Signature · 1 line
2.18.2
RFC PATCH 29/35 mips: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 28/35
arch/mips/pci/ops-bcm63xx.c | 2 +- arch/mips/pci/pci-ar2315.c | 5 ++--- arch/mips/txx9/generic/pci.c | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-)
arch/mips/pci/ops-bcm63xx.c +1 -1
@@ -295,7 +295,7 @@ static int fake_cb_bridge_write(int where, int size, u32 val)int ret; ret =fake_cb_bridge_read ((where & ~0x3 ),4 , &data); -if (ret !=0 ) +if (ret)return ret; data =preprocess_write (data, val, where, size);
arch/mips/pci/pci-ar2315.c +2 -3
@@ -259,8 +259,7 @@ static int ar2315_pci_cfg_access(struct ar2315_pci_ctrl *apc, unsigned devfn,ar2315_pci_reg_mask (apc,AR2315_PCI_MISC_CONFIG ,AR2315_PCIMISC_CFG_SEL ,0 ); -return isr &AR2315_PCI_INT_ABORT ?PCIBIOS_DEVICE_NOT_FOUND : -0 ; +return isr &AR2315_PCI_INT_ABORT ?PCIBIOS_DEVICE_NOT_FOUND :0 ; } static inline int ar2315_pci_local_cfg_rd(struct ar2315_pci_ctrl *apc,
@@ -311,7 +310,7 @@ static int ar2315_pci_host_setup(struct ar2315_pci_ctrl *apc)u32 id; res =ar2315_pci_local_cfg_rd (apc, devfn,PCI_VENDOR_ID , &id); -if (res !=0 || id !=AR2315_PCI_HOST_DEVID ) +if (res || id !=AR2315_PCI_HOST_DEVID )return -ENODEV ;/* Program MBARs */
arch/mips/txx9/generic/pci.c +1 -2
@@ -61,8 +61,7 @@ int __init txx9_pci66_check(struct pci_controller *hose, int top_bus,if (PCI_FUNC (pci_devfn))continue ;if (early_read_config_word (hose, top_bus, current_bus, - pci_devfn,PCI_VENDOR_ID , &vid) != -0 ) + pci_devfn,PCI_VENDOR_ID , &vid))continue ;if (vid ==0xffff )continue ;
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 30/35 microblaze: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/microblaze/pci/indirect_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/microblaze/pci/indirect_pci.c +2 -2
@@ -65,7 +65,7 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset, *val =in_le32 (cfg_data);break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -132,7 +132,7 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops indirect_pci_ops = {
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 31/35 m68k: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/m68k/coldfire/pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/m68k/coldfire/pci.c +4 -4
@@ -64,7 +64,7 @@ static int mcf_pci_readconfig(struct pci_bus *bus, unsigned int devfn,if (bus->number ==0 ) {if (mcf_host_slot2sid[PCI_SLOT (devfn)] ==0 ) -return PCIBIOS_SUCCESSFUL ; +return 0 ; } addr =mcf_mk_pcicar (bus->number, devfn, where);
@@ -86,7 +86,7 @@ static int mcf_pci_readconfig(struct pci_bus *bus, unsigned int devfn,__raw_writel (0 ,PCICAR );__raw_readl (PCICAR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int mcf_pci_writeconfig(struct pci_bus *bus, unsigned int devfn,
@@ -96,7 +96,7 @@ static int mcf_pci_writeconfig(struct pci_bus *bus, unsigned int devfn,if (bus->number ==0 ) {if (mcf_host_slot2sid[PCI_SLOT (devfn)] ==0 ) -return PCIBIOS_SUCCESSFUL ; +return 0 ; } addr =mcf_mk_pcicar (bus->number, devfn, where);
@@ -118,7 +118,7 @@ static int mcf_pci_writeconfig(struct pci_bus *bus, unsigned int devfn,__raw_writel (0 ,PCICAR );__raw_readl (PCICAR ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static struct pci_ops mcf_pci_ops = {
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 32/35 arm/PCI: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/arm/common/it8152.c | 4 ++-- arch/arm/mach-cns3xxx/pcie.c | 2 +- arch/arm/mach-footbridge/dc21285.c | 4 ++-- arch/arm/mach-iop32x/pci.c | 6 +++--- arch/arm/mach-ixp4xx/common-pci.c | 8 ++++---- arch/arm/mach-orion5x/pci.c | 4 ++-- arch/arm/plat-orion/pcie.c | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-)
arch/arm/common/it8152.c +2 -2
@@ -186,7 +186,7 @@ static int it8152_pci_read_config(struct pci_bus *bus, *value = v; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int it8152_pci_write_config(struct pci_bus *bus,
@@ -216,7 +216,7 @@ static int it8152_pci_write_config(struct pci_bus *bus,__raw_writel ((addr + where),IT8152_PCI_CFG_ADDR );__raw_writel ((v | vtemp),IT8152_PCI_CFG_DATA ); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops it8152_ops = {
arch/arm/mach-cns3xxx/pcie.c +1 -1
@@ -92,7 +92,7 @@ static int cns3xxx_pci_read_config(struct pci_bus *bus, unsigned int devfn, ret =pci_generic_config_read (bus, devfn, where, size, val); -if (ret ==PCIBIOS_SUCCESSFUL && !bus->number && !devfn && +if (ret ==0 && !bus->number && !devfn && (where &0xffc ) ==PCI_CLASS_REVISION )/* * RC's class is 0xb, but Linux PCI driver needs 0x604
arch/arm/mach-footbridge/dc21285.c +2 -2
@@ -86,7 +86,7 @@ dc21285_read_config(struct pci_bus *bus, unsigned int devfn, int where,return -1 ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -121,7 +121,7 @@ dc21285_write_config(struct pci_bus *bus, unsigned int devfn, int where,return -1 ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops dc21285_ops = {
arch/arm/mach-iop32x/pci.c +3 -3
@@ -118,7 +118,7 @@ iop3xx_read_config(struct pci_bus *bus, unsigned int devfn, int where, *value = val; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -131,7 +131,7 @@ iop3xx_write_config(struct pci_bus *bus, unsigned int devfn, int where,if (size !=4 ) { val =iop3xx_read (addr);if (iop3xx_pci_status ()) -return PCIBIOS_SUCCESSFUL ; +return 0 ; where = (where &3 ) *8 ;
@@ -154,7 +154,7 @@ iop3xx_write_config(struct pci_bus *bus, unsigned int devfn, int where, "r" (IOP3XX_OCCAR), "r" (IOP3XX_OCCDR)); } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops iop3xx_ops = {
arch/arm/mach-ixp4xx/common-pci.c +4 -4
@@ -208,7 +208,7 @@ static int local_read_config(int where, int size, u32 *value)crp_read (where & ~3 , &data); *value = (data >> (8 *n)) & bytemask[size];pr_debug ("local_read_config read %#x\n" , *value); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int local_write_config (int where,int size,u32 value)
@@ -221,7 +221,7 @@ static int local_write_config(int where, int size, u32 value)return PCIBIOS_BAD_REGISTER_NUMBER ; data = value << (8 *n);crp_write ((where & ~3 ) | byte_enables, data); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static u32 byte_lane_enable_bits (u32 n,int size)
@@ -255,7 +255,7 @@ static int ixp4xx_pci_read_config(struct pci_bus *bus, unsigned int devfn, int w *value = (data >> (8 *n)) & bytemask[size];pr_debug ("read_config_byte read %#x\n" , *value); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int ixp4xx_pci_write_config (struct pci_bus *bus,unsigned int devfn,int where,int size,u32 value)
@@ -276,7 +276,7 @@ static int ixp4xx_pci_write_config(struct pci_bus *bus, unsigned int devfn, intif (ixp4xx_pci_write (addr, byte_enables |NP_CMD_CONFIGWRITE , data))return PCIBIOS_DEVICE_NOT_FOUND ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }struct pci_ops ixp4xx_ops = {
arch/arm/mach-orion5x/pci.c +2 -2
@@ -289,14 +289,14 @@ static int orion5x_pci_hw_rd_conf(int bus, int dev, u32 func,spin_unlock_irqrestore (&orion5x_pci_lock, flags); -return PCIBIOS_SUCCESSFUL ; +return 0 ; }static int orion5x_pci_hw_wr_conf (int bus,int dev,u32 func,u32 where,u32 size,u32 val) {unsigned long flags; -int ret =PCIBIOS_SUCCESSFUL ; +int ret =0 ;spin_lock_irqsave (&orion5x_pci_lock, flags);
arch/arm/plat-orion/pcie.c +4 -4
@@ -221,7 +221,7 @@ int orion_pcie_rd_conf(void __iomem *base, struct pci_bus *bus,else if (size ==2 ) *val = (*val >> (8 * (where &3 ))) &0xffff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } int orion_pcie_rd_conf_tlp(void __iomem *base, struct pci_bus *bus,
@@ -244,7 +244,7 @@ int orion_pcie_rd_conf_tlp(void __iomem *base, struct pci_bus *bus,else if (size ==2 ) *val = (*val >> (8 * (where &3 ))) &0xffff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; } int orion_pcie_rd_conf_wa(void __iomem *wa_base, struct pci_bus *bus,
@@ -260,13 +260,13 @@ int orion_pcie_rd_conf_wa(void __iomem *wa_base, struct pci_bus *bus,else if (size ==2 ) *val = (*val >> (8 * (where &3 ))) &0xffff ; -return PCIBIOS_SUCCESSFUL ; +return 0 ; }int orion_pcie_wr_conf (void __iomem *base,struct pci_bus *bus,u32 devfn,int where,int size,u32 val) { -int ret =PCIBIOS_SUCCESSFUL ; +int ret =0 ; writel(PCIE_CONF_BUS(bus->number) | PCIE_CONF_DEV(PCI_SLOT(devfn)) |
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 33/35 arm/PCI: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on PATCH 32/35
arch/arm/mach-cns3xxx/pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-cns3xxx/pcie.c +1 -1
@@ -92,7 +92,7 @@ static int cns3xxx_pci_read_config(struct pci_bus *bus, unsigned int devfn, ret =pci_generic_config_read (bus, devfn, where, size, val); -if (ret ==0 && !bus->number && !devfn && +if (!ret && !bus->number && !devfn && (where &0xffc ) ==PCI_CLASS_REVISION )/* * RC's class is 0xb, but Linux PCI driver needs 0x604
Signature · 6 lines
2.18.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
RFC PATCH 34/35 PCI: Change PCIBIOS_SUCCESSFUL to 0
In reply to Saheed O. BolarinwaIn reference to the PCI spec (Chapter 2), PCIBIOS* is an x86 concept. Their scope should be limited within arch/x86.
Change all PCIBIOS_SUCCESSFUL to 0
--- arch/alpha/kernel/core_apecs.c | 4 ++-- arch/alpha/kernel/core_cia.c | 4 ++-- arch/alpha/kernel/core_irongate.c | 4 ++-- arch/alpha/kernel/core_lca.c | 4 ++-- arch/alpha/kernel/core_marvel.c | 4 ++-- arch/alpha/kernel/core_mcpcia.c | 4 ++-- arch/alpha/kernel/core_polaris.c | 4 ++-- arch/alpha/kernel/core_t2.c | 4 ++-- arch/alpha/kernel/core_titan.c | 4 ++-- arch/alpha/kernel/core_tsunami.c | 4 ++-- arch/alpha/kernel/core_wildfire.c | 4 ++-- arch/alpha/kernel/sys_miata.c | 2 +- 12 files changed, 23 insertions(+), 23 deletions(-)
arch/alpha/kernel/core_apecs.c +2 -2
@@ -287,7 +287,7 @@ apecs_read_config(struct pci_bus *bus, unsigned int devfn, int where, shift = (where &3 ) *8 ; addr = (pci_addr <<5 ) + mask +APECS_CONF ; *value =conf_read (addr, type1) >> (shift); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -304,7 +304,7 @@ apecs_write_config(struct pci_bus *bus, unsigned int devfn, int where, mask = (size -1 ) *8 ; addr = (pci_addr <<5 ) + mask +APECS_CONF ;conf_write (addr, value << ((where &3 ) *8 ), type1); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops apecs_pci_ops =
arch/alpha/kernel/core_cia.c +2 -2
@@ -221,7 +221,7 @@ cia_read_config(struct pci_bus *bus, unsigned int devfn, int where, int size, shift = (where &3 ) *8 ; addr = (pci_addr <<5 ) + mask +CIA_CONF ; *value =conf_read (addr, type1) >> (shift); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -238,7 +238,7 @@ cia_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, mask = (size -1 ) *8 ; addr = (pci_addr <<5 ) + mask +CIA_CONF ;conf_write (addr, value << ((where &3 ) *8 ), type1); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops cia_pci_ops =
arch/alpha/kernel/core_irongate.c +2 -2
@@ -121,7 +121,7 @@ irongate_read_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -152,7 +152,7 @@ irongate_write_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops irongate_pci_ops =
arch/alpha/kernel/core_lca.c +2 -2
@@ -213,7 +213,7 @@ lca_read_config(struct pci_bus *bus, unsigned int devfn, int where, mask = (size -1 ) *8 ; addr = (pci_addr <<5 ) + mask +LCA_CONF ; *value =conf_read (addr) >> (shift); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -229,7 +229,7 @@ lca_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, mask = (size -1 ) *8 ; addr = (pci_addr <<5 ) + mask +LCA_CONF ;conf_write (addr, value << ((where &3 ) *8 )); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops lca_pci_ops =
arch/alpha/kernel/core_marvel.c +2 -2
@@ -561,7 +561,7 @@ marvel_read_config(struct pci_bus *bus, unsigned int devfn, int where,return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -593,7 +593,7 @@ marvel_write_config(struct pci_bus *bus, unsigned int devfn, int where,return PCIBIOS_FUNC_NOT_SUPPORTED ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops marvel_pci_ops =
arch/alpha/kernel/core_mcpcia.c +2 -2
@@ -216,7 +216,7 @@ mcpcia_read_config(struct pci_bus *bus, unsigned int devfn, int where, *value = w;break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -233,7 +233,7 @@ mcpcia_write_config(struct pci_bus *bus, unsigned int devfn, int where, addr |= (size -1 ) *8 ; value =__kernel_insql (value, where &3 );conf_write (addr, value, type1, hose); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops mcpcia_pci_ops =
arch/alpha/kernel/core_polaris.c +2 -2
@@ -102,7 +102,7 @@ polaris_read_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; }
@@ -134,7 +134,7 @@ polaris_write_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops polaris_pci_ops =
arch/alpha/kernel/core_t2.c +2 -2
@@ -296,7 +296,7 @@ t2_read_config(struct pci_bus *bus, unsigned int devfn, int where, shift = (where &3 ) *8 ; addr = (pci_addr <<5 ) + mask +T2_CONF ; *value =conf_read (addr, type1) >> (shift); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -313,7 +313,7 @@ t2_write_config(struct pci_bus *bus, unsigned int devfn, int where, int size, mask = (size -1 ) *8 ; addr = (pci_addr <<5 ) + mask +T2_CONF ;conf_write (addr, value << ((where &3 ) *8 ), type1); -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops t2_pci_ops =
arch/alpha/kernel/core_titan.c +2 -2
@@ -158,7 +158,7 @@ titan_read_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -189,7 +189,7 @@ titan_write_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops titan_pci_ops =
arch/alpha/kernel/core_tsunami.c +2 -2
@@ -134,7 +134,7 @@ tsunami_read_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -165,7 +165,7 @@ tsunami_write_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops tsunami_pci_ops =
arch/alpha/kernel/core_wildfire.c +2 -2
@@ -400,7 +400,7 @@ wildfire_read_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } static int
@@ -431,7 +431,7 @@ wildfire_write_config(struct pci_bus *bus, unsigned int devfn, int where,break ; } -return PCIBIOS_SUCCESSFUL ; +return 0 ; } struct pci_ops wildfire_pci_ops =
arch/alpha/kernel/sys_miata.c +1 -1
@@ -185,7 +185,7 @@ miata_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)if ((slot ==7 ) && (PCI_FUNC (dev->devfn) ==3 )) {u8 irq=0 ;struct pci_dev *pdev =pci_get_slot (dev->bus, dev->devfn & ~7 ); -if (pdev ==NULL ||pci_read_config_byte (pdev,0x40 ,&irq) !=PCIBIOS_SUCCESSFUL ) { +if (pdev ==NULL ||pci_read_config_byte (pdev,0x40 , &irq) !=0 ) {pci_dev_put (pdev);return -1 ; }
Signature · 1 line
2.18.2
RFC PATCH 35/35 alpha: Tidy Success/Failure checks
In reply to Saheed O. BolarinwaRemove unnecessary check for 0.
---
This patch depends on 34/35
arch/alpha/kernel/sys_miata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/alpha/kernel/sys_miata.c +1 -1
@@ -185,7 +185,7 @@ miata_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)if ((slot ==7 ) && (PCI_FUNC (dev->devfn) ==3 )) {u8 irq=0 ;struct pci_dev *pdev =pci_get_slot (dev->bus, dev->devfn & ~7 ); -if (pdev ==NULL ||pci_read_config_byte (pdev,0x40 , &irq) !=0 ) { +if (pdev ==NULL ||pci_read_config_byte (pdev,0x40 , &irq)) {pci_dev_put (pdev);return -1 ; }
Signature · 1 line
2.18.2
Arnd Bergmann
maintainerQuoted 8 lines · Saheed O. Bolarinwa
This goal of these series is to move the definition of *all* PCIBIOS* from
include/linux/pci.htoarch/x86and limit their use within there. All other tree specific definition will be left for intact. Maybe they can be renamed.PCIBIOS* is an x86 concept as defined by the PCI spec. The returned error codes of PCIBIOS* are positive values and this introduces some complexities which other archs need not incur.
I think the intention is good, but I find the series in its current form very hard
to review, in particular the way you touch some functions three times with trivial changes. Instead of
1) replace PCIBIOS_SUCCESSFUL with 0
2) drop pointless 0-comparison
3) reformat whitespace
I would suggest to combine the first two steps into one patch per subsystem and drop the third step.
Quoted 32 lines
PLAN:
1. [PATCH v0 1-36] Replace all
PCIBIOS_SUCCESSFULwith 02a. Audit all functions returning PCIBIOS_* error values directly or
indirectly and prevent possible bug coming in (2b)2b. Make all functions returning PCIBIOS_* error values call
pcibios_err_to_errno(). *This will change their behaviour, for good.*3. Clone a
pcibios_err_to_errno()intoarch/x86/pci/pcbios.cas_v2.
This handles the positive error codes directly and will not use any PCIBIOS* definitions. So calls to it have no outside dependence.4. Make all x86 codes that needs to convert to -E* values call the
cloned version -pcibios_err_to_errno_v2()5. Assign PCIBIOS_* errors values directly to generic -E* errors
6. Refactor
pcibios_err_to_errno()and mark it deprecated7. Replace all calls to
pcibios_err_to_errno()with the proper -E* valueor 0.8. Remove all PCIBIOS* definitions in
include/linux/pci.hand
pcibios_err_to_errno()too.9. Redefine all PCIBIOS* definitions with original values inside
arch/x86/pci/pcbios.c10. Redefine
pcibios_err_to_errno()insidearch/x86/pci/pcbios.c
Quoted 7 lines
11. Replace
pcibios_err_to_errno_v2()calls withpcibios_err_to_errno()12. Remove
pcibios_err_to_errno_v2()Suggested-by Bjorn Helgaas <[email protected]>Suggested-by Yicong Yang <[email protected]>Signed-off-by "Saheed O. Bolarinwa" <[email protected]>
I would hope that there is a simpler procedure to get to good code than 12 steps that rename the same things multiple times.
Maybe the work can be split up differently, with a similar end result but fewer and easier reviewed patches. The way I'd look at the problem, there are three main areas that can be dealt with one at a time:
a) callers of the high-level config space accessors pci_{write,read}_config_{byte,word,dword}, mostly in device drivers.
b) low-level implementation of the config space accessors through struct pci_ops
c) all other occurrences of these constants
Starting with a), my first question is whether any high-level drivers even need to care about errors from these functions. I see 4913 callers that ignore the return code, and 576 that actually check it, and almost none care about the specific error (as you found as well). Unless we conclude that most PCI drivers are wrong, could we just change the return type to 'void' and assume they never fail for valid arguments on a valid pci_device* ?
For b), it might be nice to also change other aspects of the interface, e.g. passing a pci_host_bridge pointer plus bus number instead of a pci_bus pointer, or having the callback in the pci_host_bridge structure.
Quoted 8 lines
Bolarinwa Olayemi Saheed (35):
ChangePCIBIOS_SUCCESSFULto 0
ChangePCIBIOS_SUCCESSFULto 0
ChangePCIBIOS_SUCCESSFULto 0
Tidy Success/Failure checks
ChangePCIBIOS_SUCCESSFULto 0
Tidy Success/Failure checks
ChangePCIBIOS_SUCCESSFULto 0
Some patches have identical subject lines including the subsystem prefix, which you should avoid. Try to also fix the git request-pull output to not drop that prefix here so the list makes more sense.
Arnd
[trimmed the cc list; it's still too large but maybe arch folks care]
Quoted 15 lines · Arnd Bergmann
Quoted 8 lines · Saheed O. Bolarinwa
This goal of these series is to move the definition of *all* PCIBIOS* from
include/linux/pci.htoarch/x86and limit their use within there. All other tree specific definition will be left for intact. Maybe they can be renamed.PCIBIOS* is an x86 concept as defined by the PCI spec. The returned error codes of PCIBIOS* are positive values and this introduces some complexities which other archs need not incur.
I think the intention is good, but I find the series in its current form very hard to review, in particular the way you touch some functions three times with trivial changes. Instead of
Quoted 6 lines
1) replace
PCIBIOS_SUCCESSFULwith 0
2) drop pointless 0-comparison
3) reformat whitespaceI would suggest to combine the first two steps into one patch per subsystem and drop the third step.
I agree. BUT please don't just run out and post new patches to do this. Let's talk about Arnd's further ideas below first.
Quoted 13 lines
...
Maybe the work can be split up differently, with a similar end result but fewer and easier reviewed patches. The way I'd look at the problem, there are three main areas that can be dealt with one at a time:a) callers of the high-level config space accessors pci_{write,read}_config_{byte,word,dword}, mostly in device drivers.
b) low-level implementation of the config space accessors through structpci_ops
c) all other occurrences of these constants
Quoted 7 lines
Starting with a), my first question is whether any high-level drivers even need to care about errors from these functions. I see 4913 callers that ignore the return code, and 576 that actually check it, and almost none care about the specific error (as you found as well). Unless we conclude that most PCI drivers are wrong, could we just change the return type to 'void' and assume they never fail for valid arguments on a valid pci_device* ?
I really like this idea.
pci_write_config_*() has one return value, and only 100ish of 2500 callers check for errors. It's sometimes possible for config accessors to detect PCI errors and return failure, e.g., device was removed or didn't respond, but most of them don't, and detecting these errors is not really that valuable.
pci_read_config_*() is much more interesting because it returns two things, the function return value and the value read from the PCI device, and it's complicated to check both.
Again it's sometimes possible for config read accessors to detect PCI errors, but in most cases a PCI error means the accessor returns success and the value from PCI is ~0.
Checking the function return value catches programming errors (bad alignment, etc) but misses most of the interesting errors (device was unplugged or reported a PCI error).
Checking the value returned from PCI is tricky because ~0 is a valid value for some config registers, and only the driver knows for sure. If the driver knows that ~0 is a possible value, it would have to do something else, e.g., another config read of a register that *cannot* be ~0, to see whether it's really an error.
I suspect that if we had a single value to look at it would be easier to get right. Error checking with current interface would look like this:
err = pci_read_config_word(dev, addr, &val);
if (err)
return -EINVAL; if (PCI_POSSIBLE_ERROR(val)) {
/* if driver knows ~0 is invalid */
return -EINVAL;
/* if ~0 is potentially a valid value */
err = pci_read_config_word(dev, PCI_VENDOR_ID, &val2);
if (err)
return -EINVAL;
if (PCI_POSSIBLE_ERROR(val2))
return -EINVAL;}
Error checking with a possible interface that returned only a single value could look like this:
val = pci_config_read_word(dev, addr);
if (PCI_POSSIBLE_ERROR(val)) {
/* if driver knows ~0 is invalid */
return -EINVAL; /* if ~0 is potentially a valid value */
val2 = pci_config_read_word(dev, PCI_VENDOR_ID);
if (PCI_POSSIBLE_ERROR(val2))
return -EINVAL;}
Am I understanding you correctly?
Quoted 4 lines
For b), it might be nice to also change other aspects of the interface, e.g. passing a
pci_host_bridgepointer plus bus number instead of apci_buspointer, or having the callback in thepci_host_bridgestructure.
I like this idea a lot, too. I think the fact that pci_bus_read_config_word() requires a pci_bus * complicates things in a few places.
I think it's completely separate, as you say, and we should defer it for now because even part a) is a lot of work. I added it to my list of possible future projects.
Bjorn
Quoted 71 lines · Bjorn Helgaas
Quoted 8 lines
a) callers of the high-level config space accessors pci_{write,read}_config_{byte,word,dword}, mostly in device drivers.
b) low-level implementation of the config space accessors through structpci_ops
c) all other occurrences of these constantsQuoted 7 lines
Starting with a), my first question is whether any high-level drivers even need to care about errors from these functions. I see 4913 callers that ignore the return code, and 576 that actually check it, and almost none care about the specific error (as you found as well). Unless we conclude that most PCI drivers are wrong, could we just change the return type to 'void' and assume they never fail for valid arguments on a valid pci_device* ?
I really like this idea.
pci_write_config_*() has one return value, and only 100ish of 2500 callers check for errors. It's sometimes possible for config accessors to detect PCI errors and return failure, e.g., device was removed or didn't respond, but most of them don't, and detecting these errors is not really that valuable.
pci_read_config_*() is much more interesting because it returns two things, the function return value and the value read from the PCI device, and it's complicated to check both.
Again it's sometimes possible for config read accessors to detect PCI errors, but in most cases a PCI error means the accessor returns success and the value from PCI is ~0.
Checking the function return value catches programming errors (bad alignment, etc) but misses most of the interesting errors (device was unplugged or reported a PCI error).
Checking the value returned from PCI is tricky because ~0 is a valid value for some config registers, and only the driver knows for sure. If the driver knows that ~0 is a possible value, it would have to do something else, e.g., another config read of a register that *cannot* be ~0, to see whether it's really an error.
I suspect that if we had a single value to look at it would be easier to get right. Error checking with current interface would look like this:
err = pci_read_config_word(dev, addr, &val); if (err) return -EINVAL;if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL; /* if ~0 is potentially a valid value */ err = pci_read_config_word(dev, PCI_VENDOR_ID, &val2); if (err) return -EINVAL; if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Error checking with a possible interface that returned only a single value could look like this:
val = pci_config_read_word(dev, addr); if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL;
Quoted 7 lines
/* if ~0 is potentially a valid value */ val2 = pci_config_read_word(dev, PCI_VENDOR_ID); if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Am I understanding you correctly?
Let us not do this. Reading config space is really expensive on some architectures. Requiring a driver to do it twice on some values does not improve upon that situation. And is quite redundant if the Root Complex driver already knows that the first access has failed.
Additionally since multiple config accesses to the same devices is not allowed in the spec, the hardware must block and wait for a timeout if a config access does not get a response.
(Can happen if a intermediate link between the RC and endpoint has to retrain) Having to block twice is very much not ideal. And in the case with retraining the secondary access might even succeed. As the link might recover between reading the first config word and reading PCI_VENDOR_ID. Thus allowing the driver to accept invalid data from the device.
Quoted 6 lines
Quoted 5 lines
For b), it might be nice to also change other aspects of the interface, e.g. passing a
pci_host_bridgepointer plus bus number instead of apci_buspointer, or having the callback in thepci_host_bridgestructure.
Quoted 8 lines
I like this idea a lot, too. I think the fact that
pci_bus_read_config_word()requires apci_bus* complicates things in a few places.I think it's completely separate, as you say, and we should defer it for now because even part a) is a lot of work. I added it to my list of possible future projects.
What about strange PCI devices such as Non-Transparent bridges? They will require their own PCI Config space accessors that is not connected to a host bridge if one wants to do some sort of punch-through enumeration.
I guess the kernel doesn't care much about them?
Best regards,
Kjetil Oftedal
Quoted 15 lines · Kjetil Oftedal
Quoted 6 lines
Quoted 5 lines
For b), it might be nice to also change other aspects of the interface, e.g. passing a
pci_host_bridgepointer plus bus number instead of apci_buspointer, or having the callback in thepci_host_bridgestructure.Quoted 8 lines
I like this idea a lot, too. I think the fact that
pci_bus_read_config_word()requires apci_bus* complicates things in a few places.I think it's completely separate, as you say, and we should defer it for now because even part a) is a lot of work. I added it to my list of possible future projects.
Quoted 5 lines
What about strange PCI devices such as Non-Transparent bridges? They will require their own PCI Config space accessors that is not connected to a host bridge if one wants to do some sort of punch-through enumeration.
I guess the kernel doesn't care much about them?
Well, today they would require a pci_bus anyway.. . so if you want to do that sort of funny trick you may as well create a "virtual" host bridge.
Cheers,
Ben.
Arnd Bergmann
maintainerQuoted 22 lines · Bjorn Helgaas
Quoted 8 lines · Arnd Bergmann
On Mon, Jul 13, 2020 at 3:22 PM Saheed O. Bolarinwa Starting with a), my first question is whether any high-level drivers even need to care about errors from these functions. I see 4913 callers that ignore the return code, and 576 that actually check it, and almost none care about the specific error (as you found as well). Unless we conclude that most PCI drivers are wrong, could we just change the return type to 'void' and assume they never fail for valid arguments on a valid pci_device* ?
I really like this idea.
pci_write_config_*() has one return value, and only 100ish of 2500 callers check for errors. It's sometimes possible for config accessors to detect PCI errors and return failure, e.g., device was removed or didn't respond, but most of them don't, and detecting these errors is not really that valuable.
pci_read_config_*() is much more interesting because it returns two things, the function return value and the value read from the PCI device, and it's complicated to check both.
Quoted 7 lines
Again it's sometimes possible for config read accessors to detect PCI errors, but in most cases a PCI error means the accessor returns success and the value from PCI is ~0.
Checking the function return value catches programming errors (bad alignment, etc) but misses most of the interesting errors (device was unplugged or reported a PCI error).
My thinking was more that most of the time the error checking may be completely bogus to start with, and I would just not check for errors at all.
Quoted 35 lines
Checking the value returned from PCI is tricky because ~0 is a valid value for some config registers, and only the driver knows for sure. If the driver knows that ~0 is a possible value, it would have to do something else, e.g., another config read of a register that *cannot* be ~0, to see whether it's really an error.
I suspect that if we had a single value to look at it would be easier to get right. Error checking with current interface would look like this:
err = pci_read_config_word(dev, addr, &val); if (err) return -EINVAL;if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL; /* if ~0 is potentially a valid value */ err = pci_read_config_word(dev, PCI_VENDOR_ID, &val2); if (err) return -EINVAL; if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Error checking with a possible interface that returned only a single value could look like this:
val = pci_config_read_word(dev, addr); if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL;
Quoted 7 lines
/* if ~0 is potentially a valid value */ val2 = pci_config_read_word(dev, PCI_VENDOR_ID); if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Am I understanding you correctly?
That would require changing all callers of the function, which I think would involve changing some 700 files. What I was suggesting was to only change the return type to void and categorize all drivers that today check it as either
a) checking the return code is not helpful, or possibly even wrong, so we just stop doing it. I expect those to be the vast majority of callers, but that could be wrong.
b) Code that legitimately check the error code and need to take an appropriate action. These could be changed to calling a different interface such as 'pci_bus_read_config_word' or a new 'pci_device_last_error()' function.
The reasons I suspect that most callers don't actually need to check for errors are:
- Most error checking is static: PCIBIOS_BAD_REGISTER_NUMBER only happens if you pass an invalid register number, but most callers pass a compile-time constant register number that is known to be correct, or the driver would never work. Similarly, PCIBIOS_DEVICE_NOT_FOUND wouldn't normally happen since you pass a valid pci_device pointer that was already probed.
- config space accesses are very rare compared to memory space access and on the hardware side the error handling would be similar, but readl/writel don't return errors, they just access wrong registers or return 0xffffffff. arch/powerpc/kernel/eeh.c has a ton extra code written to deal with it, but no other architectures do.
- If we add code to detect errors in pci_read_config_* and do some of the stuff from powerpc's eeh_dev_check_failure(), we are more likely to catch intermittent failures when drivers don't check, or bugs with invalid arguments in device drivers than relying on drivers to get their error handling right when those code paths don't ever get covered in normal testing.
Looking at a couple of random drivers that do check the return codes, I find:
drivers/edac/amd8131_edac.c: prints the register number, then keeps going. This is not useful
drivers/net/ethernet/mellanox/mlx4/reset.c: error handling in mlx4_reset() seems reasonable, but it gets called from mlx4_pci_resume(), which has a 'void' return code and cannot propagate the error further. My guess is that it would try to keep going after a failed resume and run into random other problems then.
drivers/ata/pata_cs5536.c: error code gets passed to caller and then always ignored. Can clearly be changed
drivers/net/wireless/intersil/prism54/islpci_hotplug.c:
Out of two calls, only one is checked, which seems bogus
drivers/usb/host/pci-quirks.c: only one of many instances has a check, again this seems bogus.
drivers/leds/leds-ss4200.c: called from probe(), which seems to correctly deal with errors by failing the probe. Not sure this can ever fail though, since the driver only does it after pci_enable_device() succeeds first. Note that pci_enable_device() ignores pci_read_config_byte() errors but sanity-checks the register contents/
Arnd
[+cc Kjetil]
Quoted 27 lines · Arnd Bergmann
Quoted 26 lines · Bjorn Helgaas
Quoted 8 lines · Arnd Bergmann
On Mon, Jul 13, 2020 at 3:22 PM Saheed O. Bolarinwa Starting with a), my first question is whether any high-level drivers even need to care about errors from these functions. I see 4913 callers that ignore the return code, and 576 that actually check it, and almost none care about the specific error (as you found as well). Unless we conclude that most PCI drivers are wrong, could we just change the return type to 'void' and assume they never fail for valid arguments on a valid pci_device* ?
I really like this idea.
pci_write_config_*() has one return value, and only 100ish of 2500 callers check for errors. It's sometimes possible for config accessors to detect PCI errors and return failure, e.g., device was removed or didn't respond, but most of them don't, and detecting these errors is not really that valuable.
pci_read_config_*() is much more interesting because it returns two things, the function return value and the value read from the PCI device, and it's complicated to check both.
Again it's sometimes possible for config read accessors to detect PCI errors, but in most cases a PCI error means the accessor returns success and the value from PCI is ~0.
Quoted 7 lines
Quoted 3 lines
Checking the function return value catches programming errors (bad alignment, etc) but misses most of the interesting errors (device was unplugged or reported a PCI error).
My thinking was more that most of the time the error checking may be completely bogus to start with, and I would just not check for errors at all.
Yes. I have no problem with that. There are a few cases where it's important to check for errors, e.g., we read a status register and do something based on a bit being set. A failure will return all bits set, and we may do the wrong thing. But most of the errors we care about will be on MMIO reads, not config reads, so we can probably ignore most config read errors.
Quoted 41 lines
Quoted 41 lines
Checking the value returned from PCI is tricky because ~0 is a valid value for some config registers, and only the driver knows for sure. If the driver knows that ~0 is a possible value, it would have to do something else, e.g., another config read of a register that *cannot* be ~0, to see whether it's really an error.
I suspect that if we had a single value to look at it would be easier to get right. Error checking with current interface would look like this:
err = pci_read_config_word(dev, addr, &val); if (err) return -EINVAL;if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL; /* if ~0 is potentially a valid value */ err = pci_read_config_word(dev, PCI_VENDOR_ID, &val2); if (err) return -EINVAL; if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Error checking with a possible interface that returned only a single value could look like this:
val = pci_config_read_word(dev, addr); if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL;/* if ~0 is potentially a valid value */ val2 = pci_config_read_word(dev, PCI_VENDOR_ID); if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Quoted 4 lines
Quoted 1 line
Am I understanding you correctly?
That would require changing all callers of the function, which I think would involve changing some 700 files.
Yeah, that would be a disaster. So something like:
void pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
and where we used to return anything non-zero, we just set *val = ~0 instead? I think we do that already in most, maybe all, cases.
Quoted 11 lines
What I was suggesting was to only change the return type to void and categorize all drivers that today check it as either
a) checking the return code is not helpful, or possibly even wrong, so we just stop doing it. I expect those to be the vast majority of callers, but that could be wrong.
b) Code that legitimately check the error code and need to take an appropriate action. These could be changed to calling a different interface such as '
pci_bus_read_config_word' or a new 'pci_device_last_error()' function.
Yep, makes sense.
Quoted 10 lines
The reasons I suspect that most callers don't actually need to check for errors are:
- Most error checking is static:
PCIBIOS_BAD_REGISTER_NUMBERonly happens if you pass an invalid register number, but most callers pass a compile-time constant register number that is known to be correct, or the driver would never work. Similarly,PCIBIOS_DEVICE_NOT_FOUNDwouldn't normally happen since you pass a validpci_devicepointer that was already probed.
Yep, except for things like device removal or other PCI errors.
Quoted 7 lines
- config space accesses are very rare compared to memory space access and on the hardware side the error handling would be similar, but readl/writel don't return errors, they just access wrong registers or return
0xffffffff.arch/powerpc/kernel/eeh.chas a ton extra code written to deal with it, but no other architectures do.
Quoted 7 lines
- If we add code to detect errors in pci_read_config_* and do some of the stuff from powerpc's
eeh_dev_check_failure(), we are more likely to catch intermittent failures when drivers don't check, or bugs with invalid arguments in device drivers than relying on drivers to get their error handling right when those code paths don't ever get covered in normal testing.
Yeah, this makes sense and sounds like a potential follow-on project.
Quoted 22 lines
Looking at a couple of random drivers that do check the return codes, I find:
drivers/edac/amd8131_edac.c: prints the register number, then keeps going. This is not useful
drivers/net/ethernet/mellanox/mlx4/reset.c: error handling inmlx4_reset()seems reasonable, but it gets called frommlx4_pci_resume(), which has a 'void' return code and cannot propagate the error further. My guess is that it would try to keep going after a failed resume and run into random other problems then.
drivers/ata/pata_cs5536.c: error code gets passed to caller and then always ignored. Can clearly be changed
drivers/net/wireless/intersil/prism54/islpci_hotplug.c:
Out of two calls, only one is checked, which seems bogus
drivers/usb/host/pci-quirks.c: only one of many instances has a check, again this seems bogus.
Quoted 6 lines
drivers/leds/leds-ss4200.c: called fromprobe(), which seems to correctly deal with errors by failing the probe. Not sure this can ever fail though, since the driver only does it afterpci_enable_device()succeeds first. Note thatpci_enable_device()ignorespci_read_config_byte()errors but sanity-checks the register contents/
So maybe a good place to start is by removing some of the useless error checking for pci_read_config_*() and pci_write_config_*(). That's a decent-sized but not impractical project that could be done per subsystem or something:
git grep -E "(if|return|=).*\<pci_(read|write)_config" drivers
finds about 400 matches.
Some of those callers probably really *do* want to check for errors, and I guess we'd have to identify them and do them separately as you mentioned.
Bjorn
Quoted 6 lines · Bjorn Helgaas
Yes. I have no problem with that. There are a few cases where it's important to check for errors, e.g., we read a status register and do something based on a bit being set. A failure will return all bits set, and we may do the wrong thing. But most of the errors we care about will be on MMIO reads, not config reads, so we can probably ignore most config read errors.
And in both cases, we don't have the plumbing to provide accurate and reliable error returns for all platforms anyways (esp. not for MMIO).
I think it makes sense to stick to the good old "if all 1's, then go out of line" including for config space.
../..
Quoted 1 line
Yep, except for things like device removal or other PCI errors.
A whole bunch of these are reported asynchronously, esp for writes (and yes, including config writes, they are supposed to be non-posted but more often than not, the path from the CPU to the PCI bridge remains posted for writes including config ones).
Quoted 5 lines
So maybe a good place to start is by removing some of the useless error checking for pci_read_config_*() and pci_write_config_*(). That's a decent-sized but not impractical project that could be done per subsystem or something:
Quoted 7 lines
git grep -E "(if|return|=).*\<pci_(read|write)_config" drivers
finds about 400 matches.
Some of those callers probably really *do* want to check for errors, and I guess we'd have to identify them and do them separately as you mentioned.
I'd be curious about these considering how unreliable our error return is accross the board.
Cheers,
Ben.
Arnd Bergmann
maintainerOn Wed, Jul 15, 2020 at 1:46 AM Bjorn Helgaas <[email protected]> wrote:
So something like:
Quoted 5 lines
void
pci_read_config_word(struct pci_dev *dev, int where, u16 *val)and where we used to return anything non-zero, we just set *val = ~0 instead? I think we do that already in most, maybe all, cases.
Right, this is what I had in mind. If we start by removing the handling of the return code in all files that clearly don't need it, looking at whatever remains will give a much better idea of what a good interface should be.
Quoted 2 lines
git grep -E "(if|return|=).*\<pci_(read|write)_config" drivers
finds about 400 matches.
Right, and this is some 112 files to look at.
I had a slightly different regex, which found more false-positives, but also these:
arch/x86/kernel/amd_nb.c: : pci_read_config_dword(root, 0x64, value)); drivers/i2c/busses/i2c-sis630.c: pci_write_config_byte(sis630_dev,
SIS630_BIOS_CTL_REG, b | 0x80)) {drivers/i2c/busses/i2c-viapro.c: !pci_read_config_word(pdev,
SMBBA2, &vt596_smba) &&drivers/ide/rz1000.c: !pci_write_config_word(dev, 0x40, reg & 0xdfff)) {drivers/net/ethernet/realtek/r8169_main.c:pci_write_config_byte(pdev, 0x070f, val) = PCIBIOS_SUCCESSFUL) include/linux/rtsx_pci.h:#define rtsx_pci_read_config_dword(pcr, where, val) pci_read_config_dword((pcr)->pci, where, val) include/linux/rtsx_pci.h:#define rtsx_pci_write_config_dword(pcr, where, val) pci_write_config_dword((pcr)->pci, where, val)drivers/misc/cardreader/rts5261.c: retval rtsx_pci_read_config_dword(pcr,drivers/misc/cardreader/rts5261.c: retval rtsx_pci_write_config_dword(pcr, PCR_SETTING_REG2, lval);
That last one is interesting because I think this is a case in which we actually want to check for errors, as the driver seems to use it to ensure that accessing extended config space at offset 0x814 works before relying on the value. Unfortunately the implementation seems buggy as it a) keeps using the possibly uninitialized value after printing a warning and b) returns the PCIBIOS_* value in place of a negative errno and then ignores it in the caller.
Arnd
From: Arnd Bergmann
Quoted 7 lines
Sent: 15 July 2020 07:47
On Wed, Jul 15, 2020 at 1:46 AM Bjorn Helgaas <[email protected]> wrote:So something like:
Quoted 3 lines
void
pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
Quoted 7 lines
Quoted 2 lines
and where we used to return anything non-zero, we just set *val = ~0 instead? I think we do that already in most, maybe all, cases.
Right, this is what I had in mind. If we start by removing the handling of the return code in all files that clearly don't need it, looking at whatever remains will give a much better idea of what a good interface should be.
It would be best to get rid of that nasty 'u16 *' parameter. Make the return int and return the read value or -1 on error. (Or maybe 0xffff0000 on error??)
For a 32bit read (there must be one for the BARs) returning a 64bit signed integer would work even for 32bit systems.
If code cares about the error, and it can be detected then it can check. Otherwise the it all 'just works'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
_______________________________________________
Linux-kernel-mentees mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 11 lines · David Laight
From: Arnd Bergmann
Quoted 10 lines
Sent: 15 July 2020 07:47
On Wed, Jul 15, 2020 at 1:46 AM Bjorn Helgaas <[email protected]> wrote:So something like:
Quoted 5 lines
void
pci_read_config_word(struct pci_dev *dev, int where, u16 *val)and where we used to return anything non-zero, we just set *val = ~0 instead? I think we do that already in most, maybe all, cases.
Quoted 6 lines
Quoted 4 lines
Right, this is what I had in mind. If we start by removing the handling of the return code in all files that clearly don't need it, looking at whatever remains will give a much better idea of what a good interface should be.
It would be best to get rid of that nasty 'u16 *' parameter.
Do you mean nasty because it's basically a return value, but not returned as the *function's* return value? I agree that if we were starting from scratch it would nicer to have:
u16 pci_read_config_word(struct pci_dev *dev, int where)
but I don't think it's worth changing the thousands of callers just for that.
Quoted 8 lines
Make the return int and return the read value or -1 on error. (Or maybe
0xffff0000on error??)For a 32bit read (there must be one for the BARs) returning a 64bit signed integer would work even for 32bit systems.
If code cares about the error, and it can be detected then it can check. Otherwise the it all 'just works'.
There are u8 (byte), u16 (word), and u32 (dword) config reads & writes. But I don't think it really helps to return something wider than the access. For programmatic errors like invalid alignment, we could indeed use the extra bits to return an unambiguous error. But we still have the "device was unplugged" sort of errors where the *hardware* typically returns ~0 and the config accessor doesn't know whether that's valid data or an error.
Bjorn
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
From: Bjorn Helgaas
Quoted 21 lines
Sent: 15 July 2020 23:02
Quoted 11 lines · David Laight
From: Arnd Bergmann
Quoted 10 lines
Sent: 15 July 2020 07:47
On Wed, Jul 15, 2020 at 1:46 AM Bjorn Helgaas <[email protected]> wrote:So something like:
Quoted 5 lines
void
pci_read_config_word(struct pci_dev *dev, int where, u16 *val)and where we used to return anything non-zero, we just set *val = ~0 instead? I think we do that already in most, maybe all, cases.
Quoted 6 lines
Quoted 4 lines
Right, this is what I had in mind. If we start by removing the handling of the return code in all files that clearly don't need it, looking at whatever remains will give a much better idea of what a good interface should be.
It would be best to get rid of that nasty 'u16 *' parameter.
Quoted 8 lines
Do you mean nasty because it's basically a return value, but not returned as the *function's* return value? I agree that if we were starting from scratch it would nicer to have:
u16
pci_read_config_word(struct pci_dev *dev, int where)but I don't think it's worth changing the thousands of callers just for that.
It'll shrink the kernel text size somewhat.
It could also be 'fixed' with a static inline.
Actually you don't even want the result to be u16. Even though the domain of the value is 0..65535 keeping the type as int (or unsigned int) will save the compiler having to generate lots of masking instructions.
Code performance here will be overwhelmed by the time taken for the config space access.
But more generally all local variables should really be the size of cpu registers.
On x86-64 you need to use 'unsigned int' for anything used as array subscripts to avoid the 'sign extend' instructions. In some code paths it may matter...
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 11 lines · Arnd Bergmann
drivers/misc/cardreader/rts5261.c: retval >rtsx_pci_write_config_dword(pcr, PCR_SETTING_REG2, lval);That last one is interesting because I think this is a case in which we
actually want to check for errors, as the driver seems to use it to ensure that accessing extended config space at offset0x814works before relying on the value. Unfortunately the implementation seems buggy as it a) keeps using the possibly uninitialized value after
printing a warning and b) returns the PCIBIOS_* value in place of a negative errno and then ignores it in the caller.
In cases like this, usually checking against ~0 is sufficient
Cheers,
Ben.
Oliver O'Halloran
reviewerQuoted 8 lines · Arnd Bergmann
- Most error checking is static:
PCIBIOS_BAD_REGISTER_NUMBERonly happens if you pass an invalid register number, but most callers pass a compile-time constant register number that is known to be correct, or the driver would never work. Similarly,PCIBIOS_DEVICE_NOT_FOUNDwouldn't normally happen since you pass a validpci_devicepointer that was already probed.
Having some feedback about obvious programming errors is still useful when doing driver development. Reporting those via printk() would probably be more useful to those who care though.
Quoted 6 lines
- config space accesses are very rare compared to memory space access and on the hardware side the error handling would be similar, but readl/writel don't return errors, they just access wrong registers or return
0xffffffff.arch/powerpc/kernel/eeh.chas a ton extra code written to deal with it, but no other architectures do.
TBH the EEH MMIO hooks were probably a mistake to begin with. Errors detected via MMIO are almost always asynchronous to the error itself so you usually just wind up with a misleading stack trace rather than any kind of useful synchronous error reporting. It seems like most drivers don't bother checking for 0xFFs either and rely on the asynchronous reporting via .error_detected() instead, so I have to wonder what the point is. I've been thinking of removing the MMIO hooks and using a background poller to check for errors on each PHB periodically (assuming we don't have an EEH interrupt) instead. That would remove the requirement for eeh_dev_check_failure() to be interrupt safe too, so it might even let us fix all the godawful races in EEH.
Quoted 7 lines
- If we add code to detect errors in pci_read_config_* and do some of the stuff from powerpc's
eeh_dev_check_failure(), we are more likely to catch intermittent failures when drivers don't check, or bugs with invalid arguments in device drivers than relying on drivers to get their error handling right when those code paths don't ever get covered in normal testing.
Adding some kind of error detection to the generic config accessors wouldn't hurt, but detection is only half the problem. The main job of eeh_dev_check_failure() is waking up the EEH recovery thread which actually handles notifying drivers, device resets, etc and you'd want something in the PCI core. Right now there's two implementations of that reporting logic: one for EEH in arch/powerpc/eeh_driver.c and one for AER/DPC in drivers/pci/pcie/err.c. I think the latter could be moved into the PCI core easily enough since there's not much about it that's really specific to PCIe. Ideally we could drop the EEH specific one too, but I'm not sure how to implement that without it devolving into callback spaghetti.
Oliver
RnJvbTogT2xpdmVyIE8nSGFsbG9yYW4NCj4gU2VudDogMTUgSnVseSAyMDIwIDA1OjE5DQo+IA0K PiBPbiBXZWQsIEp1bCAxNSwgMjAyMCBhdCA4OjAzIEFNIEFybmQgQmVyZ21hbm4gPGFybmRAYXJu ZGIuZGU+IHdyb3RlOg0KLi4uDQo+ID4gLSBjb25maWcgc3BhY2UgYWNjZXNzZXMgYXJlIHZlcnkg cmFyZSBjb21wYXJlZCB0byBtZW1vcnkNCj4gPiAgIHNwYWNlIGFjY2VzcyBhbmQgb24gdGhlIGhh cmR3YXJlIHNpZGUgdGhlIGVycm9yIGhhbmRsaW5nDQo+ID4gICB3b3VsZCBiZSBzaW1pbGFyLCBi dXQgcmVhZGwvd3JpdGVsIGRvbid0IHJldHVybiBlcnJvcnMsIHRoZXkganVzdA0KPiA+ICAgYWNj ZXNzIHdyb25nIHJlZ2lzdGVycyBvciByZXR1cm4gMHhmZmZmZmZmZi4NCj4gPiAgIGFyY2gvcG93 ZXJwYy9rZXJuZWwvZWVoLmMgaGFzIGEgdG9uIGV4dHJhIGNvZGUgd3JpdHRlbiB0bw0KPiA+ICAg ZGVhbCB3aXRoIGl0LCBidXQgbm8gb3RoZXIgYXJjaGl0ZWN0dXJlcyBkby4NCj4gDQo+IFRCSCB0 aGUgRUVIIE1NSU8gaG9va3Mgd2VyZSBwcm9iYWJseSBhIG1pc3Rha2UgdG8gYmVnaW4gd2l0aC4g RXJyb3JzDQo+IGRldGVjdGVkIHZpYSBNTUlPIGFyZSBhbG1vc3QgYWx3YXlzIGFzeW5jaHJvbm91 cyB0byB0aGUgZXJyb3IgaXRzZWxmDQo+IHNvIHlvdSB1c3VhbGx5IGp1c3Qgd2luZCB1cCB3aXRo IGEgbWlzbGVhZGluZyBzdGFjayB0cmFjZSByYXRoZXIgdGhhbg0KPiBhbnkga2luZCBvZiB1c2Vm dWwgc3luY2hyb25vdXMgZXJyb3IgcmVwb3J0aW5nLiBJdCBzZWVtcyBsaWtlIG1vc3QNCj4gZHJp dmVycyBkb24ndCBib3RoZXIgY2hlY2tpbmcgZm9yIDB4RkZzIGVpdGhlciBhbmQgcmVseSBvbiB0 aGUNCj4gYXN5bmNocm9ub3VzIHJlcG9ydGluZyB2aWEgLmVycm9yX2RldGVjdGVkKCkgaW5zdGVh ZCwgc28gSSBoYXZlIHRvDQo+IHdvbmRlciB3aGF0IHRoZSBwb2ludCBpcy4gSSd2ZSBiZWVuIHRo aW5raW5nIG9mIHJlbW92aW5nIHRoZSBNTUlPDQo+IGhvb2tzIGFuZCB1c2luZyBhIGJhY2tncm91 bmQgcG9sbGVyIHRvIGNoZWNrIGZvciBlcnJvcnMgb24gZWFjaCBQSEINCj4gcGVyaW9kaWNhbGx5 IChhc3N1bWluZyB3ZSBkb24ndCBoYXZlIGFuIEVFSCBpbnRlcnJ1cHQpIGluc3RlYWQuIFRoYXQN Cj4gd291bGQgcmVtb3ZlIHRoZSByZXF1aXJlbWVudCBmb3IgZWVoX2Rldl9jaGVja19mYWlsdXJl KCkgdG8gYmUNCj4gaW50ZXJydXB0IHNhZmUgdG9vLCBzbyBpdCBtaWdodCBldmVuIGxldCB1cyBm aXggYWxsIHRoZSBnb2Rhd2Z1bCByYWNlcw0KPiBpbiBFRUguDQoNCkkndmUgJ3BsYXllZCcgd2l0 aCBQQ0llIGVycm9yIGhhbmRsaW5nIC0gd2l0aG91dCBtdWNoIHN1Y2Nlc3MuDQpXaGF0IG1pZ2h0 IGJlIHVzZWZ1bCBpcyBmb3IgYSBkcml2ZXIgdGhhdCBoYXMganVzdCByZWFkIH4wdSB0bw0KYmUg YWJsZSB0byBhc2sgJ2hhcyB0aGVyZSBiZWVuIGFuIGVycm9yIHNpZ25hbGxlZCBmb3IgdGhpcyBk ZXZpY2U/Jy4NCg0KSSBnb3QgYW4gZXJyb3IgZ2VuZXJhdGVkIGJ5IGRvaW5nIGFuIE1NSU8gYWNj ZXNzIHRoYXQgd2FzIGluc2lkZQ0KdGhlIGFkZHJlc3MgcmFuZ2UgZm9yd2FyZGVkIHRvIHRoZSBz bGF2ZSwgYnV0IG91dHNpZGUgYW55IG9mIGl0cyBCQVJzLg0KKFR3byBCQVJzIG9mIGRpZmZlcmVu dCBzaXplcyBsZWF2ZXMgYSBuaWNlIGdhcC4pDQpUaGlzIGdvdCByZXBvcnRlZCB1cCB0byB0aGUg YnJpZGdlIG5lYXJlc3QgdGhlIHNsYXZlICh3aGljaCBzdXBwb3J0ZWQNCmVycm9yIGhhbmRsaW5n KSwgYnV0IG5vdCB0byB0aGUgcm9vdCBicmlkZ2UgKHdoaWNoIEkgZG9uJ3QgdGhpbmsgZG9lcyku DQpJU1RSIGEgbWVzc2FnZSBhYm91dCBFRUggYmVpbmcgaGFuZGxlZCBieSB0aGUgaGFyZHdhcmUg KHRoZSBtYWNoaW5lDQppcyB1cCBidXQgZG1lc2cgaXMgZnVsbCBvZiBtZXNzYWdlcyBmcm9tIGEg Ym91bmNpbmcgVVNCIG1vdXNlKS4NCg0KV2l0aCBzdWNoIHBhcnRpYWwgZXJyb3IgcmVwb3J0aW5n IHVzZWZ1bCBpbmZvIGNhbiBzdGlsbCBiZSBleHRyYWN0ZWQuDQoNCk9mIGNvdXJzZSwgd2hhdCBh Y3R1YWxseSBoYXBwZW5zIG9uIGEgUENJZSBlcnJvciBpcyB0aGF0IHRoZSBzaWduYWwNCmdldHMg cm91dGVkIHRvIHNvbWUgJ2JvYXJkIHN1cHBvcnQgbG9naWMnIGFuZCB0aGVuIHBhc3NlZCBiYWNr IGludG8NCnRoZSBrZXJuZWwgYXMgYW4gTk1JIC0gd2hpY2ggdGhlbiBjcmFzaGVzIHRoZSBrZXJu ZWwhDQpUaGlzIGV2ZW4gaGFwcGVucyB3aGVuIHRoZSBQQ0llIGxpbmsgZ29lcyBkb3duIGFmdGVy IHdlJ3ZlIGRvbmUgYQ0Kc29mdC1yZW1vdmUgb2YgdGhlIGRldmljZSBpdHNlbGYhDQpSYXRoZXIg bWFrZXMgdXBkYXRpbmcgdGhlIGJvYXJkJ3MgRlBHQSB3aXRob3V0IGEgcmVib290IHRyaWNreS4N Cg0KCURhdmlkDQoNCi0NClJlZ2lzdGVyZWQgQWRkcmVzcyBMYWtlc2lkZSwgQnJhbWxleSBSb2Fk LCBNb3VudCBGYXJtLCBNaWx0b24gS2V5bmVzLCBNSzEgMVBULCBVSw0KUmVnaXN0cmF0aW9uIE5v OiAxMzk3Mzg2IChXYWxlcykNCg=
Quoted 25 lines · David Laight
From: Oliver O'Halloran
Quoted 3 lines
Sent: 15 July 2020 05:19
On Wed, Jul 15, 2020 at 8:03 AM Arnd Bergmann <[email protected]> wrote:
...
Quoted 7 lines
Quoted 6 lines
- config space accesses are very rare compared to memory space access and on the hardware side the error handling would be similar, but readl/writel don't return errors, they just access wrong registers or return
0xffffffff.arch/powerpc/kernel/eeh.chas a ton extra code written to deal with it, but no other architectures do.Quoted 12 lines
TBH the EEH MMIO hooks were probably a mistake to begin with. Errors detected via MMIO are almost always asynchronous to the error itself so you usually just wind up with a misleading stack trace rather than any kind of useful synchronous error reporting. It seems like most drivers don't bother checking for 0xFFs either and rely on the asynchronous reporting via .error_detected() instead, so I have to wonder what the point is. I've been thinking of removing the MMIO hooks and using a background poller to check for errors on each PHB periodically (assuming we don't have an EEH interrupt) instead. That would remove the requirement for
eeh_dev_check_failure()to be interrupt safe too, so it might even let us fix all the godawful races in EEH.
Quoted 3 lines
I've 'played' with PCIe error handling - without much success. What might be useful is for a driver that has just read ~0u to be able to ask 'has there been an error signalled for this device?'.
In many cases a driver will know that ~0 is not a valid value for the register it's reading. But if ~0 *could* be valid, an interface like you suggest could be useful. I don't think we have anything like that today, but maybe we could. It would certainly be nice if the PCI core noticed, logged, and cleared errors. We have some of that for AER, but that's an optional feature, and support for the error bits in the garden-variety PCI_STATUS register is pretty haphazard. As you note below, this sort of SERR/PERR reporting is frequently hard-wired in ways that takes it out of our purview.
Bjorn
Quoted 4 lines · Bjorn Helgaas
Quoted 3 lines
I've 'played' with PCIe error handling - without much success. What might be useful is for a driver that has just read ~0u to be able to ask 'has there been an error signalled for this device?'.
Quoted 9 lines
In many cases a driver will know that ~0 is not a valid value for the register it's reading. But if ~0 *could* be valid, an interface like you suggest could be useful. I don't think we have anything like that today, but maybe we could. It would certainly be nice if the PCI core noticed, logged, and cleared errors. We have some of that for AER, but that's an optional feature, and support for the error bits in the garden-variety
PCI_STATUSregister is pretty haphazard. As you note below, this sort of SERR/PERR reporting is frequently hard-wired in ways that takes it out of our purview.
We do have pci_channel_state (via pci_channel_offline()) which covers the cases where the underlying error handling (such as EEH or unplug) results in the device being offlined though this tend to be asynchronous so it might take a few ~0's before you get it.
It's typically used to break potentially infinite loops in some drivers.
There is no interface to check whether *an* error happened though for the most cases it will be captured in the status register, which is harvested (and cleared ?) by some EDAC drivers iirc...
All this lacks coordination, I agree.
Cheers,
Ben.
RnJvbTogQmVuamFtaW4gSGVycmVuc2NobWlkdA0KPiBTZW50OiAxNSBKdWx5IDIwMjAgMjM6NDkN Cj4gT24gV2VkLCAyMDIwLTA3LTE1IGF0IDE3OjEyIC0wNTAwLCBCam9ybiBIZWxnYWFzIHdyb3Rl Og0KPiA+ID4gSSd2ZSAncGxheWVkJyB3aXRoIFBDSWUgZXJyb3IgaGFuZGxpbmcgLSB3aXRob3V0 IG11Y2ggc3VjY2Vzcy4NCj4gPiA+IFdoYXQgbWlnaHQgYmUgdXNlZnVsIGlzIGZvciBhIGRyaXZl ciB0aGF0IGhhcyBqdXN0IHJlYWQgfjB1IHRvDQo+ID4gPiBiZSBhYmxlIHRvIGFzayAnaGFzIHRo ZXJlIGJlZW4gYW4gZXJyb3Igc2lnbmFsbGVkIGZvciB0aGlzIGRldmljZT8nLg0KPiA+DQo+ID4g SW4gbWFueSBjYXNlcyBhIGRyaXZlciB3aWxsIGtub3cgdGhhdCB+MCBpcyBub3QgYSB2YWxpZCB2 YWx1ZSBmb3IgdGhlDQo+ID4gcmVnaXN0ZXIgaXQncyByZWFkaW5nLiAgQnV0IGlmIH4wICpjb3Vs ZCogYmUgdmFsaWQsIGFuIGludGVyZmFjZSBsaWtlDQo+ID4geW91IHN1Z2dlc3QgY291bGQgYmUg dXNlZnVsLiAgSSBkb24ndCB0aGluayB3ZSBoYXZlIGFueXRoaW5nIGxpa2UgdGhhdA0KPiA+IHRv ZGF5LCBidXQgbWF5YmUgd2UgY291bGQuICBJdCB3b3VsZCBjZXJ0YWlubHkgYmUgbmljZSBpZiB0 aGUgUENJIGNvcmUNCj4gPiBub3RpY2VkLCBsb2dnZWQsIGFuZCBjbGVhcmVkIGVycm9ycy4gIFdl IGhhdmUgc29tZSBvZiB0aGF0IGZvciBBRVIsDQo+ID4gYnV0IHRoYXQncyBhbiBvcHRpb25hbCBm ZWF0dXJlLCBhbmQgc3VwcG9ydCBmb3IgdGhlIGVycm9yIGJpdHMgaW4gdGhlDQo+ID4gZ2FyZGVu LXZhcmlldHkgUENJX1NUQVRVUyByZWdpc3RlciBpcyBwcmV0dHkgaGFwaGF6YXJkLiAgQXMgeW91 IG5vdGUNCj4gPiBiZWxvdywgdGhpcyBzb3J0IG9mIFNFUlIvUEVSUiByZXBvcnRpbmcgaXMgZnJl cXVlbnRseSBoYXJkLXdpcmVkIGluDQo+ID4gd2F5cyB0aGF0IHRha2VzIGl0IG91dCBvZiBvdXIg cHVydmlldy4NCj4gDQo+IFdlIGRvIGhhdmUgcGNpX2NoYW5uZWxfc3RhdGUgKHZpYSBwY2lfY2hh bm5lbF9vZmZsaW5lKCkpIHdoaWNoIGNvdmVycw0KPiB0aGUgY2FzZXMgd2hlcmUgdGhlIHVuZGVy bHlpbmcgZXJyb3IgaGFuZGxpbmcgKHN1Y2ggYXMgRUVIIG9yIHVucGx1ZykNCj4gcmVzdWx0cyBp biB0aGUgZGV2aWNlIGJlaW5nIG9mZmxpbmVkIHRob3VnaCB0aGlzIHRlbmQgdG8gYmUNCj4gYXN5 bmNocm9ub3VzIHNvIGl0IG1pZ2h0IHRha2UgYSBmZXcgfjAncyBiZWZvcmUgeW91IGdldCBpdC4N Cg0KT24gb25lIG9mIG15IHN5c3RlbXMgSSBkb24ndCB0aGluayB0aGUgZXJyb3IgVExQIGZyb20g dGhlIHRhcmdldA0KbWFkZSBpdHMgd2F5IHBhc3QgdGhlIGZpcnN0IGJyaWRnZSAtIEkgY291bGQg c2VlIHRoZSBlcnJvciBpbiBpdCdzDQpzdGF0dXMgcmVnaXN0ZXJzLg0KQnV0IEkgY291bGRuJ3Qg ZmluZCBhbnkgb2YgdGhlIEFFUiBzdGF0dXMgcmVnaXN0ZXJzIGluIHRoZSByb290IGJyaWRnZS4N ClNvIEkgdGhpbmsgeW91J2QgbmVlZCBhIHNvZnR3YXJlIHBvbGwgb2YgdGhlIGJyaWRnZSByZWdp c3RlcnMgdG8NCmZpbmQgb3V0IChhbmQgY2xlYXIpIHRoZSBlcnJvci4NCg0KVGhlIE5NSSBvbiB0 aGUgZGVsbCBzeXN0ZW0gKHdoaWNoIGlzIHN1cHBvc2VkIHRvIG1lZXQgc29tZSBzcGVjaWFsDQpO RUJTPyBzZXJ2ZXIgcmVxdWlyZW1lbnRzKSBpcyBqdXN0IHN0dXBpZC4NClRvbyBsYXRlIHRvIGJl IHN5bmNocm9ub3VzIGFuZCBpbXBvc3NpYmxlIGZvciB0aGUgT1MgdG8gaGFuZGxlLg0KDQoJRGF2 aWQNCg0KLQ0KUmVnaXN0ZXJlZCBBZGRyZXNzIExha2VzaWRlLCBCcmFtbGV5IFJvYWQsIE1vdW50 IEZhcm0sIE1pbHRvbiBLZXluZXMsIE1LMSAxUFQsIFVLDQpSZWdpc3RyYXRpb24gTm86IDEzOTcz ODYgKFdhbGVzKQ0K
Rob Herring
reviewerQuoted 113 lines · Bjorn Helgaas
[trimmed the cc list; it's still too large but maybe arch folks care]
Quoted 15 lines · Arnd Bergmann
Quoted 8 lines · Saheed O. Bolarinwa
This goal of these series is to move the definition of *all* PCIBIOS* from
include/linux/pci.htoarch/x86and limit their use within there. All other tree specific definition will be left for intact. Maybe they can be renamed.PCIBIOS* is an x86 concept as defined by the PCI spec. The returned error codes of PCIBIOS* are positive values and this introduces some complexities which other archs need not incur.
I think the intention is good, but I find the series in its current form very hard to review, in particular the way you touch some functions three times with trivial changes. Instead of
Quoted 6 lines
1) replace
PCIBIOS_SUCCESSFULwith 0
2) drop pointless 0-comparison
3) reformat whitespaceI would suggest to combine the first two steps into one patch per subsystem and drop the third step.
I agree. BUT please don't just run out and post new patches to do this. Let's talk about Arnd's further ideas below first.
Quoted 13 lines
...
Maybe the work can be split up differently, with a similar end result but fewer and easier reviewed patches. The way I'd look at the problem, there are three main areas that can be dealt with one at a time:a) callers of the high-level config space accessors pci_{write,read}_config_{byte,word,dword}, mostly in device drivers.
b) low-level implementation of the config space accessors through structpci_ops
c) all other occurrences of these constantsQuoted 7 lines
Starting with a), my first question is whether any high-level drivers even need to care about errors from these functions. I see 4913 callers that ignore the return code, and 576 that actually check it, and almost none care about the specific error (as you found as well). Unless we conclude that most PCI drivers are wrong, could we just change the return type to 'void' and assume they never fail for valid arguments on a valid pci_device* ?
I really like this idea.
pci_write_config_*() has one return value, and only 100ish of 2500 callers check for errors. It's sometimes possible for config accessors to detect PCI errors and return failure, e.g., device was removed or didn't respond, but most of them don't, and detecting these errors is not really that valuable.
pci_read_config_*() is much more interesting because it returns two things, the function return value and the value read from the PCI device, and it's complicated to check both.
Again it's sometimes possible for config read accessors to detect PCI errors, but in most cases a PCI error means the accessor returns success and the value from PCI is ~0.
Checking the function return value catches programming errors (bad alignment, etc) but misses most of the interesting errors (device was unplugged or reported a PCI error).
Checking the value returned from PCI is tricky because ~0 is a valid value for some config registers, and only the driver knows for sure. If the driver knows that ~0 is a possible value, it would have to do something else, e.g., another config read of a register that *cannot* be ~0, to see whether it's really an error.
I suspect that if we had a single value to look at it would be easier to get right. Error checking with current interface would look like this:
err = pci_read_config_word(dev, addr, &val); if (err) return -EINVAL;if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL; /* if ~0 is potentially a valid value */ err = pci_read_config_word(dev, PCI_VENDOR_ID, &val2); if (err) return -EINVAL; if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Error checking with a possible interface that returned only a single value could look like this:
val = pci_config_read_word(dev, addr); if (PCI_POSSIBLE_ERROR(val)) { /* if driver knows ~0 is invalid */ return -EINVAL;/* if ~0 is potentially a valid value */ val2 = pci_config_read_word(dev, PCI_VENDOR_ID); if (PCI_POSSIBLE_ERROR(val2)) return -EINVAL;}
Am I understanding you correctly?
Quoted 8 lines
Quoted 4 lines
For b), it might be nice to also change other aspects of the interface, e.g. passing a
pci_host_bridgepointer plus bus number instead of apci_buspointer, or having the callback in thepci_host_bridgestructure.I like this idea a lot, too. I think the fact that
pci_bus_read_config_word()requires apci_bus* complicates things in a few places.
I've been looking at the various host implementations of config accessors as well as probe functions. Needing the pci_bus pointer is a big reason why host drivers will have 2 sets of config accessors or don't use the generic ones. Often that's just for the root bus config space init before pci_host_probe() is called. Perhaps that's better addressed with a fixup hook for the host bridge? ftpci100i is a good example of this.
The root bus accesses are often different from the rest of config space. Determining if an access is for the root bus or not is all over the map, but often involves a private bus number variable. I have a series to use pci_is_root_bus() instead and eliminate a bunch of bus number handling in the host drivers (I'm sure there's a bunch of hosts that would be broken if the root bus is not 0). The majority of hosts don't really need to know anything about the bus number. The more I've thought about it, it would be better if the PCI core handled this and picked the right ops to call. We already have several cases of host drivers with their own ops for this and we could eliminate several layers of indirection (looking at you, DWC). Any thoughts on direction here would be helpful.
Quoted 3 lines
I think it's completely separate, as you say, and we should defer it for now because even part a) is a lot of work. I added it to my list of possible future projects.
Got that published somewhere? :)
Rob
Quoted 12 lines · Bjorn Helgaas
Quoted 2 lines
fail for valid arguments on a valid pci_device* ?
I really like this idea.
pci_write_config_*() has one return value, and only 100ish of 2500 callers check for errors. It's sometimes possible for config accessors to detect PCI errors and return failure, e.g., device was removed or didn't respond, but most of them don't, and detecting these
errors is not really that valuable.
Quoted 3 lines
pci_read_config_*() is much more interesting because it returns two things, the function return value and the value read from the PCI device, and it's complicated to check both.
.../...
I agree. It's a mess at the moment.
We have separate mechanism to convey PCI errors (among other things the channel state) which should apply to config space when detection is possible.
I think returning all 1's is the right thing to do here and avoids odd duplicate error detection logic which I bet you is never properly tested.
Quoted 5 lines
Quoted 4 lines
For b), it might be nice to also change other aspects of the interface, e.g. passing a
pci_host_bridgepointer plus bus number instead of apci_buspointer, or having the callback in thepci_host_bridgestructure.
Quoted 7 lines
I like this idea a lot, too. I think the fact that
pci_bus_read_config_word()requires apci_bus* complicates things in a few places.I think it's completely separate, as you say, and we should defer it for now because even part a) is a lot of work. I added it to my list of possible future projects.
Agreed on both points.
Cheers,
Ben.
Quoted 4 lines · Saheed O. Bolarinwa
This goal of these series is to move the definition of *all* PCIBIOS* from
include/linux/pci.htoarch/x86and limit their use within there. All other tree specific definition will be left for intact. Maybe they can be renamed.
More comments later, but a few trivial whitespace issues you can clean up in the meantime. Don't repost for at least a few days to avoid spamming everybody. I found these with:
$ b4 am -om/ [email protected] $ git am m/20200713_refactormyself_move_all_pcibios_definitions_into_arch_x86.mbx
Applying: atm: Change PCIBIOS_SUCCESSFUL to 0 .git/rebase-apply/patch:11: trailing whitespace.
iadev = INPH_IA_DEV(dev); .git/rebase-apply/patch:12: trailing whitespace. for(i=0; i<64; i++) .git/rebase-apply/patch:13: trailing whitespace. if ((error = pci_read_config_dword(iadev->pci, .git/rebase-apply/patch:16: trailing whitespace, space before tab in indent. return error; .git/rebase-apply/patch:17: trailing whitespace. writel(0, iadev->reg+IPHASE5575_EXT_RESET);
warning: squelched 5 whitespace errors
warning: 10 lines add whitespace errors.
Applying: atm: Tidy Success/Failure checks .git/rebase-apply/patch:13: trailing whitespace.
.git/rebase-apply/patch:14: trailing whitespace.
iadev = INPH_IA_DEV(dev); .git/rebase-apply/patch:15: trailing whitespace. for(i=0; i<64; i++) .git/rebase-apply/patch:21: trailing whitespace. writel(0, iadev->reg+IPHASE5575_EXT_RESET); .git/rebase-apply/patch:22: trailing whitespace. for(i=0; i<64; i++) warning: squelched 3 whitespace errors warning: 8 lines add whitespace errors. Applying: atm: Fix Style ERROR- assignment in if condition .git/rebase-apply/patch:12: trailing whitespace. unsigned int pci[64];
.git/rebase-apply/patch:13: trailing whitespace.
.git/rebase-apply/patch:14: trailing whitespace.
iadev = INPH_IA_DEV(dev); .git/rebase-apply/patch:23: trailing whitespace. writel(0, iadev->reg+IPHASE5575_EXT_RESET); .git/rebase-apply/patch:32: trailing whitespace. udelay(5);
warning: squelched 2 whitespace errors
warning: 7 lines add whitespace errors.
Applying: PCI: Change PCIBIOS_SUCCESSFUL to 0 .git/rebase-apply/patch:37: trailing whitespace. struct pci_ops apecs_pci_ops = .git/rebase-apply/patch:50: trailing whitespace. static int
.git/rebase-apply/patch:59: trailing whitespace. struct pci_ops cia_pci_ops = .git/rebase-apply/patch:94: trailing whitespace. static int
.git/rebase-apply/patch:103: trailing whitespace. struct pci_ops lca_pci_ops =
warning: squelched 10 whitespace errors
warning: 15 lines add whitespace errors.