gemini: switch to 4.14
[oweals/openwrt.git] / target / linux / generic / pending-4.9 / 811-pci_disable_usb_common_quirks.patch
1 From: Felix Fietkau <nbd@nbd.name>
2 Subject: debloat: disable common USB quirks
3
4 Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 ---
6  drivers/usb/host/pci-quirks.c | 16 ++++++++++++++++
7  drivers/usb/host/pci-quirks.h | 18 +++++++++++++++++-
8  include/linux/usb/hcd.h       |  7 +++++++
9  3 files changed, 40 insertions(+), 1 deletion(-)
10
11 --- a/drivers/usb/host/pci-quirks.c
12 +++ b/drivers/usb/host/pci-quirks.c
13 @@ -107,6 +107,8 @@ struct amd_chipset_type {
14         u8 rev;
15  };
16  
17 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
18 +
19  static struct amd_chipset_info {
20         struct pci_dev  *nb_dev;
21         struct pci_dev  *smbus_dev;
22 @@ -511,6 +513,10 @@ void usb_amd_dev_put(void)
23  }
24  EXPORT_SYMBOL_GPL(usb_amd_dev_put);
25  
26 +#endif /* CONFIG_PCI_DISABLE_COMMON_QUIRKS */
27 +
28 +#if IS_ENABLED(CONFIG_USB_UHCI_HCD)
29 +
30  /*
31   * Make sure the controller is completely inactive, unable to
32   * generate interrupts or do DMA.
33 @@ -590,8 +596,17 @@ reset_needed:
34         uhci_reset_hc(pdev, base);
35         return 1;
36  }
37 +#else
38 +int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base)
39 +{
40 +       return 0;
41 +}
42 +
43 +#endif
44  EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
45  
46 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
47 +
48  static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask)
49  {
50         u16 cmd;
51 @@ -1158,3 +1173,4 @@ static void quirk_usb_early_handoff(stru
52  }
53  DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
54                         PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
55 +#endif
56 --- a/drivers/usb/host/pci-quirks.h
57 +++ b/drivers/usb/host/pci-quirks.h
58 @@ -4,6 +4,9 @@
59  #ifdef CONFIG_PCI
60  void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
61  int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
62 +#endif  /* CONFIG_PCI */
63 +
64 +#if defined(CONFIG_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS)
65  int usb_amd_find_chipset_info(void);
66  int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *pdev);
67  bool usb_amd_hang_symptom_quirk(void);
68 @@ -17,12 +20,25 @@ void usb_disable_xhci_ports(struct pci_d
69  void sb800_prefetch(struct device *dev, int on);
70  #else
71  struct pci_dev;
72 +static inline int usb_amd_find_chipset_info(void)
73 +{
74 +       return 0;
75 +}
76 +static inline bool usb_amd_hang_symptom_quirk(void)
77 +{
78 +       return false;
79 +}
80 +static inline bool usb_amd_prefetch_quirk(void)
81 +{
82 +       return false;
83 +}
84  static inline void usb_amd_quirk_pll_disable(void) {}
85  static inline void usb_amd_quirk_pll_enable(void) {}
86  static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
87  static inline void usb_amd_dev_put(void) {}
88  static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
89  static inline void sb800_prefetch(struct device *dev, int on) {}
90 +static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
91  #endif  /* CONFIG_PCI */
92  
93  #endif  /*  __LINUX_USB_PCI_QUIRKS_H  */
94 --- a/include/linux/usb/hcd.h
95 +++ b/include/linux/usb/hcd.h
96 @@ -461,7 +461,14 @@ extern int usb_hcd_pci_probe(struct pci_
97  extern void usb_hcd_pci_remove(struct pci_dev *dev);
98  extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
99  
100 +#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
101  extern int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev);
102 +#else
103 +static inline int usb_hcd_amd_remote_wakeup_quirk(struct pci_dev *dev)
104 +{
105 +       return 0;
106 +}
107 +#endif
108  
109  #ifdef CONFIG_PM
110  extern const struct dev_pm_ops usb_hcd_pci_pm_ops;