netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: Woojung.Huh@microchip.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/1] Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver
Date: Wed, 29 Jul 2015 12:14:01 -0700 (PDT)	[thread overview]
Message-ID: <20150729.121401.1138495718406304622.davem@davemloft.net> (raw)
In-Reply-To: <9235D6609DB808459E95D78E17F2E43D53361B@CHN-SV-EXMX02.mchp-main.com>

From: <Woojung.Huh@microchip.com>
Date: Mon, 27 Jul 2015 19:59:30 +0000

> +static int lan78xx_read_stats(struct lan78xx_net *dev,
> +			      struct lan78xx_statstage *data)
> +{
> +	int ret = 0;
> +	struct lan78xx_statstage *stats;
> +
> +	BUG_ON(!dev);
> +	BUG_ON(!data);
> +	BUG_ON(sizeof(struct lan78xx_statstage) != 0xBC);
> +
> +	stats = kmalloc(sizeof(*stats), GFP_KERNEL);
> +	if (!stats)
> +		return -ENOMEM;
> +
> +	ret = usb_control_msg(dev->udev,
> +			      usb_rcvctrlpipe(dev->udev, 0),
> +			      USB_VENDOR_REQUEST_GET_STATS,
> +			      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +			      0,
> +			      0,
> +			      (void *)stats,
> +			      sizeof(*stats),
> +			      USB_CTRL_SET_TIMEOUT);
> +	if (likely(ret >= 0)) {
> +		le32_to_cpus(stats);
> +		*data = *stats;

This doesn't work.

le32_to_cpus() will only byte swap the first 'u32' in this statistics structure,
not all of them.

You have to explicitly byte swap each and every member.

  reply	other threads:[~2015-07-29 19:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-27 19:59 [PATCH net-next 1/1] Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver Woojung.Huh
2015-07-29 19:14 ` David Miller [this message]
2015-07-29 21:57   ` Woojung.Huh
  -- strict thread matches above, loose matches on Subject: below --
2015-07-30 19:45 Woojung.Huh
2015-07-31 22:19 ` David Miller
2015-07-31 22:26   ` Woojung.Huh
2015-07-22 19:01 Woojung.Huh
2015-07-26 23:42 ` David Miller
2015-07-27 14:29   ` Woojung.Huh
2015-07-16 22:16 Woojung.Huh
2015-07-21  3:44 ` David Miller
2015-07-22 16:25   ` Woojung.Huh
2015-07-22 18:06     ` David Miller
2015-07-22 18:29       ` Woojung.Huh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150729.121401.1138495718406304622.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=Woojung.Huh@microchip.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).