mt76x0: remove mt76x0u_alloc_device routine
authorLorenzo Bianconi <lorenzo.bianconi@redhat.com>
Thu, 31 Jan 2019 16:55:56 +0000 (17:55 +0100)
committerFelix Fietkau <nbd@nbd.name>
Mon, 18 Feb 2019 18:54:34 +0000 (19:54 +0100)
Remove mt76x0u_alloc_device since it just runs mt76_alloc_device.
Move mt76_alloc_device call in mt76x0u_probe and in mt76x0e_probe

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76x0/init.c
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
drivers/net/wireless/mediatek/mt76/mt76x0/pci.c
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c

index 34db3ec24e6e66d2d4645f7c57a8e9c45aee1cfd..820632e40c1b841e344dfc549155c248b6e5d63f 100644 (file)
@@ -262,25 +262,6 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev)
 }
 EXPORT_SYMBOL_GPL(mt76x0_init_hardware);
 
-struct mt76x02_dev *
-mt76x0_alloc_device(struct device *pdev,
-                   const struct mt76_driver_ops *drv_ops,
-                   const struct ieee80211_ops *ops)
-{
-       struct mt76x02_dev *dev;
-       struct mt76_dev *mdev;
-
-       mdev = mt76_alloc_device(pdev, sizeof(*dev), ops, drv_ops);
-       if (!mdev)
-               return NULL;
-
-       dev = container_of(mdev, struct mt76x02_dev, mt76);
-       mutex_init(&dev->phy_mutex);
-
-       return dev;
-}
-EXPORT_SYMBOL_GPL(mt76x0_alloc_device);
-
 int mt76x0_register_device(struct mt76x02_dev *dev)
 {
        int ret;
index 46629f61673bd57aaecca464ff209ca685b58672..51fbd75dff31fd726ac39f4c5a76514d7c35bb56 100644 (file)
@@ -50,10 +50,6 @@ static inline bool is_mt7630(struct mt76x02_dev *dev)
 }
 
 /* Init */
-struct mt76x02_dev *
-mt76x0_alloc_device(struct device *pdev,
-                   const struct mt76_driver_ops *drv_ops,
-                   const struct ieee80211_ops *ops);
 int mt76x0_init_hardware(struct mt76x02_dev *dev);
 int mt76x0_register_device(struct mt76x02_dev *dev);
 void mt76x0_chip_onoff(struct mt76x02_dev *dev, bool enable, bool reset);
index 6992b3d7dfeca9934492287506d160905a5830b7..f302162036d0032f6eb3de51b78e07a47e55a886 100644 (file)
@@ -174,6 +174,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                .sta_remove = mt76x02_sta_remove,
        };
        struct mt76x02_dev *dev;
+       struct mt76_dev *mdev;
        int ret;
 
        ret = pcim_enable_device(pdev);
@@ -190,16 +191,20 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (ret)
                return ret;
 
-       dev = mt76x0_alloc_device(&pdev->dev, &drv_ops, &mt76x0e_ops);
-       if (!dev)
+       mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x0e_ops,
+                                &drv_ops);
+       if (!mdev)
                return -ENOMEM;
 
-       mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);
+       dev = container_of(mdev, struct mt76x02_dev, mt76);
+       mutex_init(&dev->phy_mutex);
 
-       dev->mt76.rev = mt76_rr(dev, MT_ASIC_VERSION);
-       dev_info(dev->mt76.dev, "ASIC revision: %08x\n", dev->mt76.rev);
+       mt76_mmio_init(mdev, pcim_iomap_table(pdev)[0]);
 
-       ret = devm_request_irq(dev->mt76.dev, pdev->irq, mt76x02_irq_handler,
+       mdev->rev = mt76_rr(dev, MT_ASIC_VERSION);
+       dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev);
+
+       ret = devm_request_irq(mdev->dev, pdev->irq, mt76x02_irq_handler,
                               IRQF_SHARED, KBUILD_MODNAME, dev);
        if (ret)
                goto error;
index 91d8afd9a0eda7b663749bac4bfd7f04e4336c1a..2f259bc0ad9e53b6df8d473d82554d977d89d5d7 100644 (file)
@@ -233,14 +233,18 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
        };
        struct usb_device *usb_dev = interface_to_usbdev(usb_intf);
        struct mt76x02_dev *dev;
+       struct mt76_dev *mdev;
        u32 asic_rev, mac_rev;
        int ret;
 
-       dev = mt76x0_alloc_device(&usb_intf->dev, &drv_ops,
-                                 &mt76x0u_ops);
-       if (!dev)
+       mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops,
+                                &drv_ops);
+       if (!mdev)
                return -ENOMEM;
 
+       dev = container_of(mdev, struct mt76x02_dev, mt76);
+       mutex_init(&dev->phy_mutex);
+
        /* Quirk for Archer T1U */
        if (id->driver_info)
                dev->no_2ghz = true;
@@ -250,27 +254,27 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
 
        usb_set_intfdata(usb_intf, dev);
 
-       mt76x02u_init_mcu(&dev->mt76);
-       ret = mt76u_init(&dev->mt76, usb_intf);
+       mt76x02u_init_mcu(mdev);
+       ret = mt76u_init(mdev, usb_intf);
        if (ret)
                goto err;
 
        /* Disable the HW, otherwise MCU fail to initalize on hot reboot */
        mt76x0_chip_onoff(dev, false, false);
 
-       if (!mt76x02_wait_for_mac(&dev->mt76)) {
+       if (!mt76x02_wait_for_mac(mdev)) {
                ret = -ETIMEDOUT;
                goto err;
        }
 
        asic_rev = mt76_rr(dev, MT_ASIC_VERSION);
        mac_rev = mt76_rr(dev, MT_MAC_CSR0);
-       dev_info(dev->mt76.dev, "ASIC revision: %08x MAC revision: %08x\n",
+       dev_info(mdev->dev, "ASIC revision: %08x MAC revision: %08x\n",
                 asic_rev, mac_rev);
 
        /* Note: vendor driver skips this check for MT76X0U */
        if (!(mt76_rr(dev, MT_EFUSE_CTRL) & MT_EFUSE_CTRL_SEL))
-               dev_warn(dev->mt76.dev, "Warning: eFUSE not present\n");
+               dev_warn(mdev->dev, "Warning: eFUSE not present\n");
 
        ret = mt76x0u_register_device(dev);
        if (ret < 0)
@@ -282,7 +286,7 @@ err:
        usb_set_intfdata(usb_intf, NULL);
        usb_put_dev(interface_to_usbdev(usb_intf));
 
-       ieee80211_free_hw(dev->mt76.hw);
+       ieee80211_free_hw(mdev->hw);
        return ret;
 }