From 0855214a004e70e994c285b7435d01c31cec1b3b Mon Sep 17 00:00:00 2001 From: David Brownell <dbrownell@users.sourceforge.net> Date: Fri, 23 Mar 2007 09:57:34 -0400 Subject: [PATCH] musb_hdrc: Minor root hub cleanups Minor root hub cleanups: - Use unaligned accessors to return status, in case usbcore passes a buffer that's not aligned. - Fix some glitching on restart (e.g. when switching gadget drivers while leaving the OTG-mode musb_hdrc driver loaded). Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> --- drivers/usb/musb/musb_host.c | 3 +++ drivers/usb/musb/virthub.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 0e3b691607c..d5b53d937cf 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -2121,10 +2121,13 @@ static int musb_h_get_frame_number(struct usb_hcd *hcd) static int musb_h_start(struct usb_hcd *hcd) { + struct musb *musb = hcd_to_musb(hcd); + /* NOTE: musb_start() is called when the hub driver turns * on port power, or when (OTG) peripheral starts. */ hcd->state = HC_STATE_RUNNING; + musb->port1_status = 0; return 0; } diff --git a/drivers/usb/musb/virthub.c b/drivers/usb/musb/virthub.c index 41ae741430c..6a65f4fd1c0 100644 --- a/drivers/usb/musb/virthub.c +++ b/drivers/usb/musb/virthub.c @@ -41,6 +41,8 @@ #include <linux/time.h> #include <linux/timer.h> +#include <asm/unaligned.h> + #include "musbdefs.h" @@ -300,11 +302,11 @@ int musb_hub_control( musb->xceiv.state = OTG_STATE_A_HOST; } - *(__le32 *) buf = cpu_to_le32(musb->port1_status - & ~MUSB_PORT_STAT_RESUME); + put_unaligned(cpu_to_le32(musb->port1_status & ~MUSB_PORT_STAT_RESUME), + (__le32 *) buf); /* port change status is more interesting */ - DBG((*(u16*)(buf+2)) ? 2 : 5, "port status %08x\n", + DBG(get_unaligned((u16*)(buf+2)) ? 2 : 5, "port status %08x\n", musb->port1_status); break; case SetPortFeature: -- 2.41.1