Skip to content

Commit 83c0881

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: Use PCI_HEADER_TYPE_* instead of literals
Replace literals under drivers/pci/ with PCI_HEADER_TYPE_MASK, PCI_HEADER_TYPE_NORMAL, and PCI_HEADER_TYPE_MFD. Also replace !! boolean conversions with FIELD_GET(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Wolfram Sang <[email protected]> # for Renesas R-Car
1 parent bdca03a commit 83c0881

File tree

12 files changed

+28
-27
lines changed

12 files changed

+28
-27
lines changed

drivers/pci/controller/dwc/pci-layerscape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static bool ls_pcie_is_bridge(struct ls_pcie *pcie)
5858
u32 header_type;
5959

6060
header_type = ioread8(pci->dbi_base + PCI_HEADER_TYPE);
61-
header_type &= 0x7f;
61+
header_type &= PCI_HEADER_TYPE_MASK;
6262

6363
return header_type == PCI_HEADER_TYPE_BRIDGE;
6464
}

drivers/pci/controller/mobiveil/pcie-mobiveil-host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ static bool mobiveil_pcie_is_bridge(struct mobiveil_pcie *pcie)
539539
u32 header_type;
540540

541541
header_type = mobiveil_csr_readb(pcie, PCI_HEADER_TYPE);
542-
header_type &= 0x7f;
542+
header_type &= PCI_HEADER_TYPE_MASK;
543543

544544
return header_type == PCI_HEADER_TYPE_BRIDGE;
545545
}

drivers/pci/controller/pcie-iproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ static int iproc_pcie_check_link(struct iproc_pcie *pcie)
783783

784784
/* make sure we are not in EP mode */
785785
iproc_pci_raw_config_read32(pcie, 0, PCI_HEADER_TYPE, 1, &hdr_type);
786-
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) {
786+
if ((hdr_type & PCI_HEADER_TYPE_MASK) != PCI_HEADER_TYPE_BRIDGE) {
787787
dev_err(dev, "in EP mode, hdr=%#02x\n", hdr_type);
788788
return -EFAULT;
789789
}

drivers/pci/controller/pcie-rcar-ep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void rcar_pcie_ep_hw_init(struct rcar_pcie *pcie)
4343
rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
4444
rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
4545
PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ENDPOINT << 4);
46-
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f,
46+
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), PCI_HEADER_TYPE_MASK,
4747
PCI_HEADER_TYPE_NORMAL);
4848

4949
/* Write out the physical slot number = 0 */

drivers/pci/controller/pcie-rcar-host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie)
460460
rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
461461
rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
462462
PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4);
463-
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f,
463+
rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), PCI_HEADER_TYPE_MASK,
464464
PCI_HEADER_TYPE_BRIDGE);
465465

466466
/* Enable data link layer active state reporting */

drivers/pci/controller/vmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static void vmd_domain_reset(struct vmd_dev *vmd)
527527

528528
hdr_type = readb(base + PCI_HEADER_TYPE);
529529

530-
functions = (hdr_type & 0x80) ? 8 : 1;
530+
functions = (hdr_type & PCI_HEADER_TYPE_MFD) ? 8 : 1;
531531
for (fn = 0; fn < functions; fn++) {
532532
base = vmd->cfgbar + PCIE_ECAM_OFFSET(bus,
533533
PCI_DEVFN(dev, fn), 0);

drivers/pci/hotplug/cpqphp_ctrl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
20592059
return rc;
20602060

20612061
/* If it's a bridge, check the VGA Enable bit */
2062-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2062+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
20632063
rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
20642064
if (rc)
20652065
return rc;
@@ -2342,7 +2342,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
23422342
if (rc)
23432343
return rc;
23442344

2345-
if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2345+
if ((temp_byte & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
23462346
/* set Primary bus */
23472347
dbg("set Primary bus = %d\n", func->bus);
23482348
rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
@@ -2739,7 +2739,7 @@ static int configure_new_function(struct controller *ctrl, struct pci_func *func
27392739
* PCI_BRIDGE_CTL_SERR |
27402740
* PCI_BRIDGE_CTL_NO_ISA */
27412741
rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
2742-
} else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
2742+
} else if ((temp_byte & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
27432743
/* Standard device */
27442744
rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
27452745

drivers/pci/hotplug/cpqphp_pci.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
363363
return rc;
364364

365365
/* If multi-function device, set max_functions to 8 */
366-
if (header_type & 0x80)
366+
if (header_type & PCI_HEADER_TYPE_MFD)
367367
max_functions = 8;
368368
else
369369
max_functions = 1;
@@ -372,7 +372,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
372372

373373
do {
374374
DevError = 0;
375-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
375+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
376376
/* Recurse the subordinate bus
377377
* get the subordinate bus number
378378
*/
@@ -487,13 +487,13 @@ int cpqhp_save_slot_config(struct controller *ctrl, struct pci_func *new_slot)
487487
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), 0x0B, &class_code);
488488
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, 0), PCI_HEADER_TYPE, &header_type);
489489

490-
if (header_type & 0x80) /* Multi-function device */
490+
if (header_type & PCI_HEADER_TYPE_MFD)
491491
max_functions = 8;
492492
else
493493
max_functions = 1;
494494

495495
while (function < max_functions) {
496-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
496+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
497497
/* Recurse the subordinate bus */
498498
pci_bus_read_config_byte(ctrl->pci_bus, PCI_DEVFN(new_slot->device, function), PCI_SECONDARY_BUS, &secondary_bus);
499499

@@ -571,7 +571,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
571571
/* Check for Bridge */
572572
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
573573

574-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
574+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
575575
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
576576

577577
sub_bus = (int) secondary_bus;
@@ -625,7 +625,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
625625

626626
} /* End of base register loop */
627627

628-
} else if ((header_type & 0x7F) == 0x00) {
628+
} else if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
629629
/* Figure out IO and memory base lengths */
630630
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
631631
temp_register = 0xFFFFFFFF;
@@ -723,7 +723,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func)
723723
/* Check for Bridge */
724724
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
725725

726-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
726+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
727727
/* Clear Bridge Control Register */
728728
command = 0x00;
729729
pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
@@ -858,7 +858,7 @@ int cpqhp_save_used_resources(struct controller *ctrl, struct pci_func *func)
858858
}
859859
} /* End of base register loop */
860860
/* Standard header */
861-
} else if ((header_type & 0x7F) == 0x00) {
861+
} else if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
862862
/* Figure out IO and memory base lengths */
863863
for (cloop = 0x10; cloop <= 0x24; cloop += 4) {
864864
pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
@@ -975,7 +975,7 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func)
975975
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
976976

977977
/* If this is a bridge device, restore subordinate devices */
978-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
978+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
979979
pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
980980

981981
sub_bus = (int) secondary_bus;
@@ -1067,7 +1067,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
10671067
/* Check for Bridge */
10681068
pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
10691069

1070-
if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
1070+
if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
10711071
/* In order to continue checking, we must program the
10721072
* bus registers in the bridge to respond to accesses
10731073
* for its subordinate bus(es)
@@ -1090,7 +1090,7 @@ int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
10901090

10911091
}
10921092
/* Check to see if it is a standard config header */
1093-
else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
1093+
else if ((header_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_NORMAL) {
10941094
/* Check subsystem vendor and ID */
10951095
pci_bus_read_config_dword(pci_bus, devfn, PCI_SUBSYSTEM_VENDOR_ID, &temp_register);
10961096

drivers/pci/hotplug/ibmphp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <linux/pci_hotplug.h>
20+
#include <linux/pci_regs.h>
2021

2122
extern int ibmphp_debug;
2223

@@ -286,8 +287,8 @@ int ibmphp_register_pci(void);
286287

287288
/* pci specific defines */
288289
#define PCI_VENDOR_ID_NOTVALID 0xFFFF
289-
#define PCI_HEADER_TYPE_MULTIDEVICE 0x80
290-
#define PCI_HEADER_TYPE_MULTIBRIDGE 0x81
290+
#define PCI_HEADER_TYPE_MULTIDEVICE (PCI_HEADER_TYPE_MFD|PCI_HEADER_TYPE_NORMAL)
291+
#define PCI_HEADER_TYPE_MULTIBRIDGE (PCI_HEADER_TYPE_MFD|PCI_HEADER_TYPE_BRIDGE)
291292

292293
#define LATENCY 0x64
293294
#define CACHE 64

drivers/pci/hotplug/ibmphp_pci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ static struct res_needed *scan_behind_bridge(struct pci_func *func, u8 busno)
10871087
pci_bus_read_config_dword(ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class);
10881088

10891089
debug("hdr_type behind the bridge is %x\n", hdr_type);
1090-
if ((hdr_type & 0x7f) == PCI_HEADER_TYPE_BRIDGE) {
1090+
if ((hdr_type & PCI_HEADER_TYPE_MASK) == PCI_HEADER_TYPE_BRIDGE) {
10911091
err("embedded bridges not supported for hot-plugging.\n");
10921092
amount->not_correct = 1;
10931093
return amount;

0 commit comments

Comments
 (0)