]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ACPI: catch calls of acpi_driver_data on pointer of wrong type
authorPavel Machek <pavel@suse.cz>
Mon, 22 Sep 2008 21:37:34 +0000 (14:37 -0700)
committerLen Brown <len.brown@intel.com>
Fri, 10 Oct 2008 22:05:53 +0000 (18:05 -0400)
Catch attempts to use of acpi_driver_data on pointers of wrong type.

akpm: rewritten to use proper C typechecking and remove the
"function"-used-as-lvalue thing.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
23 files changed:
drivers/acpi/ac.c
drivers/acpi/acpi_memhotplug.c
drivers/acpi/asus_acpi.c
drivers/acpi/battery.c
drivers/acpi/button.c
drivers/acpi/container.c
drivers/acpi/ec.c
drivers/acpi/fan.c
drivers/acpi/pci_link.c
drivers/acpi/pci_root.c
drivers/acpi/power.c
drivers/acpi/processor_core.c
drivers/acpi/sbs.c
drivers/acpi/sbshc.c
drivers/acpi/scan.c
drivers/acpi/thermal.c
drivers/acpi/video.c
drivers/misc/asus-laptop.c
drivers/misc/eeepc-laptop.c
drivers/misc/fujitsu-laptop.c
drivers/misc/intel_menlow.c
drivers/misc/thinkpad_acpi.c
include/acpi/acpi_bus.h

index 831883b7d6c9c5f456bb8db766ebc978b00bd907..8b6a84a43b1592a29efd2523bc2168cbd59860d9 100644 (file)
@@ -269,7 +269,7 @@ static int acpi_ac_add(struct acpi_device *device)
        ac->device = device;
        strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_AC_CLASS);
-       acpi_driver_data(device) = ac;
+       device->driver_data = ac;
 
        result = acpi_ac_get_state(ac);
        if (result)
index 5f1127ad5a9538fde4cdaa8e4a6658f2880928a7..afd955fc0dc248af6c3986661e11ba6b44620377 100644 (file)
@@ -403,7 +403,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
        mem_device->device = device;
        sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
        sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
-       acpi_driver_data(device) = mem_device;
+       device->driver_data = mem_device;
 
        /* Get the range from the _CRS */
        result = acpi_memory_get_device_resources(mem_device);
index d3d0886d637f4f6e33e7a0f0ed54fe00560d2615..91571fc0f17d57087f3e63e872773dcc40ddcd0a 100644 (file)
@@ -1321,7 +1321,7 @@ static int asus_hotk_add(struct acpi_device *device)
        hotk->handle = device->handle;
        strcpy(acpi_device_name(device), ACPI_HOTK_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_HOTK_CLASS);
-       acpi_driver_data(device) = hotk;
+       device->driver_data = hotk;
        hotk->device = device;
 
        result = asus_hotk_check();
index b1c723f9f58d1fce3861730870b58550fe13f6a2..de8046933bce6cf5154c2aaeca2a75df847845e2 100644 (file)
@@ -804,7 +804,7 @@ static int acpi_battery_add(struct acpi_device *device)
        battery->device = device;
        strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
-       acpi_driver_data(device) = battery;
+       device->driver_data = battery;
        mutex_init(&battery->lock);
        acpi_battery_update(battery);
 #ifdef CONFIG_ACPI_PROCFS_POWER
index 1dfec413588ca6e07ba06f51b69b7ea431906a2b..e22033ea2614b8963170e7865b1b569a11699169 100644 (file)
@@ -384,7 +384,7 @@ static int acpi_button_add(struct acpi_device *device)
                return -ENOMEM;
 
        button->device = device;
-       acpi_driver_data(device) = button;
+       device->driver_data = button;
 
        button->input = input = input_allocate_device();
        if (!input) {
index 3c25ec7a187142dc224c748dcb481601df626501..03ea8478e393846f7a6aa559f8cfb16faeccce88 100644 (file)
@@ -108,7 +108,7 @@ static int acpi_container_add(struct acpi_device *device)
        container->handle = device->handle;
        strcpy(acpi_device_name(device), ACPI_CONTAINER_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_CONTAINER_CLASS);
-       acpi_driver_data(device) = container;
+       device->driver_data = container;
 
        ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device <%s> bid <%s>\n",
                          acpi_device_name(device), acpi_device_bid(device)));
index 13593f9f21970ec79af46f62b0233689065e848d..5741d99d6034edaceb3183b81ae48cca873f0161 100644 (file)
@@ -788,7 +788,7 @@ static int acpi_ec_add(struct acpi_device *device)
 
        if (!first_ec)
                first_ec = ec;
-       acpi_driver_data(device) = ec;
+       device->driver_data = ec;
        acpi_ec_add_fs(device);
        pr_info(PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx\n",
                          ec->gpe, ec->command_addr, ec->data_addr);
@@ -813,7 +813,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
        }
        mutex_unlock(&ec->lock);
        acpi_ec_remove_fs(device);
-       acpi_driver_data(device) = NULL;
+       device->driver_data = NULL;
        if (ec == first_ec)
                first_ec = NULL;
        kfree(ec);
index 2655bc1b4eebc7cbb02a16afc715e703dd0e3499..e603e4070702eb17b1e304fac7390d180d99b454 100644 (file)
@@ -265,7 +265,7 @@ static int acpi_fan_add(struct acpi_device *device)
 
        dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id);
 
-       acpi_driver_data(device) = cdev;
+       device->driver_data = cdev;
        result = sysfs_create_link(&device->dev.kobj,
                                   &cdev->device.kobj,
                                   "thermal_cooling");
index cf47805a7448ccc9ddfbec7009cc975be371c760..54cd77a0a78e0206b6e58232008f876e1e6186dc 100644 (file)
@@ -737,7 +737,7 @@ static int acpi_pci_link_add(struct acpi_device *device)
        link->device = device;
        strcpy(acpi_device_name(device), ACPI_PCI_LINK_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_PCI_LINK_CLASS);
-       acpi_driver_data(device) = link;
+       device->driver_data = link;
 
        mutex_lock(&acpi_link_lock);
        result = acpi_pci_link_get_possible(link);
index c3fed31166b552761f2bb9c3b26ef2b7c3e47592..add1a19bbbfe8ecba3b0e5e6ce63962196c65a92 100644 (file)
@@ -206,7 +206,7 @@ static int __devinit acpi_pci_root_add(struct acpi_device *device)
        root->device = device;
        strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_PCI_ROOT_CLASS);
-       acpi_driver_data(device) = root;
+       device->driver_data = root;
 
        device->ops.bind = acpi_pci_bind;
 
index 4ab21cb1c8c7ebde037b51256de4c326efcfd7f6..1bef9429189bbf8d9cac96d415ed4ddb0372e379 100644 (file)
@@ -657,7 +657,7 @@ static int acpi_power_add(struct acpi_device *device)
        strcpy(resource->name, device->pnp.bus_id);
        strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_POWER_CLASS);
-       acpi_driver_data(device) = resource;
+       device->driver_data = resource;
 
        /* Evalute the object to get the system level and resource order. */
        status = acpi_evaluate_object(device->handle, NULL, NULL, &buffer);
@@ -733,7 +733,7 @@ static int acpi_power_resume(struct acpi_device *device)
        if (!device || !acpi_driver_data(device))
                return -EINVAL;
 
-       resource = (struct acpi_power_resource *)acpi_driver_data(device);
+       resource = acpi_driver_data(device);
 
        result = acpi_power_get_state(resource, &state);
        if (result)
index ee68ac54c0d412996aebefc58b6c51c1363da5af..289461649196b7e2cf5cf1b34d0683aadfe901ee 100644 (file)
@@ -818,7 +818,7 @@ static int acpi_processor_add(struct acpi_device *device)
        pr->handle = device->handle;
        strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
-       acpi_driver_data(device) = pr;
+       device->driver_data = pr;
 
        return 0;
 }
index 10a36512647ca6107a76c5982a5f3acaa140b571..d0033250b5a9c82e9d52c3639a0ff0193c9af77e 100644 (file)
@@ -931,7 +931,7 @@ static int acpi_sbs_add(struct acpi_device *device)
        sbs->device = device;
        strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_SBS_CLASS);
-       acpi_driver_data(device) = sbs;
+       device->driver_data = sbs;
 
        result = acpi_charger_add(sbs);
        if (result)
index a4e3767b8c64241c6bd1c11010f0c2001fd7e7c1..001d9143a2cb18923b2f56695e2a6fc6681cdcb7 100644 (file)
@@ -282,7 +282,7 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
        hc->ec = acpi_driver_data(device->parent);
        hc->offset = (val >> 8) & 0xff;
        hc->query_bit = val & 0xff;
-       acpi_driver_data(device) = hc;
+       device->driver_data = hc;
 
        acpi_ec_add_query_handler(hc->ec, hc->query_bit, NULL, smbus_alarm, hc);
        printk(KERN_INFO PREFIX "SBS HC: EC = 0x%p, offset = 0x%0x, query_bit = 0x%0x\n",
@@ -303,7 +303,7 @@ static int acpi_smbus_hc_remove(struct acpi_device *device, int type)
        hc = acpi_driver_data(device);
        acpi_ec_remove_query_handler(hc->ec, hc->query_bit);
        kfree(hc);
-       acpi_driver_data(device) = NULL;
+       device->driver_data = NULL;
        return 0;
 }
 
index e7b8853c310b9c59e22ec85f824d08d412d36d4d..b88536ab040a035d8571a263197d0af435985d9b 100644 (file)
@@ -384,7 +384,7 @@ static int acpi_device_remove(struct device * dev)
                        acpi_drv->ops.remove(acpi_dev, acpi_dev->removal_type);
        }
        acpi_dev->driver = NULL;
-       acpi_driver_data(acpi_dev) = NULL;
+       acpi_dev->driver_data = NULL;
 
        put_device(dev);
        return 0;
@@ -537,7 +537,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
        result = driver->ops.add(device);
        if (result) {
                device->driver = NULL;
-               acpi_driver_data(device) = NULL;
+               device->driver_data = NULL;
                return result;
        }
 
index 912703691d36306b0d2256ba345570cab139f688..e052a75c29ceec853b08fb4e54bf114fea069113 100644 (file)
@@ -1647,7 +1647,7 @@ static int acpi_thermal_add(struct acpi_device *device)
        strcpy(tz->name, device->pnp.bus_id);
        strcpy(acpi_device_name(device), ACPI_THERMAL_DEVICE_NAME);
        strcpy(acpi_device_class(device), ACPI_THERMAL_CLASS);
-       acpi_driver_data(device) = tz;
+       device->driver_data = tz;
        mutex_init(&tz->lock);
 
 
index e8a51a1700f710ca45d7ceba5a22429f7d348fbe..85c6554bcb4c04196acbc5e6354afb321f4c1f89 100644 (file)
@@ -1491,7 +1491,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
 
                strcpy(acpi_device_name(device), ACPI_VIDEO_DEVICE_NAME);
                strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
-               acpi_driver_data(device) = data;
+               device->driver_data = data;
 
                data->device_id = device_id;
                data->video = video;
@@ -1982,7 +1982,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
        video->device = device;
        strcpy(acpi_device_name(device), ACPI_VIDEO_BUS_NAME);
        strcpy(acpi_device_class(device), ACPI_VIDEO_CLASS);
-       acpi_driver_data(device) = video;
+       device->driver_data = video;
 
        acpi_video_bus_find_cap(video);
        error = acpi_video_bus_check(video);
@@ -2058,7 +2058,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
        acpi_video_bus_remove_fs(device);
  err_free_video:
        kfree(video);
-       acpi_driver_data(device) = NULL;
+       device->driver_data = NULL;
 
        return error;
 }
index 7c6dfd03de9fc9db3a6295f2751ed046f7cac845..de82f2f5a813ed9622855125012f439fd076827a 100644 (file)
@@ -996,7 +996,7 @@ static int asus_hotk_add(struct acpi_device *device)
        hotk->handle = device->handle;
        strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME);
        strcpy(acpi_device_class(device), ASUS_HOTK_CLASS);
-       acpi_driver_data(device) = hotk;
+       device->driver_data = hotk;
        hotk->device = device;
 
        result = asus_hotk_check();
index 1ee8501e90f11eb7e350355712625120dd2a5aeb..c1247056116cb817ff023d69f28131d584b4daad 100644 (file)
@@ -411,7 +411,7 @@ static int eeepc_hotk_add(struct acpi_device *device)
        ehotk->handle = device->handle;
        strcpy(acpi_device_name(device), EEEPC_HOTK_DEVICE_NAME);
        strcpy(acpi_device_class(device), EEEPC_HOTK_CLASS);
-       acpi_driver_data(device) = ehotk;
+       device->driver_data = ehotk;
        ehotk->device = device;
        result = eeepc_hotk_check();
        if (result)
index 3e56203e494720fc4af8bb8f44ed047f81cf1b8a..7b69cfb7de5d6b1403a07a5004be93f4b0e22166 100644 (file)
@@ -490,7 +490,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
        fujitsu->acpi_handle = device->handle;
        sprintf(acpi_device_name(device), "%s", ACPI_FUJITSU_DEVICE_NAME);
        sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
-       acpi_driver_data(device) = fujitsu;
+       device->driver_data = fujitsu;
 
        status = acpi_install_notify_handler(device->handle,
                                             ACPI_DEVICE_NOTIFY,
@@ -703,7 +703,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
        sprintf(acpi_device_name(device), "%s",
                ACPI_FUJITSU_HOTKEY_DEVICE_NAME);
        sprintf(acpi_device_class(device), "%s", ACPI_FUJITSU_CLASS);
-       acpi_driver_data(device) = fujitsu_hotkey;
+       device->driver_data = fujitsu_hotkey;
 
        status = acpi_install_notify_handler(device->handle,
                                             ACPI_DEVICE_NOTIFY,
index 80a1363524087a1e66e575058360d071bbca352f..cd3ea7faa5b6bd4cf55d3bd2ec2c2c0436f0ae41 100644 (file)
@@ -175,7 +175,7 @@ static int intel_menlow_memory_add(struct acpi_device *device)
                goto end;
        }
 
-       acpi_driver_data(device) = cdev;
+       device->driver_data = cdev;
        result = sysfs_create_link(&device->dev.kobj,
                                &cdev->device.kobj, "thermal_cooling");
        if (result)
index 6b9300779a431c1828acad495ddfbbec41332836..62aebaa859133df4785f2d3302e5e6afa9afcd79 100644 (file)
@@ -543,7 +543,7 @@ static int __init setup_acpi_notify(struct ibm_struct *ibm)
                return -ENODEV;
        }
 
-       acpi_driver_data(ibm->acpi->device) = ibm;
+       ibm->acpi->device->driver_data = ibm;
        sprintf(acpi_device_class(ibm->acpi->device), "%s/%s",
                TPACPI_ACPI_EVENT_PREFIX,
                ibm->name);
index a5ac0bc7f52eb1cc1849fb29afda135fb9dda6c1..47682465f1f55055d96535283e8c2bda32e0c819 100644 (file)
@@ -300,7 +300,11 @@ struct acpi_device {
        enum acpi_bus_removal_type removal_type;        /* indicate for different removal type */
 };
 
-#define acpi_driver_data(d)    ((d)->driver_data)
+static inline void *acpi_driver_data(struct acpi_device *d)
+{
+       return d->driver_data;
+}
+
 #define to_acpi_device(d)      container_of(d, struct acpi_device, dev)
 #define to_acpi_driver(d)      container_of(d, struct acpi_driver, drv)