]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/hotplug/acpiphp_ibm.c
PCI: introduce pci_slot
[linux-2.6-omap-h63xx.git] / drivers / pci / hotplug / acpiphp_ibm.c
index 47d26b65e99a88265db14a5004a429658b6b287e..2b7c45e39370f1e42fa0546f30cf6e6c7e9356f8 100644 (file)
 #include <linux/kobject.h>
 #include <asm/uaccess.h>
 #include <linux/moduleparam.h>
+#include <linux/pci.h>
 
 #include "acpiphp.h"
+#include "../pci.h"
 
 #define DRIVER_VERSION "1.0.1"
 #define DRIVER_AUTHOR  "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>"
@@ -186,7 +188,7 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status)
 
        ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot));
 
-       dbg("%s: set slot %d (%d) attention status to %d\n", __FUNCTION__,
+       dbg("%s: set slot %d (%d) attention status to %d\n", __func__,
                        ibm_slot->slot.slot_num, ibm_slot->slot.slot_id,
                        (status ? 1 : 0));
 
@@ -231,7 +233,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status)
        else
                *status = 0;
 
-       dbg("%s: get slot %d (%d) attention status is %d\n", __FUNCTION__,
+       dbg("%s: get slot %d (%d) attention status is %d\n", __func__,
                        ibm_slot->slot.slot_num, ibm_slot->slot.slot_id,
                        *status);
 
@@ -263,10 +265,10 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
        u8 subevent = event & 0xf0;
        struct notification *note = context;
 
-       dbg("%s: Received notification %02x\n", __FUNCTION__, event);
+       dbg("%s: Received notification %02x\n", __func__, event);
 
        if (subevent == 0x80) {
-               dbg("%s: generationg bus event\n", __FUNCTION__);
+               dbg("%s: generationg bus event\n", __func__);
                acpi_bus_generate_proc_event(note->device, note->event, detail);
                acpi_bus_generate_netlink_event(note->device->pnp.device_class,
                                                  note->device->dev.bus_id,
@@ -299,7 +301,7 @@ static int ibm_get_table_from_acpi(char **bufp)
 
        status = acpi_evaluate_object(ibm_acpi_handle, "APCI", NULL, &buffer);
        if (ACPI_FAILURE(status)) {
-               err("%s:  APCI evaluation failed\n", __FUNCTION__);
+               err("%s:  APCI evaluation failed\n", __func__);
                return -ENODEV;
        }
 
@@ -307,13 +309,13 @@ static int ibm_get_table_from_acpi(char **bufp)
        if (!(package) ||
                        (package->type != ACPI_TYPE_PACKAGE) ||
                        !(package->package.elements)) {
-               err("%s:  Invalid APCI object\n", __FUNCTION__);
+               err("%s:  Invalid APCI object\n", __func__);
                goto read_table_done;
        }
 
        for(size = 0, i = 0; i < package->package.count; i++) {
                if (package->package.elements[i].type != ACPI_TYPE_BUFFER) {
-                       err("%s:  Invalid APCI element %d\n", __FUNCTION__, i);
+                       err("%s:  Invalid APCI element %d\n", __func__, i);
                        goto read_table_done;
                }
                size += package->package.elements[i].buffer.length;
@@ -324,7 +326,7 @@ static int ibm_get_table_from_acpi(char **bufp)
 
        lbuf = kzalloc(size, GFP_KERNEL);
        dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n",
-                       __FUNCTION__, package->package.count, size, lbuf);
+                       __func__, package->package.count, size, lbuf);
 
        if (lbuf) {
                *bufp = lbuf;
@@ -368,7 +370,7 @@ static ssize_t ibm_read_apci_table(struct kobject *kobj,
        int bytes_read = -EINVAL;
        char *table = NULL;
        
-       dbg("%s: pos = %d, size = %zd\n", __FUNCTION__, (int)pos, size);
+       dbg("%s: pos = %d, size = %zd\n", __func__, (int)pos, size);
 
        if (pos == 0) {
                bytes_read = ibm_get_table_from_acpi(&table);
@@ -395,33 +397,34 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
 {
        acpi_handle *phandle = (acpi_handle *)context;
        acpi_status status; 
-       struct acpi_device_info info; 
-       struct acpi_buffer info_buffer = {
-               .length = sizeof(struct acpi_device_info),
-               .pointer = &info,
-       };
+       struct acpi_device_info *info;
+       struct acpi_buffer info_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       int retval = 0;
 
        status = acpi_get_object_info(handle, &info_buffer);
        if (ACPI_FAILURE(status)) {
-               err("%s:  Failed to get device information\n", __FUNCTION__);
-               return 0;
+               err("%s:  Failed to get device information status=0x%x\n",
+                       __func__, status);
+               return retval;
        }
-       info.hardware_id.value[sizeof(info.hardware_id.value) - 1] = '\0';
-
-       if (info.current_status && (info.valid & ACPI_VALID_HID) &&
-                       (!strcmp(info.hardware_id.value, IBM_HARDWARE_ID1) ||
-                       !strcmp(info.hardware_id.value, IBM_HARDWARE_ID2))) {
-               dbg("found hardware: %s, handle: %p\n", info.hardware_id.value,
-                               handle);
+       info = info_buffer.pointer;
+       info->hardware_id.value[sizeof(info->hardware_id.value) - 1] = '\0';
+
+       if (info->current_status && (info->valid & ACPI_VALID_HID) &&
+                       (!strcmp(info->hardware_id.value, IBM_HARDWARE_ID1) ||
+                        !strcmp(info->hardware_id.value, IBM_HARDWARE_ID2))) {
+               dbg("found hardware: %s, handle: %p\n",
+                       info->hardware_id.value, handle);
                *phandle = handle;
                /* returning non-zero causes the search to stop
                 * and returns this value to the caller of 
                 * acpi_walk_namespace, but it also causes some warnings
                 * in the acpi debug code to print...
                 */
-               return FOUND_APCI;
+               retval = FOUND_APCI;
        }
-       return 0;
+       kfree(info);
+       return retval;
 }
 
 static int __init ibm_acpiphp_init(void)
@@ -429,20 +432,20 @@ static int __init ibm_acpiphp_init(void)
        int retval = 0;
        acpi_status status;
        struct acpi_device *device;
-       struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
+       struct kobject *sysdir = &pci_slots_kset->kobj;
 
-       dbg("%s\n", __FUNCTION__);
+       dbg("%s\n", __func__);
 
        if (acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
                        ACPI_UINT32_MAX, ibm_find_acpi_device,
                        &ibm_acpi_handle, NULL) != FOUND_APCI) {
-               err("%s: acpi_walk_namespace failed\n", __FUNCTION__);
+               err("%s: acpi_walk_namespace failed\n", __func__);
                retval = -ENODEV;
                goto init_return;
        }
-       dbg("%s: found IBM aPCI device\n", __FUNCTION__);
+       dbg("%s: found IBM aPCI device\n", __func__);
        if (acpi_bus_get_device(ibm_acpi_handle, &device)) {
-               err("%s: acpi_bus_get_device failed\n", __FUNCTION__);
+               err("%s: acpi_bus_get_device failed\n", __func__);
                retval = -ENODEV;
                goto init_return;
        }
@@ -457,7 +460,7 @@ static int __init ibm_acpiphp_init(void)
                        &ibm_note);
        if (ACPI_FAILURE(status)) {
                err("%s: Failed to register notification handler\n",
-                               __FUNCTION__);
+                               __func__);
                retval = -EBUSY;
                goto init_cleanup;
        }
@@ -476,19 +479,19 @@ init_return:
 static void __exit ibm_acpiphp_exit(void)
 {
        acpi_status status;
-       struct kobject *sysdir = &pci_hotplug_slots_subsys.kobj;
+       struct kobject *sysdir = &pci_slots_kset->kobj;
 
-       dbg("%s\n", __FUNCTION__);
+       dbg("%s\n", __func__);
 
        if (acpiphp_unregister_attention(&ibm_attention_info))
-               err("%s: attention info deregistration failed", __FUNCTION__);
+               err("%s: attention info deregistration failed", __func__);
 
        status = acpi_remove_notify_handler(
                           ibm_acpi_handle,
                           ACPI_DEVICE_NOTIFY,
                           ibm_handle_events);
        if (ACPI_FAILURE(status))
-               err("%s: Notification handler removal failed\n", __FUNCTION__);
+               err("%s: Notification handler removal failed\n", __func__);
        /* remove the /sys entries */
        sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr);
 }