Commit 7fcc2c87 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge kroah.com:/home/greg/linux/BK/bleeding_edge-2.5

into kroah.com:/home/greg/linux/BK/gregkh-2.5
parents 94eda096 9c5e6f5a
...@@ -41,17 +41,13 @@ SPECIFIC DEVICES SUPPORTED ...@@ -41,17 +41,13 @@ SPECIFIC DEVICES SUPPORTED
ConnectTech WhiteHEAT 4 port converter ConnectTech WhiteHEAT 4 port converter
ConnectTech has been very forthcoming with information about their ConnectTech has been very forthcoming with information about their
device, including providing a unit to test with. This driver will end up device, including providing a unit to test with.
being fully supported.
Current status: The driver is officially supported by Connect Tech Inc.
The device's firmware is downloaded on connection, the new firmware http://www.connecttech.com
runs properly and all four ports are successfully recognized and connected.
Data can be sent and received through the device on all ports.
Hardware flow control needs to be implemented.
For any questions or problems with this driver, please contact Greg For any questions or problems with this driver, please contact
Kroah-Hartman at greg@kroah.com Stuart MacDonald at stuartm@connecttech.com
HandSpring Visor, Palm USB, and Clié USB driver HandSpring Visor, Palm USB, and Clié USB driver
......
...@@ -1830,6 +1830,14 @@ L: linux-usb-devel@lists.sourceforge.net ...@@ -1830,6 +1830,14 @@ L: linux-usb-devel@lists.sourceforge.net
W: http://www.kroah.com/linux/ W: http://www.kroah.com/linux/
S: Maintained S: Maintained
USB SERIAL WHITEHEAT DRIVER
P: Stuart MacDonald
M: stuartm@connecttech.com
L: linux-usb-users@lists.sourceforge.net
L: linux-usb-devel@lists.sourceforge.net
W: http://www.connecttech.com
S: Supported
USB SUBSYSTEM USB SUBSYSTEM
P: Greg Kroah-Hartman P: Greg Kroah-Hartman
M: greg@kroah.com M: greg@kroah.com
......
...@@ -1142,6 +1142,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent) ...@@ -1142,6 +1142,7 @@ int usb_new_device(struct usb_device *dev, struct device *parent)
struct usb_interface_descriptor *desc = interface->altsetting; struct usb_interface_descriptor *desc = interface->altsetting;
interface->dev.parent = &dev->dev; interface->dev.parent = &dev->dev;
interface->dev.driver = NULL;
interface->dev.bus = &usb_bus_type; interface->dev.bus = &usb_bus_type;
sprintf (&interface->dev.bus_id[0], "%d-%s:%d", sprintf (&interface->dev.bus_id[0], "%d-%s:%d",
dev->bus->busnum, dev->devpath, dev->bus->busnum, dev->devpath,
......
...@@ -79,7 +79,7 @@ static void dbg_hcc_params (struct ehci_hcd *ehci, char *label) ...@@ -79,7 +79,7 @@ static void dbg_hcc_params (struct ehci_hcd *ehci, char *label)
if (HCC_EXT_CAPS (params)) { if (HCC_EXT_CAPS (params)) {
// EHCI 0.96 ... could interpret these (legacy?) // EHCI 0.96 ... could interpret these (legacy?)
dbg ("%s extended capabilities at pci %d", dbg ("%s extended capabilities at pci %2x",
label, HCC_EXT_CAPS (params)); label, HCC_EXT_CAPS (params));
} }
if (HCC_ISOC_CACHE (params)) { if (HCC_ISOC_CACHE (params)) {
...@@ -546,6 +546,18 @@ show_registers (struct device *dev, char *buf, size_t count, loff_t off) ...@@ -546,6 +546,18 @@ show_registers (struct device *dev, char *buf, size_t count, loff_t off)
next += temp; next += temp;
} }
#ifdef EHCI_STATS
temp = snprintf (next, size, "irq normal %ld err %ld reclaim %ld\n",
ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim);
size -= temp;
next += temp;
temp = snprintf (next, size, "complete %ld unlink %ld qpatch %ld\n",
ehci->stats.complete, ehci->stats.unlink, ehci->stats.qpatch);
size -= temp;
next += temp;
#endif
spin_unlock_irqrestore (&ehci->lock, flags); spin_unlock_irqrestore (&ehci->lock, flags);
return count - size; return count - size;
......
...@@ -63,8 +63,7 @@ ...@@ -63,8 +63,7 @@
* First was PCMCIA, like ISA; then CardBus, which is PCI. * First was PCMCIA, like ISA; then CardBus, which is PCI.
* Next comes "CardBay", using USB 2.0 signals. * Next comes "CardBay", using USB 2.0 signals.
* *
* Contains additional contributions by: Brad Hards, Rory Bolt, ... * Contains additional contributions by Brad Hards, Rory Bolt, and others.
*
* Special thanks to Intel and VIA for providing host controllers to * Special thanks to Intel and VIA for providing host controllers to
* test this driver on, and Cypress (including In-System Design) for * test this driver on, and Cypress (including In-System Design) for
* providing early devices for those host controllers to talk to! * providing early devices for those host controllers to talk to!
...@@ -93,14 +92,20 @@ ...@@ -93,14 +92,20 @@
* 2001-June Works with usb-storage and NEC EHCI on 2.4 * 2001-June Works with usb-storage and NEC EHCI on 2.4
*/ */
#define DRIVER_VERSION "2002-Aug-28" #define DRIVER_VERSION "2002-Sep-23"
#define DRIVER_AUTHOR "David Brownell" #define DRIVER_AUTHOR "David Brownell"
#define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" #define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
static const char hcd_name [] = "ehci-hcd";
// #define EHCI_VERBOSE_DEBUG // #define EHCI_VERBOSE_DEBUG
// #define have_split_iso // #define have_split_iso
#ifdef DEBUG
#define EHCI_STATS
#endif
#define INTR_AUTOMAGIC /* to be removed later in 2.5 */ #define INTR_AUTOMAGIC /* to be removed later in 2.5 */
/* magic numbers that can affect system performance */ /* magic numbers that can affect system performance */
...@@ -118,6 +123,12 @@ static int log2_irq_thresh = 0; // 0 to 6 ...@@ -118,6 +123,12 @@ static int log2_irq_thresh = 0; // 0 to 6
MODULE_PARM (log2_irq_thresh, "i"); MODULE_PARM (log2_irq_thresh, "i");
MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes"); MODULE_PARM_DESC (log2_irq_thresh, "log2 IRQ latency, 1-64 microframes");
/* allow irqs at least every N URB completions */
static int max_completions = 16;
MODULE_PARM (max_completions, "i");
MODULE_PARM_DESC (max_completions,
"limit for urb completions called with irqs disenabled");
#define INTR_MASK (STS_IAA | STS_FATAL | STS_ERR | STS_INT) #define INTR_MASK (STS_IAA | STS_FATAL | STS_ERR | STS_INT)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -426,11 +437,10 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -426,11 +437,10 @@ static int ehci_start (struct usb_hcd *hcd)
/* PCI Serial Bus Release Number is at 0x60 offset */ /* PCI Serial Bus Release Number is at 0x60 offset */
pci_read_config_byte (hcd->pdev, 0x60, &tempbyte); pci_read_config_byte (hcd->pdev, 0x60, &tempbyte);
temp = readw (&ehci->caps->hci_version); temp = readw (&ehci->caps->hci_version);
info ("USB %x.%x support enabled, EHCI rev %x.%02x", info ("USB %x.%x support enabled, EHCI rev %x.%02x, %s %s",
((tempbyte & 0xf0)>>4), ((tempbyte & 0xf0)>>4), (tempbyte & 0x0f),
(tempbyte & 0x0f), temp >> 8, temp & 0xff,
temp >> 8, hcd_name, DRIVER_VERSION);
temp & 0xff);
/* /*
* From here on, khubd concurrently accesses the root * From here on, khubd concurrently accesses the root
...@@ -441,11 +451,7 @@ static int ehci_start (struct usb_hcd *hcd) ...@@ -441,11 +451,7 @@ static int ehci_start (struct usb_hcd *hcd)
*/ */
usb_connect (udev); usb_connect (udev);
udev->speed = USB_SPEED_HIGH; udev->speed = USB_SPEED_HIGH;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,32) if (hcd_register_root (hcd) != 0) {
if (usb_new_device (udev) != 0) {
#else
if (usb_register_root_hub (udev, &ehci->hcd.pdev->dev) != 0) {
#endif
if (hcd->state == USB_STATE_RUNNING) if (hcd->state == USB_STATE_RUNNING)
ehci_ready (ehci); ehci_ready (ehci);
ehci_reset (ehci); ehci_reset (ehci);
...@@ -487,6 +493,13 @@ static void ehci_stop (struct usb_hcd *hcd) ...@@ -487,6 +493,13 @@ static void ehci_stop (struct usb_hcd *hcd)
ehci_tasklet ((unsigned long) ehci); ehci_tasklet ((unsigned long) ehci);
ehci_mem_cleanup (ehci); ehci_mem_cleanup (ehci);
#ifdef EHCI_STATS
dbg ("irq normal %ld err %ld reclaim %ld",
ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim);
dbg ("complete %ld unlink %ld qpatch %ld",
ehci->stats.complete, ehci->stats.unlink, ehci->stats.qpatch);
#endif
dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status)); dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
} }
...@@ -591,21 +604,16 @@ dbg ("%s: resume port %d", hcd_to_bus (hcd)->bus_name, i); ...@@ -591,21 +604,16 @@ dbg ("%s: resume port %d", hcd_to_bus (hcd)->bus_name, i);
static void ehci_tasklet (unsigned long param) static void ehci_tasklet (unsigned long param)
{ {
struct ehci_hcd *ehci = (struct ehci_hcd *) param; struct ehci_hcd *ehci = (struct ehci_hcd *) param;
unsigned long flags;
// FIXME don't pass flags; on sparc they aren't really flags. spin_lock_irq (&ehci->lock);
// qh_completions can just leave irqs blocked,
// then have scan_async() allow IRQs if it's very busy
spin_lock_irqsave (&ehci->lock, flags);
if (ehci->reclaim_ready) if (ehci->reclaim_ready)
flags = end_unlink_async (ehci, flags); end_unlink_async (ehci);
flags = scan_async (ehci, flags); scan_async (ehci);
if (ehci->next_uframe != -1) if (ehci->next_uframe != -1)
flags = scan_periodic (ehci, flags); scan_periodic (ehci);
spin_unlock_irqrestore (&ehci->lock, flags); spin_unlock_irq (&ehci->lock);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -639,11 +647,17 @@ static void ehci_irq (struct usb_hcd *hcd) ...@@ -639,11 +647,17 @@ static void ehci_irq (struct usb_hcd *hcd)
/* INT, ERR, and IAA interrupt rates can be throttled */ /* INT, ERR, and IAA interrupt rates can be throttled */
/* normal [4.15.1.2] or error [4.15.1.1] completion */ /* normal [4.15.1.2] or error [4.15.1.1] completion */
if (likely ((status & (STS_INT|STS_ERR)) != 0)) if (likely ((status & (STS_INT|STS_ERR)) != 0)) {
if (likely ((status & STS_ERR) == 0))
COUNT (ehci->stats.normal);
else
COUNT (ehci->stats.error);
bh = 1; bh = 1;
}
/* complete the unlinking of some qh [4.15.2.3] */ /* complete the unlinking of some qh [4.15.2.3] */
if (status & STS_IAA) { if (status & STS_IAA) {
COUNT (ehci->stats.reclaim);
ehci->reclaim_ready = 1; ehci->reclaim_ready = 1;
bh = 1; bh = 1;
} }
...@@ -765,10 +779,10 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) ...@@ -765,10 +779,10 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
spin_lock_irqsave (&ehci->lock, flags); spin_lock_irqsave (&ehci->lock, flags);
if (qh->qh_state == QH_STATE_LINKED) { if (qh->qh_state == QH_STATE_LINKED) {
/* messy, can spin or block a microframe ... */ /* messy, can spin or block a microframe ... */
flags = intr_deschedule (ehci, qh, 1, flags); intr_deschedule (ehci, qh, 1);
/* qh_state == IDLE */ /* qh_state == IDLE */
} }
flags = qh_completions (ehci, qh, flags); qh_completions (ehci, qh);
/* reschedule QH iff another request is queued */ /* reschedule QH iff another request is queued */
if (!list_empty (&qh->qtd_list) if (!list_empty (&qh->qtd_list)
...@@ -881,8 +895,6 @@ static void ehci_free_config (struct usb_hcd *hcd, struct usb_device *udev) ...@@ -881,8 +895,6 @@ static void ehci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static const char hcd_name [] = "ehci-hcd";
static const struct hc_driver ehci_driver = { static const struct hc_driver ehci_driver = {
.description = hcd_name, .description = hcd_name,
......
...@@ -239,7 +239,8 @@ static int ehci_hub_control ( ...@@ -239,7 +239,8 @@ static int ehci_hub_control (
/* whoever resets must GetPortStatus to complete it!! */ /* whoever resets must GetPortStatus to complete it!! */
if ((temp & PORT_RESET) if ((temp & PORT_RESET)
&& jiffies > ehci->reset_done [wIndex]) { && time_after (jiffies,
ehci->reset_done [wIndex])) {
status |= 1 << USB_PORT_FEAT_C_RESET; status |= 1 << USB_PORT_FEAT_C_RESET;
/* force reset to complete */ /* force reset to complete */
......
...@@ -158,16 +158,13 @@ static inline void qtd_copy_status (struct urb *urb, size_t length, u32 token) ...@@ -158,16 +158,13 @@ static inline void qtd_copy_status (struct urb *urb, size_t length, u32 token)
} }
} }
/* urb->lock ignored from here on (hcd is done with urb) */ static void ehci_urb_done (struct ehci_hcd *ehci, struct urb *urb)
{
static unsigned long ehci_urb_done (
struct ehci_hcd *ehci,
struct urb *urb,
unsigned long flags
) {
#ifdef INTR_AUTOMAGIC #ifdef INTR_AUTOMAGIC
struct urb *resubmit = 0; struct urb *resubmit = 0;
struct usb_device *dev = 0; struct usb_device *dev = 0;
static int ehci_urb_enqueue (struct usb_hcd *, struct urb *, int);
#endif #endif
if (likely (urb->hcpriv != 0)) { if (likely (urb->hcpriv != 0)) {
...@@ -199,8 +196,15 @@ static unsigned long ehci_urb_done ( ...@@ -199,8 +196,15 @@ static unsigned long ehci_urb_done (
urb->status = 0; urb->status = 0;
} }
if (likely (urb->status == 0))
COUNT (ehci->stats.complete);
else if (urb->status == -ECONNRESET || urb->status == -ENOENT)
COUNT (ehci->stats.unlink);
else
COUNT (ehci->stats.error);
/* complete() can reenter this HCD */ /* complete() can reenter this HCD */
spin_unlock_irqrestore (&ehci->lock, flags); spin_unlock (&ehci->lock);
usb_hcd_giveback_urb (&ehci->hcd, urb); usb_hcd_giveback_urb (&ehci->hcd, urb);
#ifdef INTR_AUTOMAGIC #ifdef INTR_AUTOMAGIC
...@@ -222,24 +226,25 @@ static unsigned long ehci_urb_done ( ...@@ -222,24 +226,25 @@ static unsigned long ehci_urb_done (
} }
#endif #endif
spin_lock_irqsave (&ehci->lock, flags); spin_lock (&ehci->lock);
return flags;
} }
/* /*
* 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 irqsave flags (maybe modified). * Chases up to qh->hw_current. Returns number of completions called,
* indicating how much "real" work we did.
*/ */
static unsigned long static unsigned
qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags) qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
{ {
struct ehci_qtd *qtd, *last; struct ehci_qtd *qtd, *last;
struct list_head *next, *qtd_list = &qh->qtd_list; struct list_head *next, *qtd_list = &qh->qtd_list;
int unlink = 0, halted = 0; int unlink = 0, halted = 0;
unsigned count = 0;
if (unlikely (list_empty (qtd_list))) if (unlikely (list_empty (qtd_list)))
return flags; return count;
/* scan QTDs till end of list, or we reach an active one */ /* scan QTDs till end of list, or we reach an active one */
for (qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list), for (qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list),
...@@ -252,8 +257,10 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags) ...@@ -252,8 +257,10 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags)
/* clean up any state from previous QTD ...*/ /* clean up any state from previous QTD ...*/
if (last) { if (last) {
if (likely (last->urb != urb)) if (likely (last->urb != urb)) {
flags = ehci_urb_done (ehci, last->urb, flags); ehci_urb_done (ehci, last->urb);
count++;
}
/* qh overlays can have HC's old cached copies of /* qh overlays can have HC's old cached copies of
* next qtd ptrs, if an URB was queued afterwards. * next qtd ptrs, if an URB was queued afterwards.
...@@ -262,6 +269,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags) ...@@ -262,6 +269,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags)
&& last->hw_next != qh->hw_qtd_next) { && last->hw_next != qh->hw_qtd_next) {
qh->hw_alt_next = last->hw_alt_next; qh->hw_alt_next = last->hw_alt_next;
qh->hw_qtd_next = last->hw_next; qh->hw_qtd_next = last->hw_next;
COUNT (ehci->stats.qpatch);
} }
ehci_qtd_free (ehci, last); ehci_qtd_free (ehci, last);
...@@ -347,7 +355,8 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags) ...@@ -347,7 +355,8 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags)
/* last urb's completion might still need calling */ /* last urb's completion might still need calling */
if (likely (last != 0)) { if (likely (last != 0)) {
flags = ehci_urb_done (ehci, last->urb, flags); ehci_urb_done (ehci, last->urb);
count++;
ehci_qtd_free (ehci, last); ehci_qtd_free (ehci, last);
} }
...@@ -357,7 +366,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags) ...@@ -357,7 +366,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, unsigned long flags)
struct ehci_qtd, qtd_list)); struct ehci_qtd, qtd_list));
} }
return flags; return count;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -890,8 +899,7 @@ submit_async ( ...@@ -890,8 +899,7 @@ submit_async (
/* the async qh for the qtds being reclaimed are now unlinked from the HC */ /* the async qh for the qtds being reclaimed are now unlinked from the HC */
/* caller must not own ehci->lock */ /* caller must not own ehci->lock */
static unsigned long static void end_unlink_async (struct ehci_hcd *ehci)
end_unlink_async (struct ehci_hcd *ehci, unsigned long flags)
{ {
struct ehci_qh *qh = ehci->reclaim; struct ehci_qh *qh = ehci->reclaim;
...@@ -903,18 +911,15 @@ end_unlink_async (struct ehci_hcd *ehci, unsigned long flags) ...@@ -903,18 +911,15 @@ end_unlink_async (struct ehci_hcd *ehci, unsigned long flags)
ehci->reclaim = 0; ehci->reclaim = 0;
ehci->reclaim_ready = 0; ehci->reclaim_ready = 0;
flags = qh_completions (ehci, qh, flags); qh_completions (ehci, qh);
if (!list_empty (&qh->qtd_list) if (!list_empty (&qh->qtd_list)
&& HCD_IS_RUNNING (ehci->hcd.state)) && HCD_IS_RUNNING (ehci->hcd.state))
qh_link_async (ehci, qh); qh_link_async (ehci, qh);
else else
qh_put (ehci, qh); // refcount from async list qh_put (ehci, qh); // refcount from async list
return flags;
} }
/* makes sure the async qh will become idle */ /* makes sure the async qh will become idle */
/* caller must own ehci->lock */ /* caller must own ehci->lock */
...@@ -944,12 +949,14 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -944,12 +949,14 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
if (unlikely (qh == ehci->async && qh->qh_next.qh == qh)) { if (unlikely (qh == ehci->async && qh->qh_next.qh == qh)) {
/* can't get here without STS_ASS set */ /* can't get here without STS_ASS set */
if (ehci->hcd.state != USB_STATE_HALT) { if (ehci->hcd.state != USB_STATE_HALT) {
if (cmd & CMD_PSE) {
writel (cmd & ~CMD_ASE, &ehci->regs->command); writel (cmd & ~CMD_ASE, &ehci->regs->command);
(void) handshake (&ehci->regs->status, (void) handshake (&ehci->regs->status, STS_ASS, 0, 150);
STS_ASS, 0, 150); #if 0
} else // one VT8235 system wants to die with STS_FATAL
ehci_ready (ehci); // unless this qh is leaked here. others seem ok...
qh = qh_get (qh);
dbg_qh ("async/off", ehci, qh);
#endif
} }
qh->qh_next.qh = ehci->async = 0; qh->qh_next.qh = ehci->async = 0;
...@@ -986,13 +993,15 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -986,13 +993,15 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static unsigned long static void
scan_async (struct ehci_hcd *ehci, unsigned long flags) scan_async (struct ehci_hcd *ehci)
{ {
struct ehci_qh *qh; struct ehci_qh *qh;
unsigned count;
rescan: rescan:
qh = ehci->async; qh = ehci->async;
count = 0;
if (likely (qh != 0)) { if (likely (qh != 0)) {
do { do {
/* clean any finished work for this qh */ /* clean any finished work for this qh */
...@@ -1001,13 +1010,16 @@ scan_async (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1001,13 +1010,16 @@ scan_async (struct ehci_hcd *ehci, unsigned long flags)
qh = qh_get (qh); qh = qh_get (qh);
/* concurrent unlink could happen here */ /* concurrent unlink could happen here */
flags = qh_completions (ehci, qh, flags); count += qh_completions (ehci, qh);
qh_put (ehci, qh); qh_put (ehci, qh);
} }
/* unlink idle entries, reducing HC PCI usage as /* unlink idle entries, reducing HC PCI usage as
* well as HCD schedule-scanning costs. removing * well as HCD schedule-scanning costs. removing
* the last qh is deferred, since it's costly. * the last qh is deferred, since it's costly.
*
* FIXME don't unlink idle entries so quickly; it
* can penalize (common) half duplex protocols.
*/ */
if (list_empty (&qh->qtd_list) && !ehci->reclaim) { if (list_empty (&qh->qtd_list) && !ehci->reclaim) {
if (qh->qh_next.qh != qh) { if (qh->qh_next.qh != qh) {
...@@ -1020,10 +1032,18 @@ scan_async (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1020,10 +1032,18 @@ scan_async (struct ehci_hcd *ehci, unsigned long flags)
jiffies + EHCI_ASYNC_JIFFIES); jiffies + EHCI_ASYNC_JIFFIES);
} }
} }
/* keep latencies down: let any irqs in */
if (count > max_completions) {
spin_unlock_irq (&ehci->lock);
cpu_relax ();
spin_lock_irq (&ehci->lock);
goto rescan;
}
qh = qh->qh_next.qh; qh = qh->qh_next.qh;
if (!qh) /* unlinked? */ if (!qh) /* unlinked? */
goto rescan; goto rescan;
} while (qh != ehci->async); } while (qh != ehci->async);
} }
return flags;
} }
...@@ -222,11 +222,10 @@ static int disable_periodic (struct ehci_hcd *ehci) ...@@ -222,11 +222,10 @@ static int disable_periodic (struct ehci_hcd *ehci)
// FIXME microframe periods not yet handled // FIXME microframe periods not yet handled
static unsigned long intr_deschedule ( static void intr_deschedule (
struct ehci_hcd *ehci, struct ehci_hcd *ehci,
struct ehci_qh *qh, struct ehci_qh *qh,
int wait, int wait
unsigned long flags
) { ) {
int status; int status;
unsigned frame = qh->start; unsigned frame = qh->start;
...@@ -256,10 +255,8 @@ static unsigned long intr_deschedule ( ...@@ -256,10 +255,8 @@ static unsigned long intr_deschedule (
*/ */
if (((ehci_get_frame (&ehci->hcd) - frame) % qh->period) == 0) { if (((ehci_get_frame (&ehci->hcd) - frame) % qh->period) == 0) {
if (wait) { if (wait) {
spin_unlock_irqrestore (&ehci->lock, flags);
udelay (125); udelay (125);
qh->hw_next = EHCI_LIST_END; qh->hw_next = EHCI_LIST_END;
spin_lock_irqsave (&ehci->lock, flags);
} else { } else {
/* we may not be IDLE yet, but if the qh is empty /* we may not be IDLE yet, but if the qh is empty
* the race is very short. then if qh also isn't * the race is very short. then if qh also isn't
...@@ -276,10 +273,9 @@ static unsigned long intr_deschedule ( ...@@ -276,10 +273,9 @@ static unsigned long intr_deschedule (
hcd_to_bus (&ehci->hcd)->bandwidth_allocated -= hcd_to_bus (&ehci->hcd)->bandwidth_allocated -=
(qh->usecs + qh->c_usecs) / qh->period; (qh->usecs + qh->c_usecs) / qh->period;
vdbg ("descheduled qh %p, per = %d frame = %d count = %d, urbs = %d", dbg ("descheduled qh %p, period = %d frame = %d count = %d, urbs = %d",
qh, qh->period, frame, qh, qh->period, frame,
atomic_read (&qh->refcount), ehci->periodic_sched); atomic_read (&qh->refcount), ehci->periodic_sched);
return flags;
} }
static int check_period ( static int check_period (
...@@ -414,7 +410,7 @@ static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh) ...@@ -414,7 +410,7 @@ static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
/* stuff into the periodic schedule */ /* stuff into the periodic schedule */
qh->qh_state = QH_STATE_LINKED; qh->qh_state = QH_STATE_LINKED;
dbg ("qh %p usecs %d/%d period %d.0 starting %d.%d (gap %d)", dbg ("scheduled qh %p usecs %d/%d period %d.0 starting %d.%d (gap %d)",
qh, qh->usecs, qh->c_usecs, qh, qh->usecs, qh->c_usecs,
qh->period, frame, uframe, qh->gap_uf); qh->period, frame, uframe, qh->gap_uf);
do { do {
...@@ -495,29 +491,30 @@ static int intr_submit ( ...@@ -495,29 +491,30 @@ static int intr_submit (
return status; return status;
} }
static unsigned long static unsigned
intr_complete ( intr_complete (
struct ehci_hcd *ehci, struct ehci_hcd *ehci,
unsigned frame, unsigned frame,
struct ehci_qh *qh, struct ehci_qh *qh
unsigned long flags /* caller owns ehci->lock ... */
) { ) {
unsigned count;
/* nothing to report? */ /* nothing to report? */
if (likely ((qh->hw_token & __constant_cpu_to_le32 (QTD_STS_ACTIVE)) if (likely ((qh->hw_token & __constant_cpu_to_le32 (QTD_STS_ACTIVE))
!= 0)) != 0))
return flags; return 0;
if (unlikely (list_empty (&qh->qtd_list))) { if (unlikely (list_empty (&qh->qtd_list))) {
dbg ("intr qh %p no TDs?", qh); dbg ("intr qh %p no TDs?", qh);
return flags; return 0;
} }
/* handle any completions */ /* handle any completions */
flags = qh_completions (ehci, qh, flags); count = qh_completions (ehci, qh);
if (unlikely (list_empty (&qh->qtd_list))) if (unlikely (list_empty (&qh->qtd_list)))
flags = intr_deschedule (ehci, qh, 0, flags); intr_deschedule (ehci, qh, 0);
return flags; return count;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -866,12 +863,11 @@ itd_schedule (struct ehci_hcd *ehci, struct urb *urb) ...@@ -866,12 +863,11 @@ itd_schedule (struct ehci_hcd *ehci, struct urb *urb)
#define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR) #define ISO_ERRS (EHCI_ISOC_BUF_ERR | EHCI_ISOC_BABBLE | EHCI_ISOC_XACTERR)
static unsigned long static unsigned
itd_complete ( itd_complete (
struct ehci_hcd *ehci, struct ehci_hcd *ehci,
struct ehci_itd *itd, struct ehci_itd *itd,
unsigned uframe, unsigned uframe
unsigned long flags
) { ) {
struct urb *urb = itd->urb; struct urb *urb = itd->urb;
struct usb_iso_packet_descriptor *desc; struct usb_iso_packet_descriptor *desc;
...@@ -909,7 +905,7 @@ itd_complete ( ...@@ -909,7 +905,7 @@ itd_complete (
/* handle completion now? */ /* handle completion now? */
if ((itd->index + 1) != urb->number_of_packets) if ((itd->index + 1) != urb->number_of_packets)
return flags; return 0;
/* /*
* Always give the urb back to the driver ... expect it to submit * Always give the urb back to the driver ... expect it to submit
...@@ -924,16 +920,17 @@ itd_complete ( ...@@ -924,16 +920,17 @@ itd_complete (
if (urb->status == -EINPROGRESS) if (urb->status == -EINPROGRESS)
urb->status = 0; urb->status = 0;
spin_unlock_irqrestore (&ehci->lock, flags); /* complete() can reenter this HCD */
spin_unlock (&ehci->lock);
usb_hcd_giveback_urb (&ehci->hcd, urb); usb_hcd_giveback_urb (&ehci->hcd, urb);
spin_lock_irqsave (&ehci->lock, flags); spin_lock (&ehci->lock);
/* defer stopping schedule; completion can submit */ /* defer stopping schedule; completion can submit */
ehci->periodic_sched--; ehci->periodic_sched--;
if (!ehci->periodic_sched) if (!ehci->periodic_sched)
(void) disable_periodic (ehci); (void) disable_periodic (ehci);
return flags; return 1;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -945,10 +942,6 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags) ...@@ -945,10 +942,6 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
dbg ("itd_submit urb %p", urb); dbg ("itd_submit urb %p", urb);
/* NOTE DMA mapping assumes this ... */
if (urb->iso_frame_desc [0].offset != 0)
return -EINVAL;
/* allocate ITDs w/o locking anything */ /* allocate ITDs w/o locking anything */
status = itd_urb_transaction (ehci, urb, mem_flags); status = itd_urb_transaction (ehci, urb, mem_flags);
if (status < 0) if (status < 0)
...@@ -979,10 +972,11 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags) ...@@ -979,10 +972,11 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb, int mem_flags)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static unsigned long static void
scan_periodic (struct ehci_hcd *ehci, unsigned long flags) scan_periodic (struct ehci_hcd *ehci)
{ {
unsigned frame, clock, now_uframe, mod; unsigned frame, clock, now_uframe, mod;
unsigned count = 0;
mod = ehci->periodic_size << 3; mod = ehci->periodic_size << 3;
...@@ -1005,6 +999,14 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1005,6 +999,14 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags)
u32 type, *hw_p; u32 type, *hw_p;
unsigned uframes; unsigned uframes;
/* keep latencies down: let any irqs in */
if (count > max_completions) {
spin_unlock_irq (&ehci->lock);
cpu_relax ();
count = 0;
spin_lock_irq (&ehci->lock);
}
restart: restart:
/* scan schedule to _before_ current frame index */ /* scan schedule to _before_ current frame index */
if (frame == clock) if (frame == clock)
...@@ -1028,8 +1030,8 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1028,8 +1030,8 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags)
last = (q.qh->hw_next == EHCI_LIST_END); last = (q.qh->hw_next == EHCI_LIST_END);
temp = q.qh->qh_next; temp = q.qh->qh_next;
type = Q_NEXT_TYPE (q.qh->hw_next); type = Q_NEXT_TYPE (q.qh->hw_next);
flags = intr_complete (ehci, frame, count += intr_complete (ehci, frame,
qh_get (q.qh), flags); qh_get (q.qh));
qh_put (ehci, q.qh); qh_put (ehci, q.qh);
q = temp; q = temp;
break; break;
...@@ -1061,8 +1063,8 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1061,8 +1063,8 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags)
type = Q_NEXT_TYPE (*hw_p); type = Q_NEXT_TYPE (*hw_p);
/* might free q.itd ... */ /* might free q.itd ... */
flags = itd_complete (ehci, count += itd_complete (ehci,
temp.itd, uf, flags); temp.itd, uf);
break; break;
} }
} }
...@@ -1078,7 +1080,7 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1078,7 +1080,7 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags)
#ifdef have_split_iso #ifdef have_split_iso
case Q_TYPE_SITD: case Q_TYPE_SITD:
last = (q.sitd->hw_next == EHCI_LIST_END); last = (q.sitd->hw_next == EHCI_LIST_END);
flags = sitd_complete (ehci, q.sitd, flags); sitd_complete (ehci, q.sitd);
type = Q_NEXT_TYPE (q.sitd->hw_next); type = Q_NEXT_TYPE (q.sitd->hw_next);
// FIXME unlink SITD after split completes // FIXME unlink SITD after split completes
...@@ -1124,5 +1126,4 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags) ...@@ -1124,5 +1126,4 @@ scan_periodic (struct ehci_hcd *ehci, unsigned long flags)
} else } else
frame = (frame + 1) % ehci->periodic_size; frame = (frame + 1) % ehci->periodic_size;
} }
return flags;
} }
...@@ -21,6 +21,23 @@ ...@@ -21,6 +21,23 @@
/* definitions used for the EHCI driver */ /* definitions used for the EHCI driver */
/* statistics can be kept for for tuning/monitoring */
struct ehci_stats {
/* irq usage */
unsigned long normal;
unsigned long error;
unsigned long reclaim;
/* termination of urbs from core */
unsigned long complete;
unsigned long unlink;
/* qhs patched to recover from td queueing race
* (can avoid by using 'dummy td', allowing fewer irqs)
*/
unsigned long qpatch;
};
/* ehci_hcd->lock guards shared data against other CPUs: /* ehci_hcd->lock guards shared data against other CPUs:
* ehci_hcd: async, reclaim, periodic (and shadow), ... * ehci_hcd: async, reclaim, periodic (and shadow), ...
* hcd_dev: ep[] * hcd_dev: ep[]
...@@ -72,6 +89,13 @@ struct ehci_hcd { /* one per controller */ ...@@ -72,6 +89,13 @@ struct ehci_hcd { /* one per controller */
struct pci_pool *sitd_pool; /* sitd per split iso urb */ struct pci_pool *sitd_pool; /* sitd per split iso urb */
struct timer_list watchdog; struct timer_list watchdog;
#ifdef EHCI_STATS
struct ehci_stats stats;
# define COUNT(x) do { (x)++; } while (0)
#else
# define COUNT(x) do {} while (0)
#endif
}; };
/* unwrap an HCD pointer to get an EHCI_HCD pointer */ /* unwrap an HCD pointer to get an EHCI_HCD pointer */
...@@ -400,10 +424,22 @@ struct ehci_fstn { ...@@ -400,10 +424,22 @@ struct ehci_fstn {
#define SUBMIT_URB(urb,mem_flags) usb_submit_urb(urb) #define SUBMIT_URB(urb,mem_flags) usb_submit_urb(urb)
#define STUB_DEBUG_FILES #define STUB_DEBUG_FILES
static inline int hcd_register_root (struct usb_hcd *hcd)
{
return usb_new_device (hcd_to_bus (hcd)->root_hub);
}
#else /* LINUX_VERSION_CODE */ #else /* LINUX_VERSION_CODE */
// hcd_to_bus() eventually moves to hcd.h on 2.5 too
static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd) static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd)
{ return &hcd->self; } { return &hcd->self; }
// ... as does hcd_register_root()
static inline int hcd_register_root (struct usb_hcd *hcd)
{
return usb_register_root_hub (
hcd_to_bus (hcd)->root_hub, &hcd->pdev->dev);
}
#define SUBMIT_URB(urb,mem_flags) usb_submit_urb(urb,mem_flags) #define SUBMIT_URB(urb,mem_flags) usb_submit_urb(urb,mem_flags)
......
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
#endif #endif
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/version.h>
#include "../core/hcd.h" #include "../core/hcd.h"
#include <asm/io.h> #include <asm/io.h>
...@@ -108,7 +109,7 @@ ...@@ -108,7 +109,7 @@
* - lots more testing!! * - lots more testing!!
*/ */
#define DRIVER_VERSION "2002-Sep-03" #define DRIVER_VERSION "2002-Sep-17"
#define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" #define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell"
#define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" #define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
...@@ -318,9 +319,6 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev) ...@@ -318,9 +319,6 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
struct hcd_dev *dev = (struct hcd_dev *) udev->hcpriv; struct hcd_dev *dev = (struct hcd_dev *) udev->hcpriv;
int i; int i;
unsigned long flags; unsigned long flags;
#ifdef DEBUG
int rescans = 0;
#endif
rescan: rescan:
/* free any eds, and dummy tds, still hanging around */ /* free any eds, and dummy tds, still hanging around */
...@@ -340,16 +338,18 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev) ...@@ -340,16 +338,18 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
td_free (ohci, ed->dummy); td_free (ohci, ed->dummy);
break; break;
default: default:
#ifdef DEBUG err ("%s-%s ed %p (#%d) not unlinked; disconnect() bug? %d",
err ("illegal ED %d state in free_config, %d", ohci->hcd.self.bus_name, udev->devpath, ed,
i, ed->state); i, ed->state);
#endif
/* ED_OPER: some driver disconnect() is broken, /* ED_OPER: some driver disconnect() is broken,
* it didn't even start its unlinks much less wait * it didn't even start its unlinks much less wait
* for their completions. * for their completions.
* OTHERWISE: hcd bug, ed is garbage * OTHERWISE: hcd bug, ed is garbage
*
* ... we can't recycle this memory in either case,
* so just leak it to avoid oopsing.
*/ */
BUG (); continue;
} }
ed_free (ohci, ed); ed_free (ohci, ed);
} }
...@@ -360,13 +360,9 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev) ...@@ -360,13 +360,9 @@ ohci_free_config (struct usb_hcd *hcd, struct usb_device *udev)
#ifdef DEBUG #ifdef DEBUG
/* a driver->disconnect() returned before its unlinks completed? */ /* a driver->disconnect() returned before its unlinks completed? */
if (in_interrupt ()) { if (in_interrupt ()) {
dbg ("WARNING: spin in interrupt; driver->disconnect() bug"); warn ("disconnect() bug for dev usb-%s-%s ep 0x%x",
dbg ("dev usb-%s-%s ep 0x%x",
ohci->hcd.self.bus_name, udev->devpath, i); ohci->hcd.self.bus_name, udev->devpath, i);
} }
BUG_ON (!(readl (&ohci->regs->intrenable) & OHCI_INTR_SF));
BUG_ON (rescans >= 2); /* HWBUG */
rescans++;
#endif #endif
spin_unlock_irqrestore (&ohci->lock, flags); spin_unlock_irqrestore (&ohci->lock, flags);
......
...@@ -36,12 +36,7 @@ static void finish_urb (struct ohci_hcd *ohci, struct urb *urb) ...@@ -36,12 +36,7 @@ static void finish_urb (struct ohci_hcd *ohci, struct urb *urb)
{ {
unsigned long flags; unsigned long flags;
#ifdef DEBUG // ASSERT (urb->hcpriv != 0);
if (!urb->hcpriv) {
err ("already unlinked!");
BUG ();
}
#endif
urb_free_priv (ohci, urb->hcpriv); urb_free_priv (ohci, urb->hcpriv);
urb->hcpriv = NULL; urb->hcpriv = NULL;
...@@ -51,6 +46,7 @@ static void finish_urb (struct ohci_hcd *ohci, struct urb *urb) ...@@ -51,6 +46,7 @@ static void finish_urb (struct ohci_hcd *ohci, struct urb *urb)
urb->status = 0; urb->status = 0;
spin_unlock_irqrestore (&urb->lock, flags); spin_unlock_irqrestore (&urb->lock, flags);
// what lock protects these?
switch (usb_pipetype (urb->pipe)) { switch (usb_pipetype (urb->pipe)) {
case PIPE_ISOCHRONOUS: case PIPE_ISOCHRONOUS:
ohci->hcd.self.bandwidth_isoc_reqs--; ohci->hcd.self.bandwidth_isoc_reqs--;
...@@ -425,6 +421,9 @@ static struct ed *ed_get ( ...@@ -425,6 +421,9 @@ static struct ed *ed_get (
/* FIXME: Don't do this without knowing it's safe to clobber this /* FIXME: Don't do this without knowing it's safe to clobber this
* state/mode info. Currently the upper layers don't support such * state/mode info. Currently the upper layers don't support such
* guarantees; we're lucky changing config/altsetting is rare. * guarantees; we're lucky changing config/altsetting is rare.
* The state/mode info also changes during enumeration: set_address
* uses the 'wrong' device address, and ep0 maxpacketsize will often
* improve on the initial value.
*/ */
if (ed->state == ED_IDLE) { if (ed->state == ED_IDLE) {
u32 info; u32 info;
...@@ -454,25 +453,6 @@ static struct ed *ed_get ( ...@@ -454,25 +453,6 @@ static struct ed *ed_get (
} }
ed->hwINFO = info; ed->hwINFO = info;
#ifdef DEBUG
/*
* There are two other cases we ought to change hwINFO, both during
* enumeration. There, the control request completes, unlinks, and
* the next request gets queued before the unlink completes, so it
* uses old/wrong hwINFO. How much of a problem is this? khubd is
* already retrying after such failures...
*/
} else if (type == PIPE_CONTROL) {
u32 info = le32_to_cpup (&ed->hwINFO);
if (!(info & 0x7f))
dbg ("RETRY ctrl: address != 0");
info >>= 16;
if (info != udev->epmaxpacketin [0])
dbg ("RETRY ctrl: maxpacket %d != 8",
udev->epmaxpacketin [0]);
#endif /* DEBUG */
} }
done: done:
...@@ -526,10 +506,7 @@ td_fill (unsigned int info, ...@@ -526,10 +506,7 @@ td_fill (unsigned int info,
struct urb_priv *urb_priv = urb->hcpriv; struct urb_priv *urb_priv = urb->hcpriv;
int is_iso = info & TD_ISO; int is_iso = info & TD_ISO;
if (index >= urb_priv->length) { // ASSERT (index < urb_priv->length);
err ("internal OHCI error: TD index > length");
return;
}
/* aim for only one interrupt per urb. mostly applies to control /* aim for only one interrupt per urb. mostly applies to control
* and iso; other urbs rarely need more than one TD per urb. * and iso; other urbs rarely need more than one TD per urb.
...@@ -578,6 +555,7 @@ td_fill (unsigned int info, ...@@ -578,6 +555,7 @@ td_fill (unsigned int info,
wmb (); wmb ();
/* append to queue */ /* append to queue */
list_add_tail (&td->td_list, &td->ed->td_list);
td->ed->hwTailP = td->hwNextTD; td->ed->hwTailP = td->hwNextTD;
} }
...@@ -698,8 +676,7 @@ static void td_submit_urb ( ...@@ -698,8 +676,7 @@ static void td_submit_urb (
ohci->hcd.self.bandwidth_isoc_reqs++; ohci->hcd.self.bandwidth_isoc_reqs++;
break; break;
} }
if (urb_priv->length != cnt) // ASSERT (urb_priv->length == cnt);
dbg ("TD LENGTH %d != CNT %d", urb_priv->length, cnt);
} }
/*-------------------------------------------------------------------------* /*-------------------------------------------------------------------------*
...@@ -714,6 +691,8 @@ static void td_done (struct urb *urb, struct td *td) ...@@ -714,6 +691,8 @@ static void td_done (struct urb *urb, struct td *td)
u32 tdINFO = le32_to_cpup (&td->hwINFO); u32 tdINFO = le32_to_cpup (&td->hwINFO);
int cc = 0; int cc = 0;
list_del (&td->td_list);
/* ISO ... drivers see per-TD length/status */ /* ISO ... drivers see per-TD length/status */
if (tdINFO & TD_ISO) { if (tdINFO & TD_ISO) {
u16 tdPSW = le16_to_cpu (td->hwPSW [0]); u16 tdPSW = le16_to_cpu (td->hwPSW [0]);
...@@ -792,74 +771,106 @@ static void td_done (struct urb *urb, struct td *td) ...@@ -792,74 +771,106 @@ static void td_done (struct urb *urb, struct td *td)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static inline struct td *
ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
{
struct urb *urb = td->urb;
struct ed *ed = td->ed;
struct list_head *tmp = td->td_list.next;
u32 toggle = ed->hwHeadP & ED_C;
/* clear ed halt; this is the td that caused it, but keep it inactive
* until its urb->complete() has a chance to clean up.
*/
ed->hwINFO |= ED_SKIP;
wmb ();
td->ed->hwHeadP &= ~ED_H;
while (tmp != &ed->td_list) {
struct td *next;
next = list_entry (tmp, struct td, td_list);
tmp = next->td_list.next;
/* move other tds from this urb to the donelist, after 'td'.
* order won't matter here: no errors, nothing transferred.
*
* NOTE: this "knows" short control reads won't need fixup:
* hc went from the (one) data TD to the status td. that'll
* change if multi-td control DATA segments are supported,
* and we want to send the status packet.
*/
if (next->urb == urb) {
u32 info = next->hwINFO;
info |= cpu_to_le32 (TD_DONE);
info &= ~cpu_to_le32 (TD_CC);
next->hwINFO = info;
next->next_dl_td = rev;
rev = next;
continue;
}
/* restart ed with first td of this next urb */
ed->hwHeadP = cpu_to_le32 (next->td_dma) | toggle;
tmp = 0;
break;
}
/* no urbs queued? then ED is empty. */
if (tmp)
ed->hwHeadP = cpu_to_le32 (ed->dummy->td_dma) | toggle;
/* help for troubleshooting: */
dbg ("urb %p usb-%s-%s ep-%d-%s cc %d --> status %d",
urb,
urb->dev->bus->bus_name, urb->dev->devpath,
usb_pipeendpoint (urb->pipe),
usb_pipein (urb->pipe) ? "IN" : "OUT",
cc, cc_to_error [cc]);
return rev;
}
/* replies to the request have to be on a FIFO basis so /* replies to the request have to be on a FIFO basis so
* we unreverse the hc-reversed done-list * we unreverse the hc-reversed done-list
*/ */
static struct td *dl_reverse_done_list (struct ohci_hcd *ohci) static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
{ {
__u32 td_list_hc; u32 td_dma;
struct td *td_rev = NULL; struct td *td_rev = NULL;
struct td *td_list = NULL; struct td *td = NULL;
urb_priv_t *urb_priv = NULL;
unsigned long flags; unsigned long flags;
spin_lock_irqsave (&ohci->lock, flags); spin_lock_irqsave (&ohci->lock, flags);
td_list_hc = le32_to_cpup (&ohci->hcca->done_head); td_dma = le32_to_cpup (&ohci->hcca->done_head);
ohci->hcca->done_head = 0; ohci->hcca->done_head = 0;
while (td_list_hc) { /* get TD from hc's singly linked list, and
* prepend to ours. ed->td_list changes later.
*/
while (td_dma) {
int cc; int cc;
td_list = dma_to_td (ohci, td_list_hc); td = dma_to_td (ohci, td_dma);
td_list->hwINFO |= cpu_to_le32 (TD_DONE);
cc = TD_CC_GET (le32_to_cpup (&td_list->hwINFO)); td->hwINFO |= cpu_to_le32 (TD_DONE);
if (cc != TD_CC_NOERROR) { cc = TD_CC_GET (le32_to_cpup (&td->hwINFO));
urb_priv = (urb_priv_t *) td_list->urb->hcpriv;
/* Non-iso endpoints can halt on error; un-halt, /* Non-iso endpoints can halt on error; un-halt,
* and dequeue any other TDs from this urb. * and dequeue any other TDs from this urb.
* No other TD could have caused the halt. * No other TD could have caused the halt.
*/ */
if (td_list->ed->hwHeadP & ED_H) { if (cc != TD_CC_NOERROR && (td->ed->hwHeadP & ED_H))
if (urb_priv && ((td_list->index + 1) td_rev = ed_halted (ohci, td, cc, td_rev);
< urb_priv->length)) {
#ifdef DEBUG
struct urb *urb = td_list->urb;
/* help for troubleshooting: */
dbg ("urb %p usb-%s-%s ep-%d-%s "
"(td %d/%d), "
"cc %d --> status %d",
td_list->urb,
urb->dev->bus->bus_name,
urb->dev->devpath,
usb_pipeendpoint (urb->pipe),
usb_pipein (urb->pipe)
? "IN" : "OUT",
1 + td_list->index,
urb_priv->length,
cc, cc_to_error [cc]);
#endif
td_list->ed->hwHeadP =
(urb_priv->td [urb_priv->length - 1]->hwNextTD
& __constant_cpu_to_le32 (TD_MASK))
| (td_list->ed->hwHeadP & ED_C);
urb_priv->td_cnt += urb_priv->length
- td_list->index - 1;
} else
td_list->ed->hwHeadP &= ~ED_H;
}
}
td_list->next_dl_td = td_rev; td->next_dl_td = td_rev;
td_rev = td_list; td_rev = td;
td_list_hc = le32_to_cpup (&td_list->hwNextTD); td_dma = le32_to_cpup (&td->hwNextTD);
} }
spin_unlock_irqrestore (&ohci->lock, flags); spin_unlock_irqrestore (&ohci->lock, flags);
return td_list; return td_rev;
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -874,9 +885,9 @@ static void finish_unlinks (struct ohci_hcd *ohci, u16 tick) ...@@ -874,9 +885,9 @@ static void finish_unlinks (struct ohci_hcd *ohci, u16 tick)
rescan_all: rescan_all:
for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) { for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) {
struct td *td, *td_next, *tdHeadP, *tdTailP; struct list_head *entry, *tmp;
u32 *td_p;
int completed, modified; int completed, modified;
u32 *prev;
/* only take off EDs that the HC isn't using, accounting for /* only take off EDs that the HC isn't using, accounting for
* frame counter wraps. * frame counter wraps.
...@@ -897,53 +908,52 @@ static void finish_unlinks (struct ohci_hcd *ohci, u16 tick) ...@@ -897,53 +908,52 @@ static void finish_unlinks (struct ohci_hcd *ohci, u16 tick)
/* unlink urbs as requested, but rescan the list after /* unlink urbs as requested, but rescan the list after
* we call a completion since it might have unlinked * we call a completion since it might have unlinked
* another (earlier) urb * another (earlier) urb
*
* FIXME use td_list to scan, not td hashtables.
*/ */
rescan_this: rescan_this:
completed = 0; completed = 0;
prev = &ed->hwHeadP;
list_for_each_safe (entry, tmp, &ed->td_list) {
struct td *td;
struct urb *urb;
urb_priv_t *urb_priv;
u32 savebits;
tdTailP = dma_to_td (ohci, le32_to_cpup (&ed->hwTailP)); td = list_entry (entry, struct td, td_list);
tdHeadP = dma_to_td (ohci, le32_to_cpup (&ed->hwHeadP)); urb = td->urb;
td_p = &ed->hwHeadP; urb_priv = td->urb->hcpriv;
for (td = tdHeadP; td != tdTailP; td = td_next) { if (urb_priv->state != URB_DEL) {
struct urb *urb = td->urb; prev = &td->hwNextTD;
urb_priv_t *urb_priv = td->urb->hcpriv; continue;
}
td_next = dma_to_td (ohci, /* patch pointer hc uses */
le32_to_cpup (&td->hwNextTD)); savebits = *prev & cpu_to_le32 (TD_MASK);
if (urb_priv->state == URB_DEL) { *prev = td->hwNextTD | savebits;
/* HC may have partly processed this TD */ /* HC may have partly processed this TD */
td_done (urb, td); td_done (urb, td);
urb_priv->td_cnt++; urb_priv->td_cnt++;
*td_p = td->hwNextTD | (*td_p & ~TD_MASK); /* if URB is done, clean up */
/* URB is done; clean up */
if (urb_priv->td_cnt == urb_priv->length) { if (urb_priv->td_cnt == urb_priv->length) {
modified = completed = 1; modified = completed = 1;
spin_unlock (&ohci->lock); spin_unlock (&ohci->lock);
finish_urb (ohci, urb); finish_urb (ohci, urb);
spin_lock (&ohci->lock); spin_lock (&ohci->lock);
} }
} else {
td_p = &td->hwNextTD;
}
} }
if (completed && !list_empty (&ed->td_list))
goto rescan_this;
/* ED's now officially unlinked, hc doesn't see */ /* ED's now officially unlinked, hc doesn't see */
ed->state = ED_IDLE; ed->state = ED_IDLE;
ed->hwINFO &= ~ED_SKIP; ed->hwINFO &= ~(ED_SKIP | ED_DEQUEUE);
ed->hwHeadP &= ~ED_H; ed->hwHeadP &= ~ED_H;
ed->hwNextED = 0; ed->hwNextED = 0;
/* but if there's work queued, reschedule */ /* but if there's work queued, reschedule */
tdHeadP = dma_to_td (ohci, le32_to_cpup (&ed->hwHeadP)); if (!list_empty (&ed->td_list)) {
if (tdHeadP != tdTailP) {
if (completed)
goto rescan_this;
if (!ohci->disabled && !ohci->sleeping) if (!ohci->disabled && !ohci->sleeping)
ed_schedule (ohci, ed); ed_schedule (ohci, ed);
} }
...@@ -1027,10 +1037,15 @@ static void dl_done_list (struct ohci_hcd *ohci, struct td *td) ...@@ -1027,10 +1037,15 @@ static void dl_done_list (struct ohci_hcd *ohci, struct td *td)
} }
/* clean schedule: unlink EDs that are no longer busy */ /* clean schedule: unlink EDs that are no longer busy */
if ((ed->hwHeadP & __constant_cpu_to_le32 (TD_MASK)) if (list_empty (&ed->td_list))
== ed->hwTailP
&& (ed->state == ED_OPER))
ed_deschedule (ohci, ed); ed_deschedule (ohci, ed);
/* ... reenabling halted EDs only after fault cleanup */
else if (!(ed->hwINFO & ED_DEQUEUE)) {
td = list_entry (ed->td_list.next, struct td, td_list);
if (!(td->hwINFO & TD_DONE))
ed->hwINFO &= ~ED_SKIP;
}
td = td_next; td = td_next;
} }
spin_unlock_irqrestore (&ohci->lock, flags); spin_unlock_irqrestore (&ohci->lock, flags);
......
...@@ -112,3 +112,13 @@ CONFIG_USB_SPEEDTCH ...@@ -112,3 +112,13 @@ CONFIG_USB_SPEEDTCH
For more information, see Johan Verrept's webpages at For more information, see Johan Verrept's webpages at
<http://linux-usb.sourceforge.net/SpeedTouch/>. <http://linux-usb.sourceforge.net/SpeedTouch/>.
CONFIG_USB_LCD
Say Y here if you want to connect an USBLCD to your computer's
USB port. The USBLCD is a small USB interface board for
alphanumeric LCD modules. See <http://www.usblcd.de> for more
information.
This code is also available as a module ( = code which can be
inserted in and removed from the running kernel whenever you want).
The module will be called usblcd.o. If you want to compile it as
a module, say M here and read <file:Documentation/modules.txt>.
/***************************************************************************** /*****************************************************************************
* USBLCD Kernel Driver * * USBLCD Kernel Driver *
* See http://www.usblcd.de for Hardware and Documentation. * * See http://www.usblcd.de for Hardware and Documentation. *
* Version 1.01 * * Version 1.03 *
* (C) 2002 Adams IT Services <info@usblcd.de> * * (C) 2002 Adams IT Services <info@usblcd.de> *
* * * *
* This file is licensed under the GPL. See COPYING in the package. * * This file is licensed under the GPL. See COPYING in the package. *
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
#define DRIVER_VERSION "USBLCD Driver Version 1.01" #define DRIVER_VERSION "USBLCD Driver Version 1.03"
#define USBLCD_MINOR 144 #define USBLCD_MINOR 144
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define IOCTL_GET_DRV_VERSION 2 #define IOCTL_GET_DRV_VERSION 2
/* stall/wait timeout for USBLCD */ /* stall/wait timeout for USBLCD */
#define NAK_TIMEOUT (HZ) #define NAK_TIMEOUT (10*HZ)
#define IBUF_SIZE 0x1000 #define IBUF_SIZE 0x1000
#define OBUF_SIZE 0x10000 #define OBUF_SIZE 0x10000
...@@ -318,7 +318,7 @@ static void disconnect_lcd(struct usb_interface *intf) ...@@ -318,7 +318,7 @@ static void disconnect_lcd(struct usb_interface *intf)
} }
static struct usb_device_id id_table [] = { static struct usb_device_id id_table [] = {
{ .idVendor = 0x1212, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, },
{}, {},
}; };
......
...@@ -232,6 +232,7 @@ struct usb_serial_device_type { ...@@ -232,6 +232,7 @@ struct usb_serial_device_type {
extern int usb_serial_register(struct usb_serial_device_type *new_device); extern int usb_serial_register(struct usb_serial_device_type *new_device);
extern void usb_serial_deregister(struct usb_serial_device_type *device); extern void usb_serial_deregister(struct usb_serial_device_type *device);
extern void usb_serial_port_softint(void *private);
extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);
extern void usb_serial_disconnect(struct usb_interface *iface); extern void usb_serial_disconnect(struct usb_interface *iface);
......
...@@ -498,7 +498,7 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da ...@@ -498,7 +498,7 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
return -ENOMEM; return -ENOMEM;
} }
memcpy (transfer_buffer, data, length); memcpy (transfer_buffer, data, length);
result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 300); result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3*HZ);
kfree (transfer_buffer); kfree (transfer_buffer);
return result; return result;
} }
...@@ -557,13 +557,12 @@ static int serial_open (struct tty_struct *tty, struct file * filp) ...@@ -557,13 +557,12 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
retval = serial->type->open(port, filp); retval = serial->type->open(port, filp);
else else
retval = generic_open(port, filp); retval = generic_open(port, filp);
}
if (retval) { if (retval) {
port->open_count = 0; port->open_count = 0;
if (serial->type->owner) if (serial->type->owner)
__MOD_DEC_USE_COUNT(serial->type->owner); __MOD_DEC_USE_COUNT(serial->type->owner);
} }
}
up (&port->sem); up (&port->sem);
return retval; return retval;
...@@ -1091,6 +1090,8 @@ static void generic_write_bulk_callback (struct urb *urb) ...@@ -1091,6 +1090,8 @@ static void generic_write_bulk_callback (struct urb *urb)
return; return;
} }
usb_serial_port_softint((void *)port);
queue_task(&port->tqueue, &tq_immediate); queue_task(&port->tqueue, &tq_immediate);
mark_bh(IMMEDIATE_BH); mark_bh(IMMEDIATE_BH);
...@@ -1109,14 +1110,18 @@ static void generic_shutdown (struct usb_serial *serial) ...@@ -1109,14 +1110,18 @@ static void generic_shutdown (struct usb_serial *serial)
} }
} }
static void port_softint(void *private) void usb_serial_port_softint(void *private)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)private; struct usb_serial_port *port = (struct usb_serial_port *)private;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial *serial;
struct tty_struct *tty; struct tty_struct *tty;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if (!port)
return;
serial = get_usb_serial (port, __FUNCTION__);
if (!serial) if (!serial)
return; return;
...@@ -1400,7 +1405,7 @@ int usb_serial_probe(struct usb_interface *interface, ...@@ -1400,7 +1405,7 @@ int usb_serial_probe(struct usb_interface *interface,
port->number = i + serial->minor; port->number = i + serial->minor;
port->serial = serial; port->serial = serial;
port->magic = USB_SERIAL_PORT_MAGIC; port->magic = USB_SERIAL_PORT_MAGIC;
port->tqueue.routine = port_softint; port->tqueue.routine = usb_serial_port_softint;
port->tqueue.data = port; port->tqueue.data = port;
init_MUTEX (&port->sem); init_MUTEX (&port->sem);
} }
...@@ -1690,6 +1695,7 @@ EXPORT_SYMBOL(usb_serial_register); ...@@ -1690,6 +1695,7 @@ EXPORT_SYMBOL(usb_serial_register);
EXPORT_SYMBOL(usb_serial_deregister); EXPORT_SYMBOL(usb_serial_deregister);
EXPORT_SYMBOL(usb_serial_probe); EXPORT_SYMBOL(usb_serial_probe);
EXPORT_SYMBOL(usb_serial_disconnect); EXPORT_SYMBOL(usb_serial_disconnect);
EXPORT_SYMBOL(usb_serial_port_softint);
#ifdef USES_EZUSB_FUNCTIONS #ifdef USES_EZUSB_FUNCTIONS
EXPORT_SYMBOL(ezusb_writememory); EXPORT_SYMBOL(ezusb_writememory);
EXPORT_SYMBOL(ezusb_set_reset); EXPORT_SYMBOL(ezusb_set_reset);
......
/* /*
* USB ConnectTech WhiteHEAT driver * USB ConnectTech WhiteHEAT driver
* *
* Copyright (C) 2002
* Connect Tech Inc.
*
* Copyright (C) 1999 - 2001 * Copyright (C) 1999 - 2001
* Greg Kroah-Hartman (greg@kroah.com) * Greg Kroah-Hartman (greg@kroah.com)
* *
...@@ -11,6 +14,9 @@ ...@@ -11,6 +14,9 @@
* *
* See Documentation/usb/usb-serial.txt for more information on using this driver * See Documentation/usb/usb-serial.txt for more information on using this driver
* *
* (10/09/2002) Stuart MacDonald (stuartm@connecttech.com)
* Upgrade to full working driver
*
* (05/30/2001) gkh * (05/30/2001) gkh
* switched from using spinlock to a semaphore, which fixes lots of problems. * switched from using spinlock to a semaphore, which fixes lots of problems.
* *
...@@ -71,6 +77,8 @@ ...@@ -71,6 +77,8 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/serial_reg.h>
#include <linux/serial.h>
#ifdef CONFIG_USB_SERIAL_DEBUG #ifdef CONFIG_USB_SERIAL_DEBUG
static int debug = 1; static int debug = 1;
...@@ -85,8 +93,8 @@ ...@@ -85,8 +93,8 @@
/* /*
* Version Information * Version Information
*/ */
#define DRIVER_VERSION "v1.2" #define DRIVER_VERSION "v2.0"
#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>" #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Stuart MacDonald <stuartm@connecttech.com>"
#define DRIVER_DESC "USB ConnectTech WhiteHEAT driver" #define DRIVER_DESC "USB ConnectTech WhiteHEAT driver"
#define CONNECT_TECH_VENDOR_ID 0x0710 #define CONNECT_TECH_VENDOR_ID 0x0710
...@@ -125,16 +133,25 @@ static struct usb_driver whiteheat_driver = { ...@@ -125,16 +133,25 @@ static struct usb_driver whiteheat_driver = {
.id_table = id_table_combined, .id_table = id_table_combined,
}; };
/* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
static int whiteheat_firmware_download (struct usb_serial *serial);
static int whiteheat_firmware_attach (struct usb_serial *serial);
/* function prototypes for the Connect Tech WhiteHEAT serial converter */ /* function prototypes for the Connect Tech WhiteHEAT serial converter */
static int whiteheat_attach (struct usb_serial *serial);
static void whiteheat_shutdown (struct usb_serial *serial);
static int whiteheat_open (struct usb_serial_port *port, struct file *filp); static int whiteheat_open (struct usb_serial_port *port, struct file *filp);
static void whiteheat_close (struct usb_serial_port *port, struct file *filp); static void whiteheat_close (struct usb_serial_port *port, struct file *filp);
static int whiteheat_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
static int whiteheat_write_room (struct usb_serial_port *port);
static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
static void whiteheat_set_termios (struct usb_serial_port *port, struct termios * old); static void whiteheat_set_termios (struct usb_serial_port *port, struct termios * old);
static void whiteheat_break_ctl (struct usb_serial_port *port, int break_state);
static int whiteheat_chars_in_buffer (struct usb_serial_port *port);
static void whiteheat_throttle (struct usb_serial_port *port); static void whiteheat_throttle (struct usb_serial_port *port);
static void whiteheat_unthrottle (struct usb_serial_port *port); static void whiteheat_unthrottle (struct usb_serial_port *port);
static int whiteheat_firmware_download (struct usb_serial *serial); static void whiteheat_read_callback (struct urb *urb);
static int whiteheat_attach (struct usb_serial *serial); static void whiteheat_write_callback (struct urb *urb);
static void whiteheat_shutdown (struct usb_serial *serial);
static struct usb_serial_device_type whiteheat_fake_device = { static struct usb_serial_device_type whiteheat_fake_device = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
...@@ -145,6 +162,7 @@ static struct usb_serial_device_type whiteheat_fake_device = { ...@@ -145,6 +162,7 @@ static struct usb_serial_device_type whiteheat_fake_device = {
.num_bulk_out = NUM_DONT_CARE, .num_bulk_out = NUM_DONT_CARE,
.num_ports = 1, .num_ports = 1,
.probe = whiteheat_firmware_download, .probe = whiteheat_firmware_download,
.attach = whiteheat_firmware_attach,
}; };
static struct usb_serial_device_type whiteheat_device = { static struct usb_serial_device_type whiteheat_device = {
...@@ -155,201 +173,311 @@ static struct usb_serial_device_type whiteheat_device = { ...@@ -155,201 +173,311 @@ static struct usb_serial_device_type whiteheat_device = {
.num_bulk_in = NUM_DONT_CARE, .num_bulk_in = NUM_DONT_CARE,
.num_bulk_out = NUM_DONT_CARE, .num_bulk_out = NUM_DONT_CARE,
.num_ports = 4, .num_ports = 4,
.attach = whiteheat_attach,
.shutdown = whiteheat_shutdown,
.open = whiteheat_open, .open = whiteheat_open,
.close = whiteheat_close, .close = whiteheat_close,
.throttle = whiteheat_throttle, .write = whiteheat_write,
.unthrottle = whiteheat_unthrottle, .write_room = whiteheat_write_room,
.ioctl = whiteheat_ioctl, .ioctl = whiteheat_ioctl,
.set_termios = whiteheat_set_termios, .set_termios = whiteheat_set_termios,
.attach = whiteheat_attach, .break_ctl = whiteheat_break_ctl,
.shutdown = whiteheat_shutdown, .chars_in_buffer = whiteheat_chars_in_buffer,
.throttle = whiteheat_throttle,
.unthrottle = whiteheat_unthrottle,
.read_bulk_callback = whiteheat_read_callback,
.write_bulk_callback = whiteheat_write_callback,
}; };
struct whiteheat_private {
struct whiteheat_command_private {
spinlock_t lock;
__u8 port_running;
__u8 command_finished; __u8 command_finished;
wait_queue_head_t wait_command; /* for handling sleeping while waiting for a command to finish */ wait_queue_head_t wait_command; /* for handling sleeping while waiting for a command to finish */
__u8 result_buffer[64];
}; };
/* local function prototypes */ #define THROTTLED 0x01
static inline void set_rts (struct usb_serial_port *port, unsigned char rts); #define ACTUALLY_THROTTLED 0x02
static inline void set_dtr (struct usb_serial_port *port, unsigned char dtr);
static inline void set_break (struct usb_serial_port *port, unsigned char brk); struct whiteheat_private {
spinlock_t lock;
__u8 flags;
__u8 mcr;
};
/* local function prototypes */
static int start_command_port(struct usb_serial *serial);
static void stop_command_port(struct usb_serial *serial);
static void command_port_write_callback(struct urb *urb);
static void command_port_read_callback(struct urb *urb);
static int firm_send_command(struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize);
static int firm_open(struct usb_serial_port *port);
static int firm_close(struct usb_serial_port *port);
static int firm_setup_port(struct usb_serial_port *port);
static int firm_set_rts(struct usb_serial_port *port, __u8 onoff);
static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff);
static int firm_set_break(struct usb_serial_port *port, __u8 onoff);
static int firm_purge(struct usb_serial_port *port, __u8 rxtx);
static int firm_get_dtr_rts(struct usb_serial_port *port);
static int firm_report_tx_done(struct usb_serial_port *port);
#define COMMAND_PORT 4 #define COMMAND_PORT 4
#define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */ #define COMMAND_TIMEOUT (2*HZ) /* 2 second timeout for a command */
#define CLOSING_DELAY (30 * HZ)
/***************************************************************************** /*****************************************************************************
* Connect Tech's White Heat specific driver functions * Connect Tech's White Heat prerenumeration driver functions
*****************************************************************************/ *****************************************************************************/
static void command_port_write_callback (struct urb *urb)
/* steps to download the firmware to the WhiteHEAT device:
- hold the reset (by writing to the reset bit of the CPUCS register)
- download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD
- release the reset (by writing to the CPUCS register)
- download the WH.HEX file for all addresses greater than 0x1b3f using
VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
- hold the reset
- download the WH.HEX file for all addresses less than 0x1b40 using
VENDOR_REQUEST_ANCHOR_LOAD
- release the reset
- device renumerated itself and comes up as new device id with all
firmware download completed.
*/
static int whiteheat_firmware_download (struct usb_serial *serial)
{ {
int response;
const struct whiteheat_hex_record *record;
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
if (urb->status) { response = ezusb_set_reset (serial, 1);
dbg ("nonzero urb status: %d", urb->status);
return; record = &whiteheat_loader[0];
while (record->address != 0xffff) {
response = ezusb_writememory (serial, record->address,
(unsigned char *)record->data, record->data_size, 0xa0);
if (response < 0) {
err("%s - ezusb_writememory failed for loader (%d %04X %p %d)",
__FUNCTION__, response, record->address, record->data, record->data_size);
break;
}
++record;
} }
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer); response = ezusb_set_reset (serial, 0);
return; record = &whiteheat_firmware[0];
while (record->address < 0x1b40) {
++record;
}
while (record->address != 0xffff) {
response = ezusb_writememory (serial, record->address,
(unsigned char *)record->data, record->data_size, 0xa3);
if (response < 0) {
err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)",
__FUNCTION__, response, record->address, record->data, record->data_size);
break;
}
++record;
}
response = ezusb_set_reset (serial, 1);
record = &whiteheat_firmware[0];
while (record->address < 0x1b40) {
response = ezusb_writememory (serial, record->address,
(unsigned char *)record->data, record->data_size, 0xa0);
if (response < 0) {
err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)",
__FUNCTION__, response, record->address, record->data, record->data_size);
break;
}
++record;
}
response = ezusb_set_reset (serial, 0);
return 0;
} }
static void command_port_read_callback (struct urb *urb) static int whiteheat_firmware_attach (struct usb_serial *serial)
{ {
struct usb_serial_port *port = (struct usb_serial_port *)urb->context; /* We want this device to fail to have a driver assigned to it */
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); return 1;
}
/*****************************************************************************
* Connect Tech's White Heat serial driver functions
*****************************************************************************/
static int whiteheat_attach (struct usb_serial *serial)
{
struct usb_serial_port *command_port;
struct whiteheat_command_private *command_info;
struct usb_serial_port *port;
struct whiteheat_private *info; struct whiteheat_private *info;
unsigned char *data = urb->transfer_buffer; struct whiteheat_hw_info *hw_info;
int result; int pipe;
int ret;
int alen;
__u8 command[2] = { WHITEHEAT_GET_HW_INFO, 0 };
__u8 result[sizeof(*hw_info) + 1];
int i;
dbg("%s", __FUNCTION__); command_port = &serial->port[COMMAND_PORT];
if (urb->status) { pipe = usb_sndbulkpipe (serial->dev, command_port->bulk_out_endpointAddress);
dbg("%s - nonzero urb status: %d", __FUNCTION__, urb->status); ret = usb_bulk_msg (serial->dev, pipe, command, sizeof(command), &alen, COMMAND_TIMEOUT);
return; if (ret) {
err("%s: Couldn't send command [%d]", serial->type->name, ret);
goto no_firmware;
} else if (alen != sizeof(command)) {
err("%s: Send command incomplete [%d]", serial->type->name, alen);
goto no_firmware;
} }
if (!serial) { pipe = usb_rcvbulkpipe (serial->dev, command_port->bulk_in_endpointAddress);
dbg("%s - bad serial pointer, exiting", __FUNCTION__); ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(result), &alen, COMMAND_TIMEOUT);
return; if (ret) {
err("%s: Couldn't get results [%d]", serial->type->name, ret);
goto no_firmware;
} else if (alen != sizeof(result)) {
err("%s: Get results incomplete [%d]", serial->type->name, alen);
goto no_firmware;
} else if (result[0] != command[0]) {
err("%s: Command failed [%d]", serial->type->name, result[0]);
goto no_firmware;
} }
usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data); hw_info = (struct whiteheat_hw_info *)&result[1];
info = (struct whiteheat_private *)port->private; info("%s: Driver %s: Firmware v%d.%02d", serial->type->name,
if (!info) { DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev);
dbg("%s - info is NULL, exiting.", __FUNCTION__);
return;
}
/* right now, if the command is COMMAND_COMPLETE, just flip the bit saying the command finished */ for (i = 0; i < serial->num_ports; i++) {
/* in the future we're going to have to pay attention to the actual command that completed */ port = &serial->port[i];
if (data[0] == WHITEHEAT_CMD_COMPLETE) {
info->command_finished = WHITEHEAT_CMD_COMPLETE; info = (struct whiteheat_private *)kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
wake_up_interruptible(&info->wait_command); if (info == NULL)
} goto no_memory;
if (data[0] == WHITEHEAT_CMD_FAILURE) { spin_lock_init(&info->lock);
info->command_finished = WHITEHEAT_CMD_FAILURE; info->flags = 0;
wake_up_interruptible(&info->wait_command); info->mcr = 0;
port->private = info;
} }
/* Continue trying to always read */ command_info = (struct whiteheat_command_private *)kmalloc(sizeof(struct whiteheat_command_private), GFP_KERNEL);
FILL_BULK_URB(port->read_urb, serial->dev, if (command_info == NULL)
usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress), goto no_memory;
port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
command_port_read_callback, port);
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result)
dbg("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
}
spin_lock_init(&command_info->lock);
command_info->port_running = 0;
init_waitqueue_head(&command_info->wait_command);
command_port->private = command_info;
command_port->write_urb->complete = command_port_write_callback;
command_port->read_urb->complete = command_port_read_callback;
static int whiteheat_send_cmd (struct usb_serial *serial, __u8 command, __u8 *data, __u8 datasize) return 0;
{
struct whiteheat_private *info;
struct usb_serial_port *port;
int timeout;
__u8 *transfer_buffer;
int retval = 0;
dbg("%s - command %d", __FUNCTION__, command); no_firmware:
/* Firmware likely not running */
err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->name);
err("%s: If the firmware is not running (status led not blinking)\n", serial->type->name);
err("%s: please contact support@connecttech.com\n", serial->type->name);
return -ENODEV;
no_memory:
for (i--; i >= 0; i--) {
port = &serial->port[i];
kfree(port->private);
}
err("%s: Out of memory for port structures\n", serial->type->name);
return -ENOMEM;
}
port = &serial->port[COMMAND_PORT];
info = (struct whiteheat_private *)port->private;
info->command_finished = FALSE;
transfer_buffer = (__u8 *)port->write_urb->transfer_buffer; static void whiteheat_shutdown (struct usb_serial *serial)
transfer_buffer[0] = command; {
memcpy (&transfer_buffer[1], data, datasize); struct usb_serial_port *command_port;
port->write_urb->transfer_buffer_length = datasize + 1; struct usb_serial_port *port;
port->write_urb->dev = serial->dev; int i;
retval = usb_submit_urb (port->write_urb, GFP_KERNEL);
if (retval) {
dbg("%s - submit urb failed", __FUNCTION__);
goto exit;
}
/* wait for the command to complete */ dbg("%s", __FUNCTION__);
timeout = COMMAND_TIMEOUT;
while (timeout && (info->command_finished == FALSE)) {
timeout = interruptible_sleep_on_timeout (&info->wait_command, timeout);
}
if (info->command_finished == FALSE) { /* free up our private data for our command port */
dbg("%s - command timed out.", __FUNCTION__); command_port = &serial->port[COMMAND_PORT];
retval = -ETIMEDOUT; kfree (command_port->private);
goto exit; command_port->private = NULL;
}
if (info->command_finished == WHITEHEAT_CMD_FAILURE) { for (i = 0; i < serial->num_ports; i++) {
dbg("%s - command failed.", __FUNCTION__); port = &serial->port[i];
retval = -EIO; kfree(port->private);
goto exit; port->private = NULL;
} }
if (info->command_finished == WHITEHEAT_CMD_COMPLETE) return;
dbg("%s - command completed.", __FUNCTION__);
exit:
return retval;
} }
static int whiteheat_open (struct usb_serial_port *port, struct file *filp) static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
{ {
struct whiteheat_min_set open_command;
struct usb_serial_port *command_port;
struct whiteheat_private *info;
int retval = 0; int retval = 0;
struct termios old_term;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
/* set up some stuff for our command port */ retval = start_command_port(port->serial);
command_port = &port->serial->port[COMMAND_PORT]; if (retval)
if (command_port->private == NULL) {
info = (struct whiteheat_private *)kmalloc (sizeof(struct whiteheat_private), GFP_KERNEL);
if (info == NULL) {
err("%s - out of memory", __FUNCTION__);
retval = -ENOMEM;
goto exit;
}
init_waitqueue_head(&info->wait_command);
command_port->private = info;
command_port->write_urb->complete = command_port_write_callback;
command_port->read_urb->complete = command_port_read_callback;
command_port->read_urb->dev = port->serial->dev;
command_port->tty = port->tty; /* need this to "fake" our our sanity check macros */
retval = usb_submit_urb (command_port->read_urb, GFP_KERNEL);
if (retval) {
err("%s - failed submitting read urb, error %d", __FUNCTION__, retval);
goto exit; goto exit;
}
}
/* Start reading from the device */ /* Start reading from the device */
port->read_urb->dev = port->serial->dev; port->read_urb->dev = port->serial->dev;
retval = usb_submit_urb(port->read_urb, GFP_KERNEL); retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (retval) { if (retval) {
err("%s - failed submitting read urb, error %d", __FUNCTION__, retval); err("%s - failed submitting read urb, error %d", __FUNCTION__, retval);
stop_command_port(port->serial);
goto exit; goto exit;
} }
/* send an open port command */ /* send an open port command */
/* firmware uses 1 based port numbering */ retval = firm_open(port);
open_command.port = port->number - port->serial->minor + 1; if (retval) {
retval = whiteheat_send_cmd (port->serial, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command)); stop_command_port(port->serial);
if (retval) goto exit;
}
retval = firm_purge(port, WHITEHEAT_PURGE_RX | WHITEHEAT_PURGE_TX);
if (retval) {
firm_close(port);
stop_command_port(port->serial);
goto exit; goto exit;
}
old_term.c_cflag = ~port->tty->termios->c_cflag;
old_term.c_iflag = ~port->tty->termios->c_iflag;
whiteheat_set_termios(port, &old_term);
/* Need to do device specific setup here (control lines, baud rate, etc.) */ retval = firm_set_rts(port, WHITEHEAT_RTS_ON);
/* FIXME!!! */ if (retval) {
firm_close(port);
stop_command_port(port->serial);
goto exit;
}
retval = firm_set_dtr(port, WHITEHEAT_DTR_ON);
if (retval) {
firm_set_rts(port, WHITEHEAT_RTS_OFF);
firm_close(port);
stop_command_port(port->serial);
goto exit;
}
exit: exit:
dbg("%s - exit, retval = %d", __FUNCTION__, retval); dbg("%s - exit, retval = %d", __FUNCTION__, retval);
...@@ -359,129 +487,259 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp) ...@@ -359,129 +487,259 @@ static int whiteheat_open (struct usb_serial_port *port, struct file *filp)
static void whiteheat_close(struct usb_serial_port *port, struct file * filp) static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
{ {
struct whiteheat_min_set close_command;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
/* send a close command to the port */ if (tty_hung_up_p(filp)) {
/* firmware uses 1 based port numbering */ return;
close_command.port = port->number - port->serial->minor + 1; }
whiteheat_send_cmd (port->serial, WHITEHEAT_CLOSE, (__u8 *)&close_command, sizeof(close_command));
port->tty->closing = 1;
/*
* Not currently in use; tty_wait_until_sent() calls
* serial_chars_in_buffer() which deadlocks on the second semaphore
* acquisition. This should be fixed at some point. Greg's been
* notified.
if ((filp->f_flags & (O_NDELAY | O_NONBLOCK)) == 0) {
tty_wait_until_sent(port->tty, CLOSING_DELAY);
}
*/
if (port->tty->driver.flush_buffer)
port->tty->driver.flush_buffer(port->tty);
if (port->tty->ldisc.flush_buffer)
port->tty->ldisc.flush_buffer(port->tty);
/* Need to change the control lines here */ firm_report_tx_done(port);
/* FIXME */
firm_set_dtr(port, WHITEHEAT_DTR_OFF);
firm_set_rts(port, WHITEHEAT_RTS_OFF);
firm_close(port);
/* shutdown our bulk reads and writes */ /* shutdown our bulk reads and writes */
usb_unlink_urb (port->write_urb); usb_unlink_urb (port->write_urb);
usb_unlink_urb (port->read_urb); usb_unlink_urb (port->read_urb);
}
static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) stop_command_port(port->serial);
{
dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
return -ENOIOCTLCMD; port->tty->closing = 0;
} }
static void whiteheat_set_termios (struct usb_serial_port *port, struct termios *old_termios) static int whiteheat_write(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
{ {
unsigned int cflag; struct usb_serial *serial = port->serial;
struct whiteheat_port_settings port_settings; int result;
dbg("%s -port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
if ((!port->tty) || (!port->tty->termios)) { if (count == 0) {
dbg("%s - no tty structures", __FUNCTION__); dbg("%s - write request of 0 bytes", __FUNCTION__);
goto exit; return (0);
} }
cflag = port->tty->termios->c_cflag; if (port->write_urb->status == -EINPROGRESS) {
/* check that they really want us to change something */ dbg ("%s - already writing", __FUNCTION__);
if (old_termios) { return (0);
if ((cflag == old_termios->c_cflag) &&
(RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
dbg("%s - nothing to change...", __FUNCTION__);
goto exit;
}
} }
/* set the port number */ count = (count > port->bulk_out_size) ? port->bulk_out_size : count;
/* firmware uses 1 based port numbering */
port_settings.port = port->number + 1;
/* get the byte size */ if (from_user) {
switch (cflag & CSIZE) { if (copy_from_user(port->write_urb->transfer_buffer, buf, count))
case CS5: port_settings.bits = 5; break; return -EFAULT;
case CS6: port_settings.bits = 6; break; }
case CS7: port_settings.bits = 7; break; else {
default: memcpy (port->write_urb->transfer_buffer, buf, count);
case CS8: port_settings.bits = 8; break;
} }
dbg("%s - data bits = %d", __FUNCTION__, port_settings.bits);
/* determine the parity */ usb_serial_debug_data (__FILE__, __FUNCTION__, count, port->write_urb->transfer_buffer);
if (cflag & PARENB)
if (cflag & PARODD)
port_settings.parity = 'o';
else
port_settings.parity = 'e';
else
port_settings.parity = 'n';
dbg("%s - parity = %c", __FUNCTION__, port_settings.parity);
/* figure out the stop bits requested */ port->write_urb->dev = serial->dev;
if (cflag & CSTOPB) port->write_urb->transfer_buffer_length = count;
port_settings.stop = 2; result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
if (result)
err("%s - failed submitting write urb, error %d", __FUNCTION__, result);
else else
port_settings.stop = 1; result = count;
dbg("%s - stop bits = %d", __FUNCTION__, port_settings.stop);
return result;
}
/* figure out the flow control settings */
if (cflag & CRTSCTS)
port_settings.hflow = (WHITEHEAT_CTS_FLOW | WHITEHEAT_RTS_FLOW);
else
port_settings.hflow = 0;
dbg("%s - hardware flow control = %s %s %s %s", __FUNCTION__,
(port_settings.hflow & WHITEHEAT_CTS_FLOW) ? "CTS" : "",
(port_settings.hflow & WHITEHEAT_RTS_FLOW) ? "RTS" : "",
(port_settings.hflow & WHITEHEAT_DSR_FLOW) ? "DSR" : "",
(port_settings.hflow & WHITEHEAT_DTR_FLOW) ? "DTR" : "");
/* determine software flow control */ static int whiteheat_write_room(struct usb_serial_port *port)
if (I_IXOFF(port->tty)) {
port_settings.sflow = 'b'; int room = 0;
dbg("%s - port %d", __FUNCTION__, port->number);
if (port->write_urb->status != -EINPROGRESS)
room = port->bulk_out_size;
dbg("%s - returns %d", __FUNCTION__, room);
return (room);
}
static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
{
struct whiteheat_private *info = (struct whiteheat_private *)port->private;
unsigned int modem_signals = 0;
struct serial_struct serstruct;
dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
switch (cmd) {
case TIOCMGET:
firm_get_dtr_rts(port);
if (info->mcr & UART_MCR_DTR)
modem_signals |= TIOCM_DTR;
if (info->mcr & UART_MCR_RTS)
modem_signals |= TIOCM_RTS;
if (copy_to_user((unsigned int *)arg, &modem_signals, sizeof(unsigned int)));
return -EFAULT;
break;
case TIOCMSET:
if (copy_from_user(&modem_signals, (unsigned int *)arg, sizeof(unsigned int)))
return -EFAULT;
if (modem_signals & TIOCM_DTR)
info->mcr |= UART_MCR_DTR;
else else
port_settings.sflow = 'n'; info->mcr &= ~UART_MCR_DTR;
dbg("%s - software flow control = %c", __FUNCTION__, port_settings.sflow); if (modem_signals & TIOCM_RTS)
info->mcr |= UART_MCR_RTS;
else
info->mcr &= ~UART_MCR_RTS;
port_settings.xon = START_CHAR(port->tty); firm_set_dtr(port, info->mcr & UART_MCR_DTR);
port_settings.xoff = STOP_CHAR(port->tty); firm_set_rts(port, info->mcr & UART_MCR_RTS);
dbg("%s - XON = %2x, XOFF = %2x", __FUNCTION__, port_settings.xon, port_settings.xoff);
/* get the baud rate wanted */ break;
port_settings.baud = tty_get_baud_rate(port->tty);
dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud);
/* handle any settings that aren't specified in the tty structure */ case TIOCMBIS:
port_settings.lloop = 0; if (copy_from_user(&modem_signals, (unsigned int *)arg, sizeof(unsigned int)))
return -EFAULT;
/* now send the message to the device */ if (modem_signals & TIOCM_DTR)
whiteheat_send_cmd (port->serial, WHITEHEAT_SETUP_PORT, (__u8 *)&port_settings, sizeof(port_settings)); info->mcr |= UART_MCR_DTR;
if (modem_signals & TIOCM_RTS)
info->mcr |= UART_MCR_RTS;
firm_set_dtr(port, info->mcr & UART_MCR_DTR);
firm_set_rts(port, info->mcr & UART_MCR_RTS);
break;
case TIOCMBIC:
if (copy_from_user(&modem_signals, (unsigned int *)arg, sizeof(unsigned int)))
return -EFAULT;
if (modem_signals & TIOCM_DTR)
info->mcr &= ~UART_MCR_DTR;
if (modem_signals & TIOCM_RTS)
info->mcr &= ~UART_MCR_RTS;
firm_set_dtr(port, info->mcr & UART_MCR_DTR);
firm_set_rts(port, info->mcr & UART_MCR_RTS);
break;
case TIOCGSERIAL:
memset(&serstruct, 0, sizeof(serstruct));
serstruct.type = PORT_16654;
serstruct.line = port->serial->minor;
serstruct.port = port->number;
serstruct.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
serstruct.xmit_fifo_size = port->bulk_out_size;
serstruct.custom_divisor = 0;
serstruct.baud_base = 460800;
serstruct.close_delay = CLOSING_DELAY;
serstruct.closing_wait = CLOSING_DELAY;
if (copy_to_user((void *)arg, &serstruct, sizeof(serstruct)))
return -EFAULT;
break;
case TIOCSSERIAL:
if (copy_from_user(&serstruct, (void *)arg, sizeof(serstruct)))
return -EFAULT;
/*
* For now this is ignored. dip sets the ASYNC_[V]HI flags
* but this isn't used by us at all. Maybe someone somewhere
* will need the custom_divisor setting.
*/
break;
default:
return -ENOIOCTLCMD;
}
return 0;
}
static void whiteheat_set_termios (struct usb_serial_port *port, struct termios *old_termios)
{
dbg("%s -port %d", __FUNCTION__, port->number);
if ((!port->tty) || (!port->tty->termios)) {
dbg("%s - no tty structures", __FUNCTION__);
goto exit;
}
/* check that they really want us to change something */
if (old_termios) {
if ((port->tty->termios->c_cflag == old_termios->c_cflag) &&
(RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) {
dbg("%s - nothing to change...", __FUNCTION__);
goto exit;
}
}
firm_setup_port(port);
exit: exit:
return; return;
} }
static void whiteheat_break_ctl(struct usb_serial_port *port, int break_state) {
firm_set_break(port, break_state);
}
static int whiteheat_chars_in_buffer(struct usb_serial_port *port)
{
int chars = 0;
dbg("%s - port %d", __FUNCTION__, port->number);
if (port->write_urb->status == -EINPROGRESS)
chars = port->write_urb->transfer_buffer_length;
dbg ("%s - returns %d", __FUNCTION__, chars);
return (chars);
}
static void whiteheat_throttle (struct usb_serial_port *port) static void whiteheat_throttle (struct usb_serial_port *port)
{ {
struct whiteheat_private *info = (struct whiteheat_private *)port->private;
unsigned long flags;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
/* Change the control signals */ spin_lock_irqsave(&info->lock, flags);
/* FIXME!!! */ info->flags |= THROTTLED;
spin_unlock_irqrestore(&info->lock, flags);
return; return;
} }
...@@ -489,194 +747,441 @@ static void whiteheat_throttle (struct usb_serial_port *port) ...@@ -489,194 +747,441 @@ static void whiteheat_throttle (struct usb_serial_port *port)
static void whiteheat_unthrottle (struct usb_serial_port *port) static void whiteheat_unthrottle (struct usb_serial_port *port)
{ {
struct whiteheat_private *info = (struct whiteheat_private *)port->private;
int result;
unsigned long flags;
dbg("%s - port %d", __FUNCTION__, port->number); dbg("%s - port %d", __FUNCTION__, port->number);
/* Change the control signals */ spin_lock_irqsave(&info->lock, flags);
/* FIXME!!! */
if (info->flags & ACTUALLY_THROTTLED) {
/* Continue trying to always read */
port->read_urb->dev = port->serial->dev;
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
}
info->flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
spin_unlock_irqrestore(&info->lock, flags);
return; return;
} }
/* steps to download the firmware to the WhiteHEAT device: /*****************************************************************************
- hold the reset (by writing to the reset bit of the CPUCS register) * Connect Tech's White Heat callback routines
- download the VEND_AX.HEX file to the chip using VENDOR_REQUEST-ANCHOR_LOAD *****************************************************************************/
- release the reset (by writing to the CPUCS register) static void command_port_write_callback (struct urb *urb)
- download the WH.HEX file for all addresses greater than 0x1b3f using
VENDOR_REQUEST-ANCHOR_EXTERNAL_RAM_LOAD
- hold the reset
- download the WH.HEX file for all addresses less than 0x1b40 using
VENDOR_REQUEST_ANCHOR_LOAD
- release the reset
- device renumerated itself and comes up as new device id with all
firmware download completed.
*/
static int whiteheat_firmware_download (struct usb_serial *serial)
{ {
int response;
const struct whiteheat_hex_record *record;
dbg("%s", __FUNCTION__); dbg("%s", __FUNCTION__);
response = ezusb_set_reset (serial, 1); if (urb->status) {
dbg ("nonzero urb status: %d", urb->status);
return;
}
record = &whiteheat_loader[0]; usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
while (record->address != 0xffff) {
response = ezusb_writememory (serial, record->address, return;
(unsigned char *)record->data, record->data_size, 0xa0); }
if (response < 0) {
err("%s - ezusb_writememory failed for loader (%d %04X %p %d)",
__FUNCTION__, response, record->address, record->data, record->data_size); static void command_port_read_callback (struct urb *urb)
break; {
struct usb_serial_port *command_port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (command_port, __FUNCTION__);
struct whiteheat_command_private *command_info;
unsigned char *data = urb->transfer_buffer;
int result;
unsigned long flags;
dbg("%s", __FUNCTION__);
if (urb->status) {
dbg("%s - nonzero urb status: %d", __FUNCTION__, urb->status);
return;
} }
++record;
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
} }
response = ezusb_set_reset (serial, 0); usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
record = &whiteheat_firmware[0]; command_info = (struct whiteheat_command_private *)command_port->private;
while (record->address < 0x1b40) { if (!command_info) {
++record; dbg ("%s - command_info is NULL, exiting.", __FUNCTION__);
return;
} }
while (record->address != 0xffff) { spin_lock_irqsave(&command_info->lock, flags);
response = ezusb_writememory (serial, record->address,
(unsigned char *)record->data, record->data_size, 0xa3); if (data[0] == WHITEHEAT_CMD_COMPLETE) {
if (response < 0) { command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
err("%s - ezusb_writememory failed for first firmware step (%d %04X %p %d)", wake_up_interruptible(&command_info->wait_command);
__FUNCTION__, response, record->address, record->data, record->data_size); } else if (data[0] == WHITEHEAT_CMD_FAILURE) {
break; command_info->command_finished = WHITEHEAT_CMD_FAILURE;
wake_up_interruptible(&command_info->wait_command);
} else if (data[0] == WHITEHEAT_EVENT) {
/* These are unsolicited reports from the firmware, hence no waiting command to wakeup */
dbg("%s - event received", __FUNCTION__);
} else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
memcpy(command_info->result_buffer, &data[1], urb->actual_length - 1);
command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
wake_up_interruptible(&command_info->wait_command);
} else {
dbg("%s - bad reply from firmware", __FUNCTION__);
} }
++record;
/* Continue trying to always read */
command_port->read_urb->dev = serial->dev;
result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
spin_unlock_irqrestore(&command_info->lock, flags);
if (result)
dbg("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
}
static void whiteheat_read_callback(struct urb *urb)
{
struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
struct tty_struct *tty;
unsigned char *data = urb->transfer_buffer;
int i;
int result;
struct whiteheat_private *info = (struct whiteheat_private *)port->private;
unsigned long flags;
dbg("%s - port %d", __FUNCTION__, port->number);
if (!serial) {
dbg("%s - bad serial pointer, exiting", __FUNCTION__);
return;
} }
response = ezusb_set_reset (serial, 1); if (urb->status) {
dbg("%s - nonzero read bulk status received: %d", __FUNCTION__, urb->status);
return;
}
record = &whiteheat_firmware[0]; usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
while (record->address < 0x1b40) {
response = ezusb_writememory (serial, record->address, tty = port->tty;
(unsigned char *)record->data, record->data_size, 0xa0); if (tty && urb->actual_length) {
if (response < 0) { for (i = 0; i < urb->actual_length ; ++i) {
err("%s - ezusb_writememory failed for second firmware step (%d %04X %p %d)", /* if we insert more than TTY_FLIPBUF_SIZE characters, we drop them. */
__FUNCTION__, response, record->address, record->data, record->data_size); if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
break; tty_flip_buffer_push(tty);
} }
++record; /* this doesn't actually push the data through unless tty->low_latency is set */
tty_insert_flip_char(tty, data[i], 0);
}
tty_flip_buffer_push(tty);
} }
response = ezusb_set_reset (serial, 0); spin_lock_irqsave(&info->lock, flags);
if (info->flags & THROTTLED) {
info->flags |= ACTUALLY_THROTTLED;
spin_unlock_irqrestore(&info->lock, flags);
return;
}
spin_unlock_irqrestore(&info->lock, flags);
/* we want this device to fail to have a driver assigned to it. */ /* Continue trying to always read */
return 1; port->read_urb->dev = serial->dev;
result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (result)
err("%s - failed resubmitting read urb, error %d", __FUNCTION__, result);
} }
static int whiteheat_attach (struct usb_serial *serial) static void whiteheat_write_callback(struct urb *urb)
{ {
struct whiteheat_hw_info *hw_info; struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
int pipe; struct usb_serial *serial = get_usb_serial (port, __FUNCTION__);
int ret;
int alen;
__u8 command[2] = { WHITEHEAT_GET_HW_INFO, 0 };
__u8 result[sizeof(*hw_info) + 1];
pipe = usb_rcvbulkpipe (serial->dev, 7); dbg("%s - port %d", __FUNCTION__, port->number);
usb_bulk_msg (serial->dev, pipe, result, sizeof(result), &alen, 2 * HZ);
/*
* We ignore the return code. In the case where rmmod/insmod is
* performed with a WhiteHEAT connected, the above times out
* because the endpoint is already prepped, meaning the below succeeds
* regardless. All other cases the above succeeds.
*/
pipe = usb_sndbulkpipe (serial->dev, 7); if (!serial) {
ret = usb_bulk_msg (serial->dev, pipe, command, sizeof(command), &alen, 2 * HZ); dbg("%s - bad serial pointer, exiting", __FUNCTION__);
if (ret) { return;
err("%s: Couldn't send command [%d]", serial->type->name, ret);
goto error_out;
} else if (alen != sizeof(command)) {
err("%s: Send command incomplete [%d]", serial->type->name, alen);
goto error_out;
} }
pipe = usb_rcvbulkpipe (serial->dev, 7); if (urb->status) {
ret = usb_bulk_msg (serial->dev, pipe, result, sizeof(result), &alen, 2 * HZ); dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
if (ret) { return;
err("%s: Couldn't get results [%d]", serial->type->name, ret);
goto error_out;
} else if (alen != sizeof(result)) {
err("%s: Get results incomplete [%d]", serial->type->name, alen);
goto error_out;
} else if (result[0] != command[0]) {
err("%s: Command failed [%d]", serial->type->name, result[0]);
goto error_out;
} }
hw_info = (struct whiteheat_hw_info *)&result[1]; usb_serial_port_softint((void *)port);
info("%s: Driver %s: Firmware v%d.%02d", serial->type->name, queue_task(&port->tqueue, &tq_immediate);
DRIVER_VERSION, hw_info->sw_major_rev, hw_info->sw_minor_rev); mark_bh(IMMEDIATE_BH);
return 0; return;
error_out:
err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->name);
/*
* Return that we've claimed the interface. A failure here may be
* due to interception by the command_callback routine or other
* causes that don't mean that the firmware isn't running. This may
* change in the future. Probably should actually.
*/
return 0;
} }
static void whiteheat_shutdown (struct usb_serial *serial)
/*****************************************************************************
* Connect Tech's White Heat firmware interface
*****************************************************************************/
static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *data, __u8 datasize)
{ {
struct usb_serial_port *command_port; struct usb_serial_port *command_port;
struct whiteheat_command_private *command_info;
struct whiteheat_private *info;
int timeout;
__u8 *transfer_buffer;
int retval = 0;
unsigned long flags;
dbg("%s", __FUNCTION__); dbg("%s - command %d", __FUNCTION__, command);
/* free up our private data for our command port */ command_port = &port->serial->port[COMMAND_PORT];
command_port = &serial->port[COMMAND_PORT]; command_info = (struct whiteheat_command_private *)command_port->private;
if (command_port->private != NULL) { spin_lock_irqsave(&command_info->lock, flags);
kfree (command_port->private); command_info->command_finished = FALSE;
command_port->private = NULL;
transfer_buffer = (__u8 *)command_port->write_urb->transfer_buffer;
transfer_buffer[0] = command;
memcpy (&transfer_buffer[1], data, datasize);
command_port->write_urb->transfer_buffer_length = datasize + 1;
command_port->write_urb->dev = port->serial->dev;
retval = usb_submit_urb (command_port->write_urb, GFP_KERNEL);
spin_unlock_irqrestore(&command_info->lock, flags);
if (retval) {
dbg("%s - submit urb failed", __FUNCTION__);
goto exit;
} }
return; /* wait for the command to complete */
timeout = COMMAND_TIMEOUT;
while (timeout && (command_info->command_finished == FALSE)) {
timeout = interruptible_sleep_on_timeout (&command_info->wait_command, timeout);
}
spin_lock_irqsave(&command_info->lock, flags);
if (command_info->command_finished == FALSE) {
dbg("%s - command timed out.", __FUNCTION__);
retval = -ETIMEDOUT;
goto exit;
}
if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) {
dbg("%s - command failed.", __FUNCTION__);
retval = -EIO;
goto exit;
}
if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) {
dbg("%s - command completed.", __FUNCTION__);
switch (command) {
case WHITEHEAT_GET_DTR_RTS:
info = (struct whiteheat_private *)port->private;
memcpy(&info->mcr, command_info->result_buffer, sizeof(struct whiteheat_dr_info));
break;
}
}
exit:
spin_unlock_irqrestore(&command_info->lock, flags);
return retval;
} }
static void set_command (struct usb_serial_port *port, unsigned char state, unsigned char command) static int firm_open(struct usb_serial_port *port) {
{ struct whiteheat_simple open_command;
struct whiteheat_rdb_set rdb_command;
open_command.port = port->number - port->serial->minor + 1;
return firm_send_command(port, WHITEHEAT_OPEN, (__u8 *)&open_command, sizeof(open_command));
}
/* send a set rts command to the port */
/* firmware uses 1 based port numbering */
rdb_command.port = port->number - port->serial->minor + 1;
rdb_command.state = state;
whiteheat_send_cmd (port->serial, command, (__u8 *)&rdb_command, sizeof(rdb_command)); static int firm_close(struct usb_serial_port *port) {
struct whiteheat_simple close_command;
close_command.port = port->number - port->serial->minor + 1;
return firm_send_command(port, WHITEHEAT_CLOSE, (__u8 *)&close_command, sizeof(close_command));
} }
static inline void set_rts (struct usb_serial_port *port, unsigned char rts) static int firm_setup_port(struct usb_serial_port *port) {
{ struct whiteheat_port_settings port_settings;
set_command (port, rts, WHITEHEAT_SET_RTS); unsigned int cflag = port->tty->termios->c_cflag;
port_settings.port = port->number + 1;
/* get the byte size */
switch (cflag & CSIZE) {
case CS5: port_settings.bits = 5; break;
case CS6: port_settings.bits = 6; break;
case CS7: port_settings.bits = 7; break;
default:
case CS8: port_settings.bits = 8; break;
}
dbg("%s - data bits = %d", __FUNCTION__, port_settings.bits);
/* determine the parity */
if (cflag & PARENB)
if (cflag & CMSPAR)
if (cflag & PARODD)
port_settings.parity = WHITEHEAT_PAR_MARK;
else
port_settings.parity = WHITEHEAT_PAR_SPACE;
else
if (cflag & PARODD)
port_settings.parity = WHITEHEAT_PAR_ODD;
else
port_settings.parity = WHITEHEAT_PAR_EVEN;
else
port_settings.parity = WHITEHEAT_PAR_NONE;
dbg("%s - parity = %c", __FUNCTION__, port_settings.parity);
/* figure out the stop bits requested */
if (cflag & CSTOPB)
port_settings.stop = 2;
else
port_settings.stop = 1;
dbg("%s - stop bits = %d", __FUNCTION__, port_settings.stop);
/* figure out the flow control settings */
if (cflag & CRTSCTS)
port_settings.hflow = (WHITEHEAT_HFLOW_CTS | WHITEHEAT_HFLOW_RTS);
else
port_settings.hflow = WHITEHEAT_HFLOW_NONE;
dbg("%s - hardware flow control = %s %s %s %s", __FUNCTION__,
(port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "",
(port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "",
(port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "",
(port_settings.hflow & WHITEHEAT_HFLOW_DTR) ? "DTR" : "");
/* determine software flow control */
if (I_IXOFF(port->tty))
port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
else
port_settings.sflow = WHITEHEAT_SFLOW_NONE;
dbg("%s - software flow control = %c", __FUNCTION__, port_settings.sflow);
port_settings.xon = START_CHAR(port->tty);
port_settings.xoff = STOP_CHAR(port->tty);
dbg("%s - XON = %2x, XOFF = %2x", __FUNCTION__, port_settings.xon, port_settings.xoff);
/* get the baud rate wanted */
port_settings.baud = tty_get_baud_rate(port->tty);
dbg("%s - baud rate = %d", __FUNCTION__, port_settings.baud);
/* handle any settings that aren't specified in the tty structure */
port_settings.lloop = 0;
/* now send the message to the device */
return firm_send_command(port, WHITEHEAT_SETUP_PORT, (__u8 *)&port_settings, sizeof(port_settings));
}
static int firm_set_rts(struct usb_serial_port *port, __u8 onoff) {
struct whiteheat_set_rdb rts_command;
rts_command.port = port->number - port->serial->minor + 1;
rts_command.state = onoff;
return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&rts_command, sizeof(rts_command));
}
static int firm_set_dtr(struct usb_serial_port *port, __u8 onoff) {
struct whiteheat_set_rdb dtr_command;
dtr_command.port = port->number - port->serial->minor + 1;
dtr_command.state = onoff;
return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&dtr_command, sizeof(dtr_command));
}
static int firm_set_break(struct usb_serial_port *port, __u8 onoff) {
struct whiteheat_set_rdb break_command;
break_command.port = port->number - port->serial->minor + 1;
break_command.state = onoff;
return firm_send_command(port, WHITEHEAT_SET_RTS, (__u8 *)&break_command, sizeof(break_command));
}
static int firm_purge(struct usb_serial_port *port, __u8 rxtx) {
struct whiteheat_purge purge_command;
purge_command.port = port->number - port->serial->minor + 1;
purge_command.what = rxtx;
return firm_send_command(port, WHITEHEAT_PURGE, (__u8 *)&purge_command, sizeof(purge_command));
}
static int firm_get_dtr_rts(struct usb_serial_port *port) {
struct whiteheat_simple get_dr_command;
get_dr_command.port = port->number - port->serial->minor + 1;
return firm_send_command(port, WHITEHEAT_GET_DTR_RTS, (__u8 *)&get_dr_command, sizeof(get_dr_command));
} }
static inline void set_dtr (struct usb_serial_port *port, unsigned char dtr) static int firm_report_tx_done(struct usb_serial_port *port) {
struct whiteheat_simple close_command;
close_command.port = port->number - port->serial->minor + 1;
return firm_send_command(port, WHITEHEAT_REPORT_TX_DONE, (__u8 *)&close_command, sizeof(close_command));
}
/*****************************************************************************
* Connect Tech's White Heat utility functions
*****************************************************************************/
static int start_command_port(struct usb_serial *serial)
{ {
set_command (port, dtr, WHITEHEAT_SET_DTR); struct usb_serial_port *command_port;
struct whiteheat_command_private *command_info;
unsigned long flags;
int retval = 0;
command_port = &serial->port[COMMAND_PORT];
command_info = (struct whiteheat_command_private *)command_port->private;
spin_lock_irqsave(&command_info->lock, flags);
if (!command_info->port_running) {
command_port->read_urb->dev = serial->dev;
retval = usb_submit_urb(command_port->read_urb, GFP_KERNEL);
if (retval) {
err("%s - failed submitting read urb, error %d", __FUNCTION__, retval);
goto exit;
}
}
command_info->port_running++;
exit:
spin_unlock_irqrestore(&command_info->lock, flags);
return retval;
} }
static inline void set_break (struct usb_serial_port *port, unsigned char brk) static void stop_command_port(struct usb_serial *serial)
{ {
set_command (port, brk, WHITEHEAT_SET_BREAK); struct usb_serial_port *command_port;
struct whiteheat_command_private *command_info;
unsigned long flags;
command_port = &serial->port[COMMAND_PORT];
command_info = (struct whiteheat_command_private *)command_port->private;
spin_lock_irqsave(&command_info->lock, flags);
command_info->port_running--;
if (!command_info->port_running)
usb_unlink_urb(command_port->read_urb);
spin_unlock_irqrestore(&command_info->lock, flags);
} }
/*****************************************************************************
* Connect Tech's White Heat module functions
*****************************************************************************/
static int __init whiteheat_init (void) static int __init whiteheat_init (void)
{ {
usb_serial_register (&whiteheat_fake_device); usb_serial_register (&whiteheat_fake_device);
...@@ -704,4 +1209,3 @@ MODULE_LICENSE("GPL"); ...@@ -704,4 +1209,3 @@ MODULE_LICENSE("GPL");
MODULE_PARM(debug, "i"); MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, "Debug enabled or not"); MODULE_PARM_DESC(debug, "Debug enabled or not");
/* /*
* USB ConnectTech WhiteHEAT driver * USB ConnectTech WhiteHEAT driver
* *
* Copyright (C) 2002
* Connect Tech Inc.
*
* Copyright (C) 1999, 2000 * Copyright (C) 1999, 2000
* Greg Kroah-Hartman (greg@kroah.com) * Greg Kroah-Hartman (greg@kroah.com)
* *
...@@ -20,6 +23,7 @@ ...@@ -20,6 +23,7 @@
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
/* WhiteHEAT commands */ /* WhiteHEAT commands */
#define WHITEHEAT_OPEN 1 /* open the port */ #define WHITEHEAT_OPEN 1 /* open the port */
#define WHITEHEAT_CLOSE 2 /* close the port */ #define WHITEHEAT_CLOSE 2 /* close the port */
...@@ -39,109 +43,192 @@ ...@@ -39,109 +43,192 @@
#define WHITEHEAT_CMD_COMPLETE 16 /* reply for certain commands */ #define WHITEHEAT_CMD_COMPLETE 16 /* reply for certain commands */
#define WHITEHEAT_CMD_FAILURE 17 /* reply for failed commands */ #define WHITEHEAT_CMD_FAILURE 17 /* reply for failed commands */
/* Data for the WHITEHEAT_SETUP_PORT command */
#define WHITEHEAT_CTS_FLOW 0x08 /*
#define WHITEHEAT_RTS_FLOW 0x80 * Commands to the firmware
#define WHITEHEAT_DSR_FLOW 0x10 */
#define WHITEHEAT_DTR_FLOW 0x02
/*
* WHITEHEAT_OPEN
* WHITEHEAT_CLOSE
* WHITEHEAT_STATUS
* WHITEHEAT_GET_DTR_RTS
* WHITEHEAT_REPORT_TX_DONE
*/
struct whiteheat_simple {
__u8 port; /* port number (1 to N) */
};
/*
* WHITEHEAT_SETUP_PORT
*/
#define WHITEHEAT_PAR_NONE 'n' /* no parity */
#define WHITEHEAT_PAR_EVEN 'e' /* even parity */
#define WHITEHEAT_PAR_ODD 'o' /* odd parity */
#define WHITEHEAT_PAR_SPACE '0' /* space (force 0) parity */
#define WHITEHEAT_PAR_MARK '1' /* mark (force 1) parity */
#define WHITEHEAT_SFLOW_NONE 'n' /* no software flow control */
#define WHITEHEAT_SFLOW_RX 'r' /* XOFF/ON is sent when RX fills/empties */
#define WHITEHEAT_SFLOW_TX 't' /* when received XOFF/ON will stop/start TX */
#define WHITEHEAT_SFLOW_RXTX 'b' /* both SFLOW_RX and SFLOW_TX */
#define WHITEHEAT_HFLOW_NONE 0x00 /* no hardware flow control */
#define WHITEHEAT_HFLOW_RTS_TOGGLE 0x01 /* RTS is on during transmit, off otherwise */
#define WHITEHEAT_HFLOW_DTR 0x02 /* DTR is off/on when RX fills/empties */
#define WHITEHEAT_HFLOW_CTS 0x08 /* when received CTS off/on will stop/start TX */
#define WHITEHEAT_HFLOW_DSR 0x10 /* when received DSR off/on will stop/start TX */
#define WHITEHEAT_HFLOW_RTS 0x80 /* RTS is off/on when RX fills/empties */
struct whiteheat_port_settings { struct whiteheat_port_settings {
__u8 port; /* port number (1 to N) */ __u8 port; /* port number (1 to N) */
__u32 baud; /* any value allowed, default 9600, arrives little endian, range is 7 - 460800 */ __u32 baud; /* any value 7 - 460800, firmware calculates best fit; arrives little endian */
__u8 bits; /* 5, 6, 7, or 8, default 8 */ __u8 bits; /* 5, 6, 7, or 8 */
__u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */ __u8 stop; /* 1 or 2, default 1 (2 = 1.5 if bits = 5) */
__u8 parity; /* 'n, e, o, 0, or 1' (ascii), default 'n' __u8 parity; /* see WHITEHEAT_PAR_* above */
* n = none e = even o = odd __u8 sflow; /* see WHITEHEAT_SFLOW_* above */
* 0 = force 0 1 = force 1 */ __u8 xoff; /* XOFF byte value */
__u8 sflow; /* 'n, r, t, or b' (ascii), default 'n' __u8 xon; /* XON byte value */
* n = none __u8 hflow; /* see WHITEHEAT_HFLOW_* above */
* r = receive (XOFF/XON transmitted when receiver fills / empties) __u8 lloop; /* 0/1 turns local loopback mode off/on */
* t = transmit (XOFF/XON received will stop/start TX)
* b = both */
__u8 xoff; /* XOFF byte value, default 0x13 */
__u8 xon; /* XON byte value, default 0x11 */
__u8 hflow; /* bits indicate mode as follows:
* CTS (0x08) (CTS off/on will control/cause TX off/on)
* DSR (0x10) (DSR off/on will control/cause TX off/on)
* RTS (0x80) (RTS off/on when receiver fills/empties)
* DTR (0x02) (DTR off/on when receiver fills/empties) */
__u8 lloop; /* local loopback 0 or 1, default 0 */
} __attribute__ ((packed)); } __attribute__ ((packed));
/* data for WHITEHEAT_SET_RTS, WHITEHEAT_SET_DTR, and WHITEHEAT_SET_BREAK commands */
struct whiteheat_rdb_set { /*
* WHITEHEAT_SET_RTS
* WHITEHEAT_SET_DTR
* WHITEHEAT_SET_BREAK
*/
#define WHITEHEAT_RTS_OFF 0x00
#define WHITEHEAT_RTS_ON 0x01
#define WHITEHEAT_DTR_OFF 0x00
#define WHITEHEAT_DTR_ON 0x01
#define WHITEHEAT_BREAK_OFF 0x00
#define WHITEHEAT_BREAK_ON 0x01
struct whiteheat_set_rdb {
__u8 port; /* port number (1 to N) */ __u8 port; /* port number (1 to N) */
__u8 state; /* 0 = off, non-zero = on */ __u8 state; /* 0/1 turns signal off/on */
}; };
/* data for:
WHITEHEAT_OPEN /*
WHITEHEAT_CLOSE * WHITEHEAT_DUMP
WHITEHEAT_STATUS */
WHITEHEAT_GET_DTR_RTS #define WHITEHEAT_DUMP_MEM_DATA 'd' /* data */
WHITEHEAT_REPORT_TX_DONE */ #define WHITEHEAT_DUMP_MEM_IDATA 'i' /* idata */
struct whiteheat_min_set { #define WHITEHEAT_DUMP_MEM_BDATA 'b' /* bdata */
__u8 port; /* port number (1 to N) */ #define WHITEHEAT_DUMP_MEM_XDATA 'x' /* xdata */
/*
* Allowable address ranges (firmware checks address):
* Type DATA: 0x00 - 0xff
* Type IDATA: 0x80 - 0xff
* Type BDATA: 0x20 - 0x2f
* Type XDATA: 0x0000 - 0xffff
*
* B/I/DATA all read the local memory space
* XDATA reads the external memory space
* BDATA returns bits as bytes
*
* NOTE: 0x80 - 0xff (local space) are the Special Function Registers
* of the 8051, and some have on-read side-effects.
*/
struct whiteheat_dump {
__u8 mem_type; /* see WHITEHEAT_DUMP_* above */
__u16 addr; /* address, see restrictions above */
__u16 length; /* number of bytes to dump, max 63 bytes */
}; };
/* data for WHITEHEAT_PURGE command */
#define WHITEHEAT_PURGE_INPUT 0x01 /*
#define WHITEHEAT_PURGE_OUTPUT 0x02 * WHITEHEAT_PURGE
struct whiteheat_purge_set { */
#define WHITEHEAT_PURGE_RX 0x01 /* purge rx fifos */
#define WHITEHEAT_PURGE_TX 0x02 /* purge tx fifos */
struct whiteheat_purge {
__u8 port; /* port number (1 to N) */ __u8 port; /* port number (1 to N) */
__u8 what; /* bit pattern of what to purge */ __u8 what; /* bit pattern of what to purge */
}; };
/* data for WHITEHEAT_DUMP command */
struct whiteheat_dump_info {
__u8 mem_type; /* memory type: 'd' = data, 'i' = idata, 'b' = bdata, 'x' = xdata */
__u16 addr; /* memory address to dump, address range depends on the above mem_type:
* 'd' = 0 to ff (80 to FF is SFR's)
* 'i' = 80 to ff
* 'b' = 20 to 2f (bits returned as bytes)
* 'x' = 0000 to ffff (also code space) */
__u16 length; /* number of bytes to dump, max 64 */
};
/* data for WHITEHEAT_ECHO command */ /*
struct whiteheat_echo_set { * WHITEHEAT_ECHO
*/
struct whiteheat_echo {
__u8 port; /* port number (1 to N) */ __u8 port; /* port number (1 to N) */
__u8 length; /* length of message to echo */ __u8 length; /* length of message to echo, max 61 bytes */
__u8 echo_data[61]; /* data to echo */ __u8 echo_data[61]; /* data to echo */
}; };
/* data returned from WHITEHEAT_STATUS command */
#define WHITEHEAT_OVERRUN_ERROR 0x02 /*
#define WHITEHEAT_PARITY_ERROR 0x04 * WHITEHEAT_DO_TEST
#define WHITEHEAT_FRAMING_ERROR 0x08 */
#define WHITEHEAT_BREAK_ERROR 0x10 #define WHITEHEAT_TEST_UART_RW 0x01 /* read/write uart registers */
#define WHITEHEAT_TEST_UART_INTR 0x02 /* uart interrupt */
#define WHITEHEAT_OHFLOW 0x01 /* TX is stopped by CTS (waiting for CTS to go ON) */ #define WHITEHEAT_TEST_SETUP_CONT 0x03 /* setup for PORT_CONT/PORT_DISCONT */
#define WHITEHEAT_IHFLOW 0x02 /* remote TX is stopped by RTS */ #define WHITEHEAT_TEST_PORT_CONT 0x04 /* port connect */
#define WHITEHEAT_OSFLOW 0x04 /* TX is stopped by XOFF received (waiting for XON to occur) */ #define WHITEHEAT_TEST_PORT_DISCONT 0x05 /* port disconnect */
#define WHITEHEAT_ISFLOW 0x08 /* remote TX is stopped by XOFF transmitted */ #define WHITEHEAT_TEST_UART_CLK_START 0x06 /* uart clock test start */
#define WHITEHEAT_TX_DONE 0x80 /* TX has completed */ #define WHITEHEAT_TEST_UART_CLK_STOP 0x07 /* uart clock test stop */
#define WHITEHEAT_TEST_MODEM_FT 0x08 /* modem signals, requires a loopback cable/connector */
#define WHITEHEAT_MODEM_EVENT 0x01 #define WHITEHEAT_TEST_ERASE_EEPROM 0x09 /* erase eeprom */
#define WHITEHEAT_ERROR_EVENT 0x02 #define WHITEHEAT_TEST_READ_EEPROM 0x0a /* read eeprom */
#define WHITEHEAT_FLOW_EVENT 0x04 #define WHITEHEAT_TEST_PROGRAM_EEPROM 0x0b /* program eeprom */
#define WHITEHEAT_CONNECT_EVENT 0x08
struct whiteheat_test {
__u8 port; /* port number (1 to n) */
__u8 test; /* see WHITEHEAT_TEST_* above*/
__u8 info[32]; /* additional info */
};
/*
* Replies from the firmware
*/
/*
* WHITEHEAT_STATUS
*/
#define WHITEHEAT_EVENT_MODEM 0x01 /* modem field is valid */
#define WHITEHEAT_EVENT_ERROR 0x02 /* error field is valid */
#define WHITEHEAT_EVENT_FLOW 0x04 /* flow field is valid */
#define WHITEHEAT_EVENT_CONNECT 0x08 /* connect field is valid */
#define WHITEHEAT_FLOW_NONE 0x00 /* no flow control active */
#define WHITEHEAT_FLOW_HARD_OUT 0x01 /* TX is stopped by CTS (waiting for CTS to go on) */
#define WHITEHEAT_FLOW_HARD_IN 0x02 /* remote TX is stopped by RTS */
#define WHITEHEAT_FLOW_SOFT_OUT 0x04 /* TX is stopped by XOFF received (waiting for XON) */
#define WHITEHEAT_FLOW_SOFT_IN 0x08 /* remote TX is stopped by XOFF transmitted */
#define WHITEHEAT_FLOW_TX_DONE 0x80 /* TX has completed */
struct whiteheat_status_info { struct whiteheat_status_info {
__u8 port; /* port number (1 to N) */ __u8 port; /* port number (1 to N) */
__u8 event; /* indicates which of the following bytes are the current event */ __u8 event; /* indicates what the current event is, see WHITEHEAT_EVENT_* above */
__u8 modem; /* modem signal status (copy of UART MSR register) */ __u8 modem; /* modem signal status (copy of uart's MSR register) */
__u8 error; /* PFO and RX break (copy of UART LSR register) */ __u8 error; /* line status (copy of uart's LSR register) */
__u8 flow; /* flow control state */ __u8 flow; /* flow control state, see WHITEHEAT_FLOW_* above */
__u8 connect; /* connect state, non-zero value indicates connected */ __u8 connect; /* 0 means not connected, non-zero means connected */
}; };
/* data returned from WHITEHEAT_EVENT command */
struct whiteheat_event { /*
__u8 port; /* port number (1 to N) */ * WHITEHEAT_GET_DTR_RTS
__u8 event; /* indicates which of the following bytes are the current event */ */
__u8 info; /* either modem, error, flow, or connect information */ struct whiteheat_dr_info {
__u8 mcr; /* copy of uart's MCR register */
}; };
/* data retured by the WHITEHEAT_GET_HW_INFO command */
/*
* WHITEHEAT_GET_HW_INFO
*/
struct whiteheat_hw_info { struct whiteheat_hw_info {
__u8 hw_id; /* hardware id number, WhiteHEAT = 0 */ __u8 hw_id; /* hardware id number, WhiteHEAT = 0 */
__u8 sw_major_rev; /* major version number */ __u8 sw_major_rev; /* major version number */
...@@ -166,5 +253,30 @@ struct whiteheat_hw_info { ...@@ -166,5 +253,30 @@ struct whiteheat_hw_info {
} hw_eeprom_info; /* EEPROM contents */ } hw_eeprom_info; /* EEPROM contents */
}; };
#endif
/*
* WHITEHEAT_EVENT
*/
struct whiteheat_event_info {
__u8 port; /* port number (1 to N) */
__u8 event; /* see whiteheat_status_info.event */
__u8 info; /* see whiteheat_status_info.modem, .error, .flow, .connect */
};
/*
* WHITEHEAT_DO_TEST
*/
#define WHITEHEAT_TEST_FAIL 0x00 /* test failed */
#define WHITEHEAT_TEST_UNKNOWN 0x01 /* unknown test requested */
#define WHITEHEAT_TEST_PASS 0xff /* test passed */
struct whiteheat_test_info {
__u8 port; /* port number (1 to N) */
__u8 test; /* indicates which test this is a response for, see WHITEHEAT_DO_TEST above */
__u8 status; /* see WHITEHEAT_TEST_* above */
__u8 results[32]; /* test-dependent results */
};
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -70,7 +70,7 @@ datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) { ...@@ -70,7 +70,7 @@ datafab_bulk_read(struct us_data *us, unsigned char *data, unsigned int len) {
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("datafab_bulk_read: len = %d\n", len); US_DEBUGP("datafab_bulk_read: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len);
...@@ -82,7 +82,7 @@ datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) { ...@@ -82,7 +82,7 @@ datafab_bulk_write(struct us_data *us, unsigned char *data, unsigned int len) {
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("datafab_bulk_write: len = %d\n", len); US_DEBUGP("datafab_bulk_write: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len);
...@@ -144,12 +144,12 @@ static int datafab_read_data(struct us_data *us, ...@@ -144,12 +144,12 @@ static int datafab_read_data(struct us_data *us,
// send the read command // send the read command
result = datafab_bulk_write(us, command, sizeof(command)); result = datafab_bulk_write(us, command, sizeof(command));
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// read the result // read the result
result = datafab_bulk_read(us, ptr, len); result = datafab_bulk_read(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
sectors -= thistime; sectors -= thistime;
...@@ -171,7 +171,7 @@ static int datafab_read_data(struct us_data *us, ...@@ -171,7 +171,7 @@ static int datafab_read_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -243,17 +243,17 @@ static int datafab_write_data(struct us_data *us, ...@@ -243,17 +243,17 @@ static int datafab_write_data(struct us_data *us,
// send the command // send the command
result = datafab_bulk_write(us, command, sizeof(command)); result = datafab_bulk_write(us, command, sizeof(command));
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// send the data // send the data
result = datafab_bulk_write(us, ptr, len); result = datafab_bulk_write(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// read the result // read the result
result = datafab_bulk_read(us, reply, sizeof(reply)); result = datafab_bulk_read(us, reply, sizeof(reply));
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
if (reply[0] != 0x50 && reply[1] != 0) { if (reply[0] != 0x50 && reply[1] != 0) {
...@@ -280,7 +280,7 @@ static int datafab_write_data(struct us_data *us, ...@@ -280,7 +280,7 @@ static int datafab_write_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -308,11 +308,11 @@ static int datafab_determine_lun(struct us_data *us, ...@@ -308,11 +308,11 @@ static int datafab_determine_lun(struct us_data *us,
command[5] = 0xa0; command[5] = 0xa0;
rc = datafab_bulk_write(us, command, 8); rc = datafab_bulk_write(us, command, 8);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
rc = datafab_bulk_read(us, buf, sizeof(buf)); rc = datafab_bulk_read(us, buf, sizeof(buf));
if (rc == USB_STOR_TRANSPORT_GOOD) { if (rc == USB_STOR_XFER_GOOD) {
info->lun = 0; info->lun = 0;
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
} }
...@@ -320,11 +320,11 @@ static int datafab_determine_lun(struct us_data *us, ...@@ -320,11 +320,11 @@ static int datafab_determine_lun(struct us_data *us,
command[5] = 0xb0; command[5] = 0xb0;
rc = datafab_bulk_write(us, command, 8); rc = datafab_bulk_write(us, command, 8);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
rc = datafab_bulk_read(us, buf, sizeof(buf)); rc = datafab_bulk_read(us, buf, sizeof(buf));
if (rc == USB_STOR_TRANSPORT_GOOD) { if (rc == USB_STOR_XFER_GOOD) {
info->lun = 1; info->lun = 1;
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
} }
...@@ -332,7 +332,7 @@ static int datafab_determine_lun(struct us_data *us, ...@@ -332,7 +332,7 @@ static int datafab_determine_lun(struct us_data *us,
wait_ms(20); wait_ms(20);
} }
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
static int datafab_id_device(struct us_data *us, static int datafab_id_device(struct us_data *us,
...@@ -358,22 +358,23 @@ static int datafab_id_device(struct us_data *us, ...@@ -358,22 +358,23 @@ static int datafab_id_device(struct us_data *us,
command[5] += (info->lun << 4); command[5] += (info->lun << 4);
rc = datafab_bulk_write(us, command, 8); rc = datafab_bulk_write(us, command, 8);
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
// we'll go ahead and extract the media capacity while we're here... // we'll go ahead and extract the media capacity while we're here...
// //
rc = datafab_bulk_read(us, reply, sizeof(reply)); rc = datafab_bulk_read(us, reply, sizeof(reply));
if (rc == USB_STOR_TRANSPORT_GOOD) { if (rc == USB_STOR_XFER_GOOD) {
// capacity is at word offset 57-58 // capacity is at word offset 57-58
// //
info->sectors = ((u32)(reply[117]) << 24) | info->sectors = ((u32)(reply[117]) << 24) |
((u32)(reply[116]) << 16) | ((u32)(reply[116]) << 16) |
((u32)(reply[115]) << 8) | ((u32)(reply[115]) << 8) |
((u32)(reply[114]) ); ((u32)(reply[114]) );
return USB_STOR_TRANSPORT_GOOD;
} }
return rc; return USB_STOR_TRANSPORT_ERROR;
} }
......
...@@ -197,7 +197,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -197,7 +197,7 @@ freecom_readdata (Scsi_Cmnd *srb, struct us_data *us,
/* has the current command been aborted? */ /* has the current command been aborted? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_readdata(): transfer aborted\n"); US_DEBUGP("freecom_readdata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -238,7 +238,7 @@ freecom_writedata (Scsi_Cmnd *srb, struct us_data *us, ...@@ -238,7 +238,7 @@ freecom_writedata (Scsi_Cmnd *srb, struct us_data *us,
/* has the current command been aborted? */ /* has the current command been aborted? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_writedata(): transfer aborted\n"); US_DEBUGP("freecom_writedata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -301,7 +301,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -301,7 +301,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -316,7 +316,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -316,7 +316,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
US_DEBUG(pdump ((void *) fst, partial)); US_DEBUG(pdump ((void *) fst, partial));
...@@ -354,7 +354,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -354,7 +354,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -369,7 +369,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -369,7 +369,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
/* we canceled this transfer */ /* we canceled this transfer */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n"); US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
US_DEBUG(pdump ((void *) fst, partial)); US_DEBUG(pdump ((void *) fst, partial));
...@@ -430,7 +430,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -430,7 +430,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP ("freecom_transport: transfer aborted\n"); US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (partial != 4 || result != 0) if (partial != 4 || result != 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -459,7 +459,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -459,7 +459,7 @@ int freecom_transport(Scsi_Cmnd *srb, struct us_data *us)
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP ("freecom_transport: transfer aborted\n"); US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (partial != 4 || result != 0) if (partial != 4 || result != 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
......
...@@ -65,7 +65,7 @@ static inline int jumpshot_bulk_read(struct us_data *us, ...@@ -65,7 +65,7 @@ static inline int jumpshot_bulk_read(struct us_data *us,
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("jumpshot_bulk_read: len = %d\n", len); US_DEBUGP("jumpshot_bulk_read: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_READ, data, len, &act_len);
...@@ -79,7 +79,7 @@ static inline int jumpshot_bulk_write(struct us_data *us, ...@@ -79,7 +79,7 @@ static inline int jumpshot_bulk_write(struct us_data *us,
unsigned int act_len; /* ignored */ unsigned int act_len; /* ignored */
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
US_DEBUGP("jumpshot_bulk_write: len = %d\n", len); US_DEBUGP("jumpshot_bulk_write: len = %d\n", len);
return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len); return usb_storage_raw_bulk(us, SCSI_DATA_WRITE, data, len, &act_len);
...@@ -168,7 +168,7 @@ static int jumpshot_read_data(struct us_data *us, ...@@ -168,7 +168,7 @@ static int jumpshot_read_data(struct us_data *us,
// read the result // read the result
result = jumpshot_bulk_read(us, ptr, len); result = jumpshot_bulk_read(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
US_DEBUGP("jumpshot_read_data: %d bytes\n", len); US_DEBUGP("jumpshot_read_data: %d bytes\n", len);
...@@ -192,7 +192,7 @@ static int jumpshot_read_data(struct us_data *us, ...@@ -192,7 +192,7 @@ static int jumpshot_read_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -253,7 +253,7 @@ static int jumpshot_write_data(struct us_data *us, ...@@ -253,7 +253,7 @@ static int jumpshot_write_data(struct us_data *us,
// send the data // send the data
result = jumpshot_bulk_write(us, ptr, len); result = jumpshot_bulk_write(us, ptr, len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
goto leave; goto leave;
// read the result. apparently the bulk write can complete // read the result. apparently the bulk write can complete
...@@ -288,7 +288,7 @@ static int jumpshot_write_data(struct us_data *us, ...@@ -288,7 +288,7 @@ static int jumpshot_write_data(struct us_data *us,
leave: leave:
if (use_sg) if (use_sg)
kfree(buffer); kfree(buffer);
return result; return USB_STOR_TRANSPORT_ERROR;
} }
static int jumpshot_id_device(struct us_data *us, static int jumpshot_id_device(struct us_data *us,
...@@ -314,8 +314,8 @@ static int jumpshot_id_device(struct us_data *us, ...@@ -314,8 +314,8 @@ static int jumpshot_id_device(struct us_data *us,
// read the reply // read the reply
rc = jumpshot_bulk_read(us, reply, sizeof(reply)); rc = jumpshot_bulk_read(us, reply, sizeof(reply));
if (rc != USB_STOR_TRANSPORT_GOOD) if (rc != USB_STOR_XFER_GOOD)
return rc; return USB_STOR_TRANSPORT_ERROR;
info->sectors = ((u32)(reply[117]) << 24) | info->sectors = ((u32)(reply[117]) << 24) |
((u32)(reply[116]) << 16) | ((u32)(reply[116]) << 16) |
......
...@@ -61,7 +61,7 @@ usb_storage_send_control(struct us_data *us, ...@@ -61,7 +61,7 @@ usb_storage_send_control(struct us_data *us,
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_send_control(): transfer aborted\n"); US_DEBUGP("usb_stor_send_control(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
// Check the return code for the command. // Check the return code for the command.
...@@ -70,7 +70,7 @@ usb_storage_send_control(struct us_data *us, ...@@ -70,7 +70,7 @@ usb_storage_send_control(struct us_data *us,
/* a stall indicates a protocol error */ /* a stall indicates a protocol error */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("-- Stall on control pipe\n"); US_DEBUGP("-- Stall on control pipe\n");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
/* Uh oh... serious problem here */ /* Uh oh... serious problem here */
...@@ -100,14 +100,14 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -100,14 +100,14 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
" pipe 0x%x, stalled at %d bytes\n", " pipe 0x%x, stalled at %d bytes\n",
pipe, *act_len); pipe, *act_len);
if (usb_stor_clear_halt(us, pipe) < 0) if (usb_stor_clear_halt(us, pipe) < 0)
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
/* return US_BULK_TRANSFER_SHORT; */ return USB_STOR_XFER_STALLED;
} }
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_storage_raw_bulk(): transfer aborted\n"); US_DEBUGP("usb_storage_raw_bulk(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_XFER_ABORTED;
} }
if (result) { if (result) {
...@@ -122,13 +122,13 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -122,13 +122,13 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
US_DEBUGP("raw_bulk(): unknown error %d\n", US_DEBUGP("raw_bulk(): unknown error %d\n",
result); result);
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
} }
if (*act_len != len) { if (*act_len != len) {
US_DEBUGP("Warning: Transferred only %d of %d bytes\n", US_DEBUGP("Warning: Transferred only %d of %d bytes\n",
*act_len, len); *act_len, len);
return US_BULK_TRANSFER_SHORT; return USB_STOR_XFER_SHORT;
} }
#if 0 #if 0
...@@ -137,7 +137,7 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data, ...@@ -137,7 +137,7 @@ usb_storage_raw_bulk(struct us_data *us, int direction, unsigned char *data,
*act_len, len); *act_len, len);
#endif #endif
return US_BULK_TRANSFER_GOOD; return USB_STOR_XFER_GOOD;
} }
int int
...@@ -145,14 +145,14 @@ usb_storage_bulk_transport(struct us_data *us, int direction, ...@@ -145,14 +145,14 @@ usb_storage_bulk_transport(struct us_data *us, int direction,
unsigned char *data, unsigned int len, unsigned char *data, unsigned int len,
int use_sg) { int use_sg) {
int result = USB_STOR_TRANSPORT_GOOD; int result = USB_STOR_XFER_ERROR;
int transferred = 0; int transferred = 0;
int i; int i;
struct scatterlist *sg; struct scatterlist *sg;
unsigned int act_len; unsigned int act_len;
if (len == 0) if (len == 0)
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_XFER_GOOD;
#if DEBUG_PRCT #if DEBUG_PRCT
...@@ -196,7 +196,7 @@ usb_storage_bulk_transport(struct us_data *us, int direction, ...@@ -196,7 +196,7 @@ usb_storage_bulk_transport(struct us_data *us, int direction,
result = usb_storage_raw_bulk(us, direction, result = usb_storage_raw_bulk(us, direction,
buf, length, &act_len); buf, length, &act_len);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
break; break;
transferred += length; transferred += length;
} }
......
...@@ -285,12 +285,14 @@ sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) { ...@@ -285,12 +285,14 @@ sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) {
} }
result = usb_storage_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen, &act_len); result = usb_storage_raw_bulk(us, SCSI_DATA_READ, sensebuf, buflen, &act_len);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("request sense bulk in failed\n"); US_DEBUGP("request sense bulk in failed\n");
else return USB_STOR_TRANSPORT_ERROR;
}
else {
US_DEBUGP("request sense worked\n"); US_DEBUGP("request sense worked\n");
return USB_STOR_TRANSPORT_GOOD;
return result; }
} }
/* /*
...@@ -344,11 +346,12 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress, ...@@ -344,11 +346,12 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
buf, bulklen, use_sg); buf, bulklen, use_sg);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for bulk_transport in sddr09_read2%d %d\n", US_DEBUGP("Result for bulk_transport in sddr09_read2%d %d\n",
x, result); x, result);
return USB_STOR_TRANSPORT_ERROR;
return result; }
return USB_STOR_TRANSPORT_GOOD;
} }
/* /*
...@@ -510,11 +513,12 @@ sddr09_writeX(struct us_data *us, ...@@ -510,11 +513,12 @@ sddr09_writeX(struct us_data *us,
result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE,
buf, bulklen, use_sg); buf, bulklen, use_sg);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for bulk_transport in sddr09_writeX %d\n", US_DEBUGP("Result for bulk_transport in sddr09_writeX %d\n",
result); result);
return USB_STOR_TRANSPORT_ERROR;
return result; }
return USB_STOR_TRANSPORT_GOOD;
} }
/* erase address, write same address */ /* erase address, write same address */
...@@ -590,13 +594,14 @@ sddr09_read_sg_test_only(struct us_data *us) { ...@@ -590,13 +594,14 @@ sddr09_read_sg_test_only(struct us_data *us) {
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
buf, bulklen, 0); buf, bulklen, 0);
if (result != USB_STOR_TRANSPORT_GOOD) kfree(buf);
if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for bulk_transport in sddr09_read_sg %d\n", US_DEBUGP("Result for bulk_transport in sddr09_read_sg %d\n",
result); result);
return USB_STOR_TRANSPORT_ERROR;
}
kfree(buf); return USB_STOR_TRANSPORT_GOOD;
return result;
} }
#endif #endif
...@@ -629,7 +634,8 @@ sddr09_read_status(struct us_data *us, unsigned char *status) { ...@@ -629,7 +634,8 @@ sddr09_read_status(struct us_data *us, unsigned char *status) {
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, result = usb_storage_bulk_transport(us, SCSI_DATA_READ,
data, sizeof(data), 0); data, sizeof(data), 0);
*status = data[0]; *status = data[0];
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
static int static int
...@@ -953,7 +959,8 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { ...@@ -953,7 +959,8 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
deviceID[i] = content[i]; deviceID[i] = content[i];
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
static int static int
...@@ -1549,7 +1556,8 @@ int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1549,7 +1556,8 @@ int sddr09_transport(Scsi_Cmnd *srb, struct us_data *us)
srb->request_bufflen, srb->request_bufflen,
srb->use_sg); srb->use_sg);
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
return USB_STOR_TRANSPORT_GOOD; return USB_STOR_TRANSPORT_GOOD;
......
...@@ -101,16 +101,16 @@ static int sddr55_status(struct us_data *us) ...@@ -101,16 +101,16 @@ static int sddr55_status(struct us_data *us)
US_DEBUGP("Result for send_command in status %d\n", US_DEBUGP("Result for send_command in status %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
return result; return USB_STOR_TRANSPORT_ERROR;
} }
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 4); SCSI_DATA_READ, status, 4);
/* expect to get short transfer if no card fitted */ /* expect to get short transfer if no card fitted */
if (result == US_BULK_TRANSFER_SHORT) { if (result == USB_STOR_XFER_SHORT || result == USB_STOR_XFER_STALLED) {
/* had a short transfer, no card inserted, free map memory */ /* had a short transfer, no card inserted, free map memory */
if (info->lba_to_pba) if (info->lba_to_pba)
kfree(info->lba_to_pba); kfree(info->lba_to_pba);
...@@ -123,12 +123,12 @@ static int sddr55_status(struct us_data *us) ...@@ -123,12 +123,12 @@ static int sddr55_status(struct us_data *us)
info->force_read_only = 0; info->force_read_only = 0;
set_sense_info (2, 0x3a, 0); /* not ready, medium not present */ set_sense_info (2, 0x3a, 0); /* not ready, medium not present */
return result; return USB_STOR_TRANSPORT_FAILED;
} }
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
return result; return USB_STOR_TRANSPORT_FAILED;
} }
/* check write protect status */ /* check write protect status */
...@@ -138,11 +138,12 @@ static int sddr55_status(struct us_data *us) ...@@ -138,11 +138,12 @@ static int sddr55_status(struct us_data *us)
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2); SCSI_DATA_READ, status, 2);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
set_sense_info (4, 0, 0); /* hardware error */ set_sense_info (4, 0, 0); /* hardware error */
} }
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_FAILED);
} }
...@@ -214,23 +215,29 @@ static int sddr55_read_data(struct us_data *us, ...@@ -214,23 +215,29 @@ static int sddr55_read_data(struct us_data *us,
US_DEBUGP("Result for send_command in read_data %d\n", US_DEBUGP("Result for send_command in read_data %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
goto leave; goto leave;
}
/* read data */ /* read data */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, ptr, SCSI_DATA_READ, ptr,
pages<<info->pageshift); pages<<info->pageshift);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
goto leave; goto leave;
}
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, status, 2); SCSI_DATA_READ, status, 2);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_TRANSPORT_ERROR;
goto leave; goto leave;
}
/* check status for error */ /* check status for error */
if (status[0] == 0xff && status[1] == 0x4) { if (status[0] == 0xff && status[1] == 0x4) {
...@@ -247,6 +254,7 @@ static int sddr55_read_data(struct us_data *us, ...@@ -247,6 +254,7 @@ static int sddr55_read_data(struct us_data *us,
} }
us_copy_to_sgbuf_all(buffer, len, content, use_sg); us_copy_to_sgbuf_all(buffer, len, content, use_sg);
result = USB_STOR_TRANSPORT_GOOD;
leave: leave:
if (use_sg) if (use_sg)
...@@ -374,12 +382,13 @@ static int sddr55_write_data(struct us_data *us, ...@@ -374,12 +382,13 @@ static int sddr55_write_data(struct us_data *us,
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_WRITE, command, 8); SCSI_DATA_WRITE, command, 8);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for send_command in write_data %d\n", US_DEBUGP("Result for send_command in write_data %d\n",
result); result);
/* set_sense_info is superfluous here? */ /* set_sense_info is superfluous here? */
set_sense_info (3, 0x3, 0);/* peripheral write error */ set_sense_info (3, 0x3, 0);/* peripheral write error */
result = USB_STOR_TRANSPORT_FAILED;
goto leave; goto leave;
} }
...@@ -388,24 +397,26 @@ static int sddr55_write_data(struct us_data *us, ...@@ -388,24 +397,26 @@ static int sddr55_write_data(struct us_data *us,
SCSI_DATA_WRITE, ptr, SCSI_DATA_WRITE, ptr,
pages<<info->pageshift); pages<<info->pageshift);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for send_data in write_data %d\n", US_DEBUGP("Result for send_data in write_data %d\n",
result); result);
/* set_sense_info is superfluous here? */ /* set_sense_info is superfluous here? */
set_sense_info (3, 0x3, 0);/* peripheral write error */ set_sense_info (3, 0x3, 0);/* peripheral write error */
result = USB_STOR_TRANSPORT_FAILED;
goto leave; goto leave;
} }
/* now read status */ /* now read status */
result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6); result = sddr55_bulk_transport(us, SCSI_DATA_READ, status, 6);
if (result != US_BULK_TRANSFER_GOOD) { if (result != USB_STOR_XFER_GOOD) {
US_DEBUGP("Result for get_status in write_data %d\n", US_DEBUGP("Result for get_status in write_data %d\n",
result); result);
/* set_sense_info is superfluous here? */ /* set_sense_info is superfluous here? */
set_sense_info (3, 0x3, 0);/* peripheral write error */ set_sense_info (3, 0x3, 0);/* peripheral write error */
result = USB_STOR_TRANSPORT_FAILED;
goto leave; goto leave;
} }
...@@ -446,6 +457,7 @@ static int sddr55_write_data(struct us_data *us, ...@@ -446,6 +457,7 @@ static int sddr55_write_data(struct us_data *us,
sectors -= pages >> info->smallpageshift; sectors -= pages >> info->smallpageshift;
ptr += (pages << info->pageshift); ptr += (pages << info->pageshift);
} }
result = USB_STOR_TRANSPORT_GOOD;
leave: leave:
if (use_sg) if (use_sg)
...@@ -468,14 +480,14 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -468,14 +480,14 @@ static int sddr55_read_deviceID(struct us_data *us,
US_DEBUGP("Result of send_control for device ID is %d\n", US_DEBUGP("Result of send_control for device ID is %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
result = sddr55_bulk_transport(us, result = sddr55_bulk_transport(us,
SCSI_DATA_READ, content, 4); SCSI_DATA_READ, content, 4);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
*manufacturerID = content[0]; *manufacturerID = content[0];
*deviceID = content[1]; *deviceID = content[1];
...@@ -485,7 +497,7 @@ static int sddr55_read_deviceID(struct us_data *us, ...@@ -485,7 +497,7 @@ static int sddr55_read_deviceID(struct us_data *us,
SCSI_DATA_READ, content, 2); SCSI_DATA_READ, content, 2);
} }
return result; return USB_STOR_TRANSPORT_GOOD;
} }
...@@ -510,7 +522,7 @@ static unsigned long sddr55_get_capacity(struct us_data *us) { ...@@ -510,7 +522,7 @@ static unsigned long sddr55_get_capacity(struct us_data *us) {
US_DEBUGP("Result of read_deviceID is %d\n", US_DEBUGP("Result of read_deviceID is %d\n",
result); result);
if (result != US_BULK_TRANSFER_GOOD) if (result != USB_STOR_XFER_GOOD)
return 0; return 0;
US_DEBUGP("Device ID = %02X\n", deviceID); US_DEBUGP("Device ID = %02X\n", deviceID);
...@@ -603,21 +615,21 @@ static int sddr55_read_map(struct us_data *us) { ...@@ -603,21 +615,21 @@ static int sddr55_read_map(struct us_data *us) {
result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8); result = sddr55_bulk_transport(us, SCSI_DATA_WRITE, command, 8);
if ( result != US_BULK_TRANSFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
result = sddr55_bulk_transport(us, SCSI_DATA_READ, buffer, numblocks * 2); result = sddr55_bulk_transport(us, SCSI_DATA_READ, buffer, numblocks * 2);
if ( result != US_BULK_TRANSFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2); result = sddr55_bulk_transport(us, SCSI_DATA_READ, command, 2);
if ( result != US_BULK_TRANSFER_GOOD) { if ( result != USB_STOR_XFER_GOOD) {
kfree (buffer); kfree (buffer);
return -1; return -1;
} }
......
...@@ -153,7 +153,8 @@ int usbat_read_block(struct us_data *us, ...@@ -153,7 +153,8 @@ int usbat_read_block(struct us_data *us,
result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, len, use_sg); result = usb_storage_bulk_transport(us, SCSI_DATA_READ, content, len, use_sg);
return result; return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
} }
/* /*
...@@ -234,8 +235,8 @@ int usbat_write_block(struct us_data *us, ...@@ -234,8 +235,8 @@ int usbat_write_block(struct us_data *us,
result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg); result = usb_storage_bulk_transport(us, SCSI_DATA_WRITE, content, len, use_sg);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
return usbat_wait_not_busy(us, minutes); return usbat_wait_not_busy(us, minutes);
} }
...@@ -309,8 +310,8 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -309,8 +310,8 @@ int usbat_rw_block_test(struct us_data *us,
SCSI_DATA_WRITE, SCSI_DATA_WRITE,
data, num_registers*2, 0); data, num_registers*2, 0);
if (result!=USB_STOR_TRANSPORT_GOOD) if (result!=USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
} }
...@@ -341,7 +342,8 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -341,7 +342,8 @@ int usbat_rw_block_test(struct us_data *us,
* transferred. * transferred.
*/ */
if (result == US_BULK_TRANSFER_SHORT) { if (result == USB_STOR_XFER_SHORT ||
result == USB_STOR_XFER_STALLED) {
/* /*
* If we're reading and we stalled, then clear * If we're reading and we stalled, then clear
...@@ -373,8 +375,8 @@ int usbat_rw_block_test(struct us_data *us, ...@@ -373,8 +375,8 @@ int usbat_rw_block_test(struct us_data *us,
US_DEBUGP("Redoing %s\n", US_DEBUGP("Redoing %s\n",
direction==SCSI_DATA_WRITE ? "write" : "read"); direction==SCSI_DATA_WRITE ? "write" : "read");
} else if (result != US_BULK_TRANSFER_GOOD) } else if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
else else
return usbat_wait_not_busy(us, minutes); return usbat_wait_not_busy(us, minutes);
...@@ -425,8 +427,8 @@ int usbat_multiple_write(struct us_data *us, ...@@ -425,8 +427,8 @@ int usbat_multiple_write(struct us_data *us,
result = usb_storage_bulk_transport(us, result = usb_storage_bulk_transport(us,
SCSI_DATA_WRITE, data, num_registers*2, 0); SCSI_DATA_WRITE, data, num_registers*2, 0);
if (result != USB_STOR_TRANSPORT_GOOD) if (result != USB_STOR_XFER_GOOD)
return result; return USB_STOR_TRANSPORT_ERROR;
return usbat_wait_not_busy(us, 0); return usbat_wait_not_busy(us, 0);
} }
......
...@@ -572,36 +572,37 @@ int usb_stor_transfer_partial(struct us_data *us, char *buf, int length) ...@@ -572,36 +572,37 @@ int usb_stor_transfer_partial(struct us_data *us, char *buf, int length)
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe); US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
if (usb_stor_clear_halt(us, pipe) < 0) if (usb_stor_clear_halt(us, pipe) < 0)
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
return USB_STOR_XFER_STALLED;
} }
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_transfer_partial(): transfer aborted\n"); US_DEBUGP("usb_stor_transfer_partial(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_XFER_ABORTED;
}
/* did we send all the data? */
if (partial == length) {
US_DEBUGP("usb_stor_transfer_partial(): transfer complete\n");
return US_BULK_TRANSFER_GOOD;
} }
/* NAK - that means we've retried a few times already */ /* NAK - that means we've retried a few times already */
if (result == -ETIMEDOUT) { if (result == -ETIMEDOUT) {
US_DEBUGP("usb_stor_transfer_partial(): device NAKed\n"); US_DEBUGP("usb_stor_transfer_partial(): device NAKed\n");
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
} }
/* the catch-all error case */ /* the catch-all error case */
if (result) { if (result) {
US_DEBUGP("usb_stor_transfer_partial(): unknown error\n"); US_DEBUGP("usb_stor_transfer_partial(): unknown error\n");
return US_BULK_TRANSFER_FAILED; return USB_STOR_XFER_ERROR;
}
/* did we send all the data? */
if (partial == length) {
US_DEBUGP("usb_stor_transfer_partial(): transfer complete\n");
return USB_STOR_XFER_GOOD;
} }
/* no error code, so we must have transferred some data, /* no error code, so we must have transferred some data,
* just not all of it */ * just not all of it */
return US_BULK_TRANSFER_SHORT; return USB_STOR_XFER_SHORT;
} }
/* /*
...@@ -739,7 +740,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -739,7 +740,7 @@ void usb_stor_invoke_transport(Scsi_Cmnd *srb, struct us_data *us)
* Also, if we have a short transfer on a command that can't have * Also, if we have a short transfer on a command that can't have
* a short transfer, we're going to do this. * a short transfer, we're going to do this.
*/ */
if ((srb->result == US_BULK_TRANSFER_SHORT) && if ((srb->result == USB_STOR_XFER_SHORT) &&
!((srb->cmnd[0] == REQUEST_SENSE) || !((srb->cmnd[0] == REQUEST_SENSE) ||
(srb->cmnd[0] == INQUIRY) || (srb->cmnd[0] == INQUIRY) ||
(srb->cmnd[0] == MODE_SENSE) || (srb->cmnd[0] == MODE_SENSE) ||
...@@ -995,13 +996,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -995,13 +996,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_control_msg(): transfer aborted\n"); US_DEBUGP("usb_stor_control_msg(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* a stall indicates a protocol error */ /* a stall indicates a protocol error */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("-- Stall on control pipe\n"); US_DEBUGP("-- Stall on control pipe\n");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
if (result < 0) { if (result < 0) {
...@@ -1017,13 +1018,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1017,13 +1018,13 @@ int usb_stor_CBI_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("CBI data stage result is 0x%x\n", result); US_DEBUGP("CBI data stage result is 0x%x\n", result);
/* report any errors */ /* report any errors */
if (result == US_BULK_TRANSFER_ABORTED) { if (result == USB_STOR_XFER_ABORTED) {
clear_bit(US_FLIDX_IP_WANTED, &us->flags); clear_bit(US_FLIDX_IP_WANTED, &us->flags);
return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result == US_BULK_TRANSFER_FAILED) { if (result == USB_STOR_XFER_ERROR) {
clear_bit(US_FLIDX_IP_WANTED, &us->flags); clear_bit(US_FLIDX_IP_WANTED, &us->flags);
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
} }
...@@ -1103,13 +1104,13 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1103,13 +1104,13 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_CB_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_CB_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* a stall indicates a protocol error */ /* a stall indicates a protocol error */
if (result == -EPIPE) { if (result == -EPIPE) {
US_DEBUGP("-- Stall on control pipe\n"); US_DEBUGP("-- Stall on control pipe\n");
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
/* Uh oh... serious problem here */ /* Uh oh... serious problem here */
...@@ -1124,11 +1125,11 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1124,11 +1125,11 @@ int usb_stor_CB_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("CB data stage result is 0x%x\n", result); US_DEBUGP("CB data stage result is 0x%x\n", result);
/* report any errors */ /* report any errors */
if (result == US_BULK_TRANSFER_ABORTED) { if (result == USB_STOR_XFER_ABORTED) {
return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result == US_BULK_TRANSFER_FAILED) { if (result == USB_STOR_XFER_ERROR) {
return USB_STOR_TRANSPORT_FAILED; return USB_STOR_TRANSPORT_ERROR;
} }
} }
...@@ -1207,7 +1208,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1207,7 +1208,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* if we stall, we need to clear it before we go on */ /* if we stall, we need to clear it before we go on */
...@@ -1218,7 +1219,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1218,7 +1219,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result < 0) if (result < 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -1237,7 +1238,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1237,7 +1238,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
US_DEBUGP("Bulk data transfer result 0x%x\n", result); US_DEBUGP("Bulk data transfer result 0x%x\n", result);
/* if it was aborted, we need to indicate that */ /* if it was aborted, we need to indicate that */
if (result == US_BULK_TRANSFER_ABORTED) if (result == USB_STOR_XFER_ABORTED)
return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
} }
...@@ -1257,7 +1258,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1257,7 +1258,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* did the attempt to read the CSW fail? */ /* did the attempt to read the CSW fail? */
...@@ -1268,7 +1269,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1268,7 +1269,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
if (result < 0) if (result < 0)
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
...@@ -1281,7 +1282,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1281,7 +1282,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
/* if it fails again, we need a reset and return an error*/ /* if it fails again, we need a reset and return an error*/
...@@ -1292,7 +1293,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us) ...@@ -1292,7 +1293,7 @@ int usb_stor_Bulk_transport(Scsi_Cmnd *srb, struct us_data *us)
/* did we abort this command? */ /* did we abort this command? */
if (atomic_read(&us->sm_state) == US_STATE_ABORTING) { if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n"); US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED; return USB_STOR_TRANSPORT_ABORTED;
} }
return USB_STOR_TRANSPORT_ERROR; return USB_STOR_TRANSPORT_ERROR;
} }
......
...@@ -115,12 +115,13 @@ struct bulk_cs_wrap { ...@@ -115,12 +115,13 @@ struct bulk_cs_wrap {
#define US_BULK_GET_MAX_LUN 0xfe #define US_BULK_GET_MAX_LUN 0xfe
/* /*
* usb_stor_transfer() return codes * usb_stor_transfer() return codes, in order of severity
*/ */
#define US_BULK_TRANSFER_GOOD 0 /* good transfer */ #define USB_STOR_XFER_GOOD 0 /* good transfer */
#define US_BULK_TRANSFER_SHORT 1 /* transfered less than expected */ #define USB_STOR_XFER_SHORT 1 /* transfered less than expected */
#define US_BULK_TRANSFER_FAILED 2 /* transfer died in the middle */ #define USB_STOR_XFER_STALLED 2 /* endpoint stalled */
#define US_BULK_TRANSFER_ABORTED 3 /* transfer canceled */ #define USB_STOR_XFER_ERROR 3 /* transfer died in the middle */
#define USB_STOR_XFER_ABORTED 4 /* transfer canceled */
/* /*
* Transport return codes * Transport return codes
......
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