patch-2.2.18 linux/drivers/macintosh/nvram.c

Next file: linux/drivers/macintosh/via-pmu.c
Previous file: linux/drivers/macintosh/mediabay.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/macintosh/nvram.c linux/drivers/macintosh/nvram.c
@@ -14,6 +14,7 @@
 #include <linux/nvram.h>
 #include <linux/init.h>
 #include <asm/uaccess.h>
+#include <asm/nvram.h>
 
 #define NVRAM_SIZE	8192
 
@@ -76,6 +77,30 @@
 	return p - buf;
 }
 
+static int nvram_ioctl(struct inode *inode, struct file *file,
+	unsigned int cmd, unsigned long arg)
+{
+	switch(cmd) {
+		case PMAC_NVRAM_GET_OFFSET:
+		{
+			int part, offset;
+			if (copy_from_user(&part,(void*)arg,sizeof(part))!=0)
+				return -EFAULT;
+			if (part < pmac_nvram_OF || part > pmac_nvram_NR)
+				return -EINVAL;
+			offset = pmac_get_partition(part);
+			if (copy_to_user((void*)arg,&offset,sizeof(offset))!=0)
+				return -EFAULT;
+			break;
+		}
+
+		default:
+			return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int nvram_open(struct inode *inode, struct file *file)
 {
 	MOD_INC_USE_COUNT;
@@ -94,7 +119,7 @@
 	write_nvram,
 	NULL,		/* nvram_readdir */
 	NULL,		/* nvram_select */
-	NULL,		/* nvram_ioctl */
+	nvram_ioctl,
 	NULL,		/* nvram_mmap */
 	nvram_open,
 	NULL,		/* flush */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)