Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git

+282 -768
+1 -3
Documentation/filesystems/sysfs-pci.txt
··· 7 7 |-- 0000:17:00.0 8 8 | |-- class 9 9 | |-- config 10 - | |-- detach_state 11 10 | |-- device 12 11 | |-- irq 13 12 | |-- local_cpus ··· 18 19 | |-- subsystem_device 19 20 | |-- subsystem_vendor 20 21 | `-- vendor 21 - `-- detach_state 22 + `-- ... 22 23 23 24 The topmost element describes the PCI domain and bus number. In this case, 24 25 the domain number is 0000 and the bus number is 17 (both values are in hex). ··· 30 31 ---- -------- 31 32 class PCI class (ascii, ro) 32 33 config PCI config space (binary, rw) 33 - detach_state connection status (bool, rw) 34 34 device PCI device (ascii, ro) 35 35 irq IRQ number (ascii, ro) 36 36 local_cpus nearby CPU mask (cpumask, ro)
-21
Documentation/power/devices.txt
··· 207 207 #READY_AFTER_RESUME 208 208 # 209 209 210 - Driver Detach Power Management 211 - 212 - The kernel now supports the ability to place a device in a low-power 213 - state when it is detached from its driver, which happens when its 214 - module is removed. 215 - 216 - Each device contains a 'detach_state' file in its sysfs directory 217 - which can be used to control this state. Reading from this file 218 - displays what the current detach state is set to. This is 0 (On) by 219 - default. A user may write a positive integer value to this file in the 220 - range of 1-4 inclusive. 221 - 222 - A value of 1-3 will indicate the device should be placed in that 223 - low-power state, which will cause ->suspend() to be called for that 224 - device. A value of 4 indicates that the device should be shutdown, so 225 - ->shutdown() will be called for that device. 226 - 227 - The driver is responsible for reinitializing the device when the 228 - module is re-inserted during it's ->probe() (or equivalent) method. 229 - The driver core will not call any extra functions when binding the 230 - device to the driver. 231 210 232 211 pm_message_t meaning 233 212
+2 -2
Documentation/powerpc/hvcs.txt
··· 347 347 looks like the following: 348 348 349 349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls 350 - . current_vty devspec name partner_vtys 351 - .. detach_state index partner_clcs vterm_state 350 + . current_vty devspec name partner_vtys 351 + .. index partner_clcs vterm_state 352 352 353 353 Each entry is provided, by default with a "name" attribute. Reading the 354 354 "name" attribute will reveal the device type as shown in the following
+1 -1
drivers/base/Makefile
··· 1 1 # Makefile for the Linux device tree 2 2 3 - obj-y := core.o sys.o interface.o bus.o \ 3 + obj-y := core.o sys.o bus.o \ 4 4 driver.o class.o class_simple.o platform.o \ 5 5 cpu.o firmware.o init.o map.o dmapool.o \ 6 6 attribute_container.o transport_class.o
-1
drivers/base/bus.c
··· 390 390 sysfs_remove_link(&drv->kobj, kobject_name(&dev->kobj)); 391 391 sysfs_remove_link(&dev->kobj, "driver"); 392 392 list_del_init(&dev->driver_list); 393 - device_detach_shutdown(dev); 394 393 if (drv->remove) 395 394 drv->remove(dev); 396 395 dev->driver = NULL;
-3
drivers/base/core.c
··· 31 31 #define to_dev(obj) container_of(obj, struct device, kobj) 32 32 #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) 33 33 34 - extern struct attribute * dev_default_attrs[]; 35 - 36 34 static ssize_t 37 35 dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) 38 36 { ··· 87 89 static struct kobj_type ktype_device = { 88 90 .release = device_release, 89 91 .sysfs_ops = &dev_sysfs_ops, 90 - .default_attrs = dev_default_attrs, 91 92 }; 92 93 93 94
-51
drivers/base/interface.c
··· 1 - /* 2 - * drivers/base/interface.c - common driverfs interface that's exported to 3 - * the world for all devices. 4 - * 5 - * Copyright (c) 2002-3 Patrick Mochel 6 - * Copyright (c) 2002-3 Open Source Development Labs 7 - * 8 - * This file is released under the GPLv2 9 - * 10 - */ 11 - 12 - #include <linux/device.h> 13 - #include <linux/err.h> 14 - #include <linux/stat.h> 15 - #include <linux/string.h> 16 - 17 - /** 18 - * detach_state - control the default power state for the device. 19 - * 20 - * This is the state the device enters when it's driver module is 21 - * unloaded. The value is an unsigned integer, in the range of 0-4. 22 - * '0' indicates 'On', so no action will be taken when the driver is 23 - * unloaded. This is the default behavior. 24 - * '4' indicates 'Off', meaning the driver core will call the driver's 25 - * shutdown method to quiesce the device. 26 - * 1-3 indicate a low-power state for the device to enter via the 27 - * driver's suspend method. 28 - */ 29 - 30 - static ssize_t detach_show(struct device * dev, char * buf) 31 - { 32 - return sprintf(buf, "%u\n", dev->detach_state); 33 - } 34 - 35 - static ssize_t detach_store(struct device * dev, const char * buf, size_t n) 36 - { 37 - u32 state; 38 - state = simple_strtoul(buf, NULL, 10); 39 - if (state > 4) 40 - return -EINVAL; 41 - dev->detach_state = state; 42 - return n; 43 - } 44 - 45 - static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store); 46 - 47 - 48 - struct attribute * dev_default_attrs[] = { 49 - &dev_attr_detach_state.attr, 50 - NULL, 51 - };
-11
drivers/base/power/power.h
··· 1 - 2 - 3 - enum { 4 - DEVICE_PM_ON, 5 - DEVICE_PM1, 6 - DEVICE_PM2, 7 - DEVICE_PM3, 8 - DEVICE_PM_OFF, 9 - }; 10 - 11 1 /* 12 2 * shutdown.c 13 3 */ 14 4 15 - extern int device_detach_shutdown(struct device *); 16 5 extern void device_shutdown(void); 17 6 18 7
+10 -1
drivers/base/power/resume.c
··· 22 22 23 23 int resume_device(struct device * dev) 24 24 { 25 - if (dev->bus && dev->bus->resume) 25 + if (dev->power.pm_parent 26 + && dev->power.pm_parent->power.power_state) { 27 + dev_err(dev, "PM: resume from %d, parent %s still %d\n", 28 + dev->power.power_state, 29 + dev->power.pm_parent->bus_id, 30 + dev->power.pm_parent->power.power_state); 31 + } 32 + if (dev->bus && dev->bus->resume) { 33 + dev_dbg(dev,"resuming\n"); 26 34 return dev->bus->resume(dev); 35 + } 27 36 return 0; 28 37 } 29 38
+4 -19
drivers/base/power/shutdown.c
··· 19 19 extern struct subsystem devices_subsys; 20 20 21 21 22 - int device_detach_shutdown(struct device * dev) 23 - { 24 - if (!dev->detach_state) 25 - return 0; 26 - 27 - if (dev->detach_state == DEVICE_PM_OFF) { 28 - if (dev->driver && dev->driver->shutdown) 29 - dev->driver->shutdown(dev); 30 - return 0; 31 - } 32 - return dpm_runtime_suspend(dev, dev->detach_state); 33 - } 34 - 35 - 36 22 /** 37 23 * We handle system devices differently - we suspend and shut them 38 24 * down last and resume them first. That way, we don't do anything stupid like ··· 38 52 struct device * dev; 39 53 40 54 down_write(&devices_subsys.rwsem); 41 - list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) { 42 - pr_debug("shutting down %s: ", dev->bus_id); 55 + list_for_each_entry_reverse(dev, &devices_subsys.kset.list, 56 + kobj.entry) { 43 57 if (dev->driver && dev->driver->shutdown) { 44 - pr_debug("Ok\n"); 58 + dev_dbg(dev, "shutdown\n"); 45 59 dev->driver->shutdown(dev); 46 - } else 47 - pr_debug("Ignored.\n"); 60 + } 48 61 } 49 62 up_write(&devices_subsys.rwsem); 50 63
+15 -2
drivers/base/power/suspend.c
··· 39 39 { 40 40 int error = 0; 41 41 42 - dev_dbg(dev, "suspending\n"); 42 + if (dev->power.power_state) { 43 + dev_dbg(dev, "PM: suspend %d-->%d\n", 44 + dev->power.power_state, state); 45 + } 46 + if (dev->power.pm_parent 47 + && dev->power.pm_parent->power.power_state) { 48 + dev_err(dev, 49 + "PM: suspend %d->%d, parent %s already %d\n", 50 + dev->power.power_state, state, 51 + dev->power.pm_parent->bus_id, 52 + dev->power.pm_parent->power.power_state); 53 + } 43 54 44 55 dev->power.prev_state = dev->power.power_state; 45 56 46 - if (dev->bus && dev->bus->suspend && !dev->power.power_state) 57 + if (dev->bus && dev->bus->suspend && !dev->power.power_state) { 58 + dev_dbg(dev, "suspending\n"); 47 59 error = dev->bus->suspend(dev, state); 60 + } 48 61 49 62 return error; 50 63 }
+1 -1
drivers/char/raw.c
··· 122 122 { 123 123 struct block_device *bdev = filp->private_data; 124 124 125 - return blkdev_ioctl(bdev->bd_inode, filp, command, arg); 125 + return blkdev_ioctl(bdev->bd_inode, NULL, command, arg); 126 126 } 127 127 128 128 static void bind_device(struct raw_config_request *rq)
+10 -109
drivers/pci/hotplug.c
··· 52 52 if ((buffer_size - length <= 0) || (i >= num_envp)) 53 53 return -ENOMEM; 54 54 55 + envp[i++] = scratch; 56 + length += scnprintf (scratch, buffer_size - length, 57 + "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", 58 + pdev->vendor, pdev->device, 59 + pdev->subsystem_vendor, pdev->subsystem_device, 60 + (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 61 + (u8)(pdev->class)); 62 + if ((buffer_size - length <= 0) || (i >= num_envp)) 63 + return -ENOMEM; 64 + 55 65 envp[i] = NULL; 56 66 57 67 return 0; 58 68 } 59 - 60 - static int pci_visit_bus (struct pci_visit * fn, struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_parent) 61 - { 62 - struct list_head *ln; 63 - struct pci_dev *dev; 64 - struct pci_dev_wrapped wrapped_dev; 65 - int result = 0; 66 - 67 - pr_debug("PCI: Scanning bus %04x:%02x\n", pci_domain_nr(wrapped_bus->bus), 68 - wrapped_bus->bus->number); 69 - 70 - if (fn->pre_visit_pci_bus) { 71 - result = fn->pre_visit_pci_bus(wrapped_bus, wrapped_parent); 72 - if (result) 73 - return result; 74 - } 75 - 76 - ln = wrapped_bus->bus->devices.next; 77 - while (ln != &wrapped_bus->bus->devices) { 78 - dev = pci_dev_b(ln); 79 - ln = ln->next; 80 - 81 - memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped)); 82 - wrapped_dev.dev = dev; 83 - 84 - result = pci_visit_dev(fn, &wrapped_dev, wrapped_bus); 85 - if (result) 86 - return result; 87 - } 88 - 89 - if (fn->post_visit_pci_bus) 90 - result = fn->post_visit_pci_bus(wrapped_bus, wrapped_parent); 91 - 92 - return result; 93 - } 94 - 95 - static int pci_visit_bridge (struct pci_visit * fn, 96 - struct pci_dev_wrapped *wrapped_dev, 97 - struct pci_bus_wrapped *wrapped_parent) 98 - { 99 - struct pci_bus *bus; 100 - struct pci_bus_wrapped wrapped_bus; 101 - int result = 0; 102 - 103 - pr_debug("PCI: Scanning bridge %s\n", pci_name(wrapped_dev->dev)); 104 - 105 - if (fn->visit_pci_dev) { 106 - result = fn->visit_pci_dev(wrapped_dev, wrapped_parent); 107 - if (result) 108 - return result; 109 - } 110 - 111 - bus = wrapped_dev->dev->subordinate; 112 - if (bus) { 113 - memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped)); 114 - wrapped_bus.bus = bus; 115 - 116 - result = pci_visit_bus(fn, &wrapped_bus, wrapped_dev); 117 - } 118 - return result; 119 - } 120 - 121 - /** 122 - * pci_visit_dev - scans the pci buses. 123 - * @fn: callback functions that are called while visiting 124 - * @wrapped_dev: the device to scan 125 - * @wrapped_parent: the bus where @wrapped_dev is connected to 126 - * 127 - * Every bus and every function is presented to a custom 128 - * function that can act upon it. 129 - */ 130 - int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev, 131 - struct pci_bus_wrapped *wrapped_parent) 132 - { 133 - struct pci_dev* dev = wrapped_dev ? wrapped_dev->dev : NULL; 134 - int result = 0; 135 - 136 - if (!dev) 137 - return 0; 138 - 139 - if (fn->pre_visit_pci_dev) { 140 - result = fn->pre_visit_pci_dev(wrapped_dev, wrapped_parent); 141 - if (result) 142 - return result; 143 - } 144 - 145 - switch (dev->class >> 8) { 146 - case PCI_CLASS_BRIDGE_PCI: 147 - result = pci_visit_bridge(fn, wrapped_dev, 148 - wrapped_parent); 149 - if (result) 150 - return result; 151 - break; 152 - default: 153 - pr_debug("PCI: Scanning device %s\n", pci_name(dev)); 154 - if (fn->visit_pci_dev) { 155 - result = fn->visit_pci_dev (wrapped_dev, 156 - wrapped_parent); 157 - if (result) 158 - return result; 159 - } 160 - } 161 - 162 - if (fn->post_visit_pci_dev) 163 - result = fn->post_visit_pci_dev(wrapped_dev, wrapped_parent); 164 - 165 - return result; 166 - } 167 - EXPORT_SYMBOL(pci_visit_dev);
+1 -1
drivers/pci/hotplug/cpci_hotplug.h
··· 31 31 #include <linux/types.h> 32 32 #include <linux/pci.h> 33 33 34 - /* PICMG 2.12 R2.0 HS CSR bits: */ 34 + /* PICMG 2.1 R2.0 HS CSR bits: */ 35 35 #define HS_CSR_INS 0x0080 36 36 #define HS_CSR_EXT 0x0040 37 37 #define HS_CSR_PI 0x0030
+86 -83
drivers/pci/hotplug/cpci_hotplug_core.c
··· 33 33 #include <linux/init.h> 34 34 #include <linux/interrupt.h> 35 35 #include <linux/smp_lock.h> 36 + #include <asm/atomic.h> 36 37 #include <linux/delay.h> 37 38 #include "pci_hotplug.h" 38 39 #include "cpci_hotplug.h" 39 40 40 - #define DRIVER_VERSION "0.2" 41 41 #define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 42 42 #define DRIVER_DESC "CompactPCI Hot Plug Core" 43 43 ··· 54 54 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 55 55 56 56 /* local variables */ 57 - static spinlock_t list_lock; 57 + static DECLARE_RWSEM(list_rwsem); 58 58 static LIST_HEAD(slot_list); 59 59 static int slots; 60 + static atomic_t extracting; 60 61 int cpci_debug; 61 62 static struct cpci_hp_controller *controller; 62 63 static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ ··· 69 68 static int set_attention_status(struct hotplug_slot *slot, u8 value); 70 69 static int get_power_status(struct hotplug_slot *slot, u8 * value); 71 70 static int get_attention_status(struct hotplug_slot *slot, u8 * value); 71 + static int get_adapter_status(struct hotplug_slot *slot, u8 * value); 72 + static int get_latch_status(struct hotplug_slot *slot, u8 * value); 72 73 73 74 static struct hotplug_slot_ops cpci_hotplug_slot_ops = { 74 75 .owner = THIS_MODULE, ··· 79 76 .set_attention_status = set_attention_status, 80 77 .get_power_status = get_power_status, 81 78 .get_attention_status = get_attention_status, 79 + .get_adapter_status = get_adapter_status, 80 + .get_latch_status = get_latch_status, 82 81 }; 83 82 84 83 static int ··· 153 148 warn("failure to update adapter file"); 154 149 } 155 150 156 - slot->extracting = 0; 157 - 151 + if(slot->extracting) { 152 + slot->extracting = 0; 153 + atomic_dec(&extracting); 154 + } 158 155 return retval; 159 156 } 160 157 ··· 193 186 set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) 194 187 { 195 188 return cpci_set_attention_status(hotplug_slot->private, status); 189 + } 190 + 191 + static int 192 + get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value) 193 + { 194 + *value = hotplug_slot->info->adapter_status; 195 + return 0; 196 + } 197 + 198 + static int 199 + get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value) 200 + { 201 + *value = hotplug_slot->info->latch_status; 202 + return 0; 196 203 } 197 204 198 205 static void release_slot(struct hotplug_slot *hotplug_slot) ··· 294 273 } 295 274 296 275 /* Add slot to our internal list */ 297 - spin_lock(&list_lock); 276 + down_write(&list_rwsem); 298 277 list_add(&slot->slot_list, &slot_list); 299 278 slots++; 300 - spin_unlock(&list_lock); 279 + up_write(&list_rwsem); 301 280 } 302 281 return 0; 303 282 error_name: ··· 320 299 struct list_head *next; 321 300 int status; 322 301 323 - spin_lock(&list_lock); 302 + down_write(&list_rwsem); 324 303 if(!slots) { 325 - spin_unlock(&list_lock); 304 + up_write(&list_rwsem); 326 305 return -1; 327 306 } 328 307 list_for_each_safe(tmp, next, &slot_list) { ··· 340 319 slots--; 341 320 } 342 321 } 343 - spin_unlock(&list_lock); 322 + up_write(&list_rwsem); 344 323 return 0; 345 324 } 346 325 ··· 368 347 } 369 348 370 349 /* 371 - * According to PICMG 2.12 R2.0, section 6.3.2, upon 350 + * According to PICMG 2.1 R2.0, section 6.3.2, upon 372 351 * initialization, the system driver shall clear the 373 352 * INS bits of the cold-inserted devices. 374 353 */ ··· 380 359 struct pci_dev* dev; 381 360 382 361 dbg("%s - enter", __FUNCTION__); 383 - spin_lock(&list_lock); 362 + down_read(&list_rwsem); 384 363 if(!slots) { 385 - spin_unlock(&list_lock); 364 + up_read(&list_rwsem); 386 365 return -1; 387 366 } 388 367 list_for_each(tmp, &slot_list) { ··· 407 386 } 408 387 } 409 388 } 410 - spin_unlock(&list_lock); 389 + up_read(&list_rwsem); 411 390 dbg("%s - exit", __FUNCTION__); 412 391 return 0; 413 392 } ··· 419 398 struct list_head *tmp; 420 399 int extracted; 421 400 int inserted; 401 + u16 hs_csr; 422 402 423 - spin_lock(&list_lock); 403 + down_read(&list_rwsem); 424 404 if(!slots) { 425 - spin_unlock(&list_lock); 405 + up_read(&list_rwsem); 426 406 err("no slots registered, shutting down"); 427 407 return -1; 428 408 } ··· 433 411 dbg("%s - looking at slot %s", 434 412 __FUNCTION__, slot->hotplug_slot->name); 435 413 if(cpci_check_and_clear_ins(slot)) { 436 - u16 hs_csr; 437 - 438 414 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ 439 415 if(slot->dev) { 440 416 warn("slot %s already inserted", slot->hotplug_slot->name); ··· 482 462 483 463 inserted++; 484 464 } else if(cpci_check_ext(slot)) { 485 - u16 hs_csr; 486 - 487 465 /* Process extraction request */ 488 466 dbg("%s - slot %s extracted", 489 467 __FUNCTION__, slot->hotplug_slot->name); ··· 494 476 if(!slot->extracting) { 495 477 if(update_latch_status(slot->hotplug_slot, 0)) { 496 478 warn("failure to update latch file"); 479 + 497 480 } 481 + atomic_inc(&extracting); 498 482 slot->extracting = 1; 499 483 } 500 484 extracted++; 485 + } else if(slot->extracting) { 486 + hs_csr = cpci_get_hs_csr(slot); 487 + if(hs_csr == 0xffff) { 488 + /* 489 + * Hmmm, we're likely hosed at this point, should we 490 + * bother trying to tell the driver or not? 491 + */ 492 + err("card in slot %s was improperly removed", 493 + slot->hotplug_slot->name); 494 + if(update_adapter_status(slot->hotplug_slot, 0)) { 495 + warn("failure to update adapter file"); 496 + } 497 + slot->extracting = 0; 498 + atomic_dec(&extracting); 499 + } 501 500 } 502 501 } 503 - spin_unlock(&list_lock); 502 + up_read(&list_rwsem); 503 + dbg("inserted=%d, extracted=%d, extracting=%d", 504 + inserted, extracted, atomic_read(&extracting)); 504 505 if(inserted || extracted) { 505 506 return extracted; 506 507 } 507 - else { 508 + else if(!atomic_read(&extracting)) { 508 509 err("cannot find ENUM# source, shutting down"); 509 510 return -1; 510 511 } 512 + return 0; 511 513 } 512 514 513 515 /* This is the interrupt mode worker thread body */ ··· 535 497 event_thread(void *data) 536 498 { 537 499 int rc; 538 - struct slot *slot; 539 - struct list_head *tmp; 540 500 541 501 lock_kernel(); 542 502 daemonize("cpci_hp_eventd"); ··· 548 512 thread_finished); 549 513 if(thread_finished || signal_pending(current)) 550 514 break; 551 - while(controller->ops->query_enum()) { 515 + do { 552 516 rc = check_slots(); 553 - if (rc > 0) 517 + if (rc > 0) { 554 518 /* Give userspace a chance to handle extraction */ 555 519 msleep(500); 556 - else if (rc < 0) { 520 + } else if (rc < 0) { 557 521 dbg("%s - error checking slots", __FUNCTION__); 558 522 thread_finished = 1; 559 523 break; 560 524 } 561 - } 562 - /* Check for someone yanking out a board */ 563 - list_for_each(tmp, &slot_list) { 564 - slot = list_entry(tmp, struct slot, slot_list); 565 - if(slot->extracting) { 566 - /* 567 - * Hmmm, we're likely hosed at this point, should we 568 - * bother trying to tell the driver or not? 569 - */ 570 - err("card in slot %s was improperly removed", 571 - slot->hotplug_slot->name); 572 - if(update_adapter_status(slot->hotplug_slot, 0)) { 573 - warn("failure to update adapter file"); 574 - } 575 - slot->extracting = 0; 576 - } 577 - } 525 + } while(atomic_read(&extracting) != 0); 578 526 579 527 /* Re-enable ENUM# interrupt */ 580 528 dbg("%s - re-enabling irq", __FUNCTION__); 581 529 controller->ops->enable_irq(); 582 530 } 583 - 584 531 dbg("%s - event thread signals exit", __FUNCTION__); 585 532 up(&thread_exit); 586 533 return 0; ··· 574 555 poll_thread(void *data) 575 556 { 576 557 int rc; 577 - struct slot *slot; 578 - struct list_head *tmp; 579 558 580 559 lock_kernel(); 581 560 daemonize("cpci_hp_polld"); ··· 582 565 while(1) { 583 566 if(thread_finished || signal_pending(current)) 584 567 break; 585 - 586 - while(controller->ops->query_enum()) { 587 - rc = check_slots(); 588 - if(rc > 0) 589 - /* Give userspace a chance to handle extraction */ 590 - msleep(500); 591 - else if (rc < 0) { 592 - dbg("%s - error checking slots", __FUNCTION__); 593 - thread_finished = 1; 594 - break; 595 - } 596 - } 597 - /* Check for someone yanking out a board */ 598 - list_for_each(tmp, &slot_list) { 599 - slot = list_entry(tmp, struct slot, slot_list); 600 - if(slot->extracting) { 601 - /* 602 - * Hmmm, we're likely hosed at this point, should we 603 - * bother trying to tell the driver or not? 604 - */ 605 - err("card in slot %s was improperly removed", 606 - slot->hotplug_slot->name); 607 - if(update_adapter_status(slot->hotplug_slot, 0)) { 608 - warn("failure to update adapter file"); 568 + if(controller->ops->query_enum()) { 569 + do { 570 + rc = check_slots(); 571 + if(rc > 0) { 572 + /* Give userspace a chance to handle extraction */ 573 + msleep(500); 574 + } else if(rc < 0) { 575 + dbg("%s - error checking slots", __FUNCTION__); 576 + thread_finished = 1; 577 + break; 609 578 } 610 - slot->extracting = 0; 611 - } 579 + } while(atomic_read(&extracting) != 0); 612 580 } 613 - 614 581 msleep(100); 615 582 } 616 583 dbg("poll thread signals exit"); ··· 668 667 int status = 0; 669 668 670 669 if(controller) { 670 + if(atomic_read(&extracting) != 0) { 671 + return -EBUSY; 672 + } 671 673 if(!thread_finished) { 672 674 cpci_stop_thread(); 673 675 } ··· 695 691 return -ENODEV; 696 692 } 697 693 698 - spin_lock(&list_lock); 699 - if(!slots) { 700 - spin_unlock(&list_lock); 694 + down_read(&list_rwsem); 695 + if(list_empty(&slot_list)) { 696 + up_read(&list_rwsem); 701 697 return -ENODEV; 702 698 } 703 - spin_unlock(&list_lock); 699 + up_read(&list_rwsem); 704 700 705 701 if(first) { 706 702 status = init_slots(); ··· 731 727 if(!controller) { 732 728 return -ENODEV; 733 729 } 734 - 730 + if(atomic_read(&extracting) != 0) { 731 + return -EBUSY; 732 + } 735 733 if(controller->irq) { 736 734 /* Stop enum interrupt processing */ 737 735 dbg("%s - disabling irq", __FUNCTION__); ··· 753 747 * Unregister all of our slots with the pci_hotplug subsystem, 754 748 * and free up all memory that we had allocated. 755 749 */ 756 - spin_lock(&list_lock); 750 + down_write(&list_rwsem); 757 751 if(!slots) { 758 752 goto null_cleanup; 759 753 } ··· 767 761 kfree(slot); 768 762 } 769 763 null_cleanup: 770 - spin_unlock(&list_lock); 764 + up_write(&list_rwsem); 771 765 return; 772 766 } 773 767 774 768 int __init 775 769 cpci_hotplug_init(int debug) 776 770 { 777 - spin_lock_init(&list_lock); 778 771 cpci_debug = debug; 779 - 780 - info(DRIVER_DESC " version: " DRIVER_VERSION); 781 772 return 0; 782 773 } 783 774
+26 -328
drivers/pci/hotplug/cpci_hotplug_pci.c
··· 32 32 #include "pci_hotplug.h" 33 33 #include "cpci_hotplug.h" 34 34 35 - #if !defined(MODULE) 36 35 #define MY_NAME "cpci_hotplug" 37 - #else 38 - #define MY_NAME THIS_MODULE->name 39 - #endif 40 36 41 37 extern int cpci_debug; 42 38 ··· 122 126 } 123 127 return hs_csr; 124 128 } 125 - 126 - #if 0 127 - u16 cpci_set_hs_csr(struct slot* slot, u16 hs_csr) 128 - { 129 - int hs_cap; 130 - u16 new_hs_csr; 131 - 132 - hs_cap = pci_bus_find_capability(slot->bus, 133 - slot->devfn, 134 - PCI_CAP_ID_CHSWP); 135 - if(!hs_cap) { 136 - return 0xFFFF; 137 - } 138 - 139 - /* Write out the new value */ 140 - if(pci_bus_write_config_word(slot->bus, 141 - slot->devfn, 142 - hs_cap + 2, 143 - hs_csr)) { 144 - return 0xFFFF; 145 - } 146 - 147 - /* Read back what we just wrote out */ 148 - if(pci_bus_read_config_word(slot->bus, 149 - slot->devfn, 150 - hs_cap + 2, 151 - &new_hs_csr)) { 152 - return 0xFFFF; 153 - } 154 - return new_hs_csr; 155 - } 156 - #endif 157 129 158 130 int cpci_check_and_clear_ins(struct slot* slot) 159 131 { ··· 225 261 return -ENODEV; 226 262 } 227 263 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { 228 - /* Set LOO */ 229 264 hs_csr |= HS_CSR_LOO; 230 265 if(pci_bus_write_config_word(slot->bus, 231 266 slot->devfn, ··· 256 293 return -ENODEV; 257 294 } 258 295 if(hs_csr & HS_CSR_LOO) { 259 - /* Clear LOO */ 260 296 hs_csr &= ~HS_CSR_LOO; 261 297 if(pci_bus_write_config_word(slot->bus, 262 298 slot->devfn, ··· 274 312 * Device configuration functions 275 313 */ 276 314 277 - static int cpci_configure_dev(struct pci_bus *bus, struct pci_dev *dev) 315 + static void cpci_enable_device(struct pci_dev *dev) 278 316 { 279 - u8 irq_pin; 280 - int r; 317 + struct pci_bus *bus; 281 318 282 - dbg("%s - enter", __FUNCTION__); 283 - 284 - /* NOTE: device already setup from prior scan */ 285 - 286 - /* FIXME: How would we know if we need to enable the expansion ROM? */ 287 - pci_write_config_word(dev, PCI_ROM_ADDRESS, 0x00L); 288 - 289 - /* Assign resources */ 290 - dbg("assigning resources for %02x:%02x.%x", 291 - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 292 - for (r = 0; r < 6; r++) { 293 - struct resource *res = dev->resource + r; 294 - if(res->flags) 295 - pci_assign_resource(dev, r); 296 - } 297 - dbg("finished assigning resources for %02x:%02x.%x", 298 - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 299 - 300 - /* Does this function have an interrupt at all? */ 301 - dbg("checking for function interrupt"); 302 - pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin); 303 - if(irq_pin) { 304 - dbg("function uses interrupt pin %d", irq_pin); 305 - } 306 - 307 - /* 308 - * Need to explicitly set irq field to 0 so that it'll get assigned 309 - * by the pcibios platform dependent code called by pci_enable_device. 310 - */ 311 - dev->irq = 0; 312 - 313 - dbg("enabling device"); 314 - pci_enable_device(dev); /* XXX check return */ 315 - dbg("now dev->irq = %d", dev->irq); 316 - if(irq_pin && dev->irq) { 317 - pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); 318 - } 319 - 320 - /* Can't use pci_insert_device at the moment, do it manually for now */ 321 - pci_proc_attach_device(dev); 322 - dbg("notifying drivers"); 323 - //pci_announce_device_to_drivers(dev); 324 - dbg("%s - exit", __FUNCTION__); 325 - return 0; 326 - } 327 - 328 - static int cpci_configure_bridge(struct pci_bus* bus, struct pci_dev* dev) 329 - { 330 - int rc; 331 - struct pci_bus* child; 332 - struct resource* r; 333 - u8 max, n; 334 - u16 command; 335 - 336 - dbg("%s - enter", __FUNCTION__); 337 - 338 - /* Do basic bridge initialization */ 339 - rc = pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40); 340 - if(rc) { 341 - printk(KERN_ERR "%s - write of PCI_LATENCY_TIMER failed\n", __FUNCTION__); 342 - } 343 - rc = pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40); 344 - if(rc) { 345 - printk(KERN_ERR "%s - write of PCI_SEC_LATENCY_TIMER failed\n", __FUNCTION__); 346 - } 347 - rc = pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4); 348 - if(rc) { 349 - printk(KERN_ERR "%s - write of PCI_CACHE_LINE_SIZE failed\n", __FUNCTION__); 350 - } 351 - 352 - /* 353 - * Set parent bridge's subordinate field so that configuration space 354 - * access will work in pci_scan_bridge and friends. 355 - */ 356 - max = pci_max_busnr(); 357 - bus->subordinate = max + 1; 358 - pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, max + 1); 359 - 360 - /* Scan behind bridge */ 361 - n = pci_scan_bridge(bus, dev, max, 2); 362 - child = pci_find_bus(0, max + 1); 363 - if (!child) 364 - return -ENODEV; 365 - pci_proc_attach_bus(child); 366 - 367 - /* 368 - * Update parent bridge's subordinate field if there were more bridges 369 - * behind the bridge that was scanned. 370 - */ 371 - if(n > max) { 372 - bus->subordinate = n; 373 - pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, n); 374 - } 375 - 376 - /* 377 - * Update the bridge resources of the bridge to accommodate devices 378 - * behind it. 379 - */ 380 - pci_bus_size_bridges(child); 381 - pci_bus_assign_resources(child); 382 - 383 - /* Enable resource mapping via command register */ 384 - command = PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR; 385 - r = child->resource[0]; 386 - if(r && r->start) { 387 - command |= PCI_COMMAND_IO; 388 - } 389 - r = child->resource[1]; 390 - if(r && r->start) { 391 - command |= PCI_COMMAND_MEMORY; 392 - } 393 - r = child->resource[2]; 394 - if(r && r->start) { 395 - command |= PCI_COMMAND_MEMORY; 396 - } 397 - rc = pci_write_config_word(dev, PCI_COMMAND, command); 398 - if(rc) { 399 - err("Error setting command register"); 400 - return rc; 401 - } 402 - 403 - /* Set bridge control register */ 404 - command = PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_NO_ISA; 405 - rc = pci_write_config_word(dev, PCI_BRIDGE_CONTROL, command); 406 - if(rc) { 407 - err("Error setting bridge control register"); 408 - return rc; 409 - } 410 - dbg("%s - exit", __FUNCTION__); 411 - return 0; 412 - } 413 - 414 - static int configure_visit_pci_dev(struct pci_dev_wrapped *wrapped_dev, 415 - struct pci_bus_wrapped *wrapped_bus) 416 - { 417 - int rc; 418 - struct pci_dev *dev = wrapped_dev->dev; 419 - struct pci_bus *bus = wrapped_bus->bus; 420 - struct slot* slot; 421 - 422 - dbg("%s - enter", __FUNCTION__); 423 - 424 - /* 425 - * We need to fix up the hotplug representation with the Linux 426 - * representation. 427 - */ 428 - if(wrapped_dev->data) { 429 - slot = (struct slot*) wrapped_dev->data; 430 - slot->dev = dev; 431 - } 432 - 433 - /* If it's a bridge, scan behind it for devices */ 319 + pci_enable_device(dev); 434 320 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 435 - rc = cpci_configure_bridge(bus, dev); 436 - if(rc) 437 - return rc; 438 - } 439 - 440 - /* Actually configure device */ 441 - if(dev) { 442 - rc = cpci_configure_dev(bus, dev); 443 - if(rc) 444 - return rc; 445 - } 446 - dbg("%s - exit", __FUNCTION__); 447 - return 0; 448 - } 449 - 450 - static int unconfigure_visit_pci_dev_phase2(struct pci_dev_wrapped *wrapped_dev, 451 - struct pci_bus_wrapped *wrapped_bus) 452 - { 453 - struct pci_dev *dev = wrapped_dev->dev; 454 - struct slot* slot; 455 - 456 - dbg("%s - enter", __FUNCTION__); 457 - if(!dev) 458 - return -ENODEV; 459 - 460 - /* Remove the Linux representation */ 461 - if(pci_remove_device_safe(dev)) { 462 - err("Could not remove device\n"); 463 - return -1; 464 - } 465 - 466 - /* 467 - * Now remove the hotplug representation. 468 - */ 469 - if(wrapped_dev->data) { 470 - slot = (struct slot*) wrapped_dev->data; 471 - slot->dev = NULL; 472 - } else { 473 - dbg("No hotplug representation for %02x:%02x.%x", 474 - dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); 475 - } 476 - dbg("%s - exit", __FUNCTION__); 477 - return 0; 478 - } 479 - 480 - static int unconfigure_visit_pci_bus_phase2(struct pci_bus_wrapped *wrapped_bus, 481 - struct pci_dev_wrapped *wrapped_dev) 482 - { 483 - struct pci_bus *bus = wrapped_bus->bus; 484 - struct pci_bus *parent = bus->self->bus; 485 - 486 - dbg("%s - enter", __FUNCTION__); 487 - 488 - /* The cleanup code for proc entries regarding buses should be in the kernel... */ 489 - if(bus->procdir) 490 - dbg("detach_pci_bus %s", bus->procdir->name); 491 - pci_proc_detach_bus(bus); 492 - 493 - /* The cleanup code should live in the kernel... */ 494 - bus->self->subordinate = NULL; 495 - 496 - /* unlink from parent bus */ 497 - list_del(&bus->node); 498 - 499 - /* Now, remove */ 500 - if(bus) 501 - kfree(bus); 502 - 503 - /* Update parent's subordinate field */ 504 - if(parent) { 505 - u8 n = pci_bus_max_busnr(parent); 506 - if(n < parent->subordinate) { 507 - parent->subordinate = n; 508 - pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, n); 321 + bus = dev->subordinate; 322 + list_for_each_entry(dev, &bus->devices, bus_list) { 323 + cpci_enable_device(dev); 509 324 } 510 325 } 511 - dbg("%s - exit", __FUNCTION__); 512 - return 0; 513 326 } 514 - 515 - static struct pci_visit configure_functions = { 516 - .visit_pci_dev = configure_visit_pci_dev, 517 - }; 518 - 519 - static struct pci_visit unconfigure_functions_phase2 = { 520 - .post_visit_pci_bus = unconfigure_visit_pci_bus_phase2, 521 - .post_visit_pci_dev = unconfigure_visit_pci_dev_phase2 522 - }; 523 - 524 327 525 328 int cpci_configure_slot(struct slot* slot) 526 329 { 527 - int rc = 0; 330 + unsigned char busnr; 331 + struct pci_bus *child; 528 332 529 333 dbg("%s - enter", __FUNCTION__); 530 334 ··· 316 588 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 317 589 if(slot->dev == NULL) { 318 590 err("Could not find PCI device for slot %02x", slot->number); 319 - return 0; 320 - } 321 - } 322 - dbg("slot->dev = %p", slot->dev); 323 - if(slot->dev) { 324 - struct pci_dev *dev; 325 - struct pci_dev_wrapped wrapped_dev; 326 - struct pci_bus_wrapped wrapped_bus; 327 - int i; 328 - 329 - memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped)); 330 - memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped)); 331 - 332 - for (i = 0; i < 8; i++) { 333 - dev = pci_find_slot(slot->bus->number, 334 - PCI_DEVFN(PCI_SLOT(slot->dev->devfn), i)); 335 - if(!dev) 336 - continue; 337 - wrapped_dev.dev = dev; 338 - wrapped_bus.bus = slot->dev->bus; 339 - if(i) 340 - wrapped_dev.data = NULL; 341 - else 342 - wrapped_dev.data = (void*) slot; 343 - rc = pci_visit_dev(&configure_functions, &wrapped_dev, &wrapped_bus); 591 + return 1; 344 592 } 345 593 } 346 594 347 - dbg("%s - exit, rc = %d", __FUNCTION__, rc); 348 - return rc; 595 + if (slot->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 596 + pci_read_config_byte(slot->dev, PCI_SECONDARY_BUS, &busnr); 597 + child = pci_add_new_bus(slot->dev->bus, slot->dev, busnr); 598 + pci_do_scan_bus(child); 599 + pci_bus_size_bridges(child); 600 + } 601 + 602 + pci_bus_assign_resources(slot->dev->bus); 603 + 604 + cpci_enable_device(slot->dev); 605 + 606 + dbg("%s - exit", __FUNCTION__); 607 + return 0; 349 608 } 350 609 351 610 int cpci_unconfigure_slot(struct slot* slot) 352 611 { 353 - int rc = 0; 354 612 int i; 355 - struct pci_dev_wrapped wrapped_dev; 356 - struct pci_bus_wrapped wrapped_bus; 357 613 struct pci_dev *dev; 358 614 359 615 dbg("%s - enter", __FUNCTION__); 360 - 361 616 if(!slot->dev) { 362 617 err("No device for slot %02x\n", slot->number); 363 618 return -ENODEV; 364 619 } 365 620 366 - memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped)); 367 - memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped)); 368 - 369 621 for (i = 0; i < 8; i++) { 370 622 dev = pci_find_slot(slot->bus->number, 371 623 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 372 624 if(dev) { 373 - wrapped_dev.dev = dev; 374 - wrapped_bus.bus = dev->bus; 375 - if(i) 376 - wrapped_dev.data = NULL; 377 - else 378 - wrapped_dev.data = (void*) slot; 379 - dbg("%s - unconfigure phase 2", __FUNCTION__); 380 - rc = pci_visit_dev(&unconfigure_functions_phase2, 381 - &wrapped_dev, 382 - &wrapped_bus); 383 - if(rc) 384 - break; 625 + pci_remove_bus_device(dev); 626 + slot->dev = NULL; 385 627 } 386 628 } 387 - dbg("%s - exit, rc = %d", __FUNCTION__, rc); 388 - return rc; 629 + dbg("%s - exit", __FUNCTION__); 630 + return 0; 389 631 }
+1
drivers/pci/hotplug/pciehp.h
··· 130 130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 131 131 u8 ctrlcap; 132 132 u16 vendor_id; 133 + u8 cap_base; 133 134 }; 134 135 135 136 struct irq_mapping {
+1 -1
drivers/pci/hotplug/pciehp_core.c
··· 607 607 static struct pcie_port_service_id port_pci_ids[] = { { 608 608 .vendor = PCI_ANY_ID, 609 609 .device = PCI_ANY_ID, 610 - .port_type = PCIE_RC_PORT, 610 + .port_type = PCIE_ANY_PORT, 611 611 .service_type = PCIE_PORT_SERVICE_HP, 612 612 .driver_data = 0, 613 613 }, { /* end: all zeroes */ }
+79 -77
drivers/pci/hotplug/pciehp_hpc.c
··· 109 109 }; 110 110 static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */ 111 111 112 - #define PCIE_CAP_ID ( pcie_cap_base + PCIECAPID ) 113 - #define NXT_CAP_PTR ( pcie_cap_base + NXTCAPPTR ) 114 - #define CAP_REG ( pcie_cap_base + CAPREG ) 115 - #define DEV_CAP ( pcie_cap_base + DEVCAP ) 116 - #define DEV_CTRL ( pcie_cap_base + DEVCTRL ) 117 - #define DEV_STATUS ( pcie_cap_base + DEVSTATUS ) 118 - #define LNK_CAP ( pcie_cap_base + LNKCAP ) 119 - #define LNK_CTRL ( pcie_cap_base + LNKCTRL ) 120 - #define LNK_STATUS ( pcie_cap_base + LNKSTATUS ) 121 - #define SLOT_CAP ( pcie_cap_base + SLOTCAP ) 122 - #define SLOT_CTRL ( pcie_cap_base + SLOTCTRL ) 123 - #define SLOT_STATUS ( pcie_cap_base + SLOTSTATUS ) 124 - #define ROOT_CTRL ( pcie_cap_base + ROOTCTRL ) 125 - #define ROOT_STATUS ( pcie_cap_base + ROOTSTATUS ) 112 + #define PCIE_CAP_ID(cb) ( cb + PCIECAPID ) 113 + #define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR ) 114 + #define CAP_REG(cb) ( cb + CAPREG ) 115 + #define DEV_CAP(cb) ( cb + DEVCAP ) 116 + #define DEV_CTRL(cb) ( cb + DEVCTRL ) 117 + #define DEV_STATUS(cb) ( cb + DEVSTATUS ) 118 + #define LNK_CAP(cb) ( cb + LNKCAP ) 119 + #define LNK_CTRL(cb) ( cb + LNKCTRL ) 120 + #define LNK_STATUS(cb) ( cb + LNKSTATUS ) 121 + #define SLOT_CAP(cb) ( cb + SLOTCAP ) 122 + #define SLOT_CTRL(cb) ( cb + SLOTCTRL ) 123 + #define SLOT_STATUS(cb) ( cb + SLOTSTATUS ) 124 + #define ROOT_CTRL(cb) ( cb + ROOTCTRL ) 125 + #define ROOT_STATUS(cb) ( cb + ROOTSTATUS ) 126 126 127 127 #define hp_register_read_word(pdev, reg , value) \ 128 128 pci_read_config_word(pdev, reg, &value) ··· 303 303 return -1; 304 304 } 305 305 306 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 306 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 307 307 if (retval) { 308 308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 309 309 return retval; ··· 317 317 } 318 318 319 319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd); 320 - retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, cmd | CMD_CMPL_INTR_ENABLE); 320 + retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE); 321 321 if (retval) { 322 322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 323 323 return retval; ··· 342 342 return -1; 343 343 } 344 344 345 - retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 345 + retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status); 346 346 347 347 if (retval) { 348 348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 376 376 return -1; 377 377 } 378 378 379 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 379 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 380 380 381 381 if (retval) { 382 382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 383 383 return retval; 384 384 } 385 385 386 - dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL, slot_ctrl); 386 + dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 387 387 388 388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 389 389 ··· 423 423 return -1; 424 424 } 425 425 426 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 426 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 427 427 428 428 if (retval) { 429 429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 430 430 return retval; 431 431 } 432 - dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 432 + dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 433 433 434 434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 435 435 ··· 463 463 return -1; 464 464 } 465 465 466 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 466 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 467 467 468 468 if (retval) { 469 469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 490 490 return -1; 491 491 } 492 492 493 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 493 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 494 494 495 495 if (retval) { 496 496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 518 518 return -1; 519 519 } 520 520 521 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 521 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 522 522 523 523 if (retval) { 524 524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); ··· 549 549 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 550 550 return -1; 551 551 } 552 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 552 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 553 553 554 554 if (rc) { 555 555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 574 574 slot_cmd = slot_cmd | HP_INTR_ENABLE; 575 575 576 576 pcie_write_cmd(slot, slot_cmd); 577 - dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 577 + dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 578 578 579 579 return rc; 580 580 } ··· 598 598 return ; 599 599 } 600 600 601 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 601 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 602 602 603 603 if (rc) { 604 604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 611 611 612 612 pcie_write_cmd(slot, slot_cmd); 613 613 614 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 614 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 615 615 return; 616 616 } 617 617 ··· 633 633 return ; 634 634 } 635 635 636 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 636 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 637 637 638 638 if (rc) { 639 639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 646 646 if (!pciehp_poll_mode) 647 647 slot_cmd = slot_cmd | HP_INTR_ENABLE; 648 648 pcie_write_cmd(slot, slot_cmd); 649 - dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 649 + dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 650 650 651 651 return; 652 652 } ··· 669 669 return ; 670 670 } 671 671 672 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 672 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 673 673 674 674 if (rc) { 675 675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); ··· 683 683 slot_cmd = slot_cmd | HP_INTR_ENABLE; 684 684 pcie_write_cmd(slot, slot_cmd); 685 685 686 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 686 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 687 687 return; 688 688 } 689 689 ··· 707 707 *first_device_num = 0; 708 708 *num_ctlr_slots = 1; 709 709 710 - rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 710 + rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap); 711 711 712 712 if (rc) { 713 713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__); ··· 793 793 return -1; 794 794 } 795 795 796 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 796 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 797 797 798 798 if (retval) { 799 799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 800 800 return retval; 801 801 } 802 - dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL, 802 + dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), 803 803 slot_ctrl); 804 804 805 805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; ··· 813 813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd); 814 814 return -1; 815 815 } 816 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 816 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 817 817 818 818 DBG_LEAVE_ROUTINE 819 819 ··· 842 842 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 843 843 return -1; 844 844 } 845 - retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 845 + retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 846 846 847 847 if (retval) { 848 848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 849 849 return retval; 850 850 } 851 - dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL, 851 + dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), 852 852 slot_ctrl); 853 853 854 854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; ··· 862 862 err("%s: Write command failed!\n", __FUNCTION__); 863 863 return -1; 864 864 } 865 - dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 865 + dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 866 866 867 867 DBG_LEAVE_ROUTINE 868 868 ··· 900 900 return IRQ_NONE; 901 901 } 902 902 903 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 903 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 904 904 if (rc) { 905 905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 906 906 return IRQ_NONE; ··· 918 918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); 919 919 /* Mask Hot-plug Interrupt Enable */ 920 920 if (!pciehp_poll_mode) { 921 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 921 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 922 922 if (rc) { 923 923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 924 924 return IRQ_NONE; ··· 928 928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 929 929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 930 930 931 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 931 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 932 932 if (rc) { 933 933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 934 934 return IRQ_NONE; 935 935 } 936 936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 937 937 938 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 938 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 939 939 if (rc) { 940 940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 941 941 return IRQ_NONE; ··· 944 944 945 945 /* Clear command complete interrupt caused by this write */ 946 946 temp_word = 0x1f; 947 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 947 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 948 948 if (rc) { 949 949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 950 950 return IRQ_NONE; ··· 975 975 976 976 /* Clear all events after serving them */ 977 977 temp_word = 0x1F; 978 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 978 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 979 979 if (rc) { 980 980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 981 981 return IRQ_NONE; 982 982 } 983 983 /* Unmask Hot-plug Interrupt Enable */ 984 984 if (!pciehp_poll_mode) { 985 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 985 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 986 986 if (rc) { 987 987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 988 988 return IRQ_NONE; ··· 992 992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 993 993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 994 994 995 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 995 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 996 996 if (rc) { 997 997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 998 998 return IRQ_NONE; 999 999 } 1000 1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 1001 1001 1002 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1002 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1003 1003 if (rc) { 1004 1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1005 1005 return IRQ_NONE; ··· 1008 1008 1009 1009 /* Clear command complete interrupt caused by this write */ 1010 1010 temp_word = 0x1F; 1011 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1011 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1012 1012 if (rc) { 1013 1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1014 1014 return IRQ_NONE; ··· 1038 1038 return -1; 1039 1039 } 1040 1040 1041 - retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1041 + retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap); 1042 1042 1043 1043 if (retval) { 1044 1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); ··· 1079 1079 return -1; 1080 1080 } 1081 1081 1082 - retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1082 + retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap); 1083 1083 1084 1084 if (retval) { 1085 1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); ··· 1141 1141 return -1; 1142 1142 } 1143 1143 1144 - retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1144 + retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status); 1145 1145 1146 1146 if (retval) { 1147 1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 1182 1182 return -1; 1183 1183 } 1184 1184 1185 - retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1185 + retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status); 1186 1186 1187 1187 if (retval) { 1188 1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); ··· 1292 1292 goto abort_free_ctlr; 1293 1293 } 1294 1294 1295 - pcie_cap_base = cap_base; 1295 + ctrl->cap_base = cap_base; 1296 1296 1297 1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base); 1298 1298 1299 - rc = hp_register_read_word(pdev, CAP_REG, cap_reg); 1299 + rc = hp_register_read_word(pdev, CAP_REG(ctrl->cap_base), cap_reg); 1300 1300 if (rc) { 1301 1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1302 1302 goto abort_free_ctlr; 1303 1303 } 1304 - dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG, cap_reg); 1304 + dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG(ctrl->cap_base), cap_reg); 1305 1305 1306 - if (((cap_reg & SLOT_IMPL) == 0) || ((cap_reg & DEV_PORT_TYPE) != 0x0040)){ 1306 + if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040) 1307 + && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) { 1307 1308 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__); 1308 1309 goto abort_free_ctlr; 1309 1310 } 1310 1311 1311 - rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 1312 + rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap); 1312 1313 if (rc) { 1313 1314 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1314 1315 goto abort_free_ctlr; 1315 1316 } 1316 - dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP, slot_cap); 1317 + dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP(ctrl->cap_base), slot_cap); 1317 1318 1318 1319 if (!(slot_cap & HP_CAP)) { 1319 1320 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__); 1320 1321 goto abort_free_ctlr; 1321 1322 } 1322 1323 /* For debugging purpose */ 1323 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1324 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1324 1325 if (rc) { 1325 1326 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1326 1327 goto abort_free_ctlr; 1327 1328 } 1328 - dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1329 + dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), slot_status); 1329 1330 1330 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 1331 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 1331 1332 if (rc) { 1332 1333 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1333 1334 goto abort_free_ctlr; 1334 1335 } 1335 - dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 1336 + dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl); 1336 1337 1337 1338 if (first) { 1338 1339 spin_lock_init(&hpc_event_lock); ··· 1373 1372 php_ctlr->num_slots = 1; 1374 1373 1375 1374 /* Mask Hot-plug Interrupt Enable */ 1376 - rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1375 + rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1377 1376 if (rc) { 1378 1377 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1379 1378 goto abort_free_ctlr; 1380 1379 } 1381 1380 1382 - dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1381 + dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word); 1383 1382 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 1384 1383 1385 - rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1384 + rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1386 1385 if (rc) { 1387 1386 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1388 1387 goto abort_free_ctlr; 1389 1388 } 1390 1389 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word); 1391 1390 1392 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1391 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1393 1392 if (rc) { 1394 1393 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1395 1394 goto abort_free_ctlr; 1396 1395 } 1397 - dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1396 + dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base) 1397 + , slot_status); 1398 1398 1399 1399 temp_word = 0x1F; /* Clear all events */ 1400 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1400 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1401 1401 if (rc) { 1402 1402 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1403 1403 goto abort_free_ctlr; 1404 1404 } 1405 - dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1405 + dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word); 1406 1406 1407 1407 if (pciehp_poll_mode) {/* Install interrupt polling code */ 1408 1408 /* Install and start the interrupt polling timer */ ··· 1419 1417 } 1420 1418 } 1421 1419 1422 - rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1420 + rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1423 1421 if (rc) { 1424 1422 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1425 1423 goto abort_free_ctlr; 1426 1424 } 1427 - dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1425 + dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word); 1428 1426 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap); 1429 1427 1430 1428 intr_enable = intr_enable | PRSN_DETECT_ENABLE; ··· 1448 1446 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word); 1449 1447 1450 1448 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1451 - rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1449 + rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1452 1450 if (rc) { 1453 1451 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1454 1452 goto abort_free_ctlr; 1455 1453 } 1456 1454 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word); 1457 - rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1455 + rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1458 1456 if (rc) { 1459 1457 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1460 1458 goto abort_free_ctlr; 1461 1459 } 1462 1460 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, 1463 - SLOT_STATUS, slot_status); 1461 + SLOT_STATUS(ctrl->cap_base), slot_status); 1464 1462 1465 1463 temp_word = 0x1F; /* Clear all events */ 1466 - rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1464 + rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1467 1465 if (rc) { 1468 1466 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1469 1467 goto abort_free_ctlr; 1470 1468 } 1471 - dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1469 + dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word); 1472 1470 1473 1471 /* Add this HPC instance into the HPC list */ 1474 1472 spin_lock(&list_lock);
+1 -1
drivers/pci/hotplug/shpchp_core.c
··· 95 95 */ 96 96 static void release_slot(struct hotplug_slot *hotplug_slot) 97 97 { 98 - struct slot *slot = (struct slot *)hotplug_slot->private; 98 + struct slot *slot = hotplug_slot->private; 99 99 100 100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 101 101
+15 -15
drivers/pci/hotplug/shpchp_ctrl.c
··· 1885 1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0); 1886 1886 if (!func) { 1887 1887 dbg("%s: Error! slot NULL\n", __FUNCTION__); 1888 - return 1; 1888 + return -ENODEV; 1889 1889 } 1890 1890 1891 1891 /* Check to see if (latch closed, card present, power off) */ ··· 1894 1894 if (rc || !getstatus) { 1895 1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1896 1896 up(&p_slot->ctrl->crit_sect); 1897 - return 1; 1897 + return -ENODEV; 1898 1898 } 1899 1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1900 1900 if (rc || getstatus) { 1901 1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1902 1902 up(&p_slot->ctrl->crit_sect); 1903 - return 1; 1903 + return -ENODEV; 1904 1904 } 1905 1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1906 1906 if (rc || getstatus) { 1907 1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 1908 1908 up(&p_slot->ctrl->crit_sect); 1909 - return 1; 1909 + return -ENODEV; 1910 1910 } 1911 1911 up(&p_slot->ctrl->crit_sect); 1912 1912 ··· 1914 1914 1915 1915 func = shpchp_slot_create(p_slot->bus); 1916 1916 if (func == NULL) 1917 - return 1; 1917 + return -ENOMEM; 1918 1918 1919 1919 func->bus = p_slot->bus; 1920 1920 func->device = p_slot->device; ··· 1939 1939 /* Setup slot structure with entry for empty slot */ 1940 1940 func = shpchp_slot_create(p_slot->bus); 1941 1941 if (func == NULL) 1942 - return (1); /* Out of memory */ 1942 + return -ENOMEM; /* Out of memory */ 1943 1943 1944 1944 func->bus = p_slot->bus; 1945 1945 func->device = p_slot->device; ··· 1972 1972 struct pci_func *func; 1973 1973 1974 1974 if (!p_slot->ctrl) 1975 - return 1; 1975 + return -ENODEV; 1976 1976 1977 1977 pci_bus = p_slot->ctrl->pci_dev->subordinate; 1978 1978 ··· 1983 1983 if (ret || !getstatus) { 1984 1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1985 1985 up(&p_slot->ctrl->crit_sect); 1986 - return 1; 1986 + return -ENODEV; 1987 1987 } 1988 1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1989 1989 if (ret || getstatus) { 1990 1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1991 1991 up(&p_slot->ctrl->crit_sect); 1992 - return 1; 1992 + return -ENODEV; 1993 1993 } 1994 1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1995 1995 if (ret || !getstatus) { 1996 1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 1997 1997 up(&p_slot->ctrl->crit_sect); 1998 - return 1; 1998 + return -ENODEV; 1999 1999 } 2000 2000 up(&p_slot->ctrl->crit_sect); 2001 2001 ··· 2011 2011 /* Check the Class Code */ 2012 2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2013 2013 if (rc) 2014 - return rc; 2014 + return -ENODEV; 2015 2015 2016 2016 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2017 2017 /* Display/Video adapter (not supported) */ ··· 2020 2020 /* See if it's a bridge */ 2021 2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2022 2022 if (rc) 2023 - return rc; 2023 + return -ENODEV; 2024 2024 2025 2025 /* If it's a bridge, check the VGA Enable bit */ 2026 2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2027 2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2028 2028 if (rc) 2029 - return rc; 2029 + return -ENODEV; 2030 2030 2031 2031 /* If the VGA Enable bit is set, remove isn't supported */ 2032 2032 if (BCR & PCI_BRIDGE_CTL_VGA) { ··· 2042 2042 if ((func != NULL) && !rc) { 2043 2043 rc = remove_board(func, p_slot->ctrl); 2044 2044 } else if (!rc) 2045 - rc = 1; 2045 + rc = -ENODEV; 2046 2046 2047 2047 if (p_slot) 2048 2048 update_slot_info(p_slot); 2049 2049 2050 - return(rc); 2050 + return rc; 2051 2051 } 2052 2052 2053 2053
+12
drivers/pci/pci-sysfs.c
··· 73 73 return (str - buf); 74 74 } 75 75 76 + static ssize_t modalias_show(struct device *dev, char *buf) 77 + { 78 + struct pci_dev *pci_dev = to_pci_dev(dev); 79 + 80 + return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", 81 + pci_dev->vendor, pci_dev->device, 82 + pci_dev->subsystem_vendor, pci_dev->subsystem_device, 83 + (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), 84 + (u8)(pci_dev->class)); 85 + } 86 + 76 87 struct device_attribute pci_dev_attrs[] = { 77 88 __ATTR_RO(resource), 78 89 __ATTR_RO(vendor), ··· 93 82 __ATTR_RO(class), 94 83 __ATTR_RO(irq), 95 84 __ATTR_RO(local_cpus), 85 + __ATTR_RO(modalias), 96 86 __ATTR_NULL, 97 87 }; 98 88
-27
drivers/pci/pci.h
··· 32 32 extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); 33 33 extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 34 34 35 - struct pci_dev_wrapped { 36 - struct pci_dev *dev; 37 - void *data; 38 - }; 39 - 40 - struct pci_bus_wrapped { 41 - struct pci_bus *bus; 42 - void *data; 43 - }; 44 - 45 - struct pci_visit { 46 - int (* pre_visit_pci_bus) (struct pci_bus_wrapped *, 47 - struct pci_dev_wrapped *); 48 - int (* post_visit_pci_bus) (struct pci_bus_wrapped *, 49 - struct pci_dev_wrapped *); 50 - 51 - int (* pre_visit_pci_dev) (struct pci_dev_wrapped *, 52 - struct pci_bus_wrapped *); 53 - int (* visit_pci_dev) (struct pci_dev_wrapped *, 54 - struct pci_bus_wrapped *); 55 - int (* post_visit_pci_dev) (struct pci_dev_wrapped *, 56 - struct pci_bus_wrapped *); 57 - }; 58 - 59 - extern int pci_visit_dev(struct pci_visit *fn, 60 - struct pci_dev_wrapped *wrapped_dev, 61 - struct pci_bus_wrapped *wrapped_parent); 62 35 extern void pci_remove_legacy_files(struct pci_bus *bus); 63 36 64 37 /* Lock for read/write access to pci device and bus lists */
+2 -1
drivers/pci/pcie/portdrv_bus.c
··· 39 39 driver->id_table->vendor != pciedev->id.vendor) || 40 40 (driver->id_table->device != PCI_ANY_ID && 41 41 driver->id_table->device != pciedev->id.device) || 42 - driver->id_table->port_type != pciedev->id.port_type || 42 + (driver->id_table->port_type != PCIE_ANY_PORT && 43 + driver->id_table->port_type != pciedev->id.port_type) || 43 44 driver->id_table->service_type != pciedev->id.service_type ) 44 45 return 0; 45 46
+9 -1
fs/ext3/super.c
··· 225 225 int errno) 226 226 { 227 227 char nbuf[16]; 228 - const char *errstr = ext3_decode_error(sb, errno, nbuf); 228 + const char *errstr; 229 229 230 + /* Special case: if the error is EROFS, and we're not already 231 + * inside a transaction, then there's really no point in logging 232 + * an error. */ 233 + if (errno == -EROFS && journal_current_handle() == NULL && 234 + (sb->s_flags & MS_RDONLY)) 235 + return; 236 + 237 + errstr = ext3_decode_error(sb, errno, nbuf); 230 238 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n", 231 239 sb->s_id, function, errstr); 232 240
-3
include/linux/device.h
··· 273 273 BIOS data relevant to device) */ 274 274 struct dev_pm_info power; 275 275 276 - u32 detach_state; /* State to enter when device is 277 - detached from its driver. */ 278 - 279 276 u64 *dma_mask; /* dma mask (if dma'able device) */ 280 277 u64 coherent_dma_mask;/* Like dma_mask, but for 281 278 alloc_coherent mappings as
+3 -3
kernel/power/main.c
··· 156 156 goto Unlock; 157 157 } 158 158 159 - pr_debug("PM: Preparing system for suspend\n"); 159 + pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); 160 160 if ((error = suspend_prepare(state))) 161 161 goto Unlock; 162 162 163 - pr_debug("PM: Entering state.\n"); 163 + pr_debug("PM: Entering %s sleep\n", pm_states[state]); 164 164 error = suspend_enter(state); 165 165 166 - pr_debug("PM: Finishing up.\n"); 166 + pr_debug("PM: Finishing wakeup.\n"); 167 167 suspend_finish(state); 168 168 Unlock: 169 169 up(&pm_sem);
+2 -2
mm/mmap.c
··· 1244 1244 addr = mm->free_area_cache; 1245 1245 1246 1246 /* make sure it can fit in the remaining address space */ 1247 - if (addr >= len) { 1247 + if (addr > len) { 1248 1248 vma = find_vma(mm, addr-len); 1249 1249 if (!vma || addr <= vma->vm_start) 1250 1250 /* remember the address as a hint for next time */ ··· 1266 1266 1267 1267 /* try just below the current vma->vm_start */ 1268 1268 addr = vma->vm_start-len; 1269 - } while (len <= vma->vm_start); 1269 + } while (len < vma->vm_start); 1270 1270 1271 1271 /* 1272 1272 * A failed mmap() very likely causes application failure,