From: Felix Fietkau <nbd@nbd.name>
Date: Sat, 26 Apr 2025 21:10:40 +0200
Subject: [PATCH] debloat: disable common USB quirks

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/usb/host/pci-quirks.c | 7 +++++++
 drivers/usb/host/pci-quirks.h | 4 ++++
 2 files changed, 11 insertions(+)

--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -590,6 +590,7 @@ bool usb_amd_pt_check_port(struct device
 EXPORT_SYMBOL_GPL(usb_amd_pt_check_port);
 #endif /* CONFIG_USB_PCI_AMD */
 
+#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
 static int usb_asmedia_wait_write(struct pci_dev *pdev)
 {
 	unsigned long retry_count;
@@ -642,6 +643,7 @@ static inline int io_type_enabled(struct
 }
 
 #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)
+#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */
 
 #if defined(CONFIG_HAS_IOPORT) && IS_ENABLED(CONFIG_USB_UHCI_HCD)
 /*
@@ -724,6 +726,10 @@ reset_needed:
 	return 1;
 }
 EXPORT_SYMBOL_GPL(uhci_check_and_reset_hc);
+#endif
+
+#ifndef CONFIG_PCI_DISABLE_COMMON_QUIRKS
+#if defined(CONFIG_HAS_IOPORT) && IS_ENABLED(CONFIG_USB_UHCI_HCD)
 
 #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO)
 
@@ -1304,3 +1310,4 @@ static void quirk_usb_early_handoff(stru
 }
 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
 			PCI_CLASS_SERIAL_USB, 8, quirk_usb_early_handoff);
+#endif /* !CONFIG_PCI_DISABLE_COMMON_QUIRKS */
--- a/drivers/usb/host/pci-quirks.h
+++ b/drivers/usb/host/pci-quirks.h
@@ -38,12 +38,16 @@ static inline bool usb_amd_pt_check_port
 #ifdef CONFIG_USB_PCI
 void uhci_reset_hc(struct pci_dev *pdev, unsigned long base);
 int uhci_check_and_reset_hc(struct pci_dev *pdev, unsigned long base);
+#endif
+
+#if defined(CONFIG_USB_PCI) && !defined(CONFIG_PCI_DISABLE_COMMON_QUIRKS)
 void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev);
 void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev);
 void usb_disable_xhci_ports(struct pci_dev *xhci_pdev);
 #else
 struct pci_dev;
 static inline void usb_asmedia_modifyflowcontrol(struct pci_dev *pdev) {}
+static inline void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) {}
 static inline void usb_disable_xhci_ports(struct pci_dev *xhci_pdev) {}
 #endif  /* CONFIG_USB_PCI */
 
