Merge branch 'acpica' into release
Len Brown [Sat, 19 Sep 2009 05:45:22 +0000 (01:45 -0400)]
1  2 
drivers/acpi/container.c
drivers/acpi/dock.c
drivers/acpi/glue.c
drivers/acpi/scan.c
drivers/char/agp/hp-agp.c
include/acpi/acpi_bus.h

diff --combined drivers/acpi/container.c
@@@ -35,8 -35,6 +35,8 @@@
  #include <acpi/acpi_drivers.h>
  #include <acpi/container.h>
  
 +#define PREFIX "ACPI: "
 +
  #define ACPI_CONTAINER_DEVICE_NAME    "ACPI container device"
  #define ACPI_CONTAINER_CLASS          "container"
  
@@@ -202,20 -200,17 +202,17 @@@ container_walk_namespace_cb(acpi_handl
                            u32 lvl, void *context, void **rv)
  {
        char *hid = NULL;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_device_info *info;
        acpi_status status;
        int *action = context;
  
-       status = acpi_get_object_info(handle, &buffer);
-       if (ACPI_FAILURE(status) || !buffer.pointer) {
+       status = acpi_get_object_info(handle, &info);
+       if (ACPI_FAILURE(status)) {
                return AE_OK;
        }
  
-       info = buffer.pointer;
        if (info->valid & ACPI_VALID_HID)
-               hid = info->hardware_id.value;
+               hid = info->hardware_id.string;
  
        if (hid == NULL) {
                goto end;
        }
  
        end:
-       kfree(buffer.pointer);
+       kfree(info);
  
        return AE_OK;
  }
diff --combined drivers/acpi/dock.c
@@@ -33,8 -33,6 +33,8 @@@
  #include <acpi/acpi_bus.h>
  #include <acpi/acpi_drivers.h>
  
 +#define PREFIX "ACPI: "
 +
  #define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver"
  
  ACPI_MODULE_NAME("dock");
@@@ -233,18 -231,16 +233,16 @@@ static int is_ata(acpi_handle handle
  static int is_battery(acpi_handle handle)
  {
        struct acpi_device_info *info;
-       struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
        int ret = 1;
  
-       if (!ACPI_SUCCESS(acpi_get_object_info(handle, &buffer)))
+       if (!ACPI_SUCCESS(acpi_get_object_info(handle, &info)))
                return 0;
        if (!(info->valid & ACPI_VALID_HID))
                ret = 0;
        else
-               ret = !strcmp("PNP0C0A", info->hardware_id.value);
+               ret = !strcmp("PNP0C0A", info->hardware_id.string);
  
-       kfree(buffer.pointer);
+       kfree(info);
        return ret;
  }
  
diff --combined drivers/acpi/glue.c
@@@ -12,8 -12,6 +12,8 @@@
  #include <linux/rwsem.h>
  #include <linux/acpi.h>
  
 +#include "internal.h"
 +
  #define ACPI_GLUE_DEBUG       0
  #if ACPI_GLUE_DEBUG
  #define DBG(x...) printk(PREFIX x)
@@@ -95,15 -93,13 +95,13 @@@ do_acpi_find_child(acpi_handle handle, 
  {
        acpi_status status;
        struct acpi_device_info *info;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
        struct acpi_find_child *find = context;
  
-       status = acpi_get_object_info(handle, &buffer);
+       status = acpi_get_object_info(handle, &info);
        if (ACPI_SUCCESS(status)) {
-               info = buffer.pointer;
                if (info->address == find->address)
                        find->handle = handle;
-               kfree(buffer.pointer);
+               kfree(info);
        }
        return AE_OK;
  }
@@@ -123,7 -119,7 +121,7 @@@ EXPORT_SYMBOL(acpi_get_child)
  
  /* Link ACPI devices with physical devices */
  static void acpi_glue_data_handler(acpi_handle handle,
-                                  u32 function, void *context)
+                                  void *context)
  {
        /* we provide an empty handler */
  }
diff --combined drivers/acpi/scan.c
@@@ -60,13 -60,13 +60,13 @@@ static int create_modalias(struct acpi_
        }
  
        if (acpi_dev->flags.compatible_ids) {
-               struct acpi_compatible_id_list *cid_list;
+               struct acpica_device_id_list *cid_list;
                int i;
  
                cid_list = acpi_dev->pnp.cid_list;
                for (i = 0; i < cid_list->count; i++) {
                        count = snprintf(&modalias[len], size, "%s:",
-                                        cid_list->id[i].value);
+                                        cid_list->ids[i].string);
                        if (count < 0 || count >= size) {
                                printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size",
                                       acpi_dev->pnp.device_name, i);
@@@ -287,14 -287,14 +287,14 @@@ int acpi_match_device_ids(struct acpi_d
        }
  
        if (device->flags.compatible_ids) {
-               struct acpi_compatible_id_list *cid_list = device->pnp.cid_list;
+               struct acpica_device_id_list *cid_list = device->pnp.cid_list;
                int i;
  
                for (id = ids; id->id[0]; id++) {
                        /* compare multiple _CID entries against driver ids */
                        for (i = 0; i < cid_list->count; i++) {
                                if (!strcmp((char*)id->id,
-                                           cid_list->id[i].value))
+                                           cid_list->ids[i].string))
                                        return 0;
                        }
                }
@@@ -309,6 -309,10 +309,10 @@@ static void acpi_device_release(struct 
        struct acpi_device *acpi_dev = to_acpi_device(dev);
  
        kfree(acpi_dev->pnp.cid_list);
+       if (acpi_dev->flags.hardware_id)
+               kfree(acpi_dev->pnp.hardware_id);
+       if (acpi_dev->flags.unique_id)
+               kfree(acpi_dev->pnp.unique_id);
        kfree(acpi_dev);
  }
  
@@@ -687,7 -691,7 +691,7 @@@ acpi_bus_get_ejd(acpi_handle handle, ac
  }
  EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
  
- void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
+ void acpi_bus_data_handler(acpi_handle handle, void *context)
  {
  
        /* TBD */
@@@ -781,7 -785,6 +785,7 @@@ static int acpi_bus_get_wakeup_device_f
        kfree(buffer.pointer);
  
        device->wakeup.flags.valid = 1;
 +      device->wakeup.prepare_count = 0;
        /* Call _PSW/_DSW object to disable its ability to wake the sleeping
         * system for the ACPI device with the _PRW object.
         * The _PSW object is depreciated in ACPI 3.0 and is replaced by _DSW.
@@@ -1000,33 -1003,89 +1004,89 @@@ static int acpi_dock_match(struct acpi_
        return acpi_get_handle(device->handle, "_DCK", &tmp);
  }
  
+ static struct acpica_device_id_list*
+ acpi_add_cid(
+       struct acpi_device_info         *info,
+       struct acpica_device_id         *new_cid)
+ {
+       struct acpica_device_id_list    *cid;
+       char                            *next_id_string;
+       acpi_size                       cid_length;
+       acpi_size                       new_cid_length;
+       u32                             i;
+       /* Allocate new CID list with room for the new CID */
+       if (!new_cid)
+               new_cid_length = info->compatible_id_list.list_size;
+       else if (info->compatible_id_list.list_size)
+               new_cid_length = info->compatible_id_list.list_size +
+                       new_cid->length + sizeof(struct acpica_device_id);
+       else
+               new_cid_length = sizeof(struct acpica_device_id_list) + new_cid->length;
+       cid = ACPI_ALLOCATE_ZEROED(new_cid_length);
+       if (!cid) {
+               return NULL;
+       }
+       cid->list_size = new_cid_length;
+       cid->count = info->compatible_id_list.count;
+       if (new_cid)
+               cid->count++;
+       next_id_string = (char *) cid->ids + (cid->count * sizeof(struct acpica_device_id));
+       /* Copy all existing CIDs */
+       for (i = 0; i < info->compatible_id_list.count; i++) {
+               cid_length = info->compatible_id_list.ids[i].length;
+               cid->ids[i].string = next_id_string;
+               cid->ids[i].length = cid_length;
+               ACPI_MEMCPY(next_id_string, info->compatible_id_list.ids[i].string,
+                       cid_length);
+               next_id_string += cid_length;
+       }
+       /* Append the new CID */
+       if (new_cid) {
+               cid->ids[i].string = next_id_string;
+               cid->ids[i].length = new_cid->length;
+               ACPI_MEMCPY(next_id_string, new_cid->string, new_cid->length);
+       }
+       return cid;
+ }
  static void acpi_device_set_id(struct acpi_device *device,
                               struct acpi_device *parent, acpi_handle handle,
                               int type)
  {
-       struct acpi_device_info *info;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       struct acpi_device_info *info = NULL;
        char *hid = NULL;
        char *uid = NULL;
-       struct acpi_compatible_id_list *cid_list = NULL;
-       const char *cid_add = NULL;
+       struct acpica_device_id_list *cid_list = NULL;
+       char *cid_add = NULL;
        acpi_status status;
  
        switch (type) {
        case ACPI_BUS_TYPE_DEVICE:
-               status = acpi_get_object_info(handle, &buffer);
+               status = acpi_get_object_info(handle, &info);
                if (ACPI_FAILURE(status)) {
                        printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
                        return;
                }
  
-               info = buffer.pointer;
                if (info->valid & ACPI_VALID_HID)
-                       hid = info->hardware_id.value;
+                       hid = info->hardware_id.string;
                if (info->valid & ACPI_VALID_UID)
-                       uid = info->unique_id.value;
+                       uid = info->unique_id.string;
                if (info->valid & ACPI_VALID_CID)
-                       cid_list = &info->compatibility_id;
+                       cid_list = &info->compatible_id_list;
                if (info->valid & ACPI_VALID_ADR) {
                        device->pnp.bus_address = info->address;
                        device->flags.bus_address = 1;
        }
  
        if (hid) {
-               strcpy(device->pnp.hardware_id, hid);
-               device->flags.hardware_id = 1;
+               device->pnp.hardware_id = ACPI_ALLOCATE_ZEROED(strlen (hid) + 1);
+               if (device->pnp.hardware_id) {
+                       strcpy(device->pnp.hardware_id, hid);
+                       device->flags.hardware_id = 1;
+               }
        }
+       if (!device->flags.hardware_id)
+               device->pnp.hardware_id = "";
        if (uid) {
-               strcpy(device->pnp.unique_id, uid);
-               device->flags.unique_id = 1;
+               device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1);
+               if (device->pnp.unique_id) {
+                       strcpy(device->pnp.unique_id, uid);
+                       device->flags.unique_id = 1;
+               }
        }
+       if (!device->flags.unique_id)
+               device->pnp.unique_id = "";
        if (cid_list || cid_add) {
-               struct  acpi_compatible_id_list *list;
-               int size = 0;
-               int count = 0;
-               if (cid_list) {
-                       size = cid_list->size;
-               } else if (cid_add) {
-                       size = sizeof(struct acpi_compatible_id_list);
-                       cid_list = ACPI_ALLOCATE_ZEROED((acpi_size) size);
-                       if (!cid_list) {
-                               printk(KERN_ERR "Memory allocation error\n");
-                               kfree(buffer.pointer);
-                               return;
-                       } else {
-                               cid_list->count = 0;
-                               cid_list->size = size;
-                       }
+               struct acpica_device_id_list *list;
+               if (cid_add) {
+                       struct acpica_device_id cid;
+                       cid.length = strlen (cid_add) + 1;
+                       cid.string = cid_add;
+                       list = acpi_add_cid(info, &cid);
+               } else {
+                       list = acpi_add_cid(info, NULL);
                }
-               if (cid_add)
-                       size += sizeof(struct acpi_compatible_id);
-               list = kmalloc(size, GFP_KERNEL);
  
                if (list) {
-                       if (cid_list) {
-                               memcpy(list, cid_list, cid_list->size);
-                               count = cid_list->count;
-                       }
-                       if (cid_add) {
-                               strncpy(list->id[count].value, cid_add,
-                                       ACPI_MAX_CID_LENGTH);
-                               count++;
-                               device->flags.compatible_ids = 1;
-                       }
-                       list->size = size;
-                       list->count = count;
                        device->pnp.cid_list = list;
-               } else
-                       printk(KERN_ERR PREFIX "Memory allocation error\n");
+                       if (cid_add)
+                               device->flags.compatible_ids = 1;
+               }
        }
  
-       kfree(buffer.pointer);
+       kfree(info);
  }
  
  static int acpi_device_set_context(struct acpi_device *device, int type)
@@@ -1265,6 -1315,16 +1316,6 @@@ acpi_add_single_object(struct acpi_devi
        acpi_device_set_id(device, parent, handle, type);
  
        /*
 -       * The ACPI device is attached to acpi handle before getting
 -       * the power/wakeup/peformance flags. Otherwise OS can't get
 -       * the corresponding ACPI device by the acpi handle in the course
 -       * of getting the power/wakeup/performance flags.
 -       */
 -      result = acpi_device_set_context(device, type);
 -      if (result)
 -              goto end;
 -
 -      /*
         * Power Management
         * ----------------
         */
                        goto end;
        }
  
 +      if ((result = acpi_device_set_context(device, type)))
 +              goto end;
  
        result = acpi_device_register(device, parent);
  
  end:
        if (!result)
                *child = device;
-       else {
-               kfree(device->pnp.cid_list);
-               kfree(device);
-       }
+       else
+               acpi_device_release(&device->dev);
  
        return result;
  }
@@@ -107,7 -107,7 +107,7 @@@ static int __init hp_zx1_ioc_shared(voi
        hp->gart_size = HP_ZX1_GART_SIZE;
        hp->gatt_entries = hp->gart_size / hp->io_page_size;
  
 -      hp->io_pdir = gart_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
 +      hp->io_pdir = phys_to_virt(readq(hp->ioc_regs+HP_ZX1_PDIR_BASE));
        hp->gatt = &hp->io_pdir[HP_ZX1_IOVA_TO_PDIR(hp->gart_base)];
  
        if (hp->gatt[0] != HP_ZX1_SBA_IOMMU_COOKIE) {
@@@ -246,7 -246,7 +246,7 @@@ hp_zx1_configure (void
        agp_bridge->mode = readl(hp->lba_regs+hp->lba_cap_offset+PCI_AGP_STATUS);
  
        if (hp->io_pdir_owner) {
 -              writel(virt_to_gart(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
 +              writel(virt_to_phys(hp->io_pdir), hp->ioc_regs+HP_ZX1_PDIR_BASE);
                readl(hp->ioc_regs+HP_ZX1_PDIR_BASE);
                writel(hp->io_tlb_ps, hp->ioc_regs+HP_ZX1_TCNFG);
                readl(hp->ioc_regs+HP_ZX1_TCNFG);
@@@ -394,8 -394,10 +394,8 @@@ hp_zx1_remove_memory (struct agp_memor
  }
  
  static unsigned long
 -hp_zx1_mask_memory (struct agp_bridge_data *bridge,
 -                  struct page *page, int type)
 +hp_zx1_mask_memory (struct agp_bridge_data *bridge, dma_addr_t addr, int type)
  {
 -      unsigned long addr = phys_to_gart(page_to_phys(page));
        return HP_ZX1_PDIR_VALID_BIT | addr;
  }
  
@@@ -476,7 -478,6 +476,6 @@@ zx1_gart_probe (acpi_handle obj, u32 de
  {
        acpi_handle handle, parent;
        acpi_status status;
-       struct acpi_buffer buffer;
        struct acpi_device_info *info;
        u64 lba_hpa, sba_hpa, length;
        int match;
        /* Look for an enclosing IOC scope and find its CSR space */
        handle = obj;
        do {
-               buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
-               status = acpi_get_object_info(handle, &buffer);
+               status = acpi_get_object_info(handle, &info);
                if (ACPI_SUCCESS(status)) {
                        /* TBD check _CID also */
-                       info = buffer.pointer;
-                       info->hardware_id.value[sizeof(info->hardware_id)-1] = '\0';
-                       match = (strcmp(info->hardware_id.value, "HWP0001") == 0);
+                       info->hardware_id.string[sizeof(info->hardware_id.length)-1] = '\0';
+                       match = (strcmp(info->hardware_id.string, "HWP0001") == 0);
                        kfree(info);
                        if (match) {
                                status = hp_acpi_csr_space(handle, &sba_hpa, &length);
diff --combined include/acpi/acpi_bus.h
@@@ -30,6 -30,8 +30,6 @@@
  
  #include <acpi/acpi.h>
  
 -#define PREFIX                        "ACPI: "
 -
  /* TBD: Make dynamic */
  #define ACPI_MAX_HANDLES      10
  struct acpi_handle_list {
@@@ -171,17 -173,15 +171,15 @@@ struct acpi_device_dir 
  
  typedef char acpi_bus_id[8];
  typedef unsigned long acpi_bus_address;
- typedef char acpi_hardware_id[15];
- typedef char acpi_unique_id[9];
  typedef char acpi_device_name[40];
  typedef char acpi_device_class[20];
  
  struct acpi_device_pnp {
        acpi_bus_id bus_id;     /* Object name */
        acpi_bus_address bus_address;   /* _ADR */
-       acpi_hardware_id hardware_id;   /* _HID */
-       struct acpi_compatible_id_list *cid_list;       /* _CIDs */
-       acpi_unique_id unique_id;       /* _UID */
+       char *hardware_id;      /* _HID */
+       struct acpica_device_id_list *cid_list; /* _CIDs */
+       char *unique_id;        /* _UID */
        acpi_device_name device_name;   /* Driver-determined */
        acpi_device_class device_class; /*        "          */
  };
@@@ -246,6 -246,7 +244,6 @@@ struct acpi_device_perf 
  /* Wakeup Management */
  struct acpi_device_wakeup_flags {
        u8 valid:1;             /* Can successfully enable wakeup? */
 -      u8 prepared:1;          /* Has the wake-up capability been enabled? */
        u8 run_wake:1;          /* Run-Wake GPE devices */
  };
  
@@@ -260,7 -261,6 +258,7 @@@ struct acpi_device_wakeup 
        struct acpi_handle_list resources;
        struct acpi_device_wakeup_state state;
        struct acpi_device_wakeup_flags flags;
 +      int prepare_count;
  };
  
  /* Device */
@@@ -312,7 -312,7 +310,7 @@@ struct acpi_bus_event 
  
  extern struct kobject *acpi_kobj;
  extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
- void acpi_bus_private_data_handler(acpi_handle, u32, void *);
+ void acpi_bus_private_data_handler(acpi_handle, void *);
  int acpi_bus_get_private_data(acpi_handle, void **);
  extern int acpi_notifier_call_chain(struct acpi_device *, u32, u32);
  extern int register_acpi_notifier(struct notifier_block *);
@@@ -325,7 -325,7 +323,7 @@@ extern void unregister_acpi_bus_notifie
   */
  
  int acpi_bus_get_device(acpi_handle handle, struct acpi_device **device);
- void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context);
+ void acpi_bus_data_handler(acpi_handle handle, void *context);
  int acpi_bus_get_status(struct acpi_device *device);
  int acpi_bus_get_power(acpi_handle handle, int *state);
  int acpi_bus_set_power(acpi_handle handle, int state);
@@@ -367,26 -367,10 +365,26 @@@ int register_acpi_bus_type(struct acpi_
  int unregister_acpi_bus_type(struct acpi_bus_type *);
  struct device *acpi_get_physical_device(acpi_handle);
  
 +struct acpi_pci_root {
 +      struct list_head node;
 +      struct acpi_device * device;
 +      struct acpi_pci_id id;
 +      struct pci_bus *bus;
 +      u16 segment;
 +      u8 bus_nr;
 +
 +      u32 osc_support_set;    /* _OSC state of support bits */
 +      u32 osc_control_set;    /* _OSC state of control bits */
 +      u32 osc_control_qry;    /* the latest _OSC query result */
 +
 +      u32 osc_queried:1;      /* has _OSC control been queried? */
 +};
 +
  /* helper */
  acpi_handle acpi_get_child(acpi_handle, acpi_integer);
  int acpi_is_root_bridge(acpi_handle);
  acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
 +struct acpi_pci_root *acpi_pci_find_root(acpi_handle handle);
  #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
  
  #ifdef CONFIG_PM_SLEEP