}
struct mt76_dev *
-mt76_alloc_device(unsigned int size, const struct ieee80211_ops *ops)
+mt76_alloc_device(struct device *pdev, unsigned int size,
+ const struct ieee80211_ops *ops,
+ const struct mt76_driver_ops *drv_ops)
{
struct ieee80211_hw *hw;
struct mt76_dev *dev;
dev = hw->priv;
dev->hw = hw;
+ dev->dev = pdev;
+ dev->drv = drv_ops;
+
spin_lock_init(&dev->rx_lock);
spin_lock_init(&dev->lock);
spin_lock_init(&dev->cc_lock);
return &msband->chan[idx];
}
-struct mt76_dev *mt76_alloc_device(unsigned int size,
- const struct ieee80211_ops *ops);
+struct mt76_dev *mt76_alloc_device(struct device *pdev, unsigned int size,
+ const struct ieee80211_ops *ops,
+ const struct mt76_driver_ops *drv_ops);
int mt76_register_device(struct mt76_dev *dev, bool vht,
struct ieee80211_rate *rates, int n_rates);
void mt76_unregister_device(struct mt76_dev *dev);
struct mt76x02_dev *dev;
struct mt76_dev *mdev;
- mdev = mt76_alloc_device(sizeof(*dev), ops);
+ mdev = mt76_alloc_device(pdev, sizeof(*dev), ops, drv_ops);
if (!mdev)
return NULL;
- mdev->dev = pdev;
- mdev->drv = drv_ops;
-
dev = container_of(mdev, struct mt76x02_dev, mt76);
mutex_init(&dev->phy_mutex);
struct mt76x02_dev *dev;
struct mt76_dev *mdev;
- mdev = mt76_alloc_device(sizeof(*dev), &mt76x2_ops);
+ mdev = mt76_alloc_device(pdev, sizeof(*dev), &mt76x2_ops,
+ &drv_ops);
if (!mdev)
return NULL;
dev = container_of(mdev, struct mt76x02_dev, mt76);
- mdev->dev = pdev;
- mdev->drv = &drv_ops;
return dev;
}
struct mt76x02_dev *dev;
struct mt76_dev *mdev;
- mdev = mt76_alloc_device(sizeof(*dev), &mt76x2u_ops);
+ mdev = mt76_alloc_device(pdev, sizeof(*dev), &mt76x2u_ops,
+ &drv_ops);
if (!mdev)
return NULL;
dev = container_of(mdev, struct mt76x02_dev, mt76);
- mdev->dev = pdev;
- mdev->drv = &drv_ops;
return dev;
}