ACPI: autoload modules - Create __mod_acpi_device_table symbol for all ACPI drivers
[pandora-kernel.git] / drivers / acpi / sbs.c
index c1bae10..7d8e78e 100644 (file)
@@ -38,7 +38,6 @@
 #define ACPI_SBS_CLASS                 "sbs"
 #define ACPI_AC_CLASS                  "ac_adapter"
 #define ACPI_BATTERY_CLASS             "battery"
-#define ACPI_SBS_HID                   "ACPI0002"
 #define ACPI_SBS_DEVICE_NAME           "Smart Battery System"
 #define ACPI_SBS_FILE_INFO             "info"
 #define ACPI_SBS_FILE_STATE            "state"
@@ -124,10 +123,17 @@ static int acpi_sbs_add(struct acpi_device *device);
 static int acpi_sbs_remove(struct acpi_device *device, int type);
 static int acpi_sbs_resume(struct acpi_device *device);
 
+static const struct acpi_device_id sbs_device_ids[] = {
+       {"ACPI0001", 0},
+       {"ACPI0005", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
+
 static struct acpi_driver acpi_sbs_driver = {
        .name = "sbs",
        .class = ACPI_SBS_CLASS,
-       .ids = ACPI_SBS_HID,
+       .ids = sbs_device_ids,
        .ops = {
                .add = acpi_sbs_add,
                .remove = acpi_sbs_remove,
@@ -176,10 +182,8 @@ struct acpi_battery {
 };
 
 struct acpi_sbs {
-       acpi_handle handle;
        int base;
        struct acpi_device *device;
-       struct acpi_ec_smbus *smbus;
        struct mutex mutex;
        int sbsm_present;
        int sbsm_batteries_supported;
@@ -511,7 +515,7 @@ static int acpi_sbsm_get_info(struct acpi_sbs *sbs)
                                "acpi_sbs_read_word() failed"));
                goto end;
        }
-
+       sbs->sbsm_present = 1;
        sbs->sbsm_batteries_supported = battery_system_info & 0x000f;
 
       end:
@@ -1630,13 +1634,12 @@ static int acpi_sbs_add(struct acpi_device *device)
 {
        struct acpi_sbs *sbs = NULL;
        int result = 0, remove_result = 0;
-       unsigned long sbs_obj;
        int id;
        acpi_status status = AE_OK;
        unsigned long val;
 
        status =
-           acpi_evaluate_integer(device->parent->handle, "_EC", NULL, &val);
+           acpi_evaluate_integer(device->handle, "_EC", NULL, &val);
        if (ACPI_FAILURE(status)) {
                ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Error obtaining _EC"));
                return -EIO;
@@ -1653,7 +1656,7 @@ static int acpi_sbs_add(struct acpi_device *device)
 
        sbs_mutex_lock(sbs);
 
-       sbs->base = (val & 0xff00ull) >> 8;
+       sbs->base = 0xff & (val >> 8);
        sbs->device = device;
 
        strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
@@ -1665,24 +1668,10 @@ static int acpi_sbs_add(struct acpi_device *device)
                ACPI_EXCEPTION((AE_INFO, AE_ERROR, "acpi_ac_add() failed"));
                goto end;
        }
-       status = acpi_evaluate_integer(device->handle, "_SBS", NULL, &sbs_obj);
-       if (status) {
-               ACPI_EXCEPTION((AE_INFO, status,
-                               "acpi_evaluate_integer() failed"));
-               result = -EIO;
-               goto end;
-       }
-       if (sbs_obj > 0) {
-               result = acpi_sbsm_get_info(sbs);
-               if (result) {
-                       ACPI_EXCEPTION((AE_INFO, AE_ERROR,
-                                       "acpi_sbsm_get_info() failed"));
-                       goto end;
-               }
-               sbs->sbsm_present = 1;
-       }
 
-       if (sbs->sbsm_present == 0) {
+       acpi_sbsm_get_info(sbs);
+
+       if (!sbs->sbsm_present) {
                result = acpi_battery_add(sbs, 0);
                if (result) {
                        ACPI_EXCEPTION((AE_INFO, AE_ERROR,
@@ -1702,8 +1691,6 @@ static int acpi_sbs_add(struct acpi_device *device)
                }
        }
 
-       sbs->handle = device->handle;
-
        init_timer(&sbs->update_timer);
        result = acpi_check_update_proc(sbs);
        if (result)