Skip to content

Commit

Permalink
[MIPS] RTLX: Sprinkle device model code into code to make udev happier.
Browse files Browse the repository at this point in the history
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Ralf Baechle committed Feb 10, 2007
1 parent 27a3bba commit bb3d7c7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion arch/mips/kernel/rtlx.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
*/

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
Expand All @@ -34,6 +35,7 @@
#include <linux/sched.h>
#include <linux/wait.h>
#include <asm/mipsmtregs.h>
#include <asm/mips_mt.h>
#include <asm/cacheflush.h>
#include <asm/atomic.h>
#include <asm/cpu.h>
Expand Down Expand Up @@ -498,7 +500,8 @@ static char register_chrdev_failed[] __initdata =

static int rtlx_module_init(void)
{
int i;
struct device *dev;
int i, err;

major = register_chrdev(0, module_name, &rtlx_fops);
if (major < 0) {
Expand All @@ -511,6 +514,13 @@ static int rtlx_module_init(void)
init_waitqueue_head(&channel_wqs[i].rt_queue);
init_waitqueue_head(&channel_wqs[i].lx_queue);
channel_wqs[i].in_open = 0;

dev = device_create(mt_class, NULL, MKDEV(major, i),
"%s%d", module_name, i);
if (IS_ERR(dev)) {
err = PTR_ERR(dev);
goto out_chrdev;
}
}

/* set up notifiers */
Expand All @@ -525,10 +535,21 @@ static int rtlx_module_init(void)
setup_irq(rtlx_irq_num, &rtlx_irq);

return 0;

out_chrdev:
for (i = 0; i < RTLX_CHANNELS; i++)
device_destroy(mt_class, MKDEV(major, i));

return err;
}

static void __exit rtlx_module_exit(void)
{
int i;

for (i = 0; i < RTLX_CHANNELS; i++)
device_destroy(mt_class, MKDEV(major, i));

unregister_chrdev(major, module_name);
}

Expand Down

0 comments on commit bb3d7c7

Please sign in to comment.