usb: dwc3: pci: Register a software node for the dwc3 platform device
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>
Fri, 15 Jan 2021 09:49:12 +0000 (12:49 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Jan 2021 15:06:42 +0000 (16:06 +0100)
By registering the software node directly instead of just
the properties in it, the driver can take advantage of also
the other features the software nodes have.

Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20210115094914.88401-3-heikki.krogerus@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/dwc3-pci.c

index bae6a70..037bc21 100644 (file)
@@ -142,6 +142,18 @@ static const struct property_entry dwc3_pci_amd_properties[] = {
        {}
 };
 
+static const struct software_node dwc3_pci_intel_swnode = {
+       .properties = dwc3_pci_intel_properties,
+};
+
+static const struct software_node dwc3_pci_intel_mrfld_swnode = {
+       .properties = dwc3_pci_mrfld_properties,
+};
+
+static const struct software_node dwc3_pci_amd_swnode = {
+       .properties = dwc3_pci_amd_properties,
+};
+
 static int dwc3_pci_quirks(struct dwc3_pci *dwc)
 {
        struct pci_dev                  *pdev = dwc->pci;
@@ -222,7 +234,6 @@ static void dwc3_pci_resume_work(struct work_struct *work)
 
 static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
 {
-       struct property_entry *p = (struct property_entry *)id->driver_data;
        struct dwc3_pci         *dwc;
        struct resource         res[2];
        int                     ret;
@@ -265,7 +276,7 @@ static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
        dwc->dwc3->dev.parent = dev;
        ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev));
 
-       ret = platform_device_add_properties(dwc->dwc3, p);
+       ret = device_add_software_node(&dwc->dwc3->dev, (void *)id->driver_data);
        if (ret < 0)
                goto err;
 
@@ -288,6 +299,7 @@ static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
 
        return 0;
 err:
+       device_remove_software_node(&dwc->dwc3->dev);
        platform_device_put(dwc->dwc3);
        return ret;
 }
@@ -304,75 +316,76 @@ static void dwc3_pci_remove(struct pci_dev *pci)
 #endif
        device_init_wakeup(&pci->dev, false);
        pm_runtime_get(&pci->dev);
+       device_remove_software_node(&dwc->dwc3->dev);
        platform_device_unregister(dwc->dwc3);
 }
 
 static const struct pci_device_id dwc3_pci_id_table[] = {
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BSW),
-         (kernel_ulong_t) &dwc3_pci_intel_properties },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BYT),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
-         (kernel_ulong_t) &dwc3_pci_mrfld_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_mrfld_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLLP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CMLH),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTLP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTH),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT_M),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_APL),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_KBP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_GLK),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPLP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPH),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPV),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICLLP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_EHLLP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGPLP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGPH),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_JSP),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADLS),
-         (kernel_ulong_t) &dwc3_pci_intel_properties, },
+         (kernel_ulong_t) &dwc3_pci_intel_swnode, },
 
        { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NL_USB),
-         (kernel_ulong_t) &dwc3_pci_amd_properties, },
+         (kernel_ulong_t) &dwc3_pci_amd_swnode, },
        {  }    /* Terminating Entry */
 };
 MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);