Merge tag 'usb-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[platform/kernel/linux-rpi.git] / drivers / thunderbolt / nhi.c
index b5cd967..4dce2ed 100644 (file)
@@ -1184,6 +1184,7 @@ static void nhi_check_iommu(struct tb_nhi *nhi)
 static int nhi_init_msi(struct tb_nhi *nhi)
 {
        struct pci_dev *pdev = nhi->pdev;
+       struct device *dev = &pdev->dev;
        int res, irq, nvec;
 
        /* In case someone left them on. */
@@ -1214,10 +1215,8 @@ static int nhi_init_msi(struct tb_nhi *nhi)
 
                res = devm_request_irq(&pdev->dev, irq, nhi_msi,
                                       IRQF_NO_SUSPEND, "thunderbolt", nhi);
-               if (res) {
-                       dev_err(&pdev->dev, "request_irq failed, aborting\n");
-                       return res;
-               }
+               if (res)
+                       return dev_err_probe(dev, res, "request_irq failed, aborting\n");
        }
 
        return 0;
@@ -1258,26 +1257,21 @@ static struct tb *nhi_select_cm(struct tb_nhi *nhi)
 
 static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
+       struct device *dev = &pdev->dev;
        struct tb_nhi *nhi;
        struct tb *tb;
        int res;
 
-       if (!nhi_imr_valid(pdev)) {
-               dev_warn(&pdev->dev, "firmware image not valid, aborting\n");
-               return -ENODEV;
-       }
+       if (!nhi_imr_valid(pdev))
+               return dev_err_probe(dev, -ENODEV, "firmware image not valid, aborting\n");
 
        res = pcim_enable_device(pdev);
-       if (res) {
-               dev_err(&pdev->dev, "cannot enable PCI device, aborting\n");
-               return res;
-       }
+       if (res)
+               return dev_err_probe(dev, res, "cannot enable PCI device, aborting\n");
 
        res = pcim_iomap_regions(pdev, 1 << 0, "thunderbolt");
-       if (res) {
-               dev_err(&pdev->dev, "cannot obtain PCI resources, aborting\n");
-               return res;
-       }
+       if (res)
+               return dev_err_probe(dev, res, "cannot obtain PCI resources, aborting\n");
 
        nhi = devm_kzalloc(&pdev->dev, sizeof(*nhi), GFP_KERNEL);
        if (!nhi)
@@ -1288,7 +1282,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        /* cannot fail - table is allocated in pcim_iomap_regions */
        nhi->iobase = pcim_iomap_table(pdev)[0];
        nhi->hop_count = ioread32(nhi->iobase + REG_HOP_COUNT) & 0x3ff;
-       dev_dbg(&pdev->dev, "total paths: %d\n", nhi->hop_count);
+       dev_dbg(dev, "total paths: %d\n", nhi->hop_count);
 
        nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count,
                                     sizeof(*nhi->tx_rings), GFP_KERNEL);
@@ -1301,18 +1295,14 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        nhi_check_iommu(nhi);
 
        res = nhi_init_msi(nhi);
-       if (res) {
-               dev_err(&pdev->dev, "cannot enable MSI, aborting\n");
-               return res;
-       }
+       if (res)
+               return dev_err_probe(dev, res, "cannot enable MSI, aborting\n");
 
        spin_lock_init(&nhi->lock);
 
        res = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
-       if (res) {
-               dev_err(&pdev->dev, "failed to set DMA mask\n");
-               return res;
-       }
+       if (res)
+               return dev_err_probe(dev, res, "failed to set DMA mask\n");
 
        pci_set_master(pdev);
 
@@ -1323,13 +1313,11 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        }
 
        tb = nhi_select_cm(nhi);
-       if (!tb) {
-               dev_err(&nhi->pdev->dev,
+       if (!tb)
+               return dev_err_probe(dev, -ENODEV,
                        "failed to determine connection manager, aborting\n");
-               return -ENODEV;
-       }
 
-       dev_dbg(&nhi->pdev->dev, "NHI initialized, starting thunderbolt\n");
+       dev_dbg(dev, "NHI initialized, starting thunderbolt\n");
 
        res = tb_domain_add(tb);
        if (res) {
@@ -1433,6 +1421,7 @@ static struct pci_device_id nhi_ids[] = {
          .driver_data = (kernel_ulong_t)&icl_nhi_ops },
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICL_NHI1),
          .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+       /* Thunderbolt 4 */
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGL_NHI0),
          .driver_data = (kernel_ulong_t)&icl_nhi_ops },
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGL_NHI1),
@@ -1449,6 +1438,12 @@ static struct pci_device_id nhi_ids[] = {
          .driver_data = (kernel_ulong_t)&icl_nhi_ops },
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_RPL_NHI1),
          .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+       { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL_M_NHI0),
+         .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+       { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL_P_NHI0),
+         .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+       { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MTL_P_NHI1),
+         .driver_data = (kernel_ulong_t)&icl_nhi_ops },
 
        /* Any USB4 compliant host */
        { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_USB4, ~0) },