Commit 259127ba authored by Peter Senna Tschudin's avatar Peter Senna Tschudin Committed by Greg Kroah-Hartman

usb/host/fotg210: Fix coding style issues

This patch fix coding style issues reported by checkpatch that do not
change semantics of the code.
Signed-off-by: default avatarPeter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 34e51ba6
/* /* Faraday FOTG210 EHCI-like driver
* Faraday FOTG210 EHCI-like driver
* *
* Copyright (c) 2013 Faraday Technology Corporation * Copyright (c) 2013 Faraday Technology Corporation
* *
...@@ -50,14 +49,11 @@ ...@@ -50,14 +49,11 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
/*-------------------------------------------------------------------------*/
#define DRIVER_AUTHOR "Yuan-Hsin Chen" #define DRIVER_AUTHOR "Yuan-Hsin Chen"
#define DRIVER_DESC "FOTG210 Host Controller (EHCI) Driver" #define DRIVER_DESC "FOTG210 Host Controller (EHCI) Driver"
static const char hcd_name[] = "fotg210_hcd"; static const char hcd_name[] = "fotg210_hcd";
#undef FOTG210_URB_TRACE #undef FOTG210_URB_TRACE
#define FOTG210_STATS #define FOTG210_STATS
/* magic numbers that can affect system performance */ /* magic numbers that can affect system performance */
...@@ -66,9 +62,9 @@ static const char hcd_name[] = "fotg210_hcd"; ...@@ -66,9 +62,9 @@ static const char hcd_name[] = "fotg210_hcd";
#define FOTG210_TUNE_RL_TT 0 #define FOTG210_TUNE_RL_TT 0
#define FOTG210_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */ #define FOTG210_TUNE_MULT_HS 1 /* 1-3 transactions/uframe; 4.10.3 */
#define FOTG210_TUNE_MULT_TT 1 #define FOTG210_TUNE_MULT_TT 1
/*
* Some drivers think it's safe to schedule isochronous transfers more than /* Some drivers think it's safe to schedule isochronous transfers more than 256
* 256 ms into the future (partly as a result of an old bug in the scheduling * ms into the future (partly as a result of an old bug in the scheduling
* code). In an attempt to avoid trouble, we will use a minimum scheduling * code). In an attempt to avoid trouble, we will use a minimum scheduling
* length of 512 frames instead of 256. * length of 512 frames instead of 256.
*/ */
...@@ -93,43 +89,34 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us"); ...@@ -93,43 +89,34 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us");
#include "fotg210.h" #include "fotg210.h"
/*-------------------------------------------------------------------------*/
#define fotg210_dbg(fotg210, fmt, args...) \ #define fotg210_dbg(fotg210, fmt, args...) \
dev_dbg(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_dbg(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
#define fotg210_err(fotg210, fmt, args...) \ #define fotg210_err(fotg210, fmt, args...) \
dev_err(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_err(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
#define fotg210_info(fotg210, fmt, args...) \ #define fotg210_info(fotg210, fmt, args...) \
dev_info(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_info(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
#define fotg210_warn(fotg210, fmt, args...) \ #define fotg210_warn(fotg210, fmt, args...) \
dev_warn(fotg210_to_hcd(fotg210)->self.controller , fmt , ## args) dev_warn(fotg210_to_hcd(fotg210)->self.controller, fmt, ## args)
/* check the values in the HCSPARAMS register /* check the values in the HCSPARAMS register (host controller _Structural_
* (host controller _Structural_ parameters) * parameters) see EHCI spec, Table 2-4 for each value
* see EHCI spec, Table 2-4 for each value
*/ */
static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label) static void dbg_hcs_params(struct fotg210_hcd *fotg210, char *label)
{ {
u32 params = fotg210_readl(fotg210, &fotg210->caps->hcs_params); u32 params = fotg210_readl(fotg210, &fotg210->caps->hcs_params);
fotg210_dbg(fotg210, fotg210_dbg(fotg210, "%s hcs_params 0x%x ports=%d\n", label, params,
"%s hcs_params 0x%x ports=%d\n", HCS_N_PORTS(params));
label, params,
HCS_N_PORTS(params)
);
} }
/* check the values in the HCCPARAMS register /* check the values in the HCCPARAMS register (host controller _Capability_
* (host controller _Capability_ parameters) * parameters) see EHCI Spec, Table 2-5 for each value
* see EHCI Spec, Table 2-5 for each value */
* */
static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label) static void dbg_hcc_params(struct fotg210_hcd *fotg210, char *label)
{ {
u32 params = fotg210_readl(fotg210, &fotg210->caps->hcc_params); u32 params = fotg210_readl(fotg210, &fotg210->caps->hcc_params);
fotg210_dbg(fotg210, fotg210_dbg(fotg210, "%s hcc_params %04x uframes %s%s\n", label,
"%s hcc_params %04x uframes %s%s\n",
label,
params, params,
HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024", HCC_PGM_FRAMELISTLEN(params) ? "256/512/1024" : "1024",
HCC_CANPARK(params) ? " park" : ""); HCC_CANPARK(params) ? " park" : "");
...@@ -156,17 +143,20 @@ dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -156,17 +143,20 @@ dbg_qh(const char *label, struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, fotg210_dbg(fotg210, "%s qh %p n%08x info %x %x qtd %x\n", label, qh,
qh, hw->hw_next, hw->hw_info1, hw->hw_info2, hw->hw_current); hw->hw_next, hw->hw_info1, hw->hw_info2,
hw->hw_current);
dbg_qtd("overlay", fotg210, (struct fotg210_qtd *) &hw->hw_qtd_next); dbg_qtd("overlay", fotg210, (struct fotg210_qtd *) &hw->hw_qtd_next);
} }
static void __maybe_unused static void __maybe_unused
dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd) dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
{ {
fotg210_dbg(fotg210, "%s[%d] itd %p, next %08x, urb %p\n", fotg210_dbg(fotg210, "%s[%d] itd %p, next %08x, urb %p\n", label,
label, itd->frame, itd, hc32_to_cpu(fotg210, itd->hw_next), itd->frame, itd, hc32_to_cpu(fotg210, itd->hw_next),
itd->urb); itd->urb);
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
" trans: %08x %08x %08x %08x %08x %08x %08x %08x\n", " trans: %08x %08x %08x %08x %08x %08x %08x %08x\n",
hc32_to_cpu(fotg210, itd->hw_transaction[0]), hc32_to_cpu(fotg210, itd->hw_transaction[0]),
...@@ -177,6 +167,7 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -177,6 +167,7 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
hc32_to_cpu(fotg210, itd->hw_transaction[5]), hc32_to_cpu(fotg210, itd->hw_transaction[5]),
hc32_to_cpu(fotg210, itd->hw_transaction[6]), hc32_to_cpu(fotg210, itd->hw_transaction[6]),
hc32_to_cpu(fotg210, itd->hw_transaction[7])); hc32_to_cpu(fotg210, itd->hw_transaction[7]));
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
" buf: %08x %08x %08x %08x %08x %08x %08x\n", " buf: %08x %08x %08x %08x %08x %08x %08x\n",
hc32_to_cpu(fotg210, itd->hw_bufp[0]), hc32_to_cpu(fotg210, itd->hw_bufp[0]),
...@@ -186,6 +177,7 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -186,6 +177,7 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
hc32_to_cpu(fotg210, itd->hw_bufp[4]), hc32_to_cpu(fotg210, itd->hw_bufp[4]),
hc32_to_cpu(fotg210, itd->hw_bufp[5]), hc32_to_cpu(fotg210, itd->hw_bufp[5]),
hc32_to_cpu(fotg210, itd->hw_bufp[6])); hc32_to_cpu(fotg210, itd->hw_bufp[6]));
fotg210_dbg(fotg210, " index: %d %d %d %d %d %d %d %d\n", fotg210_dbg(fotg210, " index: %d %d %d %d %d %d %d %d\n",
itd->index[0], itd->index[1], itd->index[2], itd->index[0], itd->index[1], itd->index[2],
itd->index[3], itd->index[4], itd->index[5], itd->index[3], itd->index[4], itd->index[5],
...@@ -195,8 +187,7 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -195,8 +187,7 @@ dbg_itd(const char *label, struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
static int __maybe_unused static int __maybe_unused
dbg_status_buf(char *buf, unsigned len, const char *label, u32 status) dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
{ {
return scnprintf(buf, len, return scnprintf(buf, len, "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
"%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
label, label[0] ? " " : "", status, label, label[0] ? " " : "", status,
(status & STS_ASS) ? " Async" : "", (status & STS_ASS) ? " Async" : "",
(status & STS_PSS) ? " Periodic" : "", (status & STS_PSS) ? " Periodic" : "",
...@@ -207,33 +198,29 @@ dbg_status_buf(char *buf, unsigned len, const char *label, u32 status) ...@@ -207,33 +198,29 @@ dbg_status_buf(char *buf, unsigned len, const char *label, u32 status)
(status & STS_FLR) ? " FLR" : "", (status & STS_FLR) ? " FLR" : "",
(status & STS_PCD) ? " PCD" : "", (status & STS_PCD) ? " PCD" : "",
(status & STS_ERR) ? " ERR" : "", (status & STS_ERR) ? " ERR" : "",
(status & STS_INT) ? " INT" : "" (status & STS_INT) ? " INT" : "");
);
} }
static int __maybe_unused static int __maybe_unused
dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable) dbg_intr_buf(char *buf, unsigned len, const char *label, u32 enable)
{ {
return scnprintf(buf, len, return scnprintf(buf, len, "%s%sintrenable %02x%s%s%s%s%s%s",
"%s%sintrenable %02x%s%s%s%s%s%s",
label, label[0] ? " " : "", enable, label, label[0] ? " " : "", enable,
(enable & STS_IAA) ? " IAA" : "", (enable & STS_IAA) ? " IAA" : "",
(enable & STS_FATAL) ? " FATAL" : "", (enable & STS_FATAL) ? " FATAL" : "",
(enable & STS_FLR) ? " FLR" : "", (enable & STS_FLR) ? " FLR" : "",
(enable & STS_PCD) ? " PCD" : "", (enable & STS_PCD) ? " PCD" : "",
(enable & STS_ERR) ? " ERR" : "", (enable & STS_ERR) ? " ERR" : "",
(enable & STS_INT) ? " INT" : "" (enable & STS_INT) ? " INT" : "");
);
} }
static const char *const fls_strings[] = { "1024", "512", "256", "??" }; static const char *const fls_strings[] = { "1024", "512", "256", "??" };
static int static int dbg_command_buf(char *buf, unsigned len, const char *label,
dbg_command_buf(char *buf, unsigned len, const char *label, u32 command) u32 command)
{ {
return scnprintf(buf, len, return scnprintf(buf, len,
"%s%scommand %07x %s=%d ithresh=%d%s%s%s " "%s%scommand %07x %s=%d ithresh=%d%s%s%s period=%s%s %s",
"period=%s%s %s",
label, label[0] ? " " : "", command, label, label[0] ? " " : "", command,
(command & CMD_PARK) ? " park" : "(park)", (command & CMD_PARK) ? " park" : "(park)",
CMD_PARK_CNT(command), CMD_PARK_CNT(command),
...@@ -243,12 +230,11 @@ dbg_command_buf(char *buf, unsigned len, const char *label, u32 command) ...@@ -243,12 +230,11 @@ dbg_command_buf(char *buf, unsigned len, const char *label, u32 command)
(command & CMD_PSE) ? " Periodic" : "", (command & CMD_PSE) ? " Periodic" : "",
fls_strings[(command >> 2) & 0x3], fls_strings[(command >> 2) & 0x3],
(command & CMD_RESET) ? " Reset" : "", (command & CMD_RESET) ? " Reset" : "",
(command & CMD_RUN) ? "RUN" : "HALT" (command & CMD_RUN) ? "RUN" : "HALT");
);
} }
static char static char *dbg_port_buf(char *buf, unsigned len, const char *label, int port,
*dbg_port_buf(char *buf, unsigned len, const char *label, int port, u32 status) u32 status)
{ {
char *sig; char *sig;
...@@ -268,11 +254,9 @@ static char ...@@ -268,11 +254,9 @@ static char
break; break;
} }
scnprintf(buf, len, scnprintf(buf, len, "%s%sport:%d status %06x %d sig=%s%s%s%s%s%s%s%s",
"%s%sport:%d status %06x %d "
"sig=%s%s%s%s%s%s%s%s",
label, label[0] ? " " : "", port, status, label, label[0] ? " " : "", port, status,
status>>25,/*device address */ status >> 25, /*device address */
sig, sig,
(status & PORT_RESET) ? " RESET" : "", (status & PORT_RESET) ? " RESET" : "",
(status & PORT_SUSPEND) ? " SUSPEND" : "", (status & PORT_SUSPEND) ? " SUSPEND" : "",
...@@ -281,6 +265,7 @@ static char ...@@ -281,6 +265,7 @@ static char
(status & PORT_PE) ? " PE" : "", (status & PORT_PE) ? " PE" : "",
(status & PORT_CSC) ? " CSC" : "", (status & PORT_CSC) ? " CSC" : "",
(status & PORT_CONNECT) ? " CONNECT" : ""); (status & PORT_CONNECT) ? " CONNECT" : "");
return buf; return buf;
} }
...@@ -299,13 +284,11 @@ static char ...@@ -299,13 +284,11 @@ static char
#define dbg_port(fotg210, label, port, status) { \ #define dbg_port(fotg210, label, port, status) { \
char _buf[80]; \ char _buf[80]; \
fotg210_dbg(fotg210, "%s\n", dbg_port_buf(_buf, sizeof(_buf), label, port, status) ); \ fotg210_dbg(fotg210, "%s\n", \
dbg_port_buf(_buf, sizeof(_buf), label, port, status));\
} }
/*-------------------------------------------------------------------------*/
/* troubleshooting help: expose state in debugfs */ /* troubleshooting help: expose state in debugfs */
static int debug_async_open(struct inode *, struct file *); static int debug_async_open(struct inode *, struct file *);
static int debug_periodic_open(struct inode *, struct file *); static int debug_periodic_open(struct inode *, struct file *);
static int debug_registers_open(struct inode *, struct file *); static int debug_registers_open(struct inode *, struct file *);
...@@ -373,12 +356,8 @@ static inline char token_mark(struct fotg210_hcd *fotg210, __hc32 token) ...@@ -373,12 +356,8 @@ static inline char token_mark(struct fotg210_hcd *fotg210, __hc32 token)
return '/'; return '/';
} }
static void qh_lines( static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
struct fotg210_hcd *fotg210, char **nextp, unsigned *sizep)
struct fotg210_qh *qh,
char **nextp,
unsigned *sizep
)
{ {
u32 scratch; u32 scratch;
u32 hw_curr; u32 hw_curr;
...@@ -395,8 +374,8 @@ static void qh_lines( ...@@ -395,8 +374,8 @@ static void qh_lines(
else else
mark = token_mark(fotg210, hw->hw_token); mark = token_mark(fotg210, hw->hw_token);
if (mark == '/') { /* qh_alt_next controls qh advance? */ if (mark == '/') { /* qh_alt_next controls qh advance? */
if ((hw->hw_alt_next & QTD_MASK(fotg210)) if ((hw->hw_alt_next & QTD_MASK(fotg210)) ==
== fotg210->async->hw->hw_alt_next) fotg210->async->hw->hw_alt_next)
mark = '#'; /* blocked */ mark = '#'; /* blocked */
else if (hw->hw_alt_next == list_end) else if (hw->hw_alt_next == list_end)
mark = '.'; /* use hw_qtd_next */ mark = '.'; /* use hw_qtd_next */
...@@ -462,6 +441,7 @@ static void qh_lines( ...@@ -462,6 +441,7 @@ static void qh_lines(
temp = snprintf(next, size, "\n"); temp = snprintf(next, size, "\n");
if (size < temp) if (size < temp)
temp = size; temp = size;
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -523,6 +503,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -523,6 +503,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
seen = kmalloc(DBG_SCHED_LIMIT * sizeof(*seen), GFP_ATOMIC); seen = kmalloc(DBG_SCHED_LIMIT * sizeof(*seen), GFP_ATOMIC);
if (!seen) if (!seen)
return 0; return 0;
seen_count = 0; seen_count = 0;
hcd = bus_to_hcd(buf->bus); hcd = bus_to_hcd(buf->bus);
...@@ -542,6 +523,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -542,6 +523,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
p = fotg210->pshadow[i]; p = fotg210->pshadow[i];
if (likely(!p.ptr)) if (likely(!p.ptr))
continue; continue;
tag = Q_NEXT_TYPE(fotg210, fotg210->periodic[i]); tag = Q_NEXT_TYPE(fotg210, fotg210->periodic[i]);
temp = scnprintf(next, size, "%4d: ", i); temp = scnprintf(next, size, "%4d: ", i);
...@@ -601,8 +583,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -601,8 +583,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
} }
temp = scnprintf(next, size, temp = scnprintf(next, size,
"(%c%d ep%d%s " "(%c%d ep%d%s [%d/%d] q%d p%d)",
"[%d/%d] q%d p%d)",
speed_char(scratch), speed_char(scratch),
scratch & 0x007f, scratch & 0x007f,
(scratch >> 8) & 0x000f, type, (scratch >> 8) & 0x000f, type,
...@@ -619,8 +600,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) ...@@ -619,8 +600,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
break; break;
case Q_TYPE_FSTN: case Q_TYPE_FSTN:
temp = scnprintf(next, size, temp = scnprintf(next, size,
" fstn-%8x/%p", p.fstn->hw_prev, " fstn-%8x/%p",
p.fstn); p.fstn->hw_prev, p.fstn);
tag = Q_NEXT_TYPE(fotg210, p.fstn->hw_next); tag = Q_NEXT_TYPE(fotg210, p.fstn->hw_next);
p = p.fstn->fstn_next; p = p.fstn->fstn_next;
break; break;
...@@ -748,8 +729,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) ...@@ -748,8 +729,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
#ifdef FOTG210_STATS #ifdef FOTG210_STATS
temp = scnprintf(next, size, temp = scnprintf(next, size,
"irq normal %ld err %ld iaa %ld(lost %ld)\n", "irq normal %ld err %ld iaa %ld(lost %ld)\n",
fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa, fotg210->stats.normal, fotg210->stats.error,
fotg210->stats.lost_iaa); fotg210->stats.iaa, fotg210->stats.lost_iaa);
size -= temp; size -= temp;
next += temp; next += temp;
...@@ -765,8 +746,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf) ...@@ -765,8 +746,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
return buf->alloc_size - size; return buf->alloc_size - size;
} }
static struct debug_buffer *alloc_buffer(struct usb_bus *bus, static struct debug_buffer
ssize_t (*fill_func)(struct debug_buffer *)) *alloc_buffer(struct usb_bus *bus, ssize_t (*fill_func)(struct debug_buffer *))
{ {
struct debug_buffer *buf; struct debug_buffer *buf;
...@@ -850,6 +831,7 @@ static int debug_async_open(struct inode *inode, struct file *file) ...@@ -850,6 +831,7 @@ static int debug_async_open(struct inode *inode, struct file *file)
static int debug_periodic_open(struct inode *inode, struct file *file) static int debug_periodic_open(struct inode *inode, struct file *file)
{ {
struct debug_buffer *buf; struct debug_buffer *buf;
buf = alloc_buffer(inode->i_private, fill_periodic_buffer); buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -899,10 +881,7 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210) ...@@ -899,10 +881,7 @@ static inline void remove_debug_files(struct fotg210_hcd *fotg210)
debugfs_remove_recursive(fotg210->debug_dir); debugfs_remove_recursive(fotg210->debug_dir);
} }
/*-------------------------------------------------------------------------*/ /* handshake - spin reading hc until handshake completes or fails
/*
* handshake - spin reading hc until handshake completes or fails
* @ptr: address of hc register to be read * @ptr: address of hc register to be read
* @mask: bits to look at in result of read * @mask: bits to look at in result of read
* @done: value of those bits when handshake succeeds * @done: value of those bits when handshake succeeds
...@@ -936,8 +915,7 @@ static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr, ...@@ -936,8 +915,7 @@ static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr,
return -ETIMEDOUT; return -ETIMEDOUT;
} }
/* /* Force HC to halt state from unknown (EHCI spec section 2.3).
* Force HC to halt state from unknown (EHCI spec section 2.3).
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static int fotg210_halt(struct fotg210_hcd *fotg210) static int fotg210_halt(struct fotg210_hcd *fotg210)
...@@ -965,8 +943,7 @@ static int fotg210_halt(struct fotg210_hcd *fotg210) ...@@ -965,8 +943,7 @@ static int fotg210_halt(struct fotg210_hcd *fotg210)
STS_HALT, STS_HALT, 16 * 125); STS_HALT, STS_HALT, 16 * 125);
} }
/* /* Reset a non-running (STS_HALT == 1) controller.
* Reset a non-running (STS_HALT == 1) controller.
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static int fotg210_reset(struct fotg210_hcd *fotg210) static int fotg210_reset(struct fotg210_hcd *fotg210)
...@@ -975,7 +952,8 @@ static int fotg210_reset(struct fotg210_hcd *fotg210) ...@@ -975,7 +952,8 @@ static int fotg210_reset(struct fotg210_hcd *fotg210)
u32 command = fotg210_readl(fotg210, &fotg210->regs->command); u32 command = fotg210_readl(fotg210, &fotg210->regs->command);
/* If the EHCI debug controller is active, special care must be /* If the EHCI debug controller is active, special care must be
* taken before and after a host controller reset */ * taken before and after a host controller reset
*/
if (fotg210->debug && !dbgp_reset_prep(fotg210_to_hcd(fotg210))) if (fotg210->debug && !dbgp_reset_prep(fotg210_to_hcd(fotg210)))
fotg210->debug = NULL; fotg210->debug = NULL;
...@@ -998,8 +976,7 @@ static int fotg210_reset(struct fotg210_hcd *fotg210) ...@@ -998,8 +976,7 @@ static int fotg210_reset(struct fotg210_hcd *fotg210)
return retval; return retval;
} }
/* /* Idle the controller (turn off the schedules).
* Idle the controller (turn off the schedules).
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static void fotg210_quiesce(struct fotg210_hcd *fotg210) static void fotg210_quiesce(struct fotg210_hcd *fotg210)
...@@ -1025,8 +1002,6 @@ static void fotg210_quiesce(struct fotg210_hcd *fotg210) ...@@ -1025,8 +1002,6 @@ static void fotg210_quiesce(struct fotg210_hcd *fotg210)
16 * 125); 16 * 125);
} }
/*-------------------------------------------------------------------------*/
static void end_unlink_async(struct fotg210_hcd *fotg210); static void end_unlink_async(struct fotg210_hcd *fotg210);
static void unlink_empty_async(struct fotg210_hcd *fotg210); static void unlink_empty_async(struct fotg210_hcd *fotg210);
static void fotg210_work(struct fotg210_hcd *fotg210); static void fotg210_work(struct fotg210_hcd *fotg210);
...@@ -1034,8 +1009,6 @@ static void start_unlink_intr(struct fotg210_hcd *fotg210, ...@@ -1034,8 +1009,6 @@ static void start_unlink_intr(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh); struct fotg210_qh *qh);
static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh); static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
/*-------------------------------------------------------------------------*/
/* Set a bit in the USBCMD register */ /* Set a bit in the USBCMD register */
static void fotg210_set_command_bit(struct fotg210_hcd *fotg210, u32 bit) static void fotg210_set_command_bit(struct fotg210_hcd *fotg210, u32 bit)
{ {
...@@ -1056,10 +1029,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit) ...@@ -1056,10 +1029,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit)
fotg210_readl(fotg210, &fotg210->regs->command); fotg210_readl(fotg210, &fotg210->regs->command);
} }
/*-------------------------------------------------------------------------*/ /* EHCI timer support... Now using hrtimers.
/*
* EHCI timer support... Now using hrtimers.
* *
* Lots of different events are triggered from fotg210->hrtimer. Whenever * Lots of different events are triggered from fotg210->hrtimer. Whenever
* the timer routine runs, it checks each possible event; events that are * the timer routine runs, it checks each possible event; events that are
...@@ -1081,8 +1051,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit) ...@@ -1081,8 +1051,7 @@ static void fotg210_clear_command_bit(struct fotg210_hcd *fotg210, u32 bit)
* allow for an expiration range of 1 ms. * allow for an expiration range of 1 ms.
*/ */
/* /* Delay lengths for the hrtimer event types.
* Delay lengths for the hrtimer event types.
* Keep this list sorted by delay length, in the same order as * Keep this list sorted by delay length, in the same order as
* the event types indexed by enum fotg210_hrtimer_event in fotg210.h. * the event types indexed by enum fotg210_hrtimer_event in fotg210.h.
*/ */
...@@ -1369,8 +1338,7 @@ static void turn_on_io_watchdog(struct fotg210_hcd *fotg210) ...@@ -1369,8 +1338,7 @@ static void turn_on_io_watchdog(struct fotg210_hcd *fotg210)
} }
/* /* Handler functions for the hrtimer event types.
* Handler functions for the hrtimer event types.
* Keep this array in the same order as the event types indexed by * Keep this array in the same order as the event types indexed by
* enum fotg210_hrtimer_event in fotg210.h. * enum fotg210_hrtimer_event in fotg210.h.
*/ */
...@@ -1418,19 +1386,12 @@ static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t) ...@@ -1418,19 +1386,12 @@ static enum hrtimer_restart fotg210_hrtimer_func(struct hrtimer *t)
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
} }
/*-------------------------------------------------------------------------*/
#define fotg210_bus_suspend NULL #define fotg210_bus_suspend NULL
#define fotg210_bus_resume NULL #define fotg210_bus_resume NULL
/*-------------------------------------------------------------------------*/ static int check_reset_complete(struct fotg210_hcd *fotg210, int index,
u32 __iomem *status_reg, int port_status)
static int check_reset_complete( {
struct fotg210_hcd *fotg210,
int index,
u32 __iomem *status_reg,
int port_status
) {
if (!(port_status & PORT_CONNECT)) if (!(port_status & PORT_CONNECT))
return port_status; return port_status;
...@@ -1439,7 +1400,7 @@ static int check_reset_complete( ...@@ -1439,7 +1400,7 @@ static int check_reset_complete(
/* with integrated TT, there's nobody to hand it to! */ /* with integrated TT, there's nobody to hand it to! */
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"Failed to enable port %d on root hub TT\n", "Failed to enable port %d on root hub TT\n",
index+1); index + 1);
return port_status; return port_status;
} else { } else {
fotg210_dbg(fotg210, "port %d reset complete, port enabled\n", fotg210_dbg(fotg210, "port %d reset complete, port enabled\n",
...@@ -1449,13 +1410,10 @@ static int check_reset_complete( ...@@ -1449,13 +1410,10 @@ static int check_reset_complete(
return port_status; return port_status;
} }
/*-------------------------------------------------------------------------*/
/* build "status change" packet (one or two bytes) from HC registers */ /* build "status change" packet (one or two bytes) from HC registers */
static int static int fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
u32 temp, status; u32 temp, status;
...@@ -1488,9 +1446,9 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -1488,9 +1446,9 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
* controller by the user. * controller by the user.
*/ */
if ((temp & mask) != 0 || test_bit(0, &fotg210->port_c_suspend) if ((temp & mask) != 0 || test_bit(0, &fotg210->port_c_suspend) ||
|| (fotg210->reset_done[0] && time_after_eq( (fotg210->reset_done[0] &&
jiffies, fotg210->reset_done[0]))) { time_after_eq(jiffies, fotg210->reset_done[0]))) {
buf[0] |= 1 << 1; buf[0] |= 1 << 1;
status = STS_PCD; status = STS_PCD;
} }
...@@ -1499,13 +1457,9 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf) ...@@ -1499,13 +1457,9 @@ fotg210_hub_status_data(struct usb_hcd *hcd, char *buf)
return status ? retval : 0; return status ? retval : 0;
} }
/*-------------------------------------------------------------------------*/ static void fotg210_hub_descriptor(struct fotg210_hcd *fotg210,
struct usb_hub_descriptor *desc)
static void {
fotg210_hub_descriptor(
struct fotg210_hcd *fotg210,
struct usb_hub_descriptor *desc
) {
int ports = HCS_N_PORTS(fotg210->hcs_params); int ports = HCS_N_PORTS(fotg210->hcs_params);
u16 temp; u16 temp;
...@@ -1526,16 +1480,9 @@ fotg210_hub_descriptor( ...@@ -1526,16 +1480,9 @@ fotg210_hub_descriptor(
desc->wHubCharacteristics = cpu_to_le16(temp); desc->wHubCharacteristics = cpu_to_le16(temp);
} }
/*-------------------------------------------------------------------------*/ static int fotg210_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
static int fotg210_hub_control( {
struct usb_hcd *hcd,
u16 typeReq,
u16 wValue,
u16 wIndex,
char *buf,
u16 wLength
) {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
int ports = HCS_N_PORTS(fotg210->hcs_params); int ports = HCS_N_PORTS(fotg210->hcs_params);
u32 __iomem *status_reg = &fotg210->regs->port_status; u32 __iomem *status_reg = &fotg210->regs->port_status;
...@@ -1663,12 +1610,12 @@ static int fotg210_hub_control( ...@@ -1663,12 +1610,12 @@ static int fotg210_hub_control(
/* stop resume signaling */ /* stop resume signaling */
temp = fotg210_readl(fotg210, status_reg); temp = fotg210_readl(fotg210, status_reg);
fotg210_writel(fotg210, fotg210_writel(fotg210, temp &
temp & ~(PORT_RWC_BITS | PORT_RESUME), ~(PORT_RWC_BITS | PORT_RESUME),
status_reg); status_reg);
clear_bit(wIndex, &fotg210->resuming_ports); clear_bit(wIndex, &fotg210->resuming_ports);
retval = handshake(fotg210, status_reg, retval = handshake(fotg210, status_reg,
PORT_RESUME, 0, 2000 /* 2msec */); PORT_RESUME, 0, 2000);/* 2ms */
if (retval != 0) { if (retval != 0) {
fotg210_err(fotg210, fotg210_err(fotg210,
"port %d resume error %d\n", "port %d resume error %d\n",
...@@ -1680,8 +1627,7 @@ static int fotg210_hub_control( ...@@ -1680,8 +1627,7 @@ static int fotg210_hub_control(
} }
/* whoever resets must GetPortStatus to complete it!! */ /* whoever resets must GetPortStatus to complete it!! */
if ((temp & PORT_RESET) if ((temp & PORT_RESET) && time_after_eq(jiffies,
&& time_after_eq(jiffies,
fotg210->reset_done[wIndex])) { fotg210->reset_done[wIndex])) {
status |= USB_PORT_STAT_C_RESET << 16; status |= USB_PORT_STAT_C_RESET << 16;
fotg210->reset_done[wIndex] = 0; fotg210->reset_done[wIndex] = 0;
...@@ -1866,9 +1812,8 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd, ...@@ -1866,9 +1812,8 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd,
{ {
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/
/* /* There's basically three types of memory:
* There's basically three types of memory:
* - data used only by the HCD ... kmalloc is fine * - data used only by the HCD ... kmalloc is fine
* - async and periodic schedules, shared by HC and HCD ... these * - async and periodic schedules, shared by HC and HCD ... these
* need to use dma_pool or dma_alloc_coherent * need to use dma_pool or dma_alloc_coherent
...@@ -1878,10 +1823,7 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd, ...@@ -1878,10 +1823,7 @@ static int __maybe_unused fotg210_port_handed_over(struct usb_hcd *hcd,
* No memory seen by this driver is pageable. * No memory seen by this driver is pageable.
*/ */
/*-------------------------------------------------------------------------*/
/* Allocate the key transfer structures from the previously allocated pool */ /* Allocate the key transfer structures from the previously allocated pool */
static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210, static inline void fotg210_qtd_init(struct fotg210_hcd *fotg210,
struct fotg210_qtd *qtd, dma_addr_t dma) struct fotg210_qtd *qtd, dma_addr_t dma)
{ {
...@@ -1958,8 +1900,6 @@ static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210, ...@@ -1958,8 +1900,6 @@ static struct fotg210_qh *fotg210_qh_alloc(struct fotg210_hcd *fotg210,
return NULL; return NULL;
} }
/*-------------------------------------------------------------------------*/
/* The queue heads and transfer descriptors are managed from pools tied /* The queue heads and transfer descriptors are managed from pools tied
* to each of the "per device" structures. * to each of the "per device" structures.
* This is the initialisation and cleanup code. * This is the initialisation and cleanup code.
...@@ -2054,9 +1994,7 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) ...@@ -2054,9 +1994,7 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
fotg210_mem_cleanup(fotg210); fotg210_mem_cleanup(fotg210);
return -ENOMEM; return -ENOMEM;
} }
/*-------------------------------------------------------------------------*/ /* EHCI hardware queue manipulation ... the core. QH/QTD manipulation.
/*
* EHCI hardware queue manipulation ... the core. QH/QTD manipulation.
* *
* Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd" * Control, bulk, and interrupt traffic all use "qh" lists. They list "qtd"
* entries describing USB transactions, max 16-20kB/entry (with 4kB-aligned * entries describing USB transactions, max 16-20kB/entry (with 4kB-aligned
...@@ -2073,13 +2011,9 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags) ...@@ -2073,13 +2011,9 @@ static int fotg210_mem_init(struct fotg210_hcd *fotg210, gfp_t flags)
* buffer low/full speed data so the host collects it at high speed. * buffer low/full speed data so the host collects it at high speed.
*/ */
/*-------------------------------------------------------------------------*/
/* fill a qtd, returning how much of the buffer we were able to queue up */ /* fill a qtd, returning how much of the buffer we were able to queue up */
static int qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd,
static int dma_addr_t buf, size_t len, int token, int maxpacket)
qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf,
size_t len, int token, int maxpacket)
{ {
int i, count; int i, count;
u64 addr = buf; u64 addr = buf;
...@@ -2117,11 +2051,8 @@ qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf, ...@@ -2117,11 +2051,8 @@ qtd_fill(struct fotg210_hcd *fotg210, struct fotg210_qtd *qtd, dma_addr_t buf,
return count; return count;
} }
/*-------------------------------------------------------------------------*/ static inline void qh_update(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh, struct fotg210_qtd *qtd)
static inline void
qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
struct fotg210_qtd *qtd)
{ {
struct fotg210_qh_hw *hw = qh->hw; struct fotg210_qh_hw *hw = qh->hw;
...@@ -2154,8 +2085,7 @@ qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh, ...@@ -2154,8 +2085,7 @@ qh_update(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
* overlay, so qh->hw_token wrongly becomes inactive/halted), only fault * overlay, so qh->hw_token wrongly becomes inactive/halted), only fault
* recovery (including urb dequeue) would need software changes to a QH... * recovery (including urb dequeue) would need software changes to a QH...
*/ */
static void static void qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
{ {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
...@@ -2181,8 +2111,6 @@ qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2181,8 +2111,6 @@ qh_refresh(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
qh_update(fotg210, qh, qtd); qh_update(fotg210, qh, qtd);
} }
/*-------------------------------------------------------------------------*/
static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh); static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd, static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd,
...@@ -2201,8 +2129,7 @@ static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd, ...@@ -2201,8 +2129,7 @@ static void fotg210_clear_tt_buffer_complete(struct usb_hcd *hcd,
} }
static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210, static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh, struct fotg210_qh *qh, struct urb *urb, u32 token)
struct urb *urb, u32 token)
{ {
/* If an async split transaction gets an error or is unlinked, /* If an async split transaction gets an error or is unlinked,
...@@ -2213,6 +2140,7 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210, ...@@ -2213,6 +2140,7 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
*/ */
if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) { if (urb->dev->tt && !usb_pipeint(urb->pipe) && !qh->clearing_tt) {
struct usb_device *tt = urb->dev->tt->hub; struct usb_device *tt = urb->dev->tt->hub;
dev_dbg(&tt->dev, dev_dbg(&tt->dev,
"clear tt buffer port %d, a%d ep%d t%08x\n", "clear tt buffer port %d, a%d ep%d t%08x\n",
urb->dev->ttport, urb->dev->devnum, urb->dev->ttport, urb->dev->devnum,
...@@ -2226,12 +2154,8 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210, ...@@ -2226,12 +2154,8 @@ static void fotg210_clear_tt_buffer(struct fotg210_hcd *fotg210,
} }
} }
static int qtd_copy_status( static int qtd_copy_status(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, size_t length, u32 token)
struct urb *urb,
size_t length,
u32 token
)
{ {
int status = -EINPROGRESS; int status = -EINPROGRESS;
...@@ -2289,8 +2213,8 @@ static int qtd_copy_status( ...@@ -2289,8 +2213,8 @@ static int qtd_copy_status(
return status; return status;
} }
static void static void fotg210_urb_done(struct fotg210_hcd *fotg210, struct urb *urb,
fotg210_urb_done(struct fotg210_hcd *fotg210, struct urb *urb, int status) int status)
__releases(fotg210->lock) __releases(fotg210->lock)
__acquires(fotg210->lock) __acquires(fotg210->lock)
{ {
...@@ -2333,13 +2257,12 @@ __acquires(fotg210->lock) ...@@ -2333,13 +2257,12 @@ __acquires(fotg210->lock)
static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh); static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh);
/* /* Process and free completed qtds for a qh, returning URBs to drivers.
* Process and free completed qtds for a qh, returning URBs to drivers.
* Chases up to qh->hw_current. Returns number of completions called, * Chases up to qh->hw_current. Returns number of completions called,
* indicating how much "real" work we did. * indicating how much "real" work we did.
*/ */
static unsigned static unsigned qh_completions(struct fotg210_hcd *fotg210,
qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
struct fotg210_qtd *last, *end = qh->dummy; struct fotg210_qtd *last, *end = qh->dummy;
struct list_head *entry, *tmp; struct list_head *entry, *tmp;
...@@ -2366,7 +2289,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2366,7 +2289,7 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
qh->qh_state = QH_STATE_COMPLETING; qh->qh_state = QH_STATE_COMPLETING;
stopped = (state == QH_STATE_IDLE); stopped = (state == QH_STATE_IDLE);
rescan: rescan:
last = NULL; last = NULL;
last_status = -EINPROGRESS; last_status = -EINPROGRESS;
qh->needs_rescan = 0; qh->needs_rescan = 0;
...@@ -2405,20 +2328,17 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2405,20 +2328,17 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
token = hc32_to_cpu(fotg210, qtd->hw_token); token = hc32_to_cpu(fotg210, qtd->hw_token);
/* always clean up qtds the hc de-activated */ /* always clean up qtds the hc de-activated */
retry_xacterr: retry_xacterr:
if ((token & QTD_STS_ACTIVE) == 0) { if ((token & QTD_STS_ACTIVE) == 0) {
/* Report Data Buffer Error: non-fatal but useful */ /* Report Data Buffer Error: non-fatal but useful */
if (token & QTD_STS_DBE) if (token & QTD_STS_DBE)
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n", "detected DataBufferErr for urb %p ep%d%s len %d, qtd %p [qh %p]\n",
urb, urb, usb_endpoint_num(&urb->ep->desc),
usb_endpoint_num(&urb->ep->desc),
usb_endpoint_dir_in(&urb->ep->desc) usb_endpoint_dir_in(&urb->ep->desc)
? "in" : "out", ? "in" : "out",
urb->transfer_buffer_length, urb->transfer_buffer_length, qtd, qh);
qtd,
qh);
/* on STALL, error, and short reads this urb must /* on STALL, error, and short reads this urb must
* complete and all its qtds must be recycled. * complete and all its qtds must be recycled.
...@@ -2434,7 +2354,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2434,7 +2354,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
!urb->unlinked) { !urb->unlinked) {
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"detected XactErr len %zu/%zu retry %d\n", "detected XactErr len %zu/%zu retry %d\n",
qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs); qtd->length - QTD_LENGTH(token),
qtd->length,
qh->xacterrs);
/* reset the token in the qtd and the /* reset the token in the qtd and the
* qh overlay (which still contains * qh overlay (which still contains
...@@ -2462,9 +2384,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2462,9 +2384,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
* URB_SHORT_NOT_OK was set so the driver submitting * URB_SHORT_NOT_OK was set so the driver submitting
* the urbs could clean it up. * the urbs could clean it up.
*/ */
} else if (IS_SHORT_READ(token) } else if (IS_SHORT_READ(token) &&
&& !(qtd->hw_alt_next !(qtd->hw_alt_next &
& FOTG210_LIST_END(fotg210))) { FOTG210_LIST_END(fotg210))) {
stopped = 1; stopped = 1;
} }
...@@ -2488,8 +2410,8 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2488,8 +2410,8 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
continue; continue;
/* qh unlinked; token in overlay may be most current */ /* qh unlinked; token in overlay may be most current */
if (state == QH_STATE_IDLE if (state == QH_STATE_IDLE &&
&& cpu_to_hc32(fotg210, qtd->qtd_dma) cpu_to_hc32(fotg210, qtd->qtd_dma)
== hw->hw_current) { == hw->hw_current) {
token = hc32_to_cpu(fotg210, hw->hw_token); token = hc32_to_cpu(fotg210, hw->hw_token);
...@@ -2512,9 +2434,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2512,9 +2434,9 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
if (last_status == -EINPROGRESS) { if (last_status == -EINPROGRESS) {
last_status = qtd_copy_status(fotg210, urb, last_status = qtd_copy_status(fotg210, urb,
qtd->length, token); qtd->length, token);
if (last_status == -EREMOTEIO if (last_status == -EREMOTEIO &&
&& (qtd->hw_alt_next (qtd->hw_alt_next &
& FOTG210_LIST_END(fotg210))) FOTG210_LIST_END(fotg210)))
last_status = -EINPROGRESS; last_status = -EINPROGRESS;
/* As part of low/full-speed endpoint-halt processing /* As part of low/full-speed endpoint-halt processing
...@@ -2611,22 +2533,17 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -2611,22 +2533,17 @@ qh_completions(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
return count; return count;
} }
/*-------------------------------------------------------------------------*/
/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */ /* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03)) #define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
/* ... and packet size, for any kind of endpoint descriptor */ /* ... and packet size, for any kind of endpoint descriptor */
#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff) #define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
/* /* reverse of qh_urb_transaction: free a list of TDs.
* reverse of qh_urb_transaction: free a list of TDs.
* used for cleanup after errors, before HC sees an URB's TDs. * used for cleanup after errors, before HC sees an URB's TDs.
*/ */
static void qtd_list_free( static void qtd_list_free(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, struct list_head *qtd_list)
struct urb *urb, {
struct list_head *qtd_list
) {
struct list_head *entry, *temp; struct list_head *entry, *temp;
list_for_each_safe(entry, temp, qtd_list) { list_for_each_safe(entry, temp, qtd_list) {
...@@ -2638,16 +2555,11 @@ static void qtd_list_free( ...@@ -2638,16 +2555,11 @@ static void qtd_list_free(
} }
} }
/* /* create a list of filled qtds for this URB; won't link into qh.
* create a list of filled qtds for this URB; won't link into qh.
*/ */
static struct list_head * static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
qh_urb_transaction( struct urb *urb, struct list_head *head, gfp_t flags)
struct fotg210_hcd *fotg210, {
struct urb *urb,
struct list_head *head,
gfp_t flags
) {
struct fotg210_qtd *qtd, *qtd_prev; struct fotg210_qtd *qtd, *qtd_prev;
dma_addr_t buf; dma_addr_t buf;
int len, this_sg_len, maxpacket; int len, this_sg_len, maxpacket;
...@@ -2764,8 +2676,8 @@ qh_urb_transaction( ...@@ -2764,8 +2676,8 @@ qh_urb_transaction(
* have the alt_next mechanism keep the queue running after the * have the alt_next mechanism keep the queue running after the
* last data qtd (the only one, for control and most other cases). * last data qtd (the only one, for control and most other cases).
*/ */
if (likely((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 if (likely((urb->transfer_flags & URB_SHORT_NOT_OK) == 0 ||
|| usb_pipecontrol(urb->pipe))) usb_pipecontrol(urb->pipe)))
qtd->hw_alt_next = FOTG210_LIST_END(fotg210); qtd->hw_alt_next = FOTG210_LIST_END(fotg210);
/* /*
...@@ -2809,9 +2721,7 @@ qh_urb_transaction( ...@@ -2809,9 +2721,7 @@ qh_urb_transaction(
return NULL; return NULL;
} }
/*-------------------------------------------------------------------------*/ /* Would be best to create all qh's from config descriptors,
/*
* Would be best to create all qh's from config descriptors,
* when each interface/altsetting is established. Unlink * when each interface/altsetting is established. Unlink
* any previous qh and cancel its urbs first; endpoints are * any previous qh and cancel its urbs first; endpoints are
* implicitly reset then (data toggle too). * implicitly reset then (data toggle too).
...@@ -2819,20 +2729,16 @@ qh_urb_transaction( ...@@ -2819,20 +2729,16 @@ qh_urb_transaction(
*/ */
/* /* Each QH holds a qtd list; a QH is used for everything except iso.
* Each QH holds a qtd list; a QH is used for everything except iso.
* *
* For interrupt urbs, the scheduler must set the microframe scheduling * For interrupt urbs, the scheduler must set the microframe scheduling
* mask(s) each time the QH gets scheduled. For highspeed, that's * mask(s) each time the QH gets scheduled. For highspeed, that's
* just one microframe in the s-mask. For split interrupt transactions * just one microframe in the s-mask. For split interrupt transactions
* there are additional complications: c-mask, maybe FSTNs. * there are additional complications: c-mask, maybe FSTNs.
*/ */
static struct fotg210_qh * static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
qh_make( gfp_t flags)
struct fotg210_hcd *fotg210, {
struct urb *urb,
gfp_t flags
) {
struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags); struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
u32 info1 = 0, info2 = 0; u32 info1 = 0, info2 = 0;
int is_input, type; int is_input, type;
...@@ -3001,8 +2907,6 @@ qh_make( ...@@ -3001,8 +2907,6 @@ qh_make(
return qh; return qh;
} }
/*-------------------------------------------------------------------------*/
static void enable_async(struct fotg210_hcd *fotg210) static void enable_async(struct fotg210_hcd *fotg210)
{ {
if (fotg210->async_count++) if (fotg210->async_count++)
...@@ -3060,21 +2964,14 @@ static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3060,21 +2964,14 @@ static void qh_link_async(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
enable_async(fotg210); enable_async(fotg210);
} }
/*-------------------------------------------------------------------------*/ /* For control/bulk/interrupt, return QH with these TDs appended.
/*
* For control/bulk/interrupt, return QH with these TDs appended.
* Allocates and initializes the QH if necessary. * Allocates and initializes the QH if necessary.
* Returns null if it can't allocate a QH it needs to. * Returns null if it can't allocate a QH it needs to.
* If the QH has TDs (urbs) already, that's great. * If the QH has TDs (urbs) already, that's great.
*/ */
static struct fotg210_qh *qh_append_tds( static struct fotg210_qh *qh_append_tds(struct fotg210_hcd *fotg210,
struct fotg210_hcd *fotg210, struct urb *urb, struct list_head *qtd_list,
struct urb *urb, int epnum, void **ptr)
struct list_head *qtd_list,
int epnum,
void **ptr
)
{ {
struct fotg210_qh *qh = NULL; struct fotg210_qh *qh = NULL;
__hc32 qh_addr_mask = cpu_to_hc32(fotg210, 0x7f); __hc32 qh_addr_mask = cpu_to_hc32(fotg210, 0x7f);
...@@ -3146,15 +3043,9 @@ static struct fotg210_qh *qh_append_tds( ...@@ -3146,15 +3043,9 @@ static struct fotg210_qh *qh_append_tds(
return qh; return qh;
} }
/*-------------------------------------------------------------------------*/ static int submit_async(struct fotg210_hcd *fotg210, struct urb *urb,
struct list_head *qtd_list, gfp_t mem_flags)
static int {
submit_async(
struct fotg210_hcd *fotg210,
struct urb *urb,
struct list_head *qtd_list,
gfp_t mem_flags
) {
int epnum; int epnum;
unsigned long flags; unsigned long flags;
struct fotg210_qh *qh = NULL; struct fotg210_qh *qh = NULL;
...@@ -3165,11 +3056,13 @@ submit_async( ...@@ -3165,11 +3056,13 @@ submit_async(
#ifdef FOTG210_URB_TRACE #ifdef FOTG210_URB_TRACE
{ {
struct fotg210_qtd *qtd; struct fotg210_qtd *qtd;
qtd = list_entry(qtd_list->next, struct fotg210_qtd, qtd_list); qtd = list_entry(qtd_list->next, struct fotg210_qtd, qtd_list);
fotg210_dbg(fotg210, fotg210_dbg(fotg210,
"%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n", "%s %s urb %p ep%d%s len %d, qtd %p [qh %p]\n",
__func__, urb->dev->devpath, urb, __func__, urb->dev->devpath, urb,
epnum & 0x0f, (epnum & USB_DIR_IN) ? "in" : "out", epnum & 0x0f, (epnum & USB_DIR_IN)
? "in" : "out",
urb->transfer_buffer_length, urb->transfer_buffer_length,
qtd, urb->ep->hcpriv); qtd, urb->ep->hcpriv);
} }
...@@ -3196,15 +3089,13 @@ submit_async( ...@@ -3196,15 +3089,13 @@ submit_async(
*/ */
if (likely(qh->qh_state == QH_STATE_IDLE)) if (likely(qh->qh_state == QH_STATE_IDLE))
qh_link_async(fotg210, qh); qh_link_async(fotg210, qh);
done: done:
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
if (unlikely(qh == NULL)) if (unlikely(qh == NULL))
qtd_list_free(fotg210, urb, qtd_list); qtd_list_free(fotg210, urb, qtd_list);
return rc; return rc;
} }
/*-------------------------------------------------------------------------*/
static void single_unlink_async(struct fotg210_hcd *fotg210, static void single_unlink_async(struct fotg210_hcd *fotg210,
struct fotg210_qh *qh) struct fotg210_qh *qh)
{ {
...@@ -3267,7 +3158,7 @@ static void end_unlink_async(struct fotg210_hcd *fotg210) ...@@ -3267,7 +3158,7 @@ static void end_unlink_async(struct fotg210_hcd *fotg210)
struct fotg210_qh *qh; struct fotg210_qh *qh;
/* Process the idle QHs */ /* Process the idle QHs */
restart: restart:
fotg210->async_unlinking = true; fotg210->async_unlinking = true;
while (fotg210->async_iaa) { while (fotg210->async_iaa) {
qh = fotg210->async_iaa; qh = fotg210->async_iaa;
...@@ -3348,8 +3239,6 @@ static void start_unlink_async(struct fotg210_hcd *fotg210, ...@@ -3348,8 +3239,6 @@ static void start_unlink_async(struct fotg210_hcd *fotg210,
start_iaa_cycle(fotg210, false); start_iaa_cycle(fotg210, false);
} }
/*-------------------------------------------------------------------------*/
static void scan_async(struct fotg210_hcd *fotg210) static void scan_async(struct fotg210_hcd *fotg210)
{ {
struct fotg210_qh *qh; struct fotg210_qh *qh;
...@@ -3359,7 +3248,7 @@ static void scan_async(struct fotg210_hcd *fotg210) ...@@ -3359,7 +3248,7 @@ static void scan_async(struct fotg210_hcd *fotg210)
while (fotg210->qh_scan_next) { while (fotg210->qh_scan_next) {
qh = fotg210->qh_scan_next; qh = fotg210->qh_scan_next;
fotg210->qh_scan_next = qh->qh_next.qh; fotg210->qh_scan_next = qh->qh_next.qh;
rescan: rescan:
/* clean any finished work for this qh */ /* clean any finished work for this qh */
if (!list_empty(&qh->qtd_list)) { if (!list_empty(&qh->qtd_list)) {
int temp; int temp;
...@@ -3397,9 +3286,7 @@ static void scan_async(struct fotg210_hcd *fotg210) ...@@ -3397,9 +3286,7 @@ static void scan_async(struct fotg210_hcd *fotg210)
++fotg210->async_unlink_cycle; ++fotg210->async_unlink_cycle;
} }
} }
/*-------------------------------------------------------------------------*/ /* EHCI scheduled transaction support: interrupt, iso, split iso
/*
* EHCI scheduled transaction support: interrupt, iso, split iso
* These are called "periodic" transactions in the EHCI spec. * These are called "periodic" transactions in the EHCI spec.
* *
* Note that for interrupt transfers, the QH/QTD manipulation is shared * Note that for interrupt transfers, the QH/QTD manipulation is shared
...@@ -3410,18 +3297,13 @@ static void scan_async(struct fotg210_hcd *fotg210) ...@@ -3410,18 +3297,13 @@ static void scan_async(struct fotg210_hcd *fotg210)
* It keeps track of every ITD (or SITD) that's linked, and holds enough * It keeps track of every ITD (or SITD) that's linked, and holds enough
* pre-calculated schedule data to make appending to the queue be quick. * pre-calculated schedule data to make appending to the queue be quick.
*/ */
static int fotg210_get_frame(struct usb_hcd *hcd); static int fotg210_get_frame(struct usb_hcd *hcd);
/*-------------------------------------------------------------------------*/ /* periodic_next_shadow - return "next" pointer on shadow list
/*
* periodic_next_shadow - return "next" pointer on shadow list
* @periodic: host pointer to qh/itd * @periodic: host pointer to qh/itd
* @tag: hardware tag for type of this record * @tag: hardware tag for type of this record
*/ */
static union fotg210_shadow * static union fotg210_shadow *periodic_next_shadow(struct fotg210_hcd *fotg210,
periodic_next_shadow(struct fotg210_hcd *fotg210,
union fotg210_shadow *periodic, __hc32 tag) union fotg210_shadow *periodic, __hc32 tag)
{ {
switch (hc32_to_cpu(fotg210, tag)) { switch (hc32_to_cpu(fotg210, tag)) {
...@@ -3434,8 +3316,7 @@ periodic_next_shadow(struct fotg210_hcd *fotg210, ...@@ -3434,8 +3316,7 @@ periodic_next_shadow(struct fotg210_hcd *fotg210,
} }
} }
static __hc32 * static __hc32 *shadow_next_periodic(struct fotg210_hcd *fotg210,
shadow_next_periodic(struct fotg210_hcd *fotg210,
union fotg210_shadow *periodic, __hc32 tag) union fotg210_shadow *periodic, __hc32 tag)
{ {
switch (hc32_to_cpu(fotg210, tag)) { switch (hc32_to_cpu(fotg210, tag)) {
...@@ -3479,8 +3360,8 @@ static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame, ...@@ -3479,8 +3360,8 @@ static void periodic_unlink(struct fotg210_hcd *fotg210, unsigned frame,
} }
/* how many of the uframe's 125 usecs are allocated? */ /* how many of the uframe's 125 usecs are allocated? */
static unsigned short static unsigned short periodic_usecs(struct fotg210_hcd *fotg210,
periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe) unsigned frame, unsigned uframe)
{ {
__hc32 *hw_p = &fotg210->periodic[frame]; __hc32 *hw_p = &fotg210->periodic[frame];
union fotg210_shadow *q = &fotg210->pshadow[frame]; union fotg210_shadow *q = &fotg210->pshadow[frame];
...@@ -3526,8 +3407,6 @@ periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe) ...@@ -3526,8 +3407,6 @@ periodic_usecs(struct fotg210_hcd *fotg210, unsigned frame, unsigned uframe)
return usecs; return usecs;
} }
/*-------------------------------------------------------------------------*/
static int same_tt(struct usb_device *dev1, struct usb_device *dev2) static int same_tt(struct usb_device *dev1, struct usb_device *dev2)
{ {
if (!dev1->tt || !dev2->tt) if (!dev1->tt || !dev2->tt)
...@@ -3544,13 +3423,8 @@ static int same_tt(struct usb_device *dev1, struct usb_device *dev2) ...@@ -3544,13 +3423,8 @@ static int same_tt(struct usb_device *dev1, struct usb_device *dev2)
* for a periodic transfer starting at the specified frame, using * for a periodic transfer starting at the specified frame, using
* all the uframes in the mask. * all the uframes in the mask.
*/ */
static int tt_no_collision( static int tt_no_collision(struct fotg210_hcd *fotg210, unsigned period,
struct fotg210_hcd *fotg210, struct usb_device *dev, unsigned frame, u32 uf_mask)
unsigned period,
struct usb_device *dev,
unsigned frame,
u32 uf_mask
)
{ {
if (period == 0) /* error */ if (period == 0) /* error */
return 0; return 0;
...@@ -3603,8 +3477,6 @@ static int tt_no_collision( ...@@ -3603,8 +3477,6 @@ static int tt_no_collision(
return 1; return 1;
} }
/*-------------------------------------------------------------------------*/
static void enable_periodic(struct fotg210_hcd *fotg210) static void enable_periodic(struct fotg210_hcd *fotg210)
{ {
if (fotg210->periodic_count++) if (fotg210->periodic_count++)
...@@ -3628,8 +3500,6 @@ static void disable_periodic(struct fotg210_hcd *fotg210) ...@@ -3628,8 +3500,6 @@ static void disable_periodic(struct fotg210_hcd *fotg210)
fotg210_poll_PSS(fotg210); fotg210_poll_PSS(fotg210);
} }
/*-------------------------------------------------------------------------*/
/* periodic schedule slots have iso tds (normal or split) first, then a /* periodic schedule slots have iso tds (normal or split) first, then a
* sparse tree for active interrupt transfers. * sparse tree for active interrupt transfers.
* *
...@@ -3642,10 +3512,10 @@ static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3642,10 +3512,10 @@ static void qh_link_periodic(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
unsigned period = qh->period; unsigned period = qh->period;
dev_dbg(&qh->dev->dev, dev_dbg(&qh->dev->dev,
"link qh%d-%04x/%p start %d [%d/%d us]\n", "link qh%d-%04x/%p start %d [%d/%d us]\n", period,
period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
& (QH_CMASK | QH_SMASK), (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
qh, qh->start, qh->usecs, qh->c_usecs); qh->c_usecs);
/* high bandwidth, or otherwise every microframe */ /* high bandwidth, or otherwise every microframe */
if (period == 0) if (period == 0)
...@@ -3738,9 +3608,9 @@ static void qh_unlink_periodic(struct fotg210_hcd *fotg210, ...@@ -3738,9 +3608,9 @@ static void qh_unlink_periodic(struct fotg210_hcd *fotg210,
dev_dbg(&qh->dev->dev, dev_dbg(&qh->dev->dev,
"unlink qh%d-%04x/%p start %d [%d/%d us]\n", "unlink qh%d-%04x/%p start %d [%d/%d us]\n",
qh->period, qh->period, hc32_to_cpup(fotg210, &qh->hw->hw_info2) &
hc32_to_cpup(fotg210, &qh->hw->hw_info2) & (QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs,
(QH_CMASK | QH_SMASK), qh, qh->start, qh->usecs, qh->c_usecs); qh->c_usecs);
/* qh->qh_next still "live" to HC */ /* qh->qh_next still "live" to HC */
qh->qh_state = QH_STATE_UNLINK; qh->qh_state = QH_STATE_UNLINK;
...@@ -3826,15 +3696,9 @@ static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3826,15 +3696,9 @@ static void end_unlink_intr(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
disable_periodic(fotg210); disable_periodic(fotg210);
} }
/*-------------------------------------------------------------------------*/ static int check_period(struct fotg210_hcd *fotg210, unsigned frame,
unsigned uframe, unsigned period, unsigned usecs)
static int check_period( {
struct fotg210_hcd *fotg210,
unsigned frame,
unsigned uframe,
unsigned period,
unsigned usecs
) {
int claimed; int claimed;
/* complete split running into next frame? /* complete split running into next frame?
...@@ -3872,13 +3736,8 @@ static int check_period( ...@@ -3872,13 +3736,8 @@ static int check_period(
return 1; return 1;
} }
static int check_intr_schedule( static int check_intr_schedule(struct fotg210_hcd *fotg210, unsigned frame,
struct fotg210_hcd *fotg210, unsigned uframe, const struct fotg210_qh *qh, __hc32 *c_maskp)
unsigned frame,
unsigned uframe,
const struct fotg210_qh *qh,
__hc32 *c_maskp
)
{ {
int retval = -ENOSPC; int retval = -ENOSPC;
u8 mask = 0; u8 mask = 0;
...@@ -3988,12 +3847,9 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh) ...@@ -3988,12 +3847,9 @@ static int qh_schedule(struct fotg210_hcd *fotg210, struct fotg210_qh *qh)
return status; return status;
} }
static int intr_submit( static int intr_submit(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, struct list_head *qtd_list, gfp_t mem_flags)
struct urb *urb, {
struct list_head *qtd_list,
gfp_t mem_flags
) {
unsigned epnum; unsigned epnum;
unsigned long flags; unsigned long flags;
struct fotg210_qh *qh; struct fotg210_qh *qh;
...@@ -4050,7 +3906,7 @@ static void scan_intr(struct fotg210_hcd *fotg210) ...@@ -4050,7 +3906,7 @@ static void scan_intr(struct fotg210_hcd *fotg210)
list_for_each_entry_safe(qh, fotg210->qh_scan_next, list_for_each_entry_safe(qh, fotg210->qh_scan_next,
&fotg210->intr_qh_list, intr_node) { &fotg210->intr_qh_list, intr_node) {
rescan: rescan:
/* clean any finished work for this qh */ /* clean any finished work for this qh */
if (!list_empty(&qh->qtd_list)) { if (!list_empty(&qh->qtd_list)) {
int temp; int temp;
...@@ -4073,12 +3929,9 @@ static void scan_intr(struct fotg210_hcd *fotg210) ...@@ -4073,12 +3929,9 @@ static void scan_intr(struct fotg210_hcd *fotg210)
} }
} }
/*-------------------------------------------------------------------------*/
/* fotg210_iso_stream ops work with both ITD and SITD */ /* fotg210_iso_stream ops work with both ITD and SITD */
static struct fotg210_iso_stream * static struct fotg210_iso_stream *iso_stream_alloc(gfp_t mem_flags)
iso_stream_alloc(gfp_t mem_flags)
{ {
struct fotg210_iso_stream *stream; struct fotg210_iso_stream *stream;
...@@ -4091,14 +3944,9 @@ iso_stream_alloc(gfp_t mem_flags) ...@@ -4091,14 +3944,9 @@ iso_stream_alloc(gfp_t mem_flags)
return stream; return stream;
} }
static void static void iso_stream_init(struct fotg210_hcd *fotg210,
iso_stream_init( struct fotg210_iso_stream *stream, struct usb_device *dev,
struct fotg210_hcd *fotg210, int pipe, unsigned interval)
struct fotg210_iso_stream *stream,
struct usb_device *dev,
int pipe,
unsigned interval
)
{ {
u32 buf1; u32 buf1;
unsigned epnum, maxp; unsigned epnum, maxp;
...@@ -4149,8 +3997,8 @@ iso_stream_init( ...@@ -4149,8 +3997,8 @@ iso_stream_init(
stream->maxp = maxp; stream->maxp = maxp;
} }
static struct fotg210_iso_stream * static struct fotg210_iso_stream *iso_stream_find(struct fotg210_hcd *fotg210,
iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb) struct urb *urb)
{ {
unsigned epnum; unsigned epnum;
struct fotg210_iso_stream *stream; struct fotg210_iso_stream *stream;
...@@ -4187,12 +4035,10 @@ iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb) ...@@ -4187,12 +4035,10 @@ iso_stream_find(struct fotg210_hcd *fotg210, struct urb *urb)
return stream; return stream;
} }
/*-------------------------------------------------------------------------*/
/* fotg210_iso_sched ops can be ITD-only or SITD-only */ /* fotg210_iso_sched ops can be ITD-only or SITD-only */
static struct fotg210_iso_sched * static struct fotg210_iso_sched *iso_sched_alloc(unsigned packets,
iso_sched_alloc(unsigned packets, gfp_t mem_flags) gfp_t mem_flags)
{ {
struct fotg210_iso_sched *iso_sched; struct fotg210_iso_sched *iso_sched;
int size = sizeof(*iso_sched); int size = sizeof(*iso_sched);
...@@ -4205,13 +4051,9 @@ iso_sched_alloc(unsigned packets, gfp_t mem_flags) ...@@ -4205,13 +4051,9 @@ iso_sched_alloc(unsigned packets, gfp_t mem_flags)
return iso_sched; return iso_sched;
} }
static inline void static inline void itd_sched_init(struct fotg210_hcd *fotg210,
itd_sched_init(
struct fotg210_hcd *fotg210,
struct fotg210_iso_sched *iso_sched, struct fotg210_iso_sched *iso_sched,
struct fotg210_iso_stream *stream, struct fotg210_iso_stream *stream, struct urb *urb)
struct urb *urb
)
{ {
unsigned i; unsigned i;
dma_addr_t dma = urb->transfer_dma; dma_addr_t dma = urb->transfer_dma;
...@@ -4247,11 +4089,8 @@ itd_sched_init( ...@@ -4247,11 +4089,8 @@ itd_sched_init(
} }
} }
static void static void iso_sched_free(struct fotg210_iso_stream *stream,
iso_sched_free( struct fotg210_iso_sched *iso_sched)
struct fotg210_iso_stream *stream,
struct fotg210_iso_sched *iso_sched
)
{ {
if (!iso_sched) if (!iso_sched)
return; return;
...@@ -4260,13 +4099,8 @@ iso_sched_free( ...@@ -4260,13 +4099,8 @@ iso_sched_free(
kfree(iso_sched); kfree(iso_sched);
} }
static int static int itd_urb_transaction(struct fotg210_iso_stream *stream,
itd_urb_transaction( struct fotg210_hcd *fotg210, struct urb *urb, gfp_t mem_flags)
struct fotg210_iso_stream *stream,
struct fotg210_hcd *fotg210,
struct urb *urb,
gfp_t mem_flags
)
{ {
struct fotg210_itd *itd; struct fotg210_itd *itd;
dma_addr_t itd_dma; dma_addr_t itd_dma;
...@@ -4302,7 +4136,7 @@ itd_urb_transaction( ...@@ -4302,7 +4136,7 @@ itd_urb_transaction(
list_del(&itd->itd_list); list_del(&itd->itd_list);
itd_dma = itd->itd_dma; itd_dma = itd->itd_dma;
} else { } else {
alloc_itd: alloc_itd:
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
itd = dma_pool_alloc(fotg210->itd_pool, mem_flags, itd = dma_pool_alloc(fotg210->itd_pool, mem_flags,
&itd_dma); &itd_dma);
...@@ -4326,16 +4160,8 @@ itd_urb_transaction( ...@@ -4326,16 +4160,8 @@ itd_urb_transaction(
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/ static inline int itd_slot_ok(struct fotg210_hcd *fotg210, u32 mod, u32 uframe,
u8 usecs, u32 period)
static inline int
itd_slot_ok(
struct fotg210_hcd *fotg210,
u32 mod,
u32 uframe,
u8 usecs,
u32 period
)
{ {
uframe %= period; uframe %= period;
do { do {
...@@ -4350,8 +4176,7 @@ itd_slot_ok( ...@@ -4350,8 +4176,7 @@ itd_slot_ok(
return 1; return 1;
} }
/* /* This scheduler plans almost as far into the future as it has actual
* This scheduler plans almost as far into the future as it has actual
* periodic schedule slots. (Affected by TUNE_FLS, which defaults to * periodic schedule slots. (Affected by TUNE_FLS, which defaults to
* "as small as possible" to be cache-friendlier.) That limits the size * "as small as possible" to be cache-friendlier.) That limits the size
* transfers you can stream reliably; avoid more than 64 msec per urb. * transfers you can stream reliably; avoid more than 64 msec per urb.
...@@ -4363,12 +4188,8 @@ itd_slot_ok( ...@@ -4363,12 +4188,8 @@ itd_slot_ok(
#define SCHEDULE_SLOP 80 /* microframes */ #define SCHEDULE_SLOP 80 /* microframes */
static int static int iso_stream_schedule(struct fotg210_hcd *fotg210, struct urb *urb,
iso_stream_schedule( struct fotg210_iso_stream *stream)
struct fotg210_hcd *fotg210,
struct urb *urb,
struct fotg210_iso_stream *stream
)
{ {
u32 now, next, start, period, span; u32 now, next, start, period, span;
int status; int status;
...@@ -4431,6 +4252,7 @@ iso_stream_schedule( ...@@ -4431,6 +4252,7 @@ iso_stream_schedule(
*/ */
else { else {
int done = 0; int done = 0;
start = SCHEDULE_SLOP + (now & ~0x07); start = SCHEDULE_SLOP + (now & ~0x07);
/* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */
...@@ -4460,8 +4282,8 @@ iso_stream_schedule( ...@@ -4460,8 +4282,8 @@ iso_stream_schedule(
} }
/* Tried to schedule too far into the future? */ /* Tried to schedule too far into the future? */
if (unlikely(start - now + span - period if (unlikely(start - now + span - period >=
>= mod - 2 * SCHEDULE_SLOP)) { mod - 2 * SCHEDULE_SLOP)) {
fotg210_dbg(fotg210, "request %p would overflow (%d+%d >= %d)\n", fotg210_dbg(fotg210, "request %p would overflow (%d+%d >= %d)\n",
urb, start - now, span - period, urb, start - now, span - period,
mod - 2 * SCHEDULE_SLOP); mod - 2 * SCHEDULE_SLOP);
...@@ -4481,17 +4303,14 @@ iso_stream_schedule( ...@@ -4481,17 +4303,14 @@ iso_stream_schedule(
fotg210->next_frame = now >> 3; fotg210->next_frame = now >> 3;
return 0; return 0;
fail: fail:
iso_sched_free(stream, sched); iso_sched_free(stream, sched);
urb->hcpriv = NULL; urb->hcpriv = NULL;
return status; return status;
} }
/*-------------------------------------------------------------------------*/ static inline void itd_init(struct fotg210_hcd *fotg210,
struct fotg210_iso_stream *stream, struct fotg210_itd *itd)
static inline void
itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream,
struct fotg210_itd *itd)
{ {
int i; int i;
...@@ -4507,14 +4326,9 @@ itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream, ...@@ -4507,14 +4326,9 @@ itd_init(struct fotg210_hcd *fotg210, struct fotg210_iso_stream *stream,
/* All other fields are filled when scheduling */ /* All other fields are filled when scheduling */
} }
static inline void static inline void itd_patch(struct fotg210_hcd *fotg210,
itd_patch( struct fotg210_itd *itd, struct fotg210_iso_sched *iso_sched,
struct fotg210_hcd *fotg210, unsigned index, u16 uframe)
struct fotg210_itd *itd,
struct fotg210_iso_sched *iso_sched,
unsigned index,
u16 uframe
)
{ {
struct fotg210_iso_packet *uf = &iso_sched->packet[index]; struct fotg210_iso_packet *uf = &iso_sched->packet[index];
unsigned pg = itd->pg; unsigned pg = itd->pg;
...@@ -4537,8 +4351,8 @@ itd_patch( ...@@ -4537,8 +4351,8 @@ itd_patch(
} }
} }
static inline void static inline void itd_link(struct fotg210_hcd *fotg210, unsigned frame,
itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd) struct fotg210_itd *itd)
{ {
union fotg210_shadow *prev = &fotg210->pshadow[frame]; union fotg210_shadow *prev = &fotg210->pshadow[frame];
__hc32 *hw_p = &fotg210->periodic[frame]; __hc32 *hw_p = &fotg210->periodic[frame];
...@@ -4564,12 +4378,8 @@ itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd) ...@@ -4564,12 +4378,8 @@ itd_link(struct fotg210_hcd *fotg210, unsigned frame, struct fotg210_itd *itd)
} }
/* fit urb's itds into the selected schedule slot; activate as needed */ /* fit urb's itds into the selected schedule slot; activate as needed */
static void itd_link_urb( static void itd_link_urb(struct fotg210_hcd *fotg210, struct urb *urb,
struct fotg210_hcd *fotg210, unsigned mod, struct fotg210_iso_stream *stream)
struct urb *urb,
unsigned mod,
struct fotg210_iso_stream *stream
)
{ {
int packet; int packet;
unsigned next_uframe, uframe, frame; unsigned next_uframe, uframe, frame;
...@@ -4698,8 +4508,8 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -4698,8 +4508,8 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
goto done; goto done;
/* ASSERT: it's really the last itd for this urb /* ASSERT: it's really the last itd for this urb
list_for_each_entry (itd, &stream->td_list, itd_list) * list_for_each_entry (itd, &stream->td_list, itd_list)
BUG_ON (itd->urb == urb); * BUG_ON (itd->urb == urb);
*/ */
/* give urb back to the driver; completion often (re)submits */ /* give urb back to the driver; completion often (re)submits */
...@@ -4736,8 +4546,6 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd) ...@@ -4736,8 +4546,6 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
return retval; return retval;
} }
/*-------------------------------------------------------------------------*/
static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
gfp_t mem_flags) gfp_t mem_flags)
{ {
...@@ -4791,9 +4599,9 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb, ...@@ -4791,9 +4599,9 @@ static int itd_submit(struct fotg210_hcd *fotg210, struct urb *urb,
itd_link_urb(fotg210, urb, fotg210->periodic_size << 3, stream); itd_link_urb(fotg210, urb, fotg210->periodic_size << 3, stream);
else else
usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb); usb_hcd_unlink_urb_from_ep(fotg210_to_hcd(fotg210), urb);
done_not_linked: done_not_linked:
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
done: done:
return status; return status;
} }
...@@ -4893,13 +4701,11 @@ static void scan_isoc(struct fotg210_hcd *fotg210) ...@@ -4893,13 +4701,11 @@ static void scan_isoc(struct fotg210_hcd *fotg210)
} }
fotg210->next_frame = now_frame; fotg210->next_frame = now_frame;
} }
/*-------------------------------------------------------------------------*/
/* /* Display / Set uframe_periodic_max
* Display / Set uframe_periodic_max
*/ */
static ssize_t show_uframe_periodic_max(struct device *dev, static ssize_t show_uframe_periodic_max(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr, char *buf)
char *buf)
{ {
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
int n; int n;
...@@ -4911,8 +4717,7 @@ static ssize_t show_uframe_periodic_max(struct device *dev, ...@@ -4911,8 +4717,7 @@ static ssize_t show_uframe_periodic_max(struct device *dev,
static ssize_t store_uframe_periodic_max(struct device *dev, static ssize_t store_uframe_periodic_max(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr, const char *buf, size_t count)
const char *buf, size_t count)
{ {
struct fotg210_hcd *fotg210; struct fotg210_hcd *fotg210;
unsigned uframe_periodic_max; unsigned uframe_periodic_max;
...@@ -4950,13 +4755,12 @@ static ssize_t store_uframe_periodic_max(struct device *dev, ...@@ -4950,13 +4755,12 @@ static ssize_t store_uframe_periodic_max(struct device *dev,
for (frame = 0; frame < fotg210->periodic_size; ++frame) for (frame = 0; frame < fotg210->periodic_size; ++frame)
for (uframe = 0; uframe < 7; ++uframe) for (uframe = 0; uframe < 7; ++uframe)
allocated_max = max(allocated_max, allocated_max = max(allocated_max,
periodic_usecs(fotg210, frame, uframe)); periodic_usecs(fotg210, frame,
uframe));
if (allocated_max > uframe_periodic_max) { if (allocated_max > uframe_periodic_max) {
fotg210_info(fotg210, fotg210_info(fotg210,
"cannot decrease uframe_periodic_max because " "cannot decrease uframe_periodic_max because periodic bandwidth is already allocated (%u > %u)\n",
"periodic bandwidth is already allocated "
"(%u > %u)\n",
allocated_max, uframe_periodic_max); allocated_max, uframe_periodic_max);
goto out_unlock; goto out_unlock;
} }
...@@ -4964,7 +4768,8 @@ static ssize_t store_uframe_periodic_max(struct device *dev, ...@@ -4964,7 +4768,8 @@ static ssize_t store_uframe_periodic_max(struct device *dev,
/* increasing is always ok */ /* increasing is always ok */
fotg210_info(fotg210, "setting max periodic bandwidth to %u%% (== %u usec/uframe)\n", fotg210_info(fotg210,
"setting max periodic bandwidth to %u%% (== %u usec/uframe)\n",
100 * uframe_periodic_max/125, uframe_periodic_max); 100 * uframe_periodic_max/125, uframe_periodic_max);
if (uframe_periodic_max != 100) if (uframe_periodic_max != 100)
...@@ -5000,8 +4805,6 @@ static inline void remove_sysfs_files(struct fotg210_hcd *fotg210) ...@@ -5000,8 +4805,6 @@ static inline void remove_sysfs_files(struct fotg210_hcd *fotg210)
device_remove_file(controller, &dev_attr_uframe_periodic_max); device_remove_file(controller, &dev_attr_uframe_periodic_max);
} }
/*-------------------------------------------------------------------------*/
/* On some systems, leaving remote wakeup enabled prevents system shutdown. /* On some systems, leaving remote wakeup enabled prevents system shutdown.
* The firmware seems to think that powering off is a wakeup event! * The firmware seems to think that powering off is a wakeup event!
* This routine turns off remote wakeup and everything else, on all ports. * This routine turns off remote wakeup and everything else, on all ports.
...@@ -5013,8 +4816,7 @@ static void fotg210_turn_off_all_ports(struct fotg210_hcd *fotg210) ...@@ -5013,8 +4816,7 @@ static void fotg210_turn_off_all_ports(struct fotg210_hcd *fotg210)
fotg210_writel(fotg210, PORT_RWC_BITS, status_reg); fotg210_writel(fotg210, PORT_RWC_BITS, status_reg);
} }
/* /* Halt HC, turn off all ports, and let the BIOS use the companion controllers.
* Halt HC, turn off all ports, and let the BIOS use the companion controllers.
* Must be called with interrupts enabled and the lock not held. * Must be called with interrupts enabled and the lock not held.
*/ */
static void fotg210_silence_controller(struct fotg210_hcd *fotg210) static void fotg210_silence_controller(struct fotg210_hcd *fotg210)
...@@ -5046,10 +4848,7 @@ static void fotg210_shutdown(struct usb_hcd *hcd) ...@@ -5046,10 +4848,7 @@ static void fotg210_shutdown(struct usb_hcd *hcd)
hrtimer_cancel(&fotg210->hrtimer); hrtimer_cancel(&fotg210->hrtimer);
} }
/*-------------------------------------------------------------------------*/ /* fotg210_work is called from some interrupts, timers, and so on.
/*
* fotg210_work is called from some interrupts, timers, and so on.
* it calls driver completion functions, after dropping fotg210->lock. * it calls driver completion functions, after dropping fotg210->lock.
*/ */
static void fotg210_work(struct fotg210_hcd *fotg210) static void fotg210_work(struct fotg210_hcd *fotg210)
...@@ -5064,7 +4863,7 @@ static void fotg210_work(struct fotg210_hcd *fotg210) ...@@ -5064,7 +4863,7 @@ static void fotg210_work(struct fotg210_hcd *fotg210)
} }
fotg210->scanning = true; fotg210->scanning = true;
rescan: rescan:
fotg210->need_rescan = false; fotg210->need_rescan = false;
if (fotg210->async_count) if (fotg210->async_count)
scan_async(fotg210); scan_async(fotg210);
...@@ -5083,8 +4882,7 @@ static void fotg210_work(struct fotg210_hcd *fotg210) ...@@ -5083,8 +4882,7 @@ static void fotg210_work(struct fotg210_hcd *fotg210)
turn_on_io_watchdog(fotg210); turn_on_io_watchdog(fotg210);
} }
/* /* Called when the fotg210_hcd module is removed.
* Called when the fotg210_hcd module is removed.
*/ */
static void fotg210_stop(struct usb_hcd *hcd) static void fotg210_stop(struct usb_hcd *hcd)
{ {
...@@ -5114,8 +4912,8 @@ static void fotg210_stop(struct usb_hcd *hcd) ...@@ -5114,8 +4912,8 @@ static void fotg210_stop(struct usb_hcd *hcd)
#ifdef FOTG210_STATS #ifdef FOTG210_STATS
fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n", fotg210_dbg(fotg210, "irq normal %ld err %ld iaa %ld (lost %ld)\n",
fotg210->stats.normal, fotg210->stats.error, fotg210->stats.iaa, fotg210->stats.normal, fotg210->stats.error,
fotg210->stats.lost_iaa); fotg210->stats.iaa, fotg210->stats.lost_iaa);
fotg210_dbg(fotg210, "complete %ld unlink %ld\n", fotg210_dbg(fotg210, "complete %ld unlink %ld\n",
fotg210->stats.complete, fotg210->stats.unlink); fotg210->stats.complete, fotg210->stats.unlink);
#endif #endif
...@@ -5296,7 +5094,7 @@ static int fotg210_run(struct usb_hcd *hcd) ...@@ -5296,7 +5094,7 @@ static int fotg210_run(struct usb_hcd *hcd)
fotg210_readl(fotg210, &fotg210->caps->hc_capbase)); fotg210_readl(fotg210, &fotg210->caps->hc_capbase));
fotg210_info(fotg210, fotg210_info(fotg210,
"USB %x.%x started, EHCI %x.%02x\n", "USB %x.%x started, EHCI %x.%02x\n",
((fotg210->sbrn & 0xf0)>>4), (fotg210->sbrn & 0x0f), ((fotg210->sbrn & 0xf0) >> 4), (fotg210->sbrn & 0x0f),
temp >> 8, temp & 0xff); temp >> 8, temp & 0xff);
fotg210_writel(fotg210, INTR_MASK, fotg210_writel(fotg210, INTR_MASK,
...@@ -5343,8 +5141,6 @@ static int fotg210_setup(struct usb_hcd *hcd) ...@@ -5343,8 +5141,6 @@ static int fotg210_setup(struct usb_hcd *hcd)
return 0; return 0;
} }
/*-------------------------------------------------------------------------*/
static irqreturn_t fotg210_irq(struct usb_hcd *hcd) static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
...@@ -5481,10 +5277,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5481,10 +5277,7 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
/*-------------------------------------------------------------------------*/ /* non-error returns are a promise to giveback() the urb later
/*
* non-error returns are a promise to giveback() the urb later
* we drop ownership so next owner (or urb unlink) can get it * we drop ownership so next owner (or urb unlink) can get it
* *
* urb + dev is in hcd.self.controller.urb_list * urb + dev is in hcd.self.controller.urb_list
...@@ -5495,11 +5288,9 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd) ...@@ -5495,11 +5288,9 @@ static irqreturn_t fotg210_irq(struct usb_hcd *hcd)
* NOTE: control, bulk, and interrupt share the same code to append TDs * NOTE: control, bulk, and interrupt share the same code to append TDs
* to a (possibly active) QH, and the same QH scanning code. * to a (possibly active) QH, and the same QH scanning code.
*/ */
static int fotg210_urb_enqueue( static int fotg210_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
struct usb_hcd *hcd, gfp_t mem_flags)
struct urb *urb, {
gfp_t mem_flags
) {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
struct list_head qtd_list; struct list_head qtd_list;
...@@ -5599,12 +5390,10 @@ static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ...@@ -5599,12 +5390,10 @@ static int fotg210_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
return rc; return rc;
} }
/*-------------------------------------------------------------------------*/
/* bulk qh holds the data toggle */ /* bulk qh holds the data toggle */
static void static void fotg210_endpoint_disable(struct usb_hcd *hcd,
fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) struct usb_host_endpoint *ep)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
unsigned long flags; unsigned long flags;
...@@ -5671,13 +5460,13 @@ fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) ...@@ -5671,13 +5460,13 @@ fotg210_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
list_empty(&qh->qtd_list) ? "" : "(has tds)"); list_empty(&qh->qtd_list) ? "" : "(has tds)");
break; break;
} }
done: done:
ep->hcpriv = NULL; ep->hcpriv = NULL;
spin_unlock_irqrestore(&fotg210->lock, flags); spin_unlock_irqrestore(&fotg210->lock, flags);
} }
static void static void fotg210_endpoint_reset(struct usb_hcd *hcd,
fotg210_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) struct usb_host_endpoint *ep)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
struct fotg210_qh *qh; struct fotg210_qh *qh;
...@@ -5720,14 +5509,12 @@ fotg210_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) ...@@ -5720,14 +5509,12 @@ fotg210_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep)
static int fotg210_get_frame(struct usb_hcd *hcd) static int fotg210_get_frame(struct usb_hcd *hcd)
{ {
struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd); struct fotg210_hcd *fotg210 = hcd_to_fotg210(hcd);
return (fotg210_read_frame_index(fotg210) >> 3) % return (fotg210_read_frame_index(fotg210) >> 3) %
fotg210->periodic_size; fotg210->periodic_size;
} }
/*-------------------------------------------------------------------------*/ /* The EHCI in ChipIdea HDRC cannot be a separate module or device,
/*
* The EHCI in ChipIdea HDRC cannot be a separate module or device,
* because its registers (and irq) are shared between host/gadget/otg * because its registers (and irq) are shared between host/gadget/otg
* functions and in order to facilitate role switching we cannot * functions and in order to facilitate role switching we cannot
* give the fotg210 driver exclusive access to those. * give the fotg210 driver exclusive access to those.
...@@ -5818,8 +5605,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev) ...@@ -5818,8 +5605,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) { if (!res) {
dev_err(dev, dev_err(dev, "Found HC with no IRQ. Check %s setup!\n",
"Found HC with no IRQ. Check %s setup!\n",
dev_name(dev)); dev_name(dev));
return -ENODEV; return -ENODEV;
} }
...@@ -5913,8 +5699,8 @@ static int __init fotg210_hcd_init(void) ...@@ -5913,8 +5699,8 @@ static int __init fotg210_hcd_init(void)
pr_warn(KERN_WARNING "Warning! fotg210_hcd should always be loaded before uhci_hcd and ohci_hcd, not after\n"); pr_warn(KERN_WARNING "Warning! fotg210_hcd should always be loaded before uhci_hcd and ohci_hcd, not after\n");
pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd\n", pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd\n",
hcd_name, hcd_name, sizeof(struct fotg210_qh),
sizeof(struct fotg210_qh), sizeof(struct fotg210_qtd), sizeof(struct fotg210_qtd),
sizeof(struct fotg210_itd)); sizeof(struct fotg210_itd));
fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root); fotg210_debug_root = debugfs_create_dir("fotg210", usb_debug_root);
......
...@@ -137,19 +137,25 @@ struct fotg210_hcd { /* one per controller */ ...@@ -137,19 +137,25 @@ struct fotg210_hcd { /* one per controller */
/* per root hub port */ /* per root hub port */
unsigned long reset_done[FOTG210_MAX_ROOT_PORTS]; unsigned long reset_done[FOTG210_MAX_ROOT_PORTS];
/* bit vectors (one bit per port) */ /* bit vectors (one bit per port)
unsigned long bus_suspended; /* which ports were * which ports were already suspended at the start of a bus suspend
already suspended at the start of a bus suspend */ */
unsigned long companion_ports; /* which ports are unsigned long bus_suspended;
dedicated to the companion controller */
unsigned long owned_ports; /* which ports are /* which ports are edicated to the companion controller */
owned by the companion during a bus suspend */ unsigned long companion_ports;
unsigned long port_c_suspend; /* which ports have
the change-suspend feature turned on */ /* which ports are owned by the companion during a bus suspend */
unsigned long suspended_ports; /* which ports are unsigned long owned_ports;
suspended */
unsigned long resuming_ports; /* which ports have /* which ports have the change-suspend feature turned on */
started to resume */ unsigned long port_c_suspend;
/* which ports are suspended */
unsigned long suspended_ports;
/* which ports have started to resume */
unsigned long resuming_ports;
/* per-HC memory pools (could be per-bus, but ...) */ /* per-HC memory pools (could be per-bus, but ...) */
struct dma_pool *qh_pool; /* qh per active urb */ struct dma_pool *qh_pool; /* qh per active urb */
...@@ -585,10 +591,10 @@ struct fotg210_fstn { ...@@ -585,10 +591,10 @@ struct fotg210_fstn {
/* Prepare the PORTSC wakeup flags during controller suspend/resume */ /* Prepare the PORTSC wakeup flags during controller suspend/resume */
#define fotg210_prepare_ports_for_controller_suspend(fotg210, do_wakeup) \ #define fotg210_prepare_ports_for_controller_suspend(fotg210, do_wakeup) \
fotg210_adjust_port_wakeup_flags(fotg210, true, do_wakeup); fotg210_adjust_port_wakeup_flags(fotg210, true, do_wakeup)
#define fotg210_prepare_ports_for_controller_resume(fotg210) \ #define fotg210_prepare_ports_for_controller_resume(fotg210) \
fotg210_adjust_port_wakeup_flags(fotg210, false, false); fotg210_adjust_port_wakeup_flags(fotg210, false, false)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment