libata: fix remaining ap->id
[powerpc.git] / drivers / sbus / char / openprom.c
index 293bb2f..eec28c1 100644 (file)
@@ -31,7 +31,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
 #include <linux/string.h>
@@ -145,8 +144,9 @@ static int opromgetprop(void __user *argp, struct device_node *dp, struct openpr
        void *pval;
        int len;
 
-       pval = of_get_property(dp, op->oprom_array, &len);
-       if (!pval || len <= 0 || len > bufsize)
+       if (!dp ||
+           !(pval = of_get_property(dp, op->oprom_array, &len)) ||
+           len <= 0 || len > bufsize)
                return copyout(argp, op, sizeof(int));
 
        memcpy(op->oprom_array, pval, len);
@@ -161,6 +161,8 @@ static int opromnxtprop(void __user *argp, struct device_node *dp, struct openpr
        struct property *prop;
        int len;
 
+       if (!dp)
+               return copyout(argp, op, sizeof(int));
        if (op->oprom_array[0] == '\0') {
                prop = dp->properties;
                if (!prop)
@@ -266,9 +268,13 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
 
 static int oprompath2node(void __user *argp, struct device_node *dp, struct openpromio *op, int bufsize, DATA *data)
 {
+       phandle ph = 0;
+
        dp = of_find_node_by_path(op->oprom_array);
+       if (dp)
+               ph = dp->node;
        data->current_node = dp;
-       *((int *)op->oprom_array) = dp->node;
+       *((int *)op->oprom_array) = ph;
        op->oprom_size = sizeof(int);
 
        return copyout(argp, op, bufsize + sizeof(int));
@@ -623,7 +629,7 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
        case OPROMPATH2NODE:
                if ((file->f_mode & FMODE_READ) == 0)
                        return -EPERM;
-               return openprom_sunos_ioctl(inode, file, cmd, arg, 0);
+               return openprom_sunos_ioctl(inode, file, cmd, arg, NULL);
 
        case OPIOCGET:
        case OPIOCNEXTPROP:
@@ -669,7 +675,7 @@ static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
        case OPROMSETCUR:
        case OPROMPCI2NODE:
        case OPROMPATH2NODE:
-               rval = openprom_ioctl(file->f_dentry->d_inode, file, cmd, arg);
+               rval = openprom_ioctl(file->f_path.dentry->d_inode, file, cmd, arg);
                break;
        }
 
@@ -697,7 +703,7 @@ static int openprom_release(struct inode * inode, struct file * file)
        return 0;
 }
 
-static struct file_operations openprom_fops = {
+static const struct file_operations openprom_fops = {
        .owner =        THIS_MODULE,
        .llseek =       no_llseek,
        .ioctl =        openprom_ioctl,