aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2007-02-07 10:36:56 -0500
committerRalf Baechle <ralf@linux-mips.org>2007-02-10 17:38:43 -0500
commitbb3d7c7ff1cc18b4cb83820327905f7e1f8dc414 (patch)
tree5b2ba2d53fb6fbf0b9885684dbe5f3fdbed74230
parent27a3bbaf4b1e23a3afbae4d9f72b51a36859f74a (diff)
[MIPS] RTLX: Sprinkle device model code into code to make udev happier.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/kernel/rtlx.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 8610f4a925e9..f29e93c6ccfc 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -17,6 +17,7 @@
17 * 17 *
18 */ 18 */
19 19
20#include <linux/device.h>
20#include <linux/kernel.h> 21#include <linux/kernel.h>
21#include <linux/module.h> 22#include <linux/module.h>
22#include <linux/fs.h> 23#include <linux/fs.h>
@@ -34,6 +35,7 @@
34#include <linux/sched.h> 35#include <linux/sched.h>
35#include <linux/wait.h> 36#include <linux/wait.h>
36#include <asm/mipsmtregs.h> 37#include <asm/mipsmtregs.h>
38#include <asm/mips_mt.h>
37#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
38#include <asm/atomic.h> 40#include <asm/atomic.h>
39#include <asm/cpu.h> 41#include <asm/cpu.h>
@@ -498,7 +500,8 @@ static char register_chrdev_failed[] __initdata =
498 500
499static int rtlx_module_init(void) 501static int rtlx_module_init(void)
500{ 502{
501 int i; 503 struct device *dev;
504 int i, err;
502 505
503 major = register_chrdev(0, module_name, &rtlx_fops); 506 major = register_chrdev(0, module_name, &rtlx_fops);
504 if (major < 0) { 507 if (major < 0) {
@@ -511,6 +514,13 @@ static int rtlx_module_init(void)
511 init_waitqueue_head(&channel_wqs[i].rt_queue); 514 init_waitqueue_head(&channel_wqs[i].rt_queue);
512 init_waitqueue_head(&channel_wqs[i].lx_queue); 515 init_waitqueue_head(&channel_wqs[i].lx_queue);
513 channel_wqs[i].in_open = 0; 516 channel_wqs[i].in_open = 0;
517
518 dev = device_create(mt_class, NULL, MKDEV(major, i),
519 "%s%d", module_name, i);
520 if (IS_ERR(dev)) {
521 err = PTR_ERR(dev);
522 goto out_chrdev;
523 }
514 } 524 }
515 525
516 /* set up notifiers */ 526 /* set up notifiers */
@@ -525,10 +535,21 @@ static int rtlx_module_init(void)
525 setup_irq(rtlx_irq_num, &rtlx_irq); 535 setup_irq(rtlx_irq_num, &rtlx_irq);
526 536
527 return 0; 537 return 0;
538
539out_chrdev:
540 for (i = 0; i < RTLX_CHANNELS; i++)
541 device_destroy(mt_class, MKDEV(major, i));
542
543 return err;
528} 544}
529 545
530static void __exit rtlx_module_exit(void) 546static void __exit rtlx_module_exit(void)
531{ 547{
548 int i;
549
550 for (i = 0; i < RTLX_CHANNELS; i++)
551 device_destroy(mt_class, MKDEV(major, i));
552
532 unregister_chrdev(major, module_name); 553 unregister_chrdev(major, module_name);
533} 554}
534 555