Skip to content

Commit abaaac4

Browse files
ij-intelbjorn-helgaas
authored andcommitted
PCI: hotplug: Use FIELD_GET/PREP()
Instead of handcrafted shifts to handle register fields, use FIELD_GET/FIELD_PREP(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 92af77c commit abaaac4

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

drivers/pci/hotplug/pciehp_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define pr_fmt(fmt) "pciehp: " fmt
2121
#define dev_fmt pr_fmt
2222

23+
#include <linux/bitfield.h>
2324
#include <linux/moduleparam.h>
2425
#include <linux/kernel.h>
2526
#include <linux/slab.h>
@@ -103,7 +104,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
103104
struct pci_dev *pdev = ctrl->pcie->port;
104105

105106
if (status)
106-
status <<= PCI_EXP_SLTCTL_ATTN_IND_SHIFT;
107+
status = FIELD_PREP(PCI_EXP_SLTCTL_AIC, status);
107108
else
108109
status = PCI_EXP_SLTCTL_ATTN_IND_OFF;
109110

drivers/pci/hotplug/pciehp_hpc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#define dev_fmt(fmt) "pciehp: " fmt
1616

17+
#include <linux/bitfield.h>
1718
#include <linux/dmi.h>
1819
#include <linux/kernel.h>
1920
#include <linux/types.h>
@@ -484,7 +485,7 @@ int pciehp_set_raw_indicator_status(struct hotplug_slot *hotplug_slot,
484485
struct pci_dev *pdev = ctrl_dev(ctrl);
485486

486487
pci_config_pm_runtime_get(pdev);
487-
pcie_write_cmd_nowait(ctrl, status << 6,
488+
pcie_write_cmd_nowait(ctrl, FIELD_PREP(PCI_EXP_SLTCTL_AIC, status),
488489
PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC);
489490
pci_config_pm_runtime_put(pdev);
490491
return 0;
@@ -1028,7 +1029,7 @@ struct controller *pcie_init(struct pcie_device *dev)
10281029
PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC);
10291030

10301031
ctrl_info(ctrl, "Slot #%d AttnBtn%c PwrCtrl%c MRL%c AttnInd%c PwrInd%c HotPlug%c Surprise%c Interlock%c NoCompl%c IbPresDis%c LLActRep%c%s\n",
1031-
(slot_cap & PCI_EXP_SLTCAP_PSN) >> 19,
1032+
FIELD_GET(PCI_EXP_SLTCAP_PSN, slot_cap),
10321033
FLAG(slot_cap, PCI_EXP_SLTCAP_ABP),
10331034
FLAG(slot_cap, PCI_EXP_SLTCAP_PCP),
10341035
FLAG(slot_cap, PCI_EXP_SLTCAP_MRLSP),

drivers/pci/hotplug/pnv_php.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright Gavin Shan, IBM Corporation 2016.
66
*/
77

8+
#include <linux/bitfield.h>
89
#include <linux/libfdt.h>
910
#include <linux/module.h>
1011
#include <linux/pci.h>
@@ -731,7 +732,7 @@ static int pnv_php_enable_msix(struct pnv_php_slot *php_slot)
731732

732733
/* Check hotplug MSIx entry is in range */
733734
pcie_capability_read_word(pdev, PCI_EXP_FLAGS, &pcie_flag);
734-
entry.entry = (pcie_flag & PCI_EXP_FLAGS_IRQ) >> 9;
735+
entry.entry = FIELD_GET(PCI_EXP_FLAGS_IRQ, pcie_flag);
735736
if (entry.entry >= nr_entries)
736737
return -ERANGE;
737738

0 commit comments

Comments
 (0)