| .. | .. |
|---|
| 15 | 15 | #include <linux/console.h> |
|---|
| 16 | 16 | #include <linux/errno.h> |
|---|
| 17 | 17 | #include <linux/init.h> |
|---|
| 18 | +#include <linux/iopoll.h> |
|---|
| 18 | 19 | #include <linux/pci_regs.h> |
|---|
| 19 | 20 | #include <linux/pci_ids.h> |
|---|
| 20 | 21 | #include <linux/usb/ch9.h> |
|---|
| .. | .. |
|---|
| 161 | 162 | static int dbgp_wait_until_complete(void) |
|---|
| 162 | 163 | { |
|---|
| 163 | 164 | u32 ctrl; |
|---|
| 164 | | - int loop = DBGP_TIMEOUT; |
|---|
| 165 | + int ret; |
|---|
| 165 | 166 | |
|---|
| 166 | | - do { |
|---|
| 167 | | - ctrl = readl(&ehci_debug->control); |
|---|
| 168 | | - /* Stop when the transaction is finished */ |
|---|
| 169 | | - if (ctrl & DBGP_DONE) |
|---|
| 170 | | - break; |
|---|
| 171 | | - udelay(1); |
|---|
| 172 | | - } while (--loop > 0); |
|---|
| 173 | | - |
|---|
| 174 | | - if (!loop) |
|---|
| 167 | + ret = readl_poll_timeout_atomic(&ehci_debug->control, ctrl, |
|---|
| 168 | + (ctrl & DBGP_DONE), 1, DBGP_TIMEOUT); |
|---|
| 169 | + if (ret) |
|---|
| 175 | 170 | return -DBGP_TIMEOUT; |
|---|
| 176 | 171 | |
|---|
| 177 | 172 | /* |
|---|
| .. | .. |
|---|
| 631 | 626 | if (!(portsc & PORT_RESET)) |
|---|
| 632 | 627 | break; |
|---|
| 633 | 628 | } |
|---|
| 634 | | - if (portsc & PORT_RESET) { |
|---|
| 635 | | - /* force reset to complete */ |
|---|
| 636 | | - loop = 100 * 1000; |
|---|
| 637 | | - writel(portsc & ~(PORT_RWC_BITS | PORT_RESET), |
|---|
| 638 | | - &ehci_regs->port_status[port - 1]); |
|---|
| 639 | | - do { |
|---|
| 640 | | - udelay(1); |
|---|
| 641 | | - portsc = readl(&ehci_regs->port_status[port-1]); |
|---|
| 642 | | - } while ((portsc & PORT_RESET) && (--loop > 0)); |
|---|
| 643 | | - } |
|---|
| 629 | + if (portsc & PORT_RESET) { |
|---|
| 630 | + /* force reset to complete */ |
|---|
| 631 | + loop = 100 * 1000; |
|---|
| 632 | + writel(portsc & ~(PORT_RWC_BITS | PORT_RESET), |
|---|
| 633 | + &ehci_regs->port_status[port - 1]); |
|---|
| 634 | + do { |
|---|
| 635 | + udelay(1); |
|---|
| 636 | + portsc = readl(&ehci_regs->port_status[port-1]); |
|---|
| 637 | + } while ((portsc & PORT_RESET) && (--loop > 0)); |
|---|
| 638 | + } |
|---|
| 644 | 639 | |
|---|
| 645 | | - /* Device went away? */ |
|---|
| 646 | | - if (!(portsc & PORT_CONNECT)) |
|---|
| 647 | | - return -ENOTCONN; |
|---|
| 640 | + /* Device went away? */ |
|---|
| 641 | + if (!(portsc & PORT_CONNECT)) |
|---|
| 642 | + return -ENOTCONN; |
|---|
| 648 | 643 | |
|---|
| 649 | | - /* bomb out completely if something weird happened */ |
|---|
| 650 | | - if ((portsc & PORT_CSC)) |
|---|
| 651 | | - return -EINVAL; |
|---|
| 644 | + /* bomb out completely if something weird happened */ |
|---|
| 645 | + if ((portsc & PORT_CSC)) |
|---|
| 646 | + return -EINVAL; |
|---|
| 652 | 647 | |
|---|
| 653 | | - /* If we've finished resetting, then break out of the loop */ |
|---|
| 654 | | - if (!(portsc & PORT_RESET) && (portsc & PORT_PE)) |
|---|
| 655 | | - return 0; |
|---|
| 648 | + /* If we've finished resetting, then break out of the loop */ |
|---|
| 649 | + if (!(portsc & PORT_RESET) && (portsc & PORT_PE)) |
|---|
| 650 | + return 0; |
|---|
| 656 | 651 | return -EBUSY; |
|---|
| 657 | 652 | } |
|---|
| 658 | 653 | |
|---|
| .. | .. |
|---|
| 912 | 907 | |
|---|
| 913 | 908 | static void early_dbgp_write(struct console *con, const char *str, u32 n) |
|---|
| 914 | 909 | { |
|---|
| 915 | | - int chunk, ret; |
|---|
| 910 | + int chunk; |
|---|
| 916 | 911 | char buf[DBGP_MAX_PACKET]; |
|---|
| 917 | 912 | int use_cr = 0; |
|---|
| 918 | 913 | u32 cmd, ctrl; |
|---|
| .. | .. |
|---|
| 951 | 946 | buf[chunk] = *str; |
|---|
| 952 | 947 | } |
|---|
| 953 | 948 | if (chunk > 0) { |
|---|
| 954 | | - ret = dbgp_bulk_write(USB_DEBUG_DEVNUM, |
|---|
| 955 | | - dbgp_endpoint_out, buf, chunk); |
|---|
| 949 | + dbgp_bulk_write(USB_DEBUG_DEVNUM, |
|---|
| 950 | + dbgp_endpoint_out, buf, chunk); |
|---|
| 956 | 951 | } |
|---|
| 957 | 952 | } |
|---|
| 958 | 953 | if (unlikely(reset_run)) { |
|---|
| .. | .. |
|---|
| 1058 | 1053 | kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10); |
|---|
| 1059 | 1054 | } |
|---|
| 1060 | 1055 | kgdb_register_io_module(&kgdbdbgp_io_ops); |
|---|
| 1061 | | - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1; |
|---|
| 1056 | + if (early_dbgp_console.index != -1) |
|---|
| 1057 | + kgdbdbgp_io_ops.cons = &early_dbgp_console; |
|---|
| 1062 | 1058 | |
|---|
| 1063 | 1059 | return 0; |
|---|
| 1064 | 1060 | } |
|---|