]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/misc/ibmasm/ibmasmfs.c
Pull bugzilla-7880 into release branch
[linux-2.6-omap-h63xx.git] / drivers / misc / ibmasm / ibmasmfs.c
index 4a35caff5d020e0e16d0f624e648ccb8cbf5b650..22a7e8ba211d242dd0b25c477f2ea5b7c4bcd07c 100644 (file)
  *
  * Copyright (C) IBM Corporation, 2004
  *
- * Author: Max Asböck <amax@us.ibm.com> 
+ * Author: Max Asböck <amax@us.ibm.com>
  *
  */
 
 /*
- * 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.
  */
 
  * 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
+ *     write: set value
+ *     read: read value
  */
 
 #include <linux/fs.h>
@@ -147,7 +147,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;
        }
@@ -156,8 +155,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)
 {
@@ -175,7 +174,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;
@@ -244,7 +243,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);
@@ -252,7 +251,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;
 }
@@ -262,7 +261,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;
@@ -349,12 +348,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)
@@ -439,14 +438,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;
@@ -508,7 +507,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;
 }
 
@@ -564,17 +563,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);
@@ -582,28 +580,28 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
        return count;
 }
 
-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,