From: sebek64@post.cz (Marcel Sebek)
To: linux-kernel@vger.kernel.org
Cc: tim@cyberelk.net, greg@kroah.com
Subject: [PATCH 2.6] Class support for ppdev.c
Date: Sat, 10 Apr 2004 15:51:15 +0200 [thread overview]
Message-ID: <20040410135115.GA3612@penguin.localdomain> (raw)
This patch adds class support to ppdev.c.
The module compiles and loads ok.
diff -urN linux-2.6/drivers/char/ppdev.c linux-2.6-new/drivers/char/ppdev.c
--- linux-2.6/drivers/char/ppdev.c 2003-12-31 18:51:23.000000000 +0100
+++ linux-2.6-new/drivers/char/ppdev.c 2004-04-10 14:28:54.000000000 +0200
@@ -59,6 +59,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/sched.h>
+#include <linux/device.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/ioctl.h>
#include <linux/parport.h>
@@ -750,31 +751,54 @@
.release = pp_release,
};
+static struct class_simple *ppdev_class;
+
static int __init ppdev_init (void)
{
- int i;
+ int i, err = 0;
if (register_chrdev (PP_MAJOR, CHRDEV, &pp_fops)) {
printk (KERN_WARNING CHRDEV ": unable to get major %d\n",
PP_MAJOR);
return -EIO;
}
+ ppdev_class = class_simple_create(THIS_MODULE, CHRDEV);
+ if (IS_ERR(ppdev_class)) {
+ err = PTR_ERR(ppdev_class);
+ goto out_chrdev;
+ }
devfs_mk_dir("parports");
for (i = 0; i < PARPORT_MAX; i++) {
- devfs_mk_cdev(MKDEV(PP_MAJOR, i),
+ class_simple_device_add(ppdev_class, MKDEV(PP_MAJOR, i),
+ NULL, "parport%d", i);
+ err = devfs_mk_cdev(MKDEV(PP_MAJOR, i),
S_IFCHR | S_IRUGO | S_IWUGO, "parports/%d", i);
+ if (err)
+ goto out_class;
}
printk (KERN_INFO PP_VERSION "\n");
- return 0;
+ goto out;
+
+out_class:
+ for (i = 0; i < PARPORT_MAX; i++)
+ class_simple_device_remove(MKDEV(PP_MAJOR, i));
+ class_simple_destroy(ppdev_class);
+out_chrdev:
+ unregister_chrdev(PP_MAJOR, CHRDEV);
+out:
+ return err;
}
static void __exit ppdev_cleanup (void)
{
int i;
/* Clean up all parport stuff */
- for (i = 0; i < PARPORT_MAX; i++)
+ for (i = 0; i < PARPORT_MAX; i++) {
+ class_simple_device_remove(MKDEV(PP_MAJOR, i));
devfs_remove("parports/%d", i);
+ }
+ class_simple_destroy(ppdev_class);
devfs_remove("parports");
unregister_chrdev (PP_MAJOR, CHRDEV);
}
--
Marcel Sebek
jabber: sebek@jabber.cz ICQ: 279852819
linux user number: 307850 GPG ID: 5F88735E
GPG FP: 0F01 BAB8 3148 94DB B95D 1FCA 8B63 CA06 5F88 735E
next reply other threads:[~2004-04-10 13:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-10 13:51 Marcel Sebek [this message]
2004-04-10 17:01 ` Greg KH
2004-04-10 18:06 ` Marcel Sebek
2004-04-10 19:46 ` Marcel Sebek
2004-04-10 20:28 ` viro
2004-04-11 8:25 ` Marcel Sebek
2004-04-12 18:51 ` Greg KH
2004-04-13 17:29 ` Marcel Sebek
2004-05-02 6:29 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040410135115.GA3612@penguin.localdomain \
--to=sebek64@post.cz \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tim@cyberelk.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®