[PATCH] Added devfs support for i386 msr/cpuid driver

From: Per Niva (pna@mendosus.org)
Date: Mon Aug 27 2001 - 03:43:16 EST


Hi all,

I added devfs support to the i386 msr/cpuid driver,
along the lines in the microcode/mtrr drivers.

Please CC me any replies personally, as I don't
regularly follow the list.

Regards,

        Per Niva

----------------------------------------------------
pna@mendosus.org +46 705 509 654
"Beware - the world will never be the same again..."

--- arch/i386/kernel/msr.c.orig Wed Aug 22 18:24:39 2001
+++ arch/i386/kernel/msr.c Wed Aug 22 17:35:24 2001
@@ -22,6 +22,11 @@
  *
  * This driver uses /dev/cpu/%d/msr where %d is the minor number, and on
  * an SMP box will direct the access to CPU %d.
+ *
+ * ChangeLog
+ *
+ * 2001-08-22 Per Niva <pna@mendosus.org>
+ * Added support for devfs
  */

 #include <linux/module.h>
@@ -34,12 +39,17 @@
 #include <linux/poll.h>
 #include <linux/smp.h>
 #include <linux/major.h>
+#include <linux/devfs_fs_kernel.h>

 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>

+
+static devfs_handle_t devfs_handle;
+
+
 /* Note: "err" is handled in a funny way below. Otherwise one version
    of gcc or another breaks. */

@@ -250,18 +260,28 @@

 int __init msr_init(void)
 {
+#ifdef CONFIG_DEVFS_FS
+ devfs_handle = devfs_register(NULL, "cpu/msr", DEVFS_FL_DEFAULT, 0, 0,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ &msr_fops, NULL);
+#else
   if (register_chrdev(MSR_MAJOR, "cpu/msr", &msr_fops)) {
     printk(KERN_ERR "msr: unable to get major %d for msr\n",
            MSR_MAJOR);
     return -EBUSY;
   }
+#endif

   return 0;
 }

 void __exit msr_exit(void)
 {
+#ifdef CONFIG_DEVFS_FS
+ devfs_unregister(devfs_handle);
+#else
   unregister_chrdev(MSR_MAJOR, "cpu/msr");
+#endif
 }

 module_init(msr_init);

--- arch/i386/kernel/cpuid.c.orig Wed Aug 22 18:24:31 2001
+++ arch/i386/kernel/cpuid.c Wed Aug 22 18:18:03 2001
@@ -23,6 +23,11 @@
  *
  * This driver uses /dev/cpu/%d/cpuid where %d is the minor number, and on
  * an SMP box will direct the access to CPU %d.
+ *
+ * ChangeLog
+ *
+ * 2001-08-22 Per Niva <pna@mendosus.org>
+ * Added support for devfs
  */

 #include <linux/module.h>
@@ -35,12 +40,17 @@
 #include <linux/poll.h>
 #include <linux/smp.h>
 #include <linux/major.h>
+#include <linux/devfs_fs_kernel.h>

 #include <asm/processor.h>
 #include <asm/msr.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>

+
+static devfs_handle_t devfs_handle;
+
+
 #ifdef CONFIG_SMP

 struct cpuid_command {
@@ -142,18 +152,27 @@

 int __init cpuid_init(void)
 {
+#ifdef CONFIG_DEVFS_FS
+ devfs_handle = devfs_register(NULL, "cpu/cpuid", DEVFS_FL_DEFAULT, 0, 0,
+ S_IFREG | S_IRUGO | S_IWUSR,
+ &cpuid_fops, NULL);
+#else
   if (register_chrdev(CPUID_MAJOR, "cpu/cpuid", &cpuid_fops)) {
     printk(KERN_ERR "cpuid: unable to get major %d for cpuid\n",
            CPUID_MAJOR);
     return -EBUSY;
   }
-
+#endif
   return 0;
 }

 void __exit cpuid_exit(void)
 {
- unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
+#ifdef CONFIG_DEVFS_FS
+ devfs_unregister(devfs_handle);
+#else
+ unregister_chrdev(CPUID_MAJOR, "cpu/cpuid");
+#endif
 }

 module_init(cpuid_init);





-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Aug 31 2001 - 21:00:23 EST