Commit 517b9727 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] LP: add sysfs class support for lp devices

Add sysfs class support for lp devices.

Based on a patch from Hanna Linder <hannal@us.ibm.com>
parent e5da64c4
...@@ -145,6 +145,7 @@ ...@@ -145,6 +145,7 @@
struct lp_struct lp_table[LP_NO]; struct lp_struct lp_table[LP_NO];
static unsigned int lp_count = 0; static unsigned int lp_count = 0;
static struct class_simple *lp_class;
#ifdef CONFIG_LP_CONSOLE #ifdef CONFIG_LP_CONSOLE
static struct parport *console_registered; // initially NULL static struct parport *console_registered; // initially NULL
...@@ -795,6 +796,8 @@ static int lp_register(int nr, struct parport *port) ...@@ -795,6 +796,8 @@ static int lp_register(int nr, struct parport *port)
if (reset) if (reset)
lp_reset(nr); lp_reset(nr);
class_simple_device_add(lp_class, MKDEV(LP_MAJOR, nr), NULL,
"lp%d", nr);
devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO, devfs_mk_cdev(MKDEV(LP_MAJOR, nr), S_IFCHR | S_IRUGO | S_IWUGO,
"printers/%d", nr); "printers/%d", nr);
...@@ -897,6 +900,7 @@ int __init lp_init (void) ...@@ -897,6 +900,7 @@ int __init lp_init (void)
} }
devfs_mk_dir("printers"); devfs_mk_dir("printers");
lp_class = class_simple_create(THIS_MODULE, "printer");
if (parport_register_driver (&lp_driver)) { if (parport_register_driver (&lp_driver)) {
printk (KERN_ERR "lp: unable to register with parport\n"); printk (KERN_ERR "lp: unable to register with parport\n");
...@@ -958,8 +962,10 @@ static void lp_cleanup_module (void) ...@@ -958,8 +962,10 @@ static void lp_cleanup_module (void)
continue; continue;
parport_unregister_device(lp_table[offset].dev); parport_unregister_device(lp_table[offset].dev);
devfs_remove("printers/%d", offset); devfs_remove("printers/%d", offset);
class_simple_device_remove(MKDEV(LP_MAJOR, offset));
} }
devfs_remove("printers"); devfs_remove("printers");
class_simple_destroy(lp_class);
} }
__setup("lp=", lp_setup); __setup("lp=", lp_setup);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment