X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=drivers%2Fmisc%2Fibmasm%2Fibmasmfs.c;h=de966a6fb7e634d50abce07bfa82a9c47f6f8ac9;hb=95d0ad049cd6937634c0a75f9518f5166daabfce;hp=c87ef7d82b70be09b72bb724fe6d8c217aaae771;hpb=b8acb808468a88a188d7c5aba3681c583a5785f9;p=safe%2Fjmp%2Flinux-2.6 diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c index c87ef7d..de966a6 100644 --- a/drivers/misc/ibmasm/ibmasmfs.c +++ b/drivers/misc/ibmasm/ibmasmfs.c @@ -17,12 +17,12 @@ * * Copyright (C) IBM Corporation, 2004 * - * Author: Max Asböck + * Author: Max Asböck * */ /* - * Parts of this code are based on an article by Jonathan Corbet + * Parts of this code are based on an article by Jonathan Corbet * that appeared in Linux Weekly News. */ @@ -37,9 +37,7 @@ * | |-- event * | |-- reverse_heartbeat * | `-- remote_video - * | |-- connected * | |-- depth - * | |-- events * | |-- height * | `-- width * . @@ -50,39 +48,29 @@ * |-- event * |-- reverse_heartbeat * `-- remote_video - * |-- connected * |-- depth - * |-- events * |-- height * `-- width * * For each service processor the following files are created: * * command: execute dot commands - * write: execute a dot command on the service processor - * read: return the result of a previously executed dot command + * write: execute a dot command on the service processor + * read: return the result of a previously executed dot command * * events: listen for service processor events - * read: sleep (interruptible) until an event occurs + * read: sleep (interruptible) until an event occurs * write: wakeup sleeping event listener * * reverse_heartbeat: send a heartbeat to the service processor - * read: sleep (interruptible) until the reverse heartbeat fails + * read: sleep (interruptible) until the reverse heartbeat fails * write: wakeup sleeping heartbeat listener * * remote_video/width * remote_video/height * remote_video/width: control remote display settings - * write: set value - * read: read value - * - * remote_video/connected - * read: return "1" if web browser VNC java applet is connected, - * "0" otherwise - * - * remote_video/events - * read: sleep until a remote mouse or keyboard event occurs, then return - * then event. + * write: set value + * read: read value */ #include @@ -102,10 +90,11 @@ static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root); static int ibmasmfs_fill_super (struct super_block *sb, void *data, int silent); -static struct super_block *ibmasmfs_get_super(struct file_system_type *fst, - int flags, const char *name, void *data) +static int ibmasmfs_get_super(struct file_system_type *fst, + int flags, const char *name, void *data, + struct vfsmount *mnt) { - return get_sb_single(fst, flags, data, ibmasmfs_fill_super); + return get_sb_single(fst, flags, data, ibmasmfs_fill_super, mnt); } static struct super_operations ibmasmfs_s_ops = { @@ -113,7 +102,7 @@ static struct super_operations ibmasmfs_s_ops = { .drop_inode = generic_delete_inode, }; -static struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations; +static const struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations; static struct file_system_type ibmasmfs_type = { .owner = THIS_MODULE, @@ -157,9 +146,6 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) if (ret) { ret->i_mode = mode; - ret->i_uid = ret->i_gid = 0; - ret->i_blksize = PAGE_CACHE_SIZE; - ret->i_blocks = 0; ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; } return ret; @@ -167,8 +153,8 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode) static struct dentry *ibmasmfs_create_file (struct super_block *sb, struct dentry *parent, - const char *name, - struct file_operations *fops, + const char *name, + const struct file_operations *fops, void *data, int mode) { @@ -186,7 +172,7 @@ static struct dentry *ibmasmfs_create_file (struct super_block *sb, } inode->i_fop = fops; - inode->u.generic_ip = data; + inode->i_private = data; d_add(dentry, inode); return dentry; @@ -255,7 +241,7 @@ static int command_file_open(struct inode *inode, struct file *file) { struct ibmasmfs_command_data *command_data; - if (!inode->u.generic_ip) + if (!inode->i_private) return -ENODEV; command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL); @@ -263,7 +249,7 @@ static int command_file_open(struct inode *inode, struct file *file) return -ENOMEM; command_data->command = NULL; - command_data->sp = inode->u.generic_ip; + command_data->sp = inode->i_private; file->private_data = command_data; return 0; } @@ -273,7 +259,7 @@ static int command_file_close(struct inode *inode, struct file *file) struct ibmasmfs_command_data *command_data = file->private_data; if (command_data->command) - command_put(command_data->command); + command_put(command_data->command); kfree(command_data); return 0; @@ -333,7 +319,7 @@ static ssize_t command_file_write(struct file *file, const char __user *ubuff, s if (command_data->command) return -EAGAIN; - cmd = ibmasm_new_command(count); + cmd = ibmasm_new_command(command_data->sp, count); if (!cmd) return -ENOMEM; @@ -360,12 +346,12 @@ static ssize_t command_file_write(struct file *file, const char __user *ubuff, s static int event_file_open(struct inode *inode, struct file *file) { struct ibmasmfs_event_data *event_data; - struct service_processor *sp; + struct service_processor *sp; - if (!inode->u.generic_ip) + if (!inode->i_private) return -ENODEV; - sp = inode->u.generic_ip; + sp = inode->i_private; event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL); if (!event_data) @@ -450,14 +436,14 @@ static int r_heartbeat_file_open(struct inode *inode, struct file *file) { struct ibmasmfs_heartbeat_data *rhbeat; - if (!inode->u.generic_ip) + if (!inode->i_private) return -ENODEV; rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL); if (!rhbeat) return -ENOMEM; - rhbeat->sp = (struct service_processor *)inode->u.generic_ip; + rhbeat->sp = inode->i_private; rhbeat->active = 0; ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat); file->private_data = rhbeat; @@ -519,7 +505,7 @@ static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf, static int remote_settings_file_open(struct inode *inode, struct file *file) { - file->private_data = inode->u.generic_ip; + file->private_data = inode->i_private; return 0; } @@ -575,17 +561,16 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user * if (*offset != 0) return 0; - buff = kmalloc (count + 1, GFP_KERNEL); + buff = kzalloc (count + 1, GFP_KERNEL); if (!buff) return -ENOMEM; - memset(buff, 0x0, count + 1); if (copy_from_user(buff, ubuff, count)) { kfree(buff); return -EFAULT; } - + value = simple_strtoul(buff, NULL, 10); writel(value, address); kfree(buff); @@ -593,109 +578,34 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user * return count; } -static int remote_event_file_open(struct inode *inode, struct file *file) -{ - struct service_processor *sp; - unsigned long flags; - struct remote_queue *q; - - file->private_data = inode->u.generic_ip; - sp = file->private_data; - q = &sp->remote_queue; - - /* allow only one event reader */ - spin_lock_irqsave(&sp->lock, flags); - if (q->open) { - spin_unlock_irqrestore(&sp->lock, flags); - return -EBUSY; - } - q->open = 1; - spin_unlock_irqrestore(&sp->lock, flags); - - enable_mouse_interrupts(sp); - - return 0; -} - -static int remote_event_file_close(struct inode *inode, struct file *file) -{ - struct service_processor *sp = file->private_data; - - disable_mouse_interrupts(sp); - wake_up_interruptible(&sp->remote_queue.wait); - sp->remote_queue.open = 0; - - return 0; -} - -static ssize_t remote_event_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) -{ - struct service_processor *sp = file->private_data; - struct remote_queue *q = &sp->remote_queue; - size_t data_size; - struct remote_event *reader = q->reader; - size_t num_events; - - if (*offset < 0) - return -EINVAL; - if (count == 0 || count > 1024) - return 0; - if (*offset != 0) - return 0; - - if (wait_event_interruptible(q->wait, q->reader != q->writer)) - return -ERESTARTSYS; - - /* only get multiples of struct remote_event */ - num_events = min((count/sizeof(struct remote_event)), ibmasm_events_available(q)); - if (!num_events) - return 0; - - data_size = num_events * sizeof(struct remote_event); - - if (copy_to_user(buf, reader, data_size)) - return -EFAULT; - - ibmasm_advance_reader(q, num_events); - - return data_size; -} - - -static struct file_operations command_fops = { +static const struct file_operations command_fops = { .open = command_file_open, .release = command_file_close, .read = command_file_read, .write = command_file_write, }; -static struct file_operations event_fops = { +static const struct file_operations event_fops = { .open = event_file_open, .release = event_file_close, .read = event_file_read, .write = event_file_write, }; -static struct file_operations r_heartbeat_fops = { +static const struct file_operations r_heartbeat_fops = { .open = r_heartbeat_file_open, .release = r_heartbeat_file_close, .read = r_heartbeat_file_read, .write = r_heartbeat_file_write, }; -static struct file_operations remote_settings_fops = { +static const struct file_operations remote_settings_fops = { .open = remote_settings_file_open, .release = remote_settings_file_close, .read = remote_settings_file_read, .write = remote_settings_file_write, }; -static struct file_operations remote_event_fops = { - .open = remote_event_file_open, - .release = remote_event_file_close, - .read = remote_event_file_read, -}; - static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) { @@ -721,7 +631,5 @@ static void ibmasmfs_create_files (struct super_block *sb, struct dentry *root) ibmasmfs_create_file(sb, remote_dir, "width", &remote_settings_fops, (void *)display_width(sp), S_IRUSR|S_IWUSR); ibmasmfs_create_file(sb, remote_dir, "height", &remote_settings_fops, (void *)display_height(sp), S_IRUSR|S_IWUSR); ibmasmfs_create_file(sb, remote_dir, "depth", &remote_settings_fops, (void *)display_depth(sp), S_IRUSR|S_IWUSR); - ibmasmfs_create_file(sb, remote_dir, "connected", &remote_settings_fops, (void *)vnc_status(sp), S_IRUSR); - ibmasmfs_create_file(sb, remote_dir, "events", &remote_event_fops, (void *)sp, S_IRUSR); } }