Commit 835123b7 authored by Stanislaw Gruszka's avatar Stanislaw Gruszka Committed by Felix Fietkau

mt76x0: make device allocation bus neutral

Remove some USB specific code form mt76x0_alloc_device.
Signed-off-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 6d1bced1
...@@ -482,14 +482,9 @@ void mt76x0_cleanup(struct mt76x0_dev *dev) ...@@ -482,14 +482,9 @@ void mt76x0_cleanup(struct mt76x0_dev *dev)
} }
EXPORT_SYMBOL_GPL(mt76x0_cleanup); EXPORT_SYMBOL_GPL(mt76x0_cleanup);
struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev) struct mt76x0_dev *
mt76x0_alloc_device(struct device *pdev, const struct mt76_driver_ops *drv_ops)
{ {
static const struct mt76_driver_ops drv_ops = {
.tx_prepare_skb = mt76x0_tx_prepare_skb,
.tx_complete_skb = mt76x02_tx_complete_skb,
.tx_status_data = mt76x02_tx_status_data,
.rx_skb = mt76x0_queue_rx_skb,
};
struct mt76x0_dev *dev; struct mt76x0_dev *dev;
struct mt76_dev *mdev; struct mt76_dev *mdev;
...@@ -498,7 +493,7 @@ struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev) ...@@ -498,7 +493,7 @@ struct mt76x0_dev *mt76x0_alloc_device(struct device *pdev)
return NULL; return NULL;
mdev->dev = pdev; mdev->dev = pdev;
mdev->drv = &drv_ops; mdev->drv = drv_ops;
dev = container_of(mdev, struct mt76x0_dev, mt76); dev = container_of(mdev, struct mt76x0_dev, mt76);
mutex_init(&dev->reg_atomic_mutex); mutex_init(&dev->reg_atomic_mutex);
......
...@@ -134,7 +134,8 @@ int mt76x0_burst_write_regs(struct mt76x0_dev *dev, u32 offset, ...@@ -134,7 +134,8 @@ int mt76x0_burst_write_regs(struct mt76x0_dev *dev, u32 offset,
const u32 *data, int n); const u32 *data, int n);
/* Init */ /* Init */
struct mt76x0_dev *mt76x0_alloc_device(struct device *dev); struct mt76x0_dev *
mt76x0_alloc_device(struct device *pdev, const struct mt76_driver_ops *drv_ops);
int mt76x0_init_hardware(struct mt76x0_dev *dev); int mt76x0_init_hardware(struct mt76x0_dev *dev);
int mt76x0_register_device(struct mt76x0_dev *dev); int mt76x0_register_device(struct mt76x0_dev *dev);
void mt76x0_cleanup(struct mt76x0_dev *dev); void mt76x0_cleanup(struct mt76x0_dev *dev);
......
...@@ -40,7 +40,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -40,7 +40,7 @@ mt76x0e_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret) if (ret)
return ret; return ret;
dev = mt76x0_alloc_device(&pdev->dev); dev = mt76x0_alloc_device(&pdev->dev, NULL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
......
...@@ -95,6 +95,7 @@ int mt76x0_tx_prepare_skb(struct mt76_dev *mdev, void *data, ...@@ -95,6 +95,7 @@ int mt76x0_tx_prepare_skb(struct mt76_dev *mdev, void *data,
return mt76x02_set_txinfo(skb, wcid, q2ep(q->hw_idx)); return mt76x02_set_txinfo(skb, wcid, q2ep(q->hw_idx));
} }
EXPORT_SYMBOL_GPL(mt76x0_tx_prepare_skb);
void mt76x0_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, void mt76x0_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
struct sk_buff *skb) struct sk_buff *skb)
...@@ -110,4 +111,4 @@ void mt76x0_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, ...@@ -110,4 +111,4 @@ void mt76x0_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q,
mt76_rx(&dev->mt76, q, skb); mt76_rx(&dev->mt76, q, skb);
} }
EXPORT_SYMBOL_GPL(mt76x0_queue_rx_skb);
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "mt76x0.h" #include "mt76x0.h"
#include "usb.h" #include "usb.h"
#include "trace.h" #include "trace.h"
#include "../mt76x02_util.h"
static struct usb_device_id mt76x0_device_table[] = { static struct usb_device_id mt76x0_device_table[] = {
{ USB_DEVICE(0x148F, 0x7610) }, /* MT7610U */ { USB_DEVICE(0x148F, 0x7610) }, /* MT7610U */
...@@ -49,12 +50,18 @@ static struct usb_device_id mt76x0_device_table[] = { ...@@ -49,12 +50,18 @@ static struct usb_device_id mt76x0_device_table[] = {
static int mt76x0u_probe(struct usb_interface *usb_intf, static int mt76x0u_probe(struct usb_interface *usb_intf,
const struct usb_device_id *id) const struct usb_device_id *id)
{ {
static const struct mt76_driver_ops drv_ops = {
.tx_prepare_skb = mt76x0_tx_prepare_skb,
.tx_complete_skb = mt76x02_tx_complete_skb,
.tx_status_data = mt76x02_tx_status_data,
.rx_skb = mt76x0_queue_rx_skb,
};
struct usb_device *usb_dev = interface_to_usbdev(usb_intf); struct usb_device *usb_dev = interface_to_usbdev(usb_intf);
struct mt76x0_dev *dev; struct mt76x0_dev *dev;
u32 asic_rev, mac_rev; u32 asic_rev, mac_rev;
int ret; int ret;
dev = mt76x0_alloc_device(&usb_intf->dev); dev = mt76x0_alloc_device(&usb_intf->dev, &drv_ops);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment