mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 11:21:33 +00:00
mt76usb: use usb_dev private data
Setup usb device private data. This allows to remove mt76u_buf->dev and simplify some routines as no longer we need to get usb device through usb interface. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
92724071aa
commit
112f980ac8
@ -90,7 +90,6 @@ struct mt76_tx_info {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct mt76u_buf {
|
struct mt76u_buf {
|
||||||
struct mt76_dev *dev;
|
|
||||||
struct urb *urb;
|
struct urb *urb;
|
||||||
size_t len;
|
size_t len;
|
||||||
void *buf;
|
void *buf;
|
||||||
@ -765,8 +764,7 @@ static inline int
|
|||||||
mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
|
mt76u_bulk_msg(struct mt76_dev *dev, void *data, int len, int *actual_len,
|
||||||
int timeout)
|
int timeout)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf = to_usb_interface(dev->dev);
|
struct usb_device *udev = to_usb_device(dev->dev);
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
|
||||||
struct mt76_usb *usb = &dev->usb;
|
struct mt76_usb *usb = &dev->usb;
|
||||||
unsigned int pipe;
|
unsigned int pipe;
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
|
|||||||
u32 mac_rev;
|
u32 mac_rev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mdev = mt76_alloc_device(&usb_intf->dev, sizeof(*dev), &mt76x0u_ops,
|
mdev = mt76_alloc_device(&usb_dev->dev, sizeof(*dev), &mt76x0u_ops,
|
||||||
&drv_ops);
|
&drv_ops);
|
||||||
if (!mdev)
|
if (!mdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -49,7 +49,7 @@ static int mt76x2u_probe(struct usb_interface *intf,
|
|||||||
struct mt76_dev *mdev;
|
struct mt76_dev *mdev;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
mdev = mt76_alloc_device(&intf->dev, sizeof(*dev), &mt76x2u_ops,
|
mdev = mt76_alloc_device(&udev->dev, sizeof(*dev), &mt76x2u_ops,
|
||||||
&drv_ops);
|
&drv_ops);
|
||||||
if (!mdev)
|
if (!mdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -59,6 +59,8 @@ static int mt76x2u_probe(struct usb_interface *intf,
|
|||||||
udev = usb_get_dev(udev);
|
udev = usb_get_dev(udev);
|
||||||
usb_reset_device(udev);
|
usb_reset_device(udev);
|
||||||
|
|
||||||
|
usb_set_intfdata(intf, dev);
|
||||||
|
|
||||||
mt76x02u_init_mcu(mdev);
|
mt76x02u_init_mcu(mdev);
|
||||||
err = mt76u_init(mdev, intf);
|
err = mt76u_init(mdev, intf);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -31,8 +31,7 @@ static int __mt76u_vendor_request(struct mt76_dev *dev, u8 req,
|
|||||||
u8 req_type, u16 val, u16 offset,
|
u8 req_type, u16 val, u16 offset,
|
||||||
void *buf, size_t len)
|
void *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf = to_usb_interface(dev->dev);
|
struct usb_device *udev = to_usb_device(dev->dev);
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
|
||||||
unsigned int pipe;
|
unsigned int pipe;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
|
|
||||||
@ -247,8 +246,7 @@ mt76u_rd_rp(struct mt76_dev *dev, u32 base,
|
|||||||
|
|
||||||
static bool mt76u_check_sg(struct mt76_dev *dev)
|
static bool mt76u_check_sg(struct mt76_dev *dev)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf = to_usb_interface(dev->dev);
|
struct usb_device *udev = to_usb_device(dev->dev);
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
|
||||||
|
|
||||||
return (!disable_usb_sg && udev->bus->sg_tablesize > 0 &&
|
return (!disable_usb_sg && udev->bus->sg_tablesize > 0 &&
|
||||||
(udev->bus->no_sg_constraint ||
|
(udev->bus->no_sg_constraint ||
|
||||||
@ -341,7 +339,6 @@ mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf)
|
|||||||
struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
|
struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
|
||||||
|
|
||||||
buf->len = SKB_WITH_OVERHEAD(q->buf_size);
|
buf->len = SKB_WITH_OVERHEAD(q->buf_size);
|
||||||
buf->dev = dev;
|
|
||||||
|
|
||||||
buf->urb = usb_alloc_urb(0, GFP_KERNEL);
|
buf->urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||||
if (!buf->urb)
|
if (!buf->urb)
|
||||||
@ -379,8 +376,7 @@ mt76u_fill_bulk_urb(struct mt76_dev *dev, int dir, int index,
|
|||||||
struct mt76u_buf *buf, usb_complete_t complete_fn,
|
struct mt76u_buf *buf, usb_complete_t complete_fn,
|
||||||
void *context)
|
void *context)
|
||||||
{
|
{
|
||||||
struct usb_interface *intf = to_usb_interface(dev->dev);
|
struct usb_device *udev = to_usb_device(dev->dev);
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
|
||||||
u8 *data = buf->urb->num_sgs ? NULL : buf->buf;
|
u8 *data = buf->urb->num_sgs ? NULL : buf->buf;
|
||||||
unsigned int pipe;
|
unsigned int pipe;
|
||||||
|
|
||||||
@ -694,8 +690,8 @@ static void mt76u_tx_status_data(struct work_struct *work)
|
|||||||
|
|
||||||
static void mt76u_complete_tx(struct urb *urb)
|
static void mt76u_complete_tx(struct urb *urb)
|
||||||
{
|
{
|
||||||
|
struct mt76_dev *dev = dev_get_drvdata(&urb->dev->dev);
|
||||||
struct mt76u_buf *buf = urb->context;
|
struct mt76u_buf *buf = urb->context;
|
||||||
struct mt76_dev *dev = buf->dev;
|
|
||||||
|
|
||||||
if (mt76u_urb_error(urb))
|
if (mt76u_urb_error(urb))
|
||||||
dev_err(dev->dev, "tx urb failed: %d\n", urb->status);
|
dev_err(dev->dev, "tx urb failed: %d\n", urb->status);
|
||||||
@ -806,7 +802,6 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
|
|||||||
q->ndesc = MT_NUM_TX_ENTRIES;
|
q->ndesc = MT_NUM_TX_ENTRIES;
|
||||||
for (j = 0; j < q->ndesc; j++) {
|
for (j = 0; j < q->ndesc; j++) {
|
||||||
buf = &q->entry[j].ubuf;
|
buf = &q->entry[j].ubuf;
|
||||||
buf->dev = dev;
|
|
||||||
|
|
||||||
buf->urb = usb_alloc_urb(0, GFP_KERNEL);
|
buf->urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||||
if (!buf->urb)
|
if (!buf->urb)
|
||||||
|
Loading…
Reference in New Issue
Block a user