thunderbolt: Use dev_err_probe()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 22 Sep 2022 14:32:40 +0000 (17:32 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Sat, 24 Sep 2022 06:22:01 +0000 (09:22 +0300)
Unify error message format by using dev_err_probe().
While at it, use temporary variable for device in
the rest of the messaging calls.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/nhi.c

index 75c8bfd..9c38035 100644 (file)
@@ -1149,6 +1149,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. */
@@ -1179,10 +1180,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;
@@ -1223,26 +1222,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)
@@ -1253,7 +1247,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);
@@ -1266,18 +1260,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);
 
@@ -1288,13 +1278,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) {