mirror of
https://github.com/outbackdingo/mt76.git
synced 2026-10-24 13:26:48 +00:00
mt7603: move alloc_dev common code in mt76_alloc_device
Signed-off-by: Lorenzo Bianconi <[email protected]>
This commit is contained in:
committed by
Felix Fietkau
parent
11ab62057e
commit
82fa31293f
+12
-27
@@ -5,33 +5,18 @@
|
||||
#include "mac.h"
|
||||
#include "eeprom.h"
|
||||
|
||||
struct mt7603_dev *mt7603_alloc_device(struct device *pdev)
|
||||
{
|
||||
static const struct mt76_driver_ops drv_ops = {
|
||||
.txwi_size = MT_TXD_SIZE,
|
||||
.tx_prepare_skb = mt7603_tx_prepare_skb,
|
||||
.tx_complete_skb = mt7603_tx_complete_skb,
|
||||
.rx_skb = mt7603_queue_rx_skb,
|
||||
.rx_poll_complete = mt7603_rx_poll_complete,
|
||||
.sta_ps = mt7603_sta_ps,
|
||||
.sta_add = mt7603_sta_add,
|
||||
.sta_assoc = mt7603_sta_assoc,
|
||||
.sta_remove = mt7603_sta_remove,
|
||||
.update_survey = mt7603_update_channel,
|
||||
};
|
||||
struct mt7603_dev *dev;
|
||||
struct mt76_dev *mdev;
|
||||
|
||||
mdev = mt76_alloc_device(sizeof(*dev), &mt7603_ops);
|
||||
if (!mdev)
|
||||
return NULL;
|
||||
|
||||
dev = container_of(mdev, struct mt7603_dev, mt76);
|
||||
mdev->dev = pdev;
|
||||
mdev->drv = &drv_ops;
|
||||
|
||||
return dev;
|
||||
}
|
||||
const struct mt76_driver_ops mt7603_drv_ops = {
|
||||
.txwi_size = MT_TXD_SIZE,
|
||||
.tx_prepare_skb = mt7603_tx_prepare_skb,
|
||||
.tx_complete_skb = mt7603_tx_complete_skb,
|
||||
.rx_skb = mt7603_queue_rx_skb,
|
||||
.rx_poll_complete = mt7603_rx_poll_complete,
|
||||
.sta_ps = mt7603_sta_ps,
|
||||
.sta_add = mt7603_sta_add,
|
||||
.sta_assoc = mt7603_sta_assoc,
|
||||
.sta_remove = mt7603_sta_remove,
|
||||
.update_survey = mt7603_update_channel,
|
||||
};
|
||||
|
||||
static void
|
||||
mt7603_set_tmac_template(struct mt7603_dev *dev)
|
||||
|
||||
+1
-1
@@ -149,6 +149,7 @@ struct mt7603_dev {
|
||||
struct tasklet_struct pre_tbtt_tasklet;
|
||||
};
|
||||
|
||||
extern const struct mt76_driver_ops mt7603_drv_ops;
|
||||
extern const struct ieee80211_ops mt7603_ops;
|
||||
extern struct pci_driver mt7603_pci_driver;
|
||||
extern struct platform_driver mt76_wmac_driver;
|
||||
@@ -168,7 +169,6 @@ static inline bool is_mt7628(struct mt7603_dev *dev)
|
||||
|
||||
u32 mt7603_reg_map(struct mt7603_dev *dev, u32 addr);
|
||||
|
||||
struct mt7603_dev *mt7603_alloc_device(struct device *pdev);
|
||||
irqreturn_t mt7603_irq_handler(int irq, void *dev_instance);
|
||||
|
||||
int mt7603_register_device(struct mt7603_dev *dev);
|
||||
|
||||
+10
-7
@@ -15,6 +15,7 @@ static int
|
||||
mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
{
|
||||
struct mt7603_dev *dev;
|
||||
struct mt76_dev *mdev;
|
||||
int ret;
|
||||
|
||||
ret = pcim_enable_device(pdev);
|
||||
@@ -31,17 +32,19 @@ mt76pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dev = mt7603_alloc_device(&pdev->dev);
|
||||
if (!dev)
|
||||
mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops,
|
||||
&mt7603_drv_ops);
|
||||
if (!mdev)
|
||||
return -ENOMEM;
|
||||
|
||||
mt76_mmio_init(&dev->mt76, pcim_iomap_table(pdev)[0]);
|
||||
dev = container_of(mdev, struct mt7603_dev, mt76);
|
||||
mt76_mmio_init(mdev, pcim_iomap_table(pdev)[0]);
|
||||
|
||||
dev->mt76.rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
|
||||
(mt76_rr(dev, MT_HW_REV) & 0xff);
|
||||
dev_info(dev->mt76.dev, "ASIC revision: %04x\n", dev->mt76.rev);
|
||||
mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
|
||||
(mt76_rr(dev, MT_HW_REV) & 0xff);
|
||||
dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
|
||||
|
||||
ret = devm_request_irq(dev->mt76.dev, pdev->irq, mt7603_irq_handler,
|
||||
ret = devm_request_irq(mdev->dev, pdev->irq, mt7603_irq_handler,
|
||||
IRQF_SHARED, KBUILD_MODNAME, dev);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
+10
-7
@@ -12,6 +12,7 @@ mt76_wmac_probe(struct platform_device *pdev)
|
||||
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
struct mt7603_dev *dev;
|
||||
void __iomem *mem_base;
|
||||
struct mt76_dev *mdev;
|
||||
int irq;
|
||||
int ret;
|
||||
|
||||
@@ -27,17 +28,19 @@ mt76_wmac_probe(struct platform_device *pdev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev = mt7603_alloc_device(&pdev->dev);
|
||||
if (!dev)
|
||||
mdev = mt76_alloc_device(&pdev->dev, sizeof(*dev), &mt7603_ops,
|
||||
&mt7603_drv_ops);
|
||||
if (!mdev)
|
||||
return -ENOMEM;
|
||||
|
||||
mt76_mmio_init(&dev->mt76, mem_base);
|
||||
dev = container_of(mdev, struct mt7603_dev, mt76);
|
||||
mt76_mmio_init(mdev, mem_base);
|
||||
|
||||
dev->mt76.rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
|
||||
(mt76_rr(dev, MT_HW_REV) & 0xff);
|
||||
dev_info(dev->mt76.dev, "ASIC revision: %04x\n", dev->mt76.rev);
|
||||
mdev->rev = (mt76_rr(dev, MT_HW_CHIPID) << 16) |
|
||||
(mt76_rr(dev, MT_HW_REV) & 0xff);
|
||||
dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev);
|
||||
|
||||
ret = devm_request_irq(dev->mt76.dev, irq, mt7603_irq_handler,
|
||||
ret = devm_request_irq(mdev->dev, irq, mt7603_irq_handler,
|
||||
IRQF_SHARED, KBUILD_MODNAME, dev);
|
||||
if (ret)
|
||||
goto error;
|
||||
|
||||
Reference in New Issue
Block a user