[PATCH] USB: EHCI updates mostly whitespace cleanups

This cleans up the recent updates to EHCI PCI support:

- Gets rid of checks for "is this a PCI device", they're no
longer needed since this is now all PCI-only code.

- Reduce log spamming: MWI is only interesting in the atypical
case that it can actually be used.

- Whitespace cleanup, as appropriate for a new file with no
other pending patches.

So other than that minor logging change, no functional updates.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by David Brownell and committed by Linus Torvalds abcc9448 f03c17fc

+125 -135
+125 -135
drivers/usb/host/ehci-pci.c
··· 27 27 /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... 28 28 * off the controller (maybe it can boot from highspeed USB disks). 29 29 */ 30 - static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap) 30 + static int bios_handoff(struct ehci_hcd *ehci, int where, u32 cap) 31 31 { 32 32 struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); 33 33 ··· 48 48 where, cap); 49 49 // some BIOS versions seem buggy... 50 50 // return 1; 51 - ehci_warn (ehci, "continuing after BIOS bug...\n"); 51 + ehci_warn(ehci, "continuing after BIOS bug...\n"); 52 52 /* disable all SMIs, and clear "BIOS owns" flag */ 53 53 pci_write_config_dword(pdev, where + 4, 0); 54 54 pci_write_config_byte(pdev, where + 2, 0); ··· 59 59 } 60 60 61 61 /* called by khubd or root hub init threads */ 62 - static int ehci_pci_reset (struct usb_hcd *hcd) 62 + static int ehci_pci_reset(struct usb_hcd *hcd) 63 63 { 64 - struct ehci_hcd *ehci = hcd_to_ehci (hcd); 64 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 65 + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 65 66 u32 temp; 66 67 unsigned count = 256/4; 67 68 68 69 spin_lock_init (&ehci->lock); 69 70 70 71 ehci->caps = hcd->regs; 71 - ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase)); 72 - dbg_hcs_params (ehci, "reset"); 73 - dbg_hcc_params (ehci, "reset"); 72 + ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); 73 + dbg_hcs_params(ehci, "reset"); 74 + dbg_hcc_params(ehci, "reset"); 74 75 75 76 /* cache this readonly data; minimize chip reads */ 76 - ehci->hcs_params = readl (&ehci->caps->hcs_params); 77 + ehci->hcs_params = readl(&ehci->caps->hcs_params); 77 78 78 - if (hcd->self.controller->bus == &pci_bus_type) { 79 - struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 79 + /* NOTE: only the parts below this line are PCI-specific */ 80 80 81 - switch (pdev->vendor) { 82 - case PCI_VENDOR_ID_TDI: 83 - if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 84 - ehci->is_tdi_rh_tt = 1; 85 - tdi_reset (ehci); 86 - } 87 - break; 88 - case PCI_VENDOR_ID_AMD: 89 - /* AMD8111 EHCI doesn't work, according to AMD errata */ 90 - if (pdev->device == 0x7463) { 91 - ehci_info (ehci, "ignoring AMD8111 (errata)\n"); 92 - return -EIO; 93 - } 94 - break; 95 - case PCI_VENDOR_ID_NVIDIA: 96 - /* NVidia reports that certain chips don't handle 97 - * QH, ITD, or SITD addresses above 2GB. (But TD, 98 - * data buffer, and periodic schedule are normal.) 99 - */ 100 - switch (pdev->device) { 101 - case 0x003c: /* MCP04 */ 102 - case 0x005b: /* CK804 */ 103 - case 0x00d8: /* CK8 */ 104 - case 0x00e8: /* CK8S */ 105 - if (pci_set_consistent_dma_mask(pdev, 106 - DMA_31BIT_MASK) < 0) 107 - ehci_warn (ehci, "can't enable NVidia " 108 - "workaround for >2GB RAM\n"); 109 - break; 110 - } 81 + switch (pdev->vendor) { 82 + case PCI_VENDOR_ID_TDI: 83 + if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 84 + ehci->is_tdi_rh_tt = 1; 85 + tdi_reset(ehci); 86 + } 87 + break; 88 + case PCI_VENDOR_ID_AMD: 89 + /* AMD8111 EHCI doesn't work, according to AMD errata */ 90 + if (pdev->device == 0x7463) { 91 + ehci_info(ehci, "ignoring AMD8111 (errata)\n"); 92 + return -EIO; 93 + } 94 + break; 95 + case PCI_VENDOR_ID_NVIDIA: 96 + /* NVidia reports that certain chips don't handle 97 + * QH, ITD, or SITD addresses above 2GB. (But TD, 98 + * data buffer, and periodic schedule are normal.) 99 + */ 100 + switch (pdev->device) { 101 + case 0x003c: /* MCP04 */ 102 + case 0x005b: /* CK804 */ 103 + case 0x00d8: /* CK8 */ 104 + case 0x00e8: /* CK8S */ 105 + if (pci_set_consistent_dma_mask(pdev, 106 + DMA_31BIT_MASK) < 0) 107 + ehci_warn(ehci, "can't enable NVidia " 108 + "workaround for >2GB RAM\n"); 111 109 break; 112 110 } 111 + break; 112 + } 113 113 114 - /* optional debug port, normally in the first BAR */ 115 - temp = pci_find_capability (pdev, 0x0a); 116 - if (temp) { 117 - pci_read_config_dword(pdev, temp, &temp); 118 - temp >>= 16; 119 - if ((temp & (3 << 13)) == (1 << 13)) { 120 - temp &= 0x1fff; 121 - ehci->debug = hcd->regs + temp; 122 - temp = readl (&ehci->debug->control); 123 - ehci_info (ehci, "debug port %d%s\n", 124 - HCS_DEBUG_PORT(ehci->hcs_params), 125 - (temp & DBGP_ENABLED) 126 - ? " IN USE" 127 - : ""); 128 - if (!(temp & DBGP_ENABLED)) 129 - ehci->debug = NULL; 130 - } 114 + /* optional debug port, normally in the first BAR */ 115 + temp = pci_find_capability(pdev, 0x0a); 116 + if (temp) { 117 + pci_read_config_dword(pdev, temp, &temp); 118 + temp >>= 16; 119 + if ((temp & (3 << 13)) == (1 << 13)) { 120 + temp &= 0x1fff; 121 + ehci->debug = hcd->regs + temp; 122 + temp = readl(&ehci->debug->control); 123 + ehci_info(ehci, "debug port %d%s\n", 124 + HCS_DEBUG_PORT(ehci->hcs_params), 125 + (temp & DBGP_ENABLED) 126 + ? " IN USE" 127 + : ""); 128 + if (!(temp & DBGP_ENABLED)) 129 + ehci->debug = NULL; 131 130 } 131 + } 132 132 133 - temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); 134 - } else 135 - temp = 0; 133 + temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params)); 136 134 137 135 /* EHCI 0.96 and later may have "extended capabilities" */ 138 136 while (temp && count--) { 139 137 u32 cap; 140 138 141 - pci_read_config_dword (to_pci_dev(hcd->self.controller), 139 + pci_read_config_dword(to_pci_dev(hcd->self.controller), 142 140 temp, &cap); 143 - ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp); 141 + ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp); 144 142 switch (cap & 0xff) { 145 143 case 1: /* BIOS/SMM/... handoff */ 146 - if (bios_handoff (ehci, temp, cap) != 0) 144 + if (bios_handoff(ehci, temp, cap) != 0) 147 145 return -EOPNOTSUPP; 148 146 break; 149 147 case 0: /* illegal reserved capability */ 150 - ehci_warn (ehci, "illegal capability!\n"); 148 + ehci_warn(ehci, "illegal capability!\n"); 151 149 cap = 0; 152 150 /* FALLTHROUGH */ 153 151 default: /* unknown */ ··· 154 156 temp = (cap >> 8) & 0xff; 155 157 } 156 158 if (!count) { 157 - ehci_err (ehci, "bogus capabilities ... PCI problems!\n"); 159 + ehci_err(ehci, "bogus capabilities ... PCI problems!\n"); 158 160 return -EIO; 159 161 } 160 162 if (ehci_is_TDI(ehci)) 161 - ehci_reset (ehci); 163 + ehci_reset(ehci); 162 164 163 - ehci_port_power (ehci, 0); 165 + ehci_port_power(ehci, 0); 164 166 165 167 /* at least the Genesys GL880S needs fixup here */ 166 168 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 167 169 temp &= 0x0f; 168 170 if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { 169 - ehci_dbg (ehci, "bogus port configuration: " 171 + ehci_dbg(ehci, "bogus port configuration: " 170 172 "cc=%d x pcc=%d < ports=%d\n", 171 173 HCS_N_CC(ehci->hcs_params), 172 174 HCS_N_PCC(ehci->hcs_params), 173 175 HCS_N_PORTS(ehci->hcs_params)); 174 176 175 - if (hcd->self.controller->bus == &pci_bus_type) { 176 - struct pci_dev *pdev; 177 - 178 - pdev = to_pci_dev(hcd->self.controller); 179 - switch (pdev->vendor) { 180 - case 0x17a0: /* GENESYS */ 181 - /* GL880S: should be PORTS=2 */ 182 - temp |= (ehci->hcs_params & ~0xf); 183 - ehci->hcs_params = temp; 184 - break; 185 - case PCI_VENDOR_ID_NVIDIA: 186 - /* NF4: should be PCC=10 */ 187 - break; 188 - } 177 + switch (pdev->vendor) { 178 + case 0x17a0: /* GENESYS */ 179 + /* GL880S: should be PORTS=2 */ 180 + temp |= (ehci->hcs_params & ~0xf); 181 + ehci->hcs_params = temp; 182 + break; 183 + case PCI_VENDOR_ID_NVIDIA: 184 + /* NF4: should be PCC=10 */ 185 + break; 189 186 } 190 187 } 191 188 192 189 /* force HC to halt state */ 193 - return ehci_halt (ehci); 190 + return ehci_halt(ehci); 194 191 } 195 192 196 - static int ehci_pci_start (struct usb_hcd *hcd) 193 + static int ehci_pci_start(struct usb_hcd *hcd) 197 194 { 198 - struct ehci_hcd *ehci = hcd_to_ehci (hcd); 199 - int result = 0; 195 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 196 + int result = 0; 197 + struct pci_dev *pdev; 198 + u16 port_wake; 200 199 201 - if (hcd->self.controller->bus == &pci_bus_type) { 202 - struct pci_dev *pdev; 203 - u16 port_wake; 200 + pdev = to_pci_dev(hcd->self.controller); 204 201 205 - pdev = to_pci_dev(hcd->self.controller); 202 + /* Serial Bus Release Number is at PCI 0x60 offset */ 203 + pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 206 204 207 - /* Serial Bus Release Number is at PCI 0x60 offset */ 208 - pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 205 + /* port wake capability, reported by boot firmware */ 206 + pci_read_config_word(pdev, 0x62, &port_wake); 207 + hcd->can_wakeup = (port_wake & 1) != 0; 209 208 210 - /* port wake capability, reported by boot firmware */ 211 - pci_read_config_word(pdev, 0x62, &port_wake); 212 - hcd->can_wakeup = (port_wake & 1) != 0; 209 + /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */ 210 + result = pci_set_mwi(pdev); 211 + if (!result) 212 + ehci_dbg(ehci, "MWI active\n"); 213 213 214 - /* help hc dma work well with cachelines */ 215 - result = pci_set_mwi(pdev); 216 - if (result) 217 - ehci_dbg(ehci, "unable to enable MWI - not fatal.\n"); 218 - } 219 - 220 - return ehci_run (hcd); 214 + return ehci_run(hcd); 221 215 } 222 216 223 217 /* always called by thread; normally rmmod */ 224 218 225 - static void ehci_pci_stop (struct usb_hcd *hcd) 219 + static void ehci_pci_stop(struct usb_hcd *hcd) 226 220 { 227 - ehci_stop (hcd); 221 + ehci_stop(hcd); 228 222 } 229 223 230 224 /*-------------------------------------------------------------------------*/ ··· 232 242 * Also they depend on separate root hub suspend/resume. 233 243 */ 234 244 235 - static int ehci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 245 + static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) 236 246 { 237 - struct ehci_hcd *ehci = hcd_to_ehci (hcd); 247 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 238 248 239 - if (time_before (jiffies, ehci->next_statechange)) 240 - msleep (10); 249 + if (time_before(jiffies, ehci->next_statechange)) 250 + msleep(10); 241 251 242 252 // could save FLADJ in case of Vaux power loss 243 253 // ... we'd only use it to handle clock skew ··· 245 255 return 0; 246 256 } 247 257 248 - static int ehci_pci_resume (struct usb_hcd *hcd) 258 + static int ehci_pci_resume(struct usb_hcd *hcd) 249 259 { 250 - struct ehci_hcd *ehci = hcd_to_ehci (hcd); 260 + struct ehci_hcd *ehci = hcd_to_ehci(hcd); 251 261 unsigned port; 252 262 struct usb_device *root = hcd->self.root_hub; 253 263 int retval = -EINVAL; 254 264 255 265 // maybe restore FLADJ 256 266 257 - if (time_before (jiffies, ehci->next_statechange)) 258 - msleep (100); 267 + if (time_before(jiffies, ehci->next_statechange)) 268 + msleep(100); 259 269 260 270 /* If CF is clear, we lost PCI Vaux power and need to restart. */ 261 - if (readl (&ehci->regs->configured_flag) != cpu_to_le32(FLAG_CF)) 271 + if (readl(&ehci->regs->configured_flag) != cpu_to_le32(FLAG_CF)) 262 272 goto restart; 263 273 264 274 /* If any port is suspended (or owned by the companion), 265 275 * we know we can/must resume the HC (and mustn't reset it). 266 276 * We just defer that to the root hub code. 267 277 */ 268 - for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) { 278 + for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { 269 279 u32 status; 270 280 port--; 271 - status = readl (&ehci->regs->port_status [port]); 281 + status = readl(&ehci->regs->port_status [port]); 272 282 if (!(status & PORT_POWER)) 273 283 continue; 274 284 if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { ··· 279 289 280 290 restart: 281 291 ehci_dbg(ehci, "lost power, restarting\n"); 282 - for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) { 292 + for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { 283 293 port--; 284 294 if (!root->children [port]) 285 295 continue; 286 - usb_set_device_state (root->children[port], 296 + usb_set_device_state(root->children[port], 287 297 USB_STATE_NOTATTACHED); 288 298 } 289 299 290 300 /* Else reset, to cope with power loss or flush-to-storage 291 301 * style "resume" having let BIOS kick in during reboot. 292 302 */ 293 - (void) ehci_halt (ehci); 294 - (void) ehci_reset (ehci); 295 - (void) ehci_pci_reset (hcd); 303 + (void) ehci_halt(ehci); 304 + (void) ehci_reset(ehci); 305 + (void) ehci_pci_reset(hcd); 296 306 297 307 /* emptying the schedule aborts any urbs */ 298 - spin_lock_irq (&ehci->lock); 308 + spin_lock_irq(&ehci->lock); 299 309 if (ehci->reclaim) 300 310 ehci->reclaim_ready = 1; 301 - ehci_work (ehci, NULL); 302 - spin_unlock_irq (&ehci->lock); 311 + ehci_work(ehci, NULL); 312 + spin_unlock_irq(&ehci->lock); 303 313 304 314 /* restart; khubd will disconnect devices */ 305 - retval = ehci_run (hcd); 315 + retval = ehci_run(hcd); 306 316 307 317 /* here we "know" root ports should always stay powered; 308 318 * but some controllers may lose all power. 309 319 */ 310 - ehci_port_power (ehci, 1); 320 + ehci_port_power(ehci, 1); 311 321 312 322 return retval; 313 323 } ··· 366 376 }, 367 377 { /* end: all zeroes */ } 368 378 }; 369 - MODULE_DEVICE_TABLE (pci, pci_ids); 379 + MODULE_DEVICE_TABLE(pci, pci_ids); 370 380 371 381 /* pci driver glue; this is a "new style" PCI driver module */ 372 382 static struct pci_driver ehci_pci_driver = { ··· 382 392 #endif 383 393 }; 384 394 385 - static int __init ehci_hcd_pci_init (void) 395 + static int __init ehci_hcd_pci_init(void) 386 396 { 387 397 if (usb_disabled()) 388 398 return -ENODEV; 389 399 390 - pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", 400 + pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", 391 401 hcd_name, 392 - sizeof (struct ehci_qh), sizeof (struct ehci_qtd), 393 - sizeof (struct ehci_itd), sizeof (struct ehci_sitd)); 402 + sizeof(struct ehci_qh), sizeof(struct ehci_qtd), 403 + sizeof(struct ehci_itd), sizeof(struct ehci_sitd)); 394 404 395 - return pci_register_driver (&ehci_pci_driver); 405 + return pci_register_driver(&ehci_pci_driver); 396 406 } 397 - module_init (ehci_hcd_pci_init); 407 + module_init(ehci_hcd_pci_init); 398 408 399 - static void __exit ehci_hcd_pci_cleanup (void) 409 + static void __exit ehci_hcd_pci_cleanup(void) 400 410 { 401 - pci_unregister_driver (&ehci_pci_driver); 411 + pci_unregister_driver(&ehci_pci_driver); 402 412 } 403 - module_exit (ehci_hcd_pci_cleanup); 413 + module_exit(ehci_hcd_pci_cleanup);