blob: ce5b75616b453dd49c8fce21cf699fb465b6f4ad [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};
Eric W. Biederman7f78e032013-03-02 19:39:14 -0800113MODULE_ALIAS_FS("ibmasmfs");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent)
116{
117 struct inode *root;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119 sb->s_blocksize = PAGE_CACHE_SIZE;
120 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
121 sb->s_magic = IBMASMFS_MAGIC;
122 sb->s_op = &ibmasmfs_s_ops;
123 sb->s_time_gran = 1;
124
125 root = ibmasmfs_make_inode (sb, S_IFDIR | 0500);
126 if (!root)
127 return -ENOMEM;
128
129 root->i_op = &simple_dir_inode_operations;
130 root->i_fop = ibmasmfs_dir_ops;
131
Al Viro318ceed2012-02-12 22:08:01 -0500132 sb->s_root = d_make_root(root);
133 if (!sb->s_root)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
Al Viro318ceed2012-02-12 22:08:01 -0500136 ibmasmfs_create_files(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 return 0;
138}
139
140static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
141{
142 struct inode *ret = new_inode(sb);
143
144 if (ret) {
Christoph Hellwig85fe4022010-10-23 11:19:54 -0400145 ret->i_ino = get_next_ino();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 ret->i_mode = mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
148 }
149 return ret;
150}
151
152static struct dentry *ibmasmfs_create_file (struct super_block *sb,
153 struct dentry *parent,
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700154 const char *name,
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800155 const struct file_operations *fops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 void *data,
157 int mode)
158{
159 struct dentry *dentry;
160 struct inode *inode;
161
162 dentry = d_alloc_name(parent, name);
163 if (!dentry)
164 return NULL;
165
166 inode = ibmasmfs_make_inode(sb, S_IFREG | mode);
167 if (!inode) {
168 dput(dentry);
169 return NULL;
170 }
171
172 inode->i_fop = fops;
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700173 inode->i_private = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 d_add(dentry, inode);
176 return dentry;
177}
178
179static struct dentry *ibmasmfs_create_dir (struct super_block *sb,
180 struct dentry *parent,
181 const char *name)
182{
183 struct dentry *dentry;
184 struct inode *inode;
185
186 dentry = d_alloc_name(parent, name);
187 if (!dentry)
188 return NULL;
189
190 inode = ibmasmfs_make_inode(sb, S_IFDIR | 0500);
191 if (!inode) {
192 dput(dentry);
193 return NULL;
194 }
195
196 inode->i_op = &simple_dir_inode_operations;
197 inode->i_fop = ibmasmfs_dir_ops;
198
199 d_add(dentry, inode);
200 return dentry;
201}
202
203int ibmasmfs_register(void)
204{
205 return register_filesystem(&ibmasmfs_type);
206}
207
208void ibmasmfs_unregister(void)
209{
210 unregister_filesystem(&ibmasmfs_type);
211}
212
213void ibmasmfs_add_sp(struct service_processor *sp)
214{
215 list_add(&sp->node, &service_processors);
216}
217
218/* struct to save state between command file operations */
219struct ibmasmfs_command_data {
220 struct service_processor *sp;
221 struct command *command;
222};
223
224/* struct to save state between event file operations */
225struct ibmasmfs_event_data {
226 struct service_processor *sp;
227 struct event_reader reader;
228 int active;
229};
230
231/* struct to save state between reverse heartbeat file operations */
232struct ibmasmfs_heartbeat_data {
233 struct service_processor *sp;
234 struct reverse_heartbeat heartbeat;
235 int active;
236};
237
238static int command_file_open(struct inode *inode, struct file *file)
239{
240 struct ibmasmfs_command_data *command_data;
241
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700242 if (!inode->i_private)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 return -ENODEV;
244
245 command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL);
246 if (!command_data)
247 return -ENOMEM;
248
249 command_data->command = NULL;
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700250 command_data->sp = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 file->private_data = command_data;
252 return 0;
253}
254
255static int command_file_close(struct inode *inode, struct file *file)
256{
257 struct ibmasmfs_command_data *command_data = file->private_data;
258
259 if (command_data->command)
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700260 command_put(command_data->command);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
262 kfree(command_data);
263 return 0;
264}
265
266static ssize_t command_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
267{
268 struct ibmasmfs_command_data *command_data = file->private_data;
269 struct command *cmd;
270 int len;
271 unsigned long flags;
272
273 if (*offset < 0)
274 return -EINVAL;
275 if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
276 return 0;
277 if (*offset != 0)
278 return 0;
279
280 spin_lock_irqsave(&command_data->sp->lock, flags);
281 cmd = command_data->command;
282 if (cmd == NULL) {
283 spin_unlock_irqrestore(&command_data->sp->lock, flags);
284 return 0;
285 }
286 command_data->command = NULL;
287 spin_unlock_irqrestore(&command_data->sp->lock, flags);
288
289 if (cmd->status != IBMASM_CMD_COMPLETE) {
290 command_put(cmd);
291 return -EIO;
292 }
293 len = min(count, cmd->buffer_size);
294 if (copy_to_user(buf, cmd->buffer, len)) {
295 command_put(cmd);
296 return -EFAULT;
297 }
298 command_put(cmd);
299
300 return len;
301}
302
303static ssize_t command_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
304{
305 struct ibmasmfs_command_data *command_data = file->private_data;
306 struct command *cmd;
307 unsigned long flags;
308
309 if (*offset < 0)
310 return -EINVAL;
311 if (count == 0 || count > IBMASM_CMD_MAX_BUFFER_SIZE)
312 return 0;
313 if (*offset != 0)
314 return 0;
315
316 /* commands are executed sequentially, only one command at a time */
317 if (command_data->command)
318 return -EAGAIN;
319
Max Asbock88187602005-06-21 17:16:36 -0700320 cmd = ibmasm_new_command(command_data->sp, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 if (!cmd)
322 return -ENOMEM;
323
324 if (copy_from_user(cmd->buffer, ubuff, count)) {
325 command_put(cmd);
326 return -EFAULT;
327 }
328
329 spin_lock_irqsave(&command_data->sp->lock, flags);
330 if (command_data->command) {
331 spin_unlock_irqrestore(&command_data->sp->lock, flags);
332 command_put(cmd);
333 return -EAGAIN;
334 }
335 command_data->command = cmd;
336 spin_unlock_irqrestore(&command_data->sp->lock, flags);
337
338 ibmasm_exec_command(command_data->sp, cmd);
339 ibmasm_wait_for_response(cmd, get_dot_command_timeout(cmd->buffer));
340
341 return count;
342}
343
344static int event_file_open(struct inode *inode, struct file *file)
345{
346 struct ibmasmfs_event_data *event_data;
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700347 struct service_processor *sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700349 if (!inode->i_private)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 return -ENODEV;
351
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700352 sp = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
354 event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL);
355 if (!event_data)
356 return -ENOMEM;
357
358 ibmasm_event_reader_register(sp, &event_data->reader);
359
360 event_data->sp = sp;
Max Asbockb8acb802005-06-21 17:16:33 -0700361 event_data->active = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 file->private_data = event_data;
363 return 0;
364}
365
366static int event_file_close(struct inode *inode, struct file *file)
367{
368 struct ibmasmfs_event_data *event_data = file->private_data;
369
370 ibmasm_event_reader_unregister(event_data->sp, &event_data->reader);
371 kfree(event_data);
372 return 0;
373}
374
375static ssize_t event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
376{
377 struct ibmasmfs_event_data *event_data = file->private_data;
378 struct event_reader *reader = &event_data->reader;
Max Asbockb8acb802005-06-21 17:16:33 -0700379 struct service_processor *sp = event_data->sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 int ret;
Max Asbockb8acb802005-06-21 17:16:33 -0700381 unsigned long flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383 if (*offset < 0)
384 return -EINVAL;
385 if (count == 0 || count > IBMASM_EVENT_MAX_SIZE)
386 return 0;
387 if (*offset != 0)
388 return 0;
389
Max Asbockb8acb802005-06-21 17:16:33 -0700390 spin_lock_irqsave(&sp->lock, flags);
391 if (event_data->active) {
392 spin_unlock_irqrestore(&sp->lock, flags);
393 return -EBUSY;
394 }
395 event_data->active = 1;
396 spin_unlock_irqrestore(&sp->lock, flags);
397
398 ret = ibmasm_get_next_event(sp, reader);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 if (ret <= 0)
Max Asbockb8acb802005-06-21 17:16:33 -0700400 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
Max Asbockb8acb802005-06-21 17:16:33 -0700402 if (count < reader->data_size) {
403 ret = -EINVAL;
404 goto out;
405 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406
Max Asbockb8acb802005-06-21 17:16:33 -0700407 if (copy_to_user(buf, reader->data, reader->data_size)) {
408 ret = -EFAULT;
409 goto out;
410 }
411 ret = reader->data_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412
Max Asbockb8acb802005-06-21 17:16:33 -0700413out:
414 event_data->active = 0;
415 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416}
417
418static ssize_t event_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
419{
420 struct ibmasmfs_event_data *event_data = file->private_data;
421
422 if (*offset < 0)
423 return -EINVAL;
424 if (count != 1)
425 return 0;
426 if (*offset != 0)
427 return 0;
428
Max Asbockb8acb802005-06-21 17:16:33 -0700429 ibmasm_cancel_next_event(&event_data->reader);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 return 0;
431}
432
433static int r_heartbeat_file_open(struct inode *inode, struct file *file)
434{
435 struct ibmasmfs_heartbeat_data *rhbeat;
436
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700437 if (!inode->i_private)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 return -ENODEV;
439
440 rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL);
441 if (!rhbeat)
442 return -ENOMEM;
443
Theodore Ts'o8e18e292006-09-27 01:50:46 -0700444 rhbeat->sp = inode->i_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 rhbeat->active = 0;
446 ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat);
447 file->private_data = rhbeat;
448 return 0;
449}
450
451static int r_heartbeat_file_close(struct inode *inode, struct file *file)
452{
453 struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
454
455 kfree(rhbeat);
456 return 0;
457}
458
459static ssize_t r_heartbeat_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
460{
461 struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
462 unsigned long flags;
463 int result;
464
465 if (*offset < 0)
466 return -EINVAL;
467 if (count == 0 || count > 1024)
468 return 0;
469 if (*offset != 0)
470 return 0;
471
472 /* allow only one reverse heartbeat per process */
473 spin_lock_irqsave(&rhbeat->sp->lock, flags);
474 if (rhbeat->active) {
475 spin_unlock_irqrestore(&rhbeat->sp->lock, flags);
476 return -EBUSY;
477 }
478 rhbeat->active = 1;
479 spin_unlock_irqrestore(&rhbeat->sp->lock, flags);
480
481 result = ibmasm_start_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat);
482 rhbeat->active = 0;
483
484 return result;
485}
486
487static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf, size_t count, loff_t *offset)
488{
489 struct ibmasmfs_heartbeat_data *rhbeat = file->private_data;
490
491 if (*offset < 0)
492 return -EINVAL;
493 if (count != 1)
494 return 0;
495 if (*offset != 0)
496 return 0;
497
498 if (rhbeat->active)
499 ibmasm_stop_reverse_heartbeat(&rhbeat->heartbeat);
500
501 return 1;
502}
503
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504static int remote_settings_file_close(struct inode *inode, struct file *file)
505{
506 return 0;
507}
508
509static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
510{
511 void __iomem *address = (void __iomem *)file->private_data;
512 unsigned char *page;
513 int retval;
514 int len = 0;
515 unsigned int value;
516
517 if (*offset < 0)
518 return -EINVAL;
519 if (count == 0 || count > 1024)
520 return 0;
521 if (*offset != 0)
522 return 0;
523
524 page = (unsigned char *)__get_free_page(GFP_KERNEL);
525 if (!page)
526 return -ENOMEM;
527
528 value = readl(address);
529 len = sprintf(page, "%d\n", value);
530
531 if (copy_to_user(buf, page, len)) {
532 retval = -EFAULT;
533 goto exit;
534 }
535 *offset += len;
536 retval = len;
537
538exit:
539 free_page((unsigned long)page);
540 return retval;
541}
542
543static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
544{
545 void __iomem *address = (void __iomem *)file->private_data;
546 char *buff;
547 unsigned int value;
548
549 if (*offset < 0)
550 return -EINVAL;
551 if (count == 0 || count > 1024)
552 return 0;
553 if (*offset != 0)
554 return 0;
555
Yoann Padioleaudd00cc42007-07-19 01:49:03 -0700556 buff = kzalloc (count + 1, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 if (!buff)
558 return -ENOMEM;
559
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560
561 if (copy_from_user(buff, ubuff, count)) {
562 kfree(buff);
563 return -EFAULT;
564 }
Dmitry Torokhov3110dc72007-07-17 04:03:58 -0700565
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 value = simple_strtoul(buff, NULL, 10);
567 writel(value, address);
568 kfree(buff);
569
570 return count;
571}
572
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800573static const struct file_operations command_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .open = command_file_open,
575 .release = command_file_close,
576 .read = command_file_read,
577 .write = command_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200578 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579};
580
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800581static const struct file_operations event_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .open = event_file_open,
583 .release = event_file_close,
584 .read = event_file_read,
585 .write = event_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200586 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587};
588
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800589static const struct file_operations r_heartbeat_fops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .open = r_heartbeat_file_open,
591 .release = r_heartbeat_file_close,
592 .read = r_heartbeat_file_read,
593 .write = r_heartbeat_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200594 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595};
596
Arjan van de Vend54b1fd2007-02-12 00:55:34 -0800597static const struct file_operations remote_settings_fops = {
Stephen Boyd234e3402012-04-05 14:25:11 -0700598 .open = simple_open,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .release = remote_settings_file_close,
600 .read = remote_settings_file_read,
601 .write = remote_settings_file_write,
Arnd Bergmann275bd412010-07-06 22:54:51 +0200602 .llseek = generic_file_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603};
604
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605
Al Viro318ceed2012-02-12 22:08:01 -0500606static void ibmasmfs_create_files (struct super_block *sb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607{
608 struct list_head *entry;
609 struct service_processor *sp;
610
611 list_for_each(entry, &service_processors) {
612 struct dentry *dir;
613 struct dentry *remote_dir;
614 sp = list_entry(entry, struct service_processor, node);
Al Viro318ceed2012-02-12 22:08:01 -0500615 dir = ibmasmfs_create_dir(sb, sb->s_root, sp->dirname);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 if (!dir)
617 continue;
618
619 ibmasmfs_create_file(sb, dir, "command", &command_fops, sp, S_IRUSR|S_IWUSR);
620 ibmasmfs_create_file(sb, dir, "event", &event_fops, sp, S_IRUSR|S_IWUSR);
621 ibmasmfs_create_file(sb, dir, "reverse_heartbeat", &r_heartbeat_fops, sp, S_IRUSR|S_IWUSR);
622
623 remote_dir = ibmasmfs_create_dir(sb, dir, "remote_video");
624 if (!remote_dir)
625 continue;
626
627 ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR);
628 ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR);
629 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 -0700630 }
631}