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

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

index 28ec19a..6c619f1 100644 (file)
@@ -49,7 +49,6 @@ static inline bool mt76x2_channel_silent(struct mt76x02_dev *dev)
 
 extern const struct ieee80211_ops mt76x2_ops;
 
-struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev);
 int mt76x2_register_device(struct mt76x02_dev *dev);
 
 void mt76x2_phy_power_on(struct mt76x02_dev *dev);
index 92432fe..6274655 100644 (file)
@@ -30,7 +30,19 @@ static const struct pci_device_id mt76pci_device_table[] = {
 static int
 mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
+       static const struct mt76_driver_ops drv_ops = {
+               .txwi_size = sizeof(struct mt76x02_txwi),
+               .update_survey = mt76x02_update_channel,
+               .tx_prepare_skb = mt76x02_tx_prepare_skb,
+               .tx_complete_skb = mt76x02_tx_complete_skb,
+               .rx_skb = mt76x02_queue_rx_skb,
+               .rx_poll_complete = mt76x02_rx_poll_complete,
+               .sta_ps = mt76x02_sta_ps,
+               .sta_add = mt76x02_sta_add,
+               .sta_remove = mt76x02_sta_remove,
+       };
        struct mt76x02_dev *dev;
+       struct mt76_dev *mdev;
        int ret;
 
        ret = pcim_enable_device(pdev);
@@ -47,17 +59,19 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (ret)
                return ret;
 
-       dev = mt76x2_alloc_device(&pdev->dev);
-       if (!dev)
+       mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt76x2_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);
+       mt76_mmio_init(mdev, pcim_iomap_table(pdev)[0]);
        mt76x2_reset_wlan(dev, false);
 
-       dev->mt76.rev = mt76_rr(dev, MT_ASIC_VERSION);
-       dev_info(dev->mt76.dev, "ASIC revision: %08x\n", dev->mt76.rev);
+       mdev->rev = mt76_rr(dev, MT_ASIC_VERSION);
+       dev_info(mdev->dev, "ASIC revision: %08x\n", mdev->rev);
 
-       ret = devm_request_irq(dev->mt76.dev, pdev->irq, mt76x02_irq_handler,
+       ret = devm_request_irq(mdev->dev, pdev->irq, mt76x02_irq_handler,
                               IRQF_SHARED, KBUILD_MODNAME, dev);
        if (ret)
                goto error;
index d5816c7..d4e3d7c 100644 (file)
@@ -313,32 +313,6 @@ void mt76x2_cleanup(struct mt76x02_dev *dev)
        mt76x02_mcu_cleanup(dev);
 }
 
-struct mt76x02_dev *mt76x2_alloc_device(struct device *pdev)
-{
-       static const struct mt76_driver_ops drv_ops = {
-               .txwi_size = sizeof(struct mt76x02_txwi),
-               .update_survey = mt76x02_update_channel,
-               .tx_prepare_skb = mt76x02_tx_prepare_skb,
-               .tx_complete_skb = mt76x02_tx_complete_skb,
-               .rx_skb = mt76x02_queue_rx_skb,
-               .rx_poll_complete = mt76x02_rx_poll_complete,
-               .sta_ps = mt76x02_sta_ps,
-               .sta_add = mt76x02_sta_add,
-               .sta_remove = mt76x02_sta_remove,
-       };
-       struct mt76x02_dev *dev;
-       struct mt76_dev *mdev;
-
-       mdev = mt76_alloc_device(pdev, sizeof(*dev), &mt76x2_ops,
-                                &drv_ops);
-       if (!mdev)
-               return NULL;
-
-       dev = container_of(mdev, struct mt76x02_dev, mt76);
-
-       return dev;
-}
-
 int mt76x2_register_device(struct mt76x02_dev *dev)
 {
        int ret;