aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/button.c
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2011-03-22 22:21:40 -0400
committerLen Brown <len.brown@intel.com>2011-03-22 23:20:35 -0400
commit912b7427fc13467bac042cc72f2eccbdbc39d773 (patch)
tree9f64f62f0fa41218ed0319f7fa9e6521c4c389fd /drivers/acpi/button.c
parentaad83b143008e1d406248803550bfbfc600b6398 (diff)
ACPI button: remove unused procfs I/F
Remove unused ACPI button procfs interface. Only /proc/acpi/button/lid/LID/state remains. Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/button.c')
-rw-r--r--drivers/acpi/button.c163
1 files changed, 60 insertions, 103 deletions
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 12c28f4adb67..d27d072472f9 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -78,8 +78,6 @@ static int acpi_button_add(struct acpi_device *device);
78static int acpi_button_remove(struct acpi_device *device, int type); 78static int acpi_button_remove(struct acpi_device *device, int type);
79static int acpi_button_resume(struct acpi_device *device); 79static int acpi_button_resume(struct acpi_device *device);
80static void acpi_button_notify(struct acpi_device *device, u32 event); 80static void acpi_button_notify(struct acpi_device *device, u32 event);
81static int acpi_button_info_open_fs(struct inode *inode, struct file *file);
82static int acpi_button_state_open_fs(struct inode *inode, struct file *file);
83 81
84static struct acpi_driver acpi_button_driver = { 82static struct acpi_driver acpi_button_driver = {
85 .name = "button", 83 .name = "button",
@@ -101,22 +99,6 @@ struct acpi_button {
101 bool wakeup_enabled; 99 bool wakeup_enabled;
102}; 100};
103 101
104static const struct file_operations acpi_button_info_fops = {
105 .owner = THIS_MODULE,
106 .open = acpi_button_info_open_fs,
107 .read = seq_read,
108 .llseek = seq_lseek,
109 .release = single_release,
110};
111
112static const struct file_operations acpi_button_state_fops = {
113 .owner = THIS_MODULE,
114 .open = acpi_button_state_open_fs,
115 .read = seq_read,
116 .llseek = seq_lseek,
117 .release = single_release,
118};
119
120static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier); 102static BLOCKING_NOTIFIER_HEAD(acpi_lid_notifier);
121static struct acpi_device *lid_device; 103static struct acpi_device *lid_device;
122 104
@@ -125,20 +107,7 @@ static struct acpi_device *lid_device;
125 -------------------------------------------------------------------------- */ 107 -------------------------------------------------------------------------- */
126 108
127static struct proc_dir_entry *acpi_button_dir; 109static struct proc_dir_entry *acpi_button_dir;
128 110static struct proc_dir_entry *acpi_lid_dir;
129static int acpi_button_info_seq_show(struct seq_file *seq, void *offset)
130{
131 struct acpi_device *device = seq->private;
132
133 seq_printf(seq, "type: %s\n",
134 acpi_device_name(device));
135 return 0;
136}
137
138static int acpi_button_info_open_fs(struct inode *inode, struct file *file)
139{
140 return single_open(file, acpi_button_info_seq_show, PDE(inode)->data);
141}
142 111
143static int acpi_button_state_seq_show(struct seq_file *seq, void *offset) 112static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
144{ 113{
@@ -158,77 +127,85 @@ static int acpi_button_state_open_fs(struct inode *inode, struct file *file)
158 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data); 127 return single_open(file, acpi_button_state_seq_show, PDE(inode)->data);
159} 128}
160 129
161static struct proc_dir_entry *acpi_power_dir; 130static const struct file_operations acpi_button_state_fops = {
162static struct proc_dir_entry *acpi_sleep_dir; 131 .owner = THIS_MODULE,
163static struct proc_dir_entry *acpi_lid_dir; 132 .open = acpi_button_state_open_fs,
133 .read = seq_read,
134 .llseek = seq_lseek,
135 .release = single_release,
136};
164 137
165static int acpi_button_add_fs(struct acpi_device *device) 138static int acpi_button_add_fs(struct acpi_device *device)
166{ 139{
167 struct acpi_button *button = acpi_driver_data(device); 140 struct acpi_button *button = acpi_driver_data(device);
168 struct proc_dir_entry *entry = NULL; 141 struct proc_dir_entry *entry = NULL;
142 int ret = 0;
169 143
170 switch (button->type) { 144 /* procfs I/F for ACPI lid device only */
171 case ACPI_BUTTON_TYPE_POWER: 145 if (button->type != ACPI_BUTTON_TYPE_LID)
172 if (!acpi_power_dir) 146 return 0;
173 acpi_power_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_POWER, 147
174 acpi_button_dir); 148 if (acpi_button_dir || acpi_lid_dir) {
175 entry = acpi_power_dir; 149 printk(KERN_ERR PREFIX "More than one Lid device found!\n");
176 break; 150 return -EEXIST;
177 case ACPI_BUTTON_TYPE_SLEEP:
178 if (!acpi_sleep_dir)
179 acpi_sleep_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_SLEEP,
180 acpi_button_dir);
181 entry = acpi_sleep_dir;
182 break;
183 case ACPI_BUTTON_TYPE_LID:
184 if (!acpi_lid_dir)
185 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID,
186 acpi_button_dir);
187 entry = acpi_lid_dir;
188 break;
189 } 151 }
190 152
191 if (!entry) 153 /* create /proc/acpi/button */
154 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
155 if (!acpi_button_dir)
192 return -ENODEV; 156 return -ENODEV;
193 157
194 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), entry); 158 /* create /proc/acpi/button/lid */
195 if (!acpi_device_dir(device)) 159 acpi_lid_dir = proc_mkdir(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
196 return -ENODEV; 160 if (!acpi_lid_dir) {
161 ret = -ENODEV;
162 goto remove_button_dir;
163 }
197 164
198 /* 'info' [R] */ 165 /* create /proc/acpi/button/lid/LID/ */
199 entry = proc_create_data(ACPI_BUTTON_FILE_INFO, 166 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), acpi_lid_dir);
200 S_IRUGO, acpi_device_dir(device), 167 if (!acpi_device_dir(device)) {
201 &acpi_button_info_fops, device); 168 ret = -ENODEV;
202 if (!entry) 169 goto remove_lid_dir;
203 return -ENODEV; 170 }
204 171
205 /* show lid state [R] */ 172 /* create /proc/acpi/button/lid/LID/state */
206 if (button->type == ACPI_BUTTON_TYPE_LID) { 173 entry = proc_create_data(ACPI_BUTTON_FILE_STATE,
207 entry = proc_create_data(ACPI_BUTTON_FILE_STATE, 174 S_IRUGO, acpi_device_dir(device),
208 S_IRUGO, acpi_device_dir(device), 175 &acpi_button_state_fops, device);
209 &acpi_button_state_fops, device); 176 if (!entry) {
210 if (!entry) 177 ret = -ENODEV;
211 return -ENODEV; 178 goto remove_dev_dir;
212 } 179 }
213 180
214 return 0; 181done:
182 return ret;
183
184remove_dev_dir:
185 remove_proc_entry(acpi_device_bid(device),
186 acpi_lid_dir);
187 acpi_device_dir(device) = NULL;
188remove_lid_dir:
189 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
190remove_button_dir:
191 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
192 goto done;
215} 193}
216 194
217static int acpi_button_remove_fs(struct acpi_device *device) 195static int acpi_button_remove_fs(struct acpi_device *device)
218{ 196{
219 struct acpi_button *button = acpi_driver_data(device); 197 struct acpi_button *button = acpi_driver_data(device);
220 198
221 if (acpi_device_dir(device)) { 199 if (button->type != ACPI_BUTTON_TYPE_LID)
222 if (button->type == ACPI_BUTTON_TYPE_LID) 200 return 0;
223 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
224 acpi_device_dir(device));
225 remove_proc_entry(ACPI_BUTTON_FILE_INFO,
226 acpi_device_dir(device));
227 201
228 remove_proc_entry(acpi_device_bid(device), 202 remove_proc_entry(ACPI_BUTTON_FILE_STATE,
229 acpi_device_dir(device)->parent); 203 acpi_device_dir(device));
230 acpi_device_dir(device) = NULL; 204 remove_proc_entry(acpi_device_bid(device),
231 } 205 acpi_lid_dir);
206 acpi_device_dir(device) = NULL;
207 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
208 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
232 209
233 return 0; 210 return 0;
234} 211}
@@ -468,32 +445,12 @@ static int acpi_button_remove(struct acpi_device *device, int type)
468 445
469static int __init acpi_button_init(void) 446static int __init acpi_button_init(void)
470{ 447{
471 int result; 448 return acpi_bus_register_driver(&acpi_button_driver);
472
473 acpi_button_dir = proc_mkdir(ACPI_BUTTON_CLASS, acpi_root_dir);
474 if (!acpi_button_dir)
475 return -ENODEV;
476
477 result = acpi_bus_register_driver(&acpi_button_driver);
478 if (result < 0) {
479 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
480 return -ENODEV;
481 }
482
483 return 0;
484} 449}
485 450
486static void __exit acpi_button_exit(void) 451static void __exit acpi_button_exit(void)
487{ 452{
488 acpi_bus_unregister_driver(&acpi_button_driver); 453 acpi_bus_unregister_driver(&acpi_button_driver);
489
490 if (acpi_power_dir)
491 remove_proc_entry(ACPI_BUTTON_SUBCLASS_POWER, acpi_button_dir);
492 if (acpi_sleep_dir)
493 remove_proc_entry(ACPI_BUTTON_SUBCLASS_SLEEP, acpi_button_dir);
494 if (acpi_lid_dir)
495 remove_proc_entry(ACPI_BUTTON_SUBCLASS_LID, acpi_button_dir);
496 remove_proc_entry(ACPI_BUTTON_CLASS, acpi_root_dir);
497} 454}
498 455
499module_init(acpi_button_init); 456module_init(acpi_button_init);