blob: 1c034b80d4082c4c3e328403749c03b8e83bdada [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * IBM ASM Service Processor Device Driver
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) IBM Corporation, 2004
19 *
Al Virod36b6912011-12-29 17:09:01 -050020 * Author: Max Asböck <amax@us.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 *
22 */
23
24/*
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070025 * Parts of this code are based on an article by Jonathan Corbet
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 * that appeared in Linux Weekly News.
27 */
28
29
30/*
31 * The IBMASM file virtual filesystem. It creates the following hierarchy
Justin P. Mattock5ecd602e2011-04-08 08:23:23 -070032 * dynamically when mounted from user space:
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 *
34 * /ibmasm
35 * |-- 0
36 * | |-- command
37 * | |-- event
38 * | |-- reverse_heartbeat
39 * | `-- remote_video
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 * | |-- depth
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 * | |-- height
42 * | `-- width
43 * .
44 * .
45 * .
46 * `-- n
47 * |-- command
48 * |-- event
49 * |-- reverse_heartbeat
50 * `-- remote_video
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 * |-- depth
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 * |-- height
53 * `-- width
54 *
55 * For each service processor the following files are created:
56 *
57 * command: execute dot commands
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070058 * write: execute a dot command on the service processor
59 * read: return the result of a previously executed dot command
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 *
61 * events: listen for service processor events
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070062 * read: sleep (interruptible) until an event occurs
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 * write: wakeup sleeping event listener
64 *
65 * reverse_heartbeat: send a heartbeat to the service processor
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070066 * read: sleep (interruptible) until the reverse heartbeat fails
Linus Torvalds1da177e2005-04-16 15:20:36 -070067 * write: wakeup sleeping heartbeat listener
68 *
69 * remote_video/width
70 * remote_video/height
71 * remote_video/width: control remote display settings
Dmitry Torokhov3110dc72007-07-17 04:03:58 -070072 * write: set value
73 * read: read value
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 */
75
76#include <linux/fs.h>
77#include <linux/pagemap.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090078#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#include <asm/uaccess.h>
80#include <asm/io.h>
81#include "ibmasm.h"
82#include "remote.h"
83#include "dot_command.h"
84
85#define IBMASMFS_MAGIC 0x66726f67
86
87static LIST_HEAD(service_processors);
88
89static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode);
Al Viro318ceed2012-02-12 22:08:01 -050090static void ibmasmfs_create_files (struct super_block *sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent);
92
93
Al Virofc14f2f2010-07-25 01:48:30 +040094static struct dentry *ibmasmfs_mount(struct file_system_type *fst,
95 int flags, const char *name, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Al Virofc14f2f2010-07-25 01:48:30 +040097 return mount_single(fst, flags, data, ibmasmfs_fill_super);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
Alexey Dobriyanb87221d2009-09-21 17:01:09 -0700100static const struct super_operations ibmasmfs_s_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 .statfs = simple_statfs,
102 .drop_inode = generic_delete_inode,
103};
104
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800105static const struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
107static struct file_system_type ibmasmfs_type = {
108 .owner = THIS_MODULE,
109 .name = "ibmasmfs",
Al Virofc14f2f2010-07-25 01:48:30 +0400110 .mount = ibmasmfs_mount,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 .kill_sb = kill_litter_super,
112};
113
114static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent)
115{
116 struct inode *root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 sb->s_blocksize = PAGE_CACHE_SIZE;
119 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
120 sb->s_magic = IBMASMFS_MAGIC;
121 sb->s_op = &ibmasmfs_s_ops;
122 sb->s_time_gran = 1;
123
124 root = ibmasmfs_make_inode (sb, S_IFDIR | 0500);
125 if (!root)
126 return -ENOMEM;
127
128 root->i_op = &simple_dir_inode_operations;
129 root->i_fop = ibmasmfs_dir_ops;
130
Al Viro318ceed2012-02-12 22:08:01 -0500131 sb->s_root = d_make_root(root);
132 if (!sb->s_root)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Al Viro318ceed2012-02-12 22:08:01 -0500135 ibmasmfs_create_files(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 return 0;
137}
138
139static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
140{
141 struct inode *ret = new_inode(sb);
142
143 if (ret) {
Christoph Hellwig85fe4022010-10-23 11:19:54 -0400144 ret->i_ino = get_next_ino();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 ret->i_mode = mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
147 }
148 return ret;
149}
150
151static struct dentry *ibmasmfs_create_file (struct super_block *sb,
152 struct dentry *parent,
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700153 const char *name,
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800154 const struct file_operations *fops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 void *data,
156 int mode)
157{
158 struct dentry *dentry;
159 struct inode *inode;
160
161 dentry = d_alloc_name(parent, name);
162 if (!dentry)
163 return NULL;
164
165 inode = ibmasmfs_make_inode(sb, S_IFREG | mode);
166 if (!inode) {
167 dput(dentry);
168 return NULL;
169 }
170
171 inode->i_fop = fops;
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700172 inode->i_private = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174 d_add(dentry, inode);
175 return dentry;
176}
177
178static struct dentry *ibmasmfs_create_dir (struct super_block *sb,
179 struct dentry *parent,
180 const char *name)
181{
182 struct dentry *dentry;
183 struct inode *inode;
184
185 dentry = d_alloc_name(parent, name);
186 if (!dentry)
187 return NULL;
188
189 inode = ibmasmfs_make_inode(sb, S_IFDIR | 0500);
190 if (!inode) {
191 dput(dentry);
192 return NULL;
193 }
194
195 inode->i_op = &simple_dir_inode_operations;
196 inode->i_fop = ibmasmfs_dir_ops;
197
198 d_add(dentry, inode);
199 return dentry;
200}
201
202int ibmasmfs_register(void)
203{
204 return register_filesystem(&ibmasmfs_type);
205}
206
207void ibmasmfs_unregister(void)
208{
209 unregister_filesystem(&ibmasmfs_type);
210}
211
212void ibmasmfs_add_sp(struct service_processor *sp)
213{
214 list_add(&sp->node, &service_processors);
215}
216
217/* struct to save state between command file operations */
218struct ibmasmfs_command_data {
219 struct service_processor *sp;
220 struct command *command;
221};
222
223/* struct to save state between event file operations */
224struct ibmasmfs_event_data {
225 struct service_processor *sp;
226 struct event_reader reader;
227 int active;
228};
229
230/* struct to save state between reverse heartbeat file operations */
231struct ibmasmfs_heartbeat_data {
232 struct service_processor *sp;
233 struct reverse_heartbeat heartbeat;
234 int active;
235};
236
237static int command_file_open(struct inode *inode, struct file *file)
238{
239 struct ibmasmfs_command_data *command_data;
240
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700241 if (!inode->i_private)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 return -ENODEV;
243
244 command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL);
245 if (!command_data)
246 return -ENOMEM;
247
248 command_data->command = NULL;
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700249 command_data->sp = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 file->private_data = command_data;
251 return 0;
252}
253
254static int command_file_close(struct inode *inode, struct file *file)
255{
256 struct ibmasmfs_command_data *command_data = file->private_data;
257
258 if (command_data->command)
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700259 command_put(command_data->command);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 kfree(command_data);
262 return 0;
263}
264
265static ssize_t command_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
266{
267 struct ibmasmfs_command_data *command_data = file->private_data;
268 struct command *cmd;
269 int len;
270 unsigned long flags;
271
272 if (*offset < 0)
273 return -EINVAL;
274 if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
275 return 0;
276 if (*offset != 0)
277 return 0;
278
279 spin_lock_irqsave(&command_data->sp->lock, flags);
280 cmd = command_data->command;
281 if (cmd == NULL) {
282 spin_unlock_irqrestore(&command_data->sp->lock, flags);
283 return 0;
284 }
285 command_data->command = NULL;
286 spin_unlock_irqrestore(&command_data->sp->lock, flags);
287
288 if (cmd->status != IBMASM_CMD_COMPLETE) {
289 command_put(cmd);
290 return -EIO;
291 }
292 len = min(count, cmd->buffer_size);
293 if (copy_to_user(buf, cmd->buffer, len)) {
294 command_put(cmd);
295 return -EFAULT;
296 }
297 command_put(cmd);
298
299 return len;
300}
301
302static ssize_t command_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
303{
304 struct ibmasmfs_command_data *command_data = file->private_data;
305 struct command *cmd;
306 unsigned long flags;
307
308 if (*offset < 0)
309 return -EINVAL;
310 if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
311 return 0;
312 if (*offset != 0)
313 return 0;
314
315 /* commands are executed sequentially, only one command at a time */
316 if (command_data->command)
317 return -EAGAIN;
318
Max Asbock88187602005-06-21 17:16:36 -0700319 cmd = ibmasm_new_command(command_data->sp, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 if (!cmd)
321 return -ENOMEM;
322
323 if (copy_from_user(cmd->buffer, ubuff, count)) {
324 command_put(cmd);
325 return -EFAULT;
326 }
327
328 spin_lock_irqsave(&command_data->sp->lock, flags);
329 if (command_data->command) {
330 spin_unlock_irqrestore(&command_data->sp->lock, flags);
331 command_put(cmd);
332 return -EAGAIN;
333 }
334 command_data->command = cmd;
335 spin_unlock_irqrestore(&command_data->sp->lock, flags);
336
337 ibmasm_exec_command(command_data->sp, cmd);
338 ibmasm_wait_for_response(cmd, get_dot_command_timeout(cmd->buffer));
339
340 return count;
341}
342
343static int event_file_open(struct inode *inode, struct file *file)
344{
345 struct ibmasmfs_event_data *event_data;
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700346 struct service_processor *sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700348 if (!inode->i_private)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 return -ENODEV;
350
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700351 sp = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL);
354 if (!event_data)
355 return -ENOMEM;
356
357 ibmasm_event_reader_register(sp, &event_data->reader);
358
359 event_data->sp = sp;
Max Asbockb8acb802005-06-21 17:16:33 -0700360 event_data->active = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 file->private_data = event_data;
362 return 0;
363}
364
365static int event_file_close(struct inode *inode, struct file *file)
366{
367 struct ibmasmfs_event_data *event_data = file->private_data;
368
369 ibmasm_event_reader_unregister(event_data->sp, &event_data->reader);
370 kfree(event_data);
371 return 0;
372}
373
374static ssize_t event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
375{
376 struct ibmasmfs_event_data *event_data = file->private_data;
377 struct event_reader *reader = &event_data->reader;
Max Asbockb8acb802005-06-21 17:16:33 -0700378 struct service_processor *sp = event_data->sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 int ret;
Max Asbockb8acb802005-06-21 17:16:33 -0700380 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
382 if (*offset < 0)
383 return -EINVAL;
384 if (count == 0 || count > IBMASM_EVENT_MAX_SIZE)
385 return 0;
386 if (*offset != 0)
387 return 0;
388
Max Asbockb8acb802005-06-21 17:16:33 -0700389 spin_lock_irqsave(&sp->lock, flags);
390 if (event_data->active) {
391 spin_unlock_irqrestore(&sp->lock, flags);
392 return -EBUSY;
393 }
394 event_data->active = 1;
395 spin_unlock_irqrestore(&sp->lock, flags);
396
397 ret = ibmasm_get_next_event(sp, reader);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 if (ret <= 0)
Max Asbockb8acb802005-06-21 17:16:33 -0700399 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
Max Asbockb8acb802005-06-21 17:16:33 -0700401 if (count < reader->data_size) {
402 ret = -EINVAL;
403 goto out;
404 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405
Max Asbockb8acb802005-06-21 17:16:33 -0700406 if (copy_to_user(buf, reader->data, reader->data_size)) {
407 ret = -EFAULT;
408 goto out;
409 }
410 ret = reader->data_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411
Max Asbockb8acb802005-06-21 17:16:33 -0700412out:
413 event_data->active = 0;
414 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415}
416
417static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
418{
419 struct ibmasmfs_event_data *event_data = file->private_data;
420
421 if (*offset < 0)
422 return -EINVAL;
423 if (count != 1)
424 return 0;
425 if (*offset != 0)
426 return 0;
427
Max Asbockb8acb802005-06-21 17:16:33 -0700428 ibmasm_cancel_next_event(&event_data->reader);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 return 0;
430}
431
432static int r_heartbeat_file_open(struct inode *inode, struct file *file)
433{
434 struct ibmasmfs_heartbeat_data *rhbeat;
435
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700436 if (!inode->i_private)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 return -ENODEV;
438
439 rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL);
440 if (!rhbeat)
441 return -ENOMEM;
442
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700443 rhbeat->sp = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 rhbeat->active = 0;
445 ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat);
446 file->private_data = rhbeat;
447 return 0;
448}
449
450static int r_heartbeat_file_close(struct inode *inode, struct file *file)
451{
452 struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
453
454 kfree(rhbeat);
455 return 0;
456}
457
458static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
459{
460 struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
461 unsigned long flags;
462 int result;
463
464 if (*offset < 0)
465 return -EINVAL;
466 if (count == 0 || count > 1024)
467 return 0;
468 if (*offset != 0)
469 return 0;
470
471 /* allow only one reverse heartbeat per process */
472 spin_lock_irqsave(&rhbeat->sp->lock, flags);
473 if (rhbeat->active) {
474 spin_unlock_irqrestore(&rhbeat->sp->lock, flags);
475 return -EBUSY;
476 }
477 rhbeat->active = 1;
478 spin_unlock_irqrestore(&rhbeat->sp->lock, flags);
479
480 result = ibmasm_start_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat);
481 rhbeat->active = 0;
482
483 return result;
484}
485
486static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
487{
488 struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
489
490 if (*offset < 0)
491 return -EINVAL;
492 if (count != 1)
493 return 0;
494 if (*offset != 0)
495 return 0;
496
497 if (rhbeat->active)
498 ibmasm_stop_reverse_heartbeat(&rhbeat->heartbeat);
499
500 return 1;
501}
502
503static int remote_settings_file_open(struct inode *inode, struct file *file)
504{
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700505 file->private_data = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 return 0;
507}
508
509static int remote_settings_file_close(struct inode *inode, struct file *file)
510{
511 return 0;
512}
513
514static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
515{
516 void __iomem *address = (void __iomem *)file->private_data;
517 unsigned char *page;
518 int retval;
519 int len = 0;
520 unsigned int value;
521
522 if (*offset < 0)
523 return -EINVAL;
524 if (count == 0 || count > 1024)
525 return 0;
526 if (*offset != 0)
527 return 0;
528
529 page = (unsigned char *)__get_free_page(GFP_KERNEL);
530 if (!page)
531 return -ENOMEM;
532
533 value = readl(address);
534 len = sprintf(page, "%d\n", value);
535
536 if (copy_to_user(buf, page, len)) {
537 retval = -EFAULT;
538 goto exit;
539 }
540 *offset += len;
541 retval = len;
542
543exit:
544 free_page((unsigned long)page);
545 return retval;
546}
547
548static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
549{
550 void __iomem *address = (void __iomem *)file->private_data;
551 char *buff;
552 unsigned int value;
553
554 if (*offset < 0)
555 return -EINVAL;
556 if (count == 0 || count > 1024)
557 return 0;
558 if (*offset != 0)
559 return 0;
560
Yoann Padioleaudd00cc42007-07-19 01:49:03 -0700561 buff = kzalloc (count + 1, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 if (!buff)
563 return -ENOMEM;
564
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565
566 if (copy_from_user(buff, ubuff, count)) {
567 kfree(buff);
568 return -EFAULT;
569 }
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700570
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 value = simple_strtoul(buff, NULL, 10);
572 writel(value, address);
573 kfree(buff);
574
575 return count;
576}
577
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800578static const struct file_operations command_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .open = command_file_open,
580 .release = command_file_close,
581 .read = command_file_read,
582 .write = command_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200583 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584};
585
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800586static const struct file_operations event_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .open = event_file_open,
588 .release = event_file_close,
589 .read = event_file_read,
590 .write = event_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200591 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592};
593
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800594static const struct file_operations r_heartbeat_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 .open = r_heartbeat_file_open,
596 .release = r_heartbeat_file_close,
597 .read = r_heartbeat_file_read,
598 .write = r_heartbeat_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200599 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600};
601
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800602static const struct file_operations remote_settings_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .open = remote_settings_file_open,
604 .release = remote_settings_file_close,
605 .read = remote_settings_file_read,
606 .write = remote_settings_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200607 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608};
609
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
Al Viro318ceed2012-02-12 22:08:01 -0500611static void ibmasmfs_create_files (struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612{
613 struct list_head *entry;
614 struct service_processor *sp;
615
616 list_for_each(entry, &service_processors) {
617 struct dentry *dir;
618 struct dentry *remote_dir;
619 sp = list_entry(entry, struct service_processor, node);
Al Viro318ceed2012-02-12 22:08:01 -0500620 dir = ibmasmfs_create_dir(sb, sb->s_root, sp->dirname);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 if (!dir)
622 continue;
623
624 ibmasmfs_create_file(sb, dir, "command", &command_fops, sp, S_IRUSR|S_IWUSR);
625 ibmasmfs_create_file(sb, dir, "event", &event_fops, sp, S_IRUSR|S_IWUSR);
626 ibmasmfs_create_file(sb, dir, "reverse_heartbeat", &r_heartbeat_fops, sp, S_IRUSR|S_IWUSR);
627
628 remote_dir = ibmasmfs_create_dir(sb, dir, "remote_video");
629 if (!remote_dir)
630 continue;
631
632 ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR);
633 ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR);
634 ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 }
636}