summaryrefslogtreecommitdiffstats
path: root/sys/i386/pci
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2009-09-24 07:11:23 +0000
committeravg <avg@FreeBSD.org>2009-09-24 07:11:23 +0000
commit96f7c01c8c88ab09204b311bf34772cbf18318b9 (patch)
tree74e4fa7e170e28930cb74fb5fb991eab8429fe07 /sys/i386/pci
parente9f89a2ebc629284a87e05e0400dca7ada271d6b (diff)
downloadFreeBSD-src-96f7c01c8c88ab09204b311bf34772cbf18318b9.zip
FreeBSD-src-96f7c01c8c88ab09204b311bf34772cbf18318b9.tar.gz
number of cleanups in i386 and amd64 pci md code
o introduce PCIE_REGMAX and use it instead of ad-hoc constant o where 'reg' parameter/variable is not already unsigned, cast it to unsigned before comparison with maximum value to cut off negative values o use PCI_SLOTMAX in several places where 31 or 32 were explicitly used o drop redundant check of 'bytes' in i386 pciereg_cfgread() - valid values are already checked in the subsequent switch Reviewed by: jhb MFC after: 1 week
Diffstat (limited to 'sys/i386/pci')
-rw-r--r--sys/i386/pci/pci_cfgreg.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c
index 20050e6..ae56990 100644
--- a/sys/i386/pci/pci_cfgreg.c
+++ b/sys/i386/pci/pci_cfgreg.c
@@ -299,9 +299,9 @@ pci_cfgenable(unsigned bus, unsigned slot, unsigned func, int reg, int bytes)
if (bus <= PCI_BUSMAX
&& slot < devmax
&& func <= PCI_FUNCMAX
- && reg <= PCI_REGMAX
+ && (unsigned)reg <= PCI_REGMAX
&& bytes != 3
- && (unsigned) bytes <= 4
+ && (unsigned)bytes <= 4
&& (reg & (bytes - 1)) == 0) {
switch (cfgmech) {
case CFGMECH_PCIE:
@@ -595,7 +595,7 @@ pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus)
* fall back to using type 1 config access instead.
*/
if (pci_cfgregopen() != 0) {
- for (slot = 0; slot < 32; slot++) {
+ for (slot = 0; slot <= PCI_SLOTMAX; slot++) {
val1 = pcireg_cfgread(0, slot, 0, 0, 4);
if (val1 == 0xffffffff)
continue;
@@ -661,8 +661,8 @@ pciereg_cfgread(int bus, unsigned slot, unsigned func, unsigned reg,
vm_paddr_t pa, papage;
int data = -1;
- if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 ||
- func > PCI_FUNCMAX || reg >= 0x1000 || bytes > 4 || bytes == 3)
+ if (bus < pcie_minbus || bus > pcie_maxbus || slot > PCI_SLOTMAX ||
+ func > PCI_FUNCMAX || reg > PCIE_REGMAX)
return (-1);
critical_enter();
@@ -695,8 +695,8 @@ pciereg_cfgwrite(int bus, unsigned slot, unsigned func, unsigned reg, int data,
volatile vm_offset_t va;
vm_paddr_t pa, papage;
- if (bus < pcie_minbus || bus > pcie_maxbus || slot >= 32 ||
- func > PCI_FUNCMAX || reg >= 0x1000)
+ if (bus < pcie_minbus || bus > pcie_maxbus || slot > PCI_SLOTMAX ||
+ func > PCI_FUNCMAX || reg > PCIE_REGMAX)
return;
critical_enter();
OpenPOWER on IntegriCloud