treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / mt7603 / pci.c
blob2f2f337e22014f661fb6d1a56b9a2befec738f70
1 // SPDX-License-Identifier: ISC
3 #include <linux/kernel.h>
4 #include <linux/module.h>
5 #include <linux/pci.h>
7 #include "mt7603.h"
9 static const struct pci_device_id mt76pci_device_table[] = {
10 { PCI_DEVICE(0x14c3, 0x7603) },
11 { },
14 static int
15 mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
17 struct mt7603_dev *dev;
18 struct mt76_dev *mdev;
19 int ret;
21 ret = pcim_enable_device(pdev);
22 if (ret)
23 return ret;
25 ret = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
26 if (ret)
27 return ret;
29 pci_set_master(pdev);
31 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
32 if (ret)
33 return ret;
35 mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops,
36 &mt7603_drv_ops);
37 if (!mdev)
38 return -ENOMEM;
40 dev = container_of(mdev, struct mt7603_dev, mt76);
41 mt76_mmio_init(mdev, pcim_iomap_table(pdev)[0]);
43 mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
44 (mt76_rr(dev, MT_HW_REV) & 0xff);
45 dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
47 ret = devm_request_irq(mdev->dev, pdev->irq, mt7603_irq_handler,
48 IRQF_SHARED, KBUILD_MODNAME, dev);
49 if (ret)
50 goto error;
52 ret = mt7603_register_device(dev);
53 if (ret)
54 goto error;
56 return 0;
57 error:
58 ieee80211_free_hw(mt76_hw(dev));
59 return ret;
62 static void
63 mt76pci_remove(struct pci_dev *pdev)
65 struct mt76_dev *mdev = pci_get_drvdata(pdev);
66 struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
68 mt7603_unregister_device(dev);
71 MODULE_DEVICE_TABLE(pci, mt76pci_device_table);
72 MODULE_FIRMWARE(MT7603_FIRMWARE_E1);
73 MODULE_FIRMWARE(MT7603_FIRMWARE_E2);
75 struct pci_driver mt7603_pci_driver = {
76 .name = KBUILD_MODNAME,
77 .id_table = mt76pci_device_table,
78 .probe = mt76pci_probe,
79 .remove = mt76pci_remove,