aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/mcs7830.c
diff options
context:
space:
mode:
authorMing Lei <ming.lei@canonical.com>2012-10-24 15:46:59 -0400
committerDavid S. Miller <davem@davemloft.net>2012-10-26 03:36:51 -0400
commit9c06a2b582345ae968b20639566575fec8b415d3 (patch)
tree5a993fbe472b5de05fd21b5d9568ca8998f202a1 /drivers/net/usb/mcs7830.c
parent3898cdf9ab7ffbb022a737b57b0c1cd539eb96bd (diff)
usbnet: mcs7830: apply introduced usb command APIs
Acked-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb/mcs7830.c')
-rw-r--r--drivers/net/usb/mcs7830.c85
1 files changed, 6 insertions, 79 deletions
diff --git a/drivers/net/usb/mcs7830.c b/drivers/net/usb/mcs7830.c
index cc7e72010ac3..3f3f566afa0b 100644
--- a/drivers/net/usb/mcs7830.c
+++ b/drivers/net/usb/mcs7830.c
@@ -124,93 +124,20 @@ static const char driver_name[] = "MOSCHIP usb-ethernet driver";
124 124
125static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data) 125static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data)
126{ 126{
127 struct usb_device *xdev = dev->udev; 127 return usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ,
128 int ret; 128 0x0000, index, data, size);
129 void *buffer;
130
131 buffer = kmalloc(size, GFP_NOIO);
132 if (buffer == NULL)
133 return -ENOMEM;
134
135 ret = usb_control_msg(xdev, usb_rcvctrlpipe(xdev, 0), MCS7830_RD_BREQ,
136 MCS7830_RD_BMREQ, 0x0000, index, buffer,
137 size, MCS7830_CTRL_TIMEOUT);
138 memcpy(data, buffer, size);
139 kfree(buffer);
140
141 return ret;
142} 129}
143 130
144static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data) 131static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data)
145{ 132{
146 struct usb_device *xdev = dev->udev; 133 return usbnet_write_cmd(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ,
147 int ret; 134 0x0000, index, data, size);
148 void *buffer;
149
150 buffer = kmemdup(data, size, GFP_NOIO);
151 if (buffer == NULL)
152 return -ENOMEM;
153
154 ret = usb_control_msg(xdev, usb_sndctrlpipe(xdev, 0), MCS7830_WR_BREQ,
155 MCS7830_WR_BMREQ, 0x0000, index, buffer,
156 size, MCS7830_CTRL_TIMEOUT);
157 kfree(buffer);
158 return ret;
159}
160
161static void mcs7830_async_cmd_callback(struct urb *urb)
162{
163 struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context;
164 int status = urb->status;
165
166 if (status < 0)
167 printk(KERN_DEBUG "%s() failed with %d\n",
168 __func__, status);
169
170 kfree(req);
171 usb_free_urb(urb);
172} 135}
173 136
174static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data) 137static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data)
175{ 138{
176 struct usb_ctrlrequest *req; 139 usbnet_write_cmd_async(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ,
177 int ret; 140 0x0000, index, data, size);
178 struct urb *urb;
179
180 urb = usb_alloc_urb(0, GFP_ATOMIC);
181 if (!urb) {
182 dev_dbg(&dev->udev->dev,
183 "Error allocating URB in write_cmd_async!\n");
184 return;
185 }
186
187 req = kmalloc(sizeof *req, GFP_ATOMIC);
188 if (!req) {
189 dev_err(&dev->udev->dev,
190 "Failed to allocate memory for control request\n");
191 goto out;
192 }
193 req->bRequestType = MCS7830_WR_BMREQ;
194 req->bRequest = MCS7830_WR_BREQ;
195 req->wValue = 0;
196 req->wIndex = cpu_to_le16(index);
197 req->wLength = cpu_to_le16(size);
198
199 usb_fill_control_urb(urb, dev->udev,
200 usb_sndctrlpipe(dev->udev, 0),
201 (void *)req, data, size,
202 mcs7830_async_cmd_callback, req);
203
204 ret = usb_submit_urb(urb, GFP_ATOMIC);
205 if (ret < 0) {
206 dev_err(&dev->udev->dev,
207 "Error submitting the control message: ret=%d\n", ret);
208 goto out;
209 }
210 return;
211out:
212 kfree(req);
213 usb_free_urb(urb);
214} 141}
215 142
216static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr) 143static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr)