]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/dock.c
arm ide breakage
[linux-2.6-omap-h63xx.git] / drivers / acpi / dock.c
index ac7dfefcb50b44a4938a5aa13fd4fdb10b59229e..5b30b8d91d716126cdd3305d61ee8fd625eea016 100644 (file)
@@ -294,7 +294,7 @@ EXPORT_SYMBOL_GPL(is_dock_device);
  */
 static int dock_present(struct dock_station *ds)
 {
-       unsigned long sta;
+       unsigned long long sta;
        acpi_status status;
 
        if (ds) {
@@ -488,8 +488,9 @@ static void handle_dock(struct dock_station *ds, int dock)
        arg.integer.value = dock;
        status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
        if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
-               printk(KERN_ERR PREFIX "%s - failed to execute _DCK\n",
-                        (char *)name_buffer.pointer);
+               ACPI_EXCEPTION((AE_INFO, status, "%s - failed to execute"
+                       " _DCK\n", (char *)name_buffer.pointer));
+
        kfree(buffer.pointer);
        kfree(name_buffer.pointer);
 }
@@ -609,6 +610,7 @@ register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
 {
        struct dock_dependent_device *dd;
        struct dock_station *dock_station;
+       int ret = -EINVAL;
 
        if (!dock_station_count)
                return -ENODEV;
@@ -618,16 +620,21 @@ register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
         * this would include the dock station itself
         */
        list_for_each_entry(dock_station, &dock_stations, sibiling) {
+               /*
+                * An ATA bay can be in a dock and itself can be ejected
+                * seperately, so there are two 'dock stations' which need the
+                * ops
+                */
                dd = find_dock_dependent_device(dock_station, handle);
                if (dd) {
                        dd->ops = ops;
                        dd->context = context;
                        dock_add_hotplug_device(dock_station, dd);
-                       return 0;
+                       ret = 0;
                }
        }
 
-       return -EINVAL;
+       return ret;
 }
 
 EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
@@ -893,7 +900,7 @@ static DEVICE_ATTR(undock, S_IWUSR, NULL, write_undock);
 static ssize_t show_dock_uid(struct device *dev,
                             struct device_attribute *attr, char *buf)
 {
-       unsigned long lbuf;
+       unsigned long long lbuf;
        struct dock_station *dock_station = *((struct dock_station **)
                dev->platform_data);
        acpi_status status = acpi_evaluate_integer(dock_station->handle,
@@ -901,10 +908,30 @@ static ssize_t show_dock_uid(struct device *dev,
        if (ACPI_FAILURE(status))
            return 0;
 
-       return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf);
+       return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
 }
 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
 
+static ssize_t show_dock_type(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct dock_station *dock_station = *((struct dock_station **)
+               dev->platform_data);
+       char *type;
+
+       if (dock_station->flags & DOCK_IS_DOCK)
+               type = "dock_station";
+       else if (dock_station->flags & DOCK_IS_ATA)
+               type = "ata_bay";
+       else if (dock_station->flags & DOCK_IS_BAT)
+               type = "battery_bay";
+       else
+               type = "unknown";
+
+       return snprintf(buf, PAGE_SIZE, "%s\n", type);
+}
+static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
+
 /**
  * dock_add - add a new dock station
  * @handle: the dock station handle
@@ -993,6 +1020,9 @@ static int dock_add(acpi_handle handle)
                dock_station = NULL;
                return ret;
        }
+       ret = device_create_file(&dock_device->dev, &dev_attr_type);
+       if (ret)
+               printk(KERN_ERR"Error %d adding sysfs file\n", ret);
 
        /* Find dependent devices */
        acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
@@ -1014,6 +1044,7 @@ static int dock_add(acpi_handle handle)
        return 0;
 
 dock_add_err_unregister:
+       device_remove_file(&dock_device->dev, &dev_attr_type);
        device_remove_file(&dock_device->dev, &dev_attr_docked);
        device_remove_file(&dock_device->dev, &dev_attr_undock);
        device_remove_file(&dock_device->dev, &dev_attr_uid);
@@ -1041,6 +1072,7 @@ static int dock_remove(struct dock_station *dock_station)
            kfree(dd);
 
        /* cleanup sysfs */
+       device_remove_file(&dock_device->dev, &dev_attr_type);
        device_remove_file(&dock_device->dev, &dev_attr_docked);
        device_remove_file(&dock_device->dev, &dev_attr_undock);
        device_remove_file(&dock_device->dev, &dev_attr_uid);
@@ -1078,8 +1110,8 @@ find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
 static acpi_status
 find_bay(acpi_handle handle, u32 lvl, void *context, void **rv)
 {
-       /* If bay is in a dock, it's already handled */
-       if (is_ejectable_bay(handle) && !is_dock_device(handle))
+       /* If bay is a dock, it's already handled */
+       if (is_ejectable_bay(handle) && !is_dock(handle))
                dock_add(handle);
        return AE_OK;
 }