From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core patches for 2.6.6
Date: Fri, 14 May 2004 16:07:21 -0700 [thread overview]
Message-ID: <10845760411194@kroah.com> (raw)
In-Reply-To: <10845760412992@kroah.com>
ChangeSet 1.1587.5.13, 2004/05/02 20:28:38-07:00, sebek64@post.cz
[PATCH] Class support for ppdev.c
drivers/char/ppdev.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 43 insertions(+), 2 deletions(-)
diff -Nru a/drivers/char/ppdev.c b/drivers/char/ppdev.c
--- a/drivers/char/ppdev.c Fri May 14 15:59:42 2004
+++ b/drivers/char/ppdev.c Fri May 14 15:59:42 2004
@@ -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>
@@ -739,6 +740,8 @@
return mask;
}
+static struct class_simple *ppdev_class;
+
static struct file_operations pp_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
@@ -750,23 +753,59 @@
.release = pp_release,
};
+static void pp_attach(struct parport *port)
+{
+ class_simple_device_add(ppdev_class, MKDEV(PP_MAJOR, port->number),
+ NULL, "parport%d", port->number);
+}
+
+static void pp_detach(struct parport *port)
+{
+ class_simple_device_remove(MKDEV(PP_MAJOR, port->number));
+}
+
+static struct parport_driver pp_driver = {
+ .name = CHRDEV,
+ .attach = pp_attach,
+ .detach = pp_detach,
+};
+
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),
S_IFCHR | S_IRUGO | S_IWUGO, "parports/%d", i);
}
+ if (parport_register_driver(&pp_driver)) {
+ printk (KERN_WARNING CHRDEV ": unable to register with parport\n");
+ goto out_class;
+ }
printk (KERN_INFO PP_VERSION "\n");
- return 0;
+ goto out;
+
+out_class:
+ for (i = 0; i < PARPORT_MAX; i++)
+ devfs_remove("parports/%d", i);
+ devfs_remove("parports");
+ class_simple_destroy(ppdev_class);
+out_chrdev:
+ unregister_chrdev(PP_MAJOR, CHRDEV);
+out:
+ return err;
}
static void __exit ppdev_cleanup (void)
@@ -775,7 +814,9 @@
/* Clean up all parport stuff */
for (i = 0; i < PARPORT_MAX; i++)
devfs_remove("parports/%d", i);
+ parport_unregister_driver(&pp_driver);
devfs_remove("parports");
+ class_simple_destroy(ppdev_class);
unregister_chrdev (PP_MAJOR, CHRDEV);
}
next prev parent reply other threads:[~2004-05-15 1:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-14 23:06 [BK PATCH] Driver Core patches for 2.6.6 Greg KH
2004-05-14 23:07 ` [PATCH] " Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH [this message]
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:07 ` Greg KH
2004-05-14 23:24 ` zombies with AMD64 and 32 bit userspace with 2.6 David Lang
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=10845760411194@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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