]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.31/patches.arch/acpi-dock-add-type-sysfs-file-for-dock.patch
Merge branch 'master' into next
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.arch / acpi-dock-add-type-sysfs-file-for-dock.patch
1 From: Shaohua Li <shaohua.li@intel.com>
2 Subject: add 'type' sysfs file for dock
3 Patch-mainline: submitted 2008-08-28
4 References: fate#304731,bnc#401740
5
6 add a sysfs file to present dock type. Suggested by Holger.
7
8 Signed-off-by: Shaohua Li <shaohua.li@intel.com>
9 Signed-off-by: Holger Macht <hmacht@suse.de>
10 ---
11
12 ---
13 drivers/acpi/dock.c | 25 +++++++++++++++++++++++++
14 1 file changed, 25 insertions(+)
15
16 --- a/drivers/acpi/dock.c
17 +++ b/drivers/acpi/dock.c
18 @@ -909,6 +909,26 @@ static ssize_t show_dock_uid(struct devi
19 }
20 static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
21
22 +static ssize_t show_dock_type(struct device *dev,
23 + struct device_attribute *attr, char *buf)
24 +{
25 + struct dock_station *dock_station = *((struct dock_station **)
26 + dev->platform_data);
27 + char *type;
28 +
29 + if (dock_station->flags & DOCK_IS_DOCK)
30 + type = "dock_station";
31 + else if (dock_station->flags & DOCK_IS_ATA)
32 + type = "ata_bay";
33 + else if (dock_station->flags & DOCK_IS_BAT)
34 + type = "battery_bay";
35 + else
36 + type = "unknown";
37 +
38 + return snprintf(buf, PAGE_SIZE, "%s\n", type);
39 +}
40 +static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
41 +
42 /**
43 * dock_add - add a new dock station
44 * @handle: the dock station handle
45 @@ -997,6 +1017,9 @@ static int dock_add(acpi_handle handle)
46 dock_station = NULL;
47 return ret;
48 }
49 + ret = device_create_file(&dock_device->dev, &dev_attr_type);
50 + if (ret)
51 + printk(KERN_ERR"Error %d adding sysfs file\n", ret);
52
53 /* Find dependent devices */
54 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
55 @@ -1018,6 +1041,7 @@ static int dock_add(acpi_handle handle)
56 return 0;
57
58 dock_add_err_unregister:
59 + device_remove_file(&dock_device->dev, &dev_attr_type);
60 device_remove_file(&dock_device->dev, &dev_attr_docked);
61 device_remove_file(&dock_device->dev, &dev_attr_undock);
62 device_remove_file(&dock_device->dev, &dev_attr_uid);
63 @@ -1045,6 +1069,7 @@ static int dock_remove(struct dock_stati
64 kfree(dd);
65
66 /* cleanup sysfs */
67 + device_remove_file(&dock_device->dev, &dev_attr_type);
68 device_remove_file(&dock_device->dev, &dev_attr_docked);
69 device_remove_file(&dock_device->dev, &dev_attr_undock);
70 device_remove_file(&dock_device->dev, &dev_attr_uid);