aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb/asix.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2010-05-22 02:36:56 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-05-22 02:36:56 -0400
commitcf9b59e9d3e008591d1f54830f570982bb307a0d (patch)
tree113478ce8fd8c832ba726ffdf59b82cb46356476 /drivers/net/usb/asix.c
parent44504b2bebf8b5823c59484e73096a7d6574471d (diff)
parentf4b87dee923342505e1ddba8d34ce9de33e75050 (diff)
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and build failures in vio.c after merge. Conflicts: drivers/i2c/busses/i2c-cpm.c drivers/i2c/busses/i2c-mpc.c drivers/net/gianfar.c Also fixed up one line in arch/powerpc/kernel/vio.c to use the correct node pointer. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/net/usb/asix.c')
-rw-r--r--drivers/net/usb/asix.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 35f56fc82803..31b73310ec77 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -224,10 +224,9 @@ static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
224 cmd, value, index, size); 224 cmd, value, index, size);
225 225
226 if (data) { 226 if (data) {
227 buf = kmalloc(size, GFP_KERNEL); 227 buf = kmemdup(data, size, GFP_KERNEL);
228 if (!buf) 228 if (!buf)
229 goto out; 229 goto out;
230 memcpy(buf, data, size);
231 } 230 }
232 231
233 err = usb_control_msg( 232 err = usb_control_msg(
@@ -322,8 +321,29 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
322 /* get the packet length */ 321 /* get the packet length */
323 size = (u16) (header & 0x0000ffff); 322 size = (u16) (header & 0x0000ffff);
324 323
325 if ((skb->len) - ((size + 1) & 0xfffe) == 0) 324 if ((skb->len) - ((size + 1) & 0xfffe) == 0) {
325 u8 alignment = (u32)skb->data & 0x3;
326 if (alignment != 0x2) {
327 /*
328 * not 16bit aligned so use the room provided by
329 * the 32 bit header to align the data
330 *
331 * note we want 16bit alignment as MAC header is
332 * 14bytes thus ip header will be aligned on
333 * 32bit boundary so accessing ipheader elements
334 * using a cast to struct ip header wont cause
335 * an unaligned accesses.
336 */
337 u8 realignment = (alignment + 2) & 0x3;
338 memmove(skb->data - realignment,
339 skb->data,
340 size);
341 skb->data -= realignment;
342 skb_set_tail_pointer(skb, size);
343 }
326 return 2; 344 return 2;
345 }
346
327 if (size > ETH_FRAME_LEN) { 347 if (size > ETH_FRAME_LEN) {
328 netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", 348 netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n",
329 size); 349 size);
@@ -331,7 +351,18 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
331 } 351 }
332 ax_skb = skb_clone(skb, GFP_ATOMIC); 352 ax_skb = skb_clone(skb, GFP_ATOMIC);
333 if (ax_skb) { 353 if (ax_skb) {
354 u8 alignment = (u32)packet & 0x3;
334 ax_skb->len = size; 355 ax_skb->len = size;
356
357 if (alignment != 0x2) {
358 /*
359 * not 16bit aligned use the room provided by
360 * the 32 bit header to align the data
361 */
362 u8 realignment = (alignment + 2) & 0x3;
363 memmove(packet - realignment, packet, size);
364 packet -= realignment;
365 }
335 ax_skb->data = packet; 366 ax_skb->data = packet;
336 skb_set_tail_pointer(ax_skb, size); 367 skb_set_tail_pointer(ax_skb, size);
337 usbnet_skb_return(dev, ax_skb); 368 usbnet_skb_return(dev, ax_skb);
@@ -558,16 +589,14 @@ static void asix_set_multicast(struct net_device *net)
558 * for our 8 byte filter buffer 589 * for our 8 byte filter buffer
559 * to avoid allocating memory that 590 * to avoid allocating memory that
560 * is tricky to free later */ 591 * is tricky to free later */
561 struct dev_mc_list *mc_list; 592 struct netdev_hw_addr *ha;
562 u32 crc_bits; 593 u32 crc_bits;
563 594
564 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); 595 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
565 596
566 /* Build the multicast hash filter. */ 597 /* Build the multicast hash filter. */
567 netdev_for_each_mc_addr(mc_list, net) { 598 netdev_for_each_mc_addr(ha, net) {
568 crc_bits = 599 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
569 ether_crc(ETH_ALEN,
570 mc_list->dmi_addr) >> 26;
571 data->multi_filter[crc_bits >> 3] |= 600 data->multi_filter[crc_bits >> 3] |=
572 1 << (crc_bits & 7); 601 1 << (crc_bits & 7);
573 } 602 }
@@ -794,16 +823,14 @@ static void ax88172_set_multicast(struct net_device *net)
794 * for our 8 byte filter buffer 823 * for our 8 byte filter buffer
795 * to avoid allocating memory that 824 * to avoid allocating memory that
796 * is tricky to free later */ 825 * is tricky to free later */
797 struct dev_mc_list *mc_list; 826 struct netdev_hw_addr *ha;
798 u32 crc_bits; 827 u32 crc_bits;
799 828
800 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); 829 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
801 830
802 /* Build the multicast hash filter. */ 831 /* Build the multicast hash filter. */
803 netdev_for_each_mc_addr(mc_list, net) { 832 netdev_for_each_mc_addr(ha, net) {
804 crc_bits = 833 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
805 ether_crc(ETH_ALEN,
806 mc_list->dmi_addr) >> 26;
807 data->multi_filter[crc_bits >> 3] |= 834 data->multi_filter[crc_bits >> 3] |=
808 1 << (crc_bits & 7); 835 1 << (crc_bits & 7);
809 } 836 }