mac80211: refresh patches
[openwrt/staging/rmilecki.git] / package / kernel / mac80211 / patches / build / 101-backport-add-pci_disable_link_state-wrapper-with-ret.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 28 Oct 2019 15:20:40 +0100
3 Subject: [PATCH] backport: add pci_disable_link_state wrapper with return code
4
5 The signature of pci_disable_link_state was changed to indicate if the state
6 was successfully disabled. Since the old version did not have this, add a
7 wrapper which checks the pcie register to determine the return code
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/backport-include/linux/pci.h
13 +++ b/backport-include/linux/pci.h
14 @@ -240,4 +240,29 @@ static inline struct pci_dev *pcie_find_
15 (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
16 #endif
17
18 +#if defined(CONFIG_PCI) && LINUX_VERSION_IS_LESS(5,3,0)
19 +
20 +static inline int
21 +LINUX_BACKPORT(pci_disable_link_state)(struct pci_dev *pdev, int state)
22 +{
23 + u16 aspmc;
24 +
25 + pci_disable_link_state(pdev, state);
26 +
27 + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspmc);
28 + if ((state & PCIE_LINK_STATE_L0S) &&
29 + (aspmc & PCI_EXP_LNKCTL_ASPM_L0S))
30 + return -EPERM;
31 +
32 + if ((state & PCIE_LINK_STATE_L1) &&
33 + (aspmc & PCI_EXP_LNKCTL_ASPM_L1))
34 + return -EPERM;
35 +
36 + return 0;
37 +}
38 +
39 +#define pci_disable_link_state LINUX_BACKPORT(pci_disable_link_state)
40 +
41 +#endif
42 +
43 #endif /* _BACKPORT_LINUX_PCI_H */