Thomas Renninger | 1195a09 | 2010-07-16 13:11:31 +0200 | [diff] [blame^] | 1 | #include <linux/kernel.h> |
| 2 | #include <linux/acpi.h> |
| 3 | #include <linux/debugfs.h> |
| 4 | #include "internal.h" |
| 5 | |
| 6 | MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>"); |
| 7 | MODULE_DESCRIPTION("ACPI EC sysfs access driver"); |
| 8 | MODULE_LICENSE("GPL"); |
| 9 | |
| 10 | struct sysdev_class acpi_ec_sysdev_class = { |
| 11 | .name = "ec", |
| 12 | }; |
| 13 | |
| 14 | static struct dentry *acpi_ec_debugfs_dir; |
| 15 | |
| 16 | int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count) |
| 17 | { |
| 18 | struct dentry *dev_dir; |
| 19 | char name[64]; |
| 20 | if (ec_device_count == 0) { |
| 21 | acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL); |
| 22 | if (!acpi_ec_debugfs_dir) |
| 23 | return -ENOMEM; |
| 24 | } |
| 25 | |
| 26 | sprintf(name, "ec%u", ec_device_count); |
| 27 | dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir); |
| 28 | if (!dev_dir) { |
| 29 | if (ec_device_count == 0) |
| 30 | debugfs_remove_recursive(acpi_ec_debugfs_dir); |
| 31 | /* TBD: Proper cleanup for multiple ECs */ |
| 32 | return -ENOMEM; |
| 33 | } |
| 34 | |
| 35 | debugfs_create_x32("gpe", 0444, dev_dir, (u32 *)&first_ec->gpe); |
| 36 | debugfs_create_bool("use_global_lock", 0444, dev_dir, |
| 37 | (u32 *)&first_ec->global_lock); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static int __init acpi_ec_sys_init(void) |
| 42 | { |
| 43 | int err = 0; |
| 44 | if (first_ec) |
| 45 | err = acpi_ec_add_debugfs(first_ec, 0); |
| 46 | else |
| 47 | err = -ENODEV; |
| 48 | return err; |
| 49 | } |
| 50 | |
| 51 | static void __exit acpi_ec_sys_exit(void) |
| 52 | { |
| 53 | debugfs_remove_recursive(acpi_ec_debugfs_dir); |
| 54 | } |
| 55 | |
| 56 | module_init(acpi_ec_sys_init); |
| 57 | module_exit(acpi_ec_sys_exit); |