From: Stefan Kristiansson Date: Thu, 15 Dec 2011 08:05:46 +0200 Subject: [U-Boot] [PATCH] USB: Use (get|put)_unaligned_le16 for accessing wMaxPacketSize In-Reply-To: <1323901203-9274-2-git-send-email-trini@ti.com> References: <1323901203-9274-1-git-send-email-trini@ti.com> <1323901203-9274-2-git-send-email-trini@ti.com> Message-ID: <20111215060546.GA4355@chokladfabriken.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Tom, after taking a second look at this a couple of things came to mind On Wed, Dec 14, 2011 at 03:20:03PM -0700, Tom Rini wrote: > In 9792987721c7980453fe6447c3fa6593b44f8458 Stefan describes a usecase > where the previous behavior of leaving wMaxPacketSize be unaligned > caused fatal problems. The initial fix for this problem was incomplete > however as it showed another cases of non-aligned access that previously > worked implicitly. This switches to making sure that all access of > wMaxPacketSize are done via (get|put)_unaligned_le16. > Why the _le16? Shouldn't it just be (get|put)_unaligned? > - le16_to_cpus(&(dev->config.if_desc[ifno].ep_desc[epno].\ > - wMaxPacketSize)); > + ep_wMaxPacketSize = get_unaligned_le16(&dev->config.\ > + if_desc[ifno].\ > + ep_desc[epno].\ > + wMaxPacketSize); > + le16_to_cpus(&ep_wMaxPacketSize); > USB_PRINTF("if %d, ep %d\n", ifno, epno); > break; > default: Since this code is changing the wMaxPacketSize, it should probably be: ep_wMaxPacketSize = get_unaligned(&dev->config.\ if_desc[ifno].\ ep_desc[epno].\ wMaxPacketSize); put_unaligned(le16_to_cpu(ep_wMaxPacketSize), &dev->config.\ if_desc[ifno].\ ep_desc[epno].\ wMaxPacketSize); Stefan