aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dock.c
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2008-08-27 22:07:45 -0400
committerLen Brown <len.brown@intel.com>2008-09-23 23:48:59 -0400
commit8652b00fd6416773f113dab3dfa0d4509def825b (patch)
treebe80ebd30d9b47639a2e7b74f560a74db207b01d /drivers/acpi/dock.c
parent61b836958371c717d1e6d4fea1d2c512969ad20b (diff)
dock: add 'type' sysfs file
add a sysfs file to present dock type. Suggested by Holger. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/dock.c')
-rw-r--r--drivers/acpi/dock.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index c877cc526002..b7d15818215c 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -911,6 +911,26 @@ static ssize_t show_dock_uid(struct device *dev,
911} 911}
912static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); 912static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
913 913
914static ssize_t show_dock_type(struct device *dev,
915 struct device_attribute *attr, char *buf)
916{
917 struct dock_station *dock_station = *((struct dock_station **)
918 dev->platform_data);
919 char *type;
920
921 if (dock_station->flags & DOCK_IS_DOCK)
922 type = "dock_station";
923 else if (dock_station->flags & DOCK_IS_ATA)
924 type = "ata_bay";
925 else if (dock_station->flags & DOCK_IS_BAT)
926 type = "battery_bay";
927 else
928 type = "unknown";
929
930 return snprintf(buf, PAGE_SIZE, "%s\n", type);
931}
932static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
933
914/** 934/**
915 * dock_add - add a new dock station 935 * dock_add - add a new dock station
916 * @handle: the dock station handle 936 * @handle: the dock station handle
@@ -999,6 +1019,9 @@ static int dock_add(acpi_handle handle)
999 dock_station = NULL; 1019 dock_station = NULL;
1000 return ret; 1020 return ret;
1001 } 1021 }
1022 ret = device_create_file(&dock_device->dev, &dev_attr_type);
1023 if (ret)
1024 printk(KERN_ERR"Error %d adding sysfs file\n", ret);
1002 1025
1003 /* Find dependent devices */ 1026 /* Find dependent devices */
1004 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 1027 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
@@ -1020,6 +1043,7 @@ static int dock_add(acpi_handle handle)
1020 return 0; 1043 return 0;
1021 1044
1022dock_add_err_unregister: 1045dock_add_err_unregister:
1046 device_remove_file(&dock_device->dev, &dev_attr_type);
1023 device_remove_file(&dock_device->dev, &dev_attr_docked); 1047 device_remove_file(&dock_device->dev, &dev_attr_docked);
1024 device_remove_file(&dock_device->dev, &dev_attr_undock); 1048 device_remove_file(&dock_device->dev, &dev_attr_undock);
1025 device_remove_file(&dock_device->dev, &dev_attr_uid); 1049 device_remove_file(&dock_device->dev, &dev_attr_uid);
@@ -1047,6 +1071,7 @@ static int dock_remove(struct dock_station *dock_station)
1047 kfree(dd); 1071 kfree(dd);
1048 1072
1049 /* cleanup sysfs */ 1073 /* cleanup sysfs */
1074 device_remove_file(&dock_device->dev, &dev_attr_type);
1050 device_remove_file(&dock_device->dev, &dev_attr_docked); 1075 device_remove_file(&dock_device->dev, &dev_attr_docked);
1051 device_remove_file(&dock_device->dev, &dev_attr_undock); 1076 device_remove_file(&dock_device->dev, &dev_attr_undock);
1052 device_remove_file(&dock_device->dev, &dev_attr_uid); 1077 device_remove_file(&dock_device->dev, &dev_attr_uid);