All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Added devfs support for i386 msr/cpuid driver
@ 2001-08-27  8:43 Per Niva
  2001-08-27 11:16 ` Arjan van de Ven
  0 siblings, 1 reply; 5+ messages in thread
From: Per Niva @ 2001-08-27  8:43 UTC (permalink / raw)
  To: hpa; +Cc: linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3244 bytes --]


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);

[-- Attachment #2: Type: APPLICATION/x-gzip, Size: 763 bytes --]

[-- Attachment #3: Type: APPLICATION/x-gzip, Size: 725 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-09-03 19:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-27  8:43 [PATCH] Added devfs support for i386 msr/cpuid driver Per Niva
2001-08-27 11:16 ` Arjan van de Ven
2001-08-27 14:52   ` Richard Gooch
2001-08-27 14:55     ` Per Niva
2001-09-03 19:57       ` Richard Gooch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.