treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / mt7603 / soc.c
blob68efb300c0d88a426a8a86f79daa5f785a0e1f37
1 // SPDX-License-Identifier: ISC
3 #include <linux/kernel.h>
4 #include <linux/module.h>
5 #include <linux/platform_device.h>
7 #include "mt7603.h"
9 static int
10 mt76_wmac_probe(struct platform_device *pdev)
12 struct mt7603_dev *dev;
13 void __iomem *mem_base;
14 struct mt76_dev *mdev;
15 int irq;
16 int ret;
18 irq = platform_get_irq(pdev, 0);
19 if (irq < 0)
20 return irq;
22 mem_base = devm_platform_ioremap_resource(pdev, 0);
23 if (IS_ERR(mem_base)) {
24 dev_err(&pdev->dev, "Failed to get memory resource\n");
25 return PTR_ERR(mem_base);
28 mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops,
29 &mt7603_drv_ops);
30 if (!mdev)
31 return -ENOMEM;
33 dev = container_of(mdev, struct mt7603_dev, mt76);
34 mt76_mmio_init(mdev, mem_base);
36 mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
37 (mt76_rr(dev, MT_HW_REV) & 0xff);
38 dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
40 ret = devm_request_irq(mdev->dev, irq, mt7603_irq_handler,
41 IRQF_SHARED, KBUILD_MODNAME, dev);
42 if (ret)
43 goto error;
45 ret = mt7603_register_device(dev);
46 if (ret)
47 goto error;
49 return 0;
50 error:
51 ieee80211_free_hw(mt76_hw(dev));
52 return ret;
55 static int
56 mt76_wmac_remove(struct platform_device *pdev)
58 struct mt76_dev *mdev = platform_get_drvdata(pdev);
59 struct mt7603_dev *dev = container_of(mdev, struct mt7603_dev, mt76);
61 mt7603_unregister_device(dev);
63 return 0;
66 static const struct of_device_id of_wmac_match[] = {
67 { .compatible = "mediatek,mt7628-wmac" },
68 {},
71 MODULE_DEVICE_TABLE(of, of_wmac_match);
72 MODULE_FIRMWARE(MT7628_FIRMWARE_E1);
73 MODULE_FIRMWARE(MT7628_FIRMWARE_E2);
75 struct platform_driver mt76_wmac_driver = {
76 .probe = mt76_wmac_probe,
77 .remove = mt76_wmac_remove,
78 .driver = {
79 .name = "mt76_wmac",
80 .of_match_table = of_wmac_match,