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:22 -0700 [thread overview]
Message-ID: <1084576042851@kroah.com> (raw)
In-Reply-To: <1084576042499@kroah.com>
ChangeSet 1.1587.5.17, 2004/05/02 20:29:59-07:00, hannal@us.ibm.com
[PATCH] add class support to drivers/char/tipar.c
This patch adds class support to the Texas Instruments graphing calculators
with a parallel link cable.
I have verified it compiles. If someone has the hardware please verify it works.
drivers/char/tipar.c | 49 ++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 42 insertions(+), 7 deletions(-)
diff -Nru a/drivers/char/tipar.c b/drivers/char/tipar.c
--- a/drivers/char/tipar.c Fri May 14 15:58:43 2004
+++ b/drivers/char/tipar.c Fri May 14 15:58:43 2004
@@ -58,6 +58,7 @@
#include <asm/bitops.h>
#include <linux/devfs_fs_kernel.h> /* DevFs support */
#include <linux/parport.h> /* Our code depend on parport */
+#include <linux/device.h>
/*
* TI definitions
@@ -92,6 +93,8 @@
static unsigned int tp_count; /* tipar count */
static unsigned long opened; /* opened devices */
+static struct class_simple *tipar_class;
+
/* --- macros for parport access -------------------------------------- */
#define r_dtr(x) (parport_read_data(table[(x)].dev->port))
@@ -424,18 +427,26 @@
static int
tipar_register(int nr, struct parport *port)
{
+ int err = 0;
+
/* Register our module into parport */
table[nr].dev = parport_register_device(port, "tipar",
NULL, NULL, NULL, 0,
(void *) &table[nr]);
- if (table[nr].dev == NULL)
- return 1;
+ if (table[nr].dev == NULL) {
+ err = 1;
+ goto out;
+ }
+ class_simple_device_add(tipar_class, MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
+ NULL, "par%d", nr);
/* Use devfs, tree: /dev/ticables/par/[0..2] */
- devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
+ err = devfs_mk_cdev(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr),
S_IFCHR | S_IRUGO | S_IWUGO,
"ticables/par/%d", nr);
+ if (err)
+ goto out_class;
/* Display informations */
printk(KERN_INFO "tipar%d: using %s (%s).\n", nr, port->name,
@@ -447,7 +458,14 @@
else
printk("tipar%d: link cable not found.\n", nr);
- return 0;
+ err = 0;
+ goto out;
+
+out_class:
+ class_simple_device_remove(MKDEV(TIPAR_MAJOR, TIPAR_MINOR + nr));
+ class_simple_destroy(tipar_class);
+out:
+ return err;
}
static void
@@ -477,23 +495,38 @@
int __init
tipar_init_module(void)
{
+ int err = 0;
+
printk("tipar: parallel link cable driver, version %s\n",
DRIVER_VERSION);
if (register_chrdev(TIPAR_MAJOR, "tipar", &tipar_fops)) {
printk("tipar: unable to get major %d\n", TIPAR_MAJOR);
- return -EIO;
+ err = -EIO;
+ goto out;
}
/* Use devfs with tree: /dev/ticables/par/[0..2] */
devfs_mk_dir("ticables/par");
+ tipar_class = class_simple_create(THIS_MODULE, "ticables");
+ if (IS_ERR(tipar_class)) {
+ err = PTR_ERR(tipar_class);
+ goto out_chrdev;
+ }
if (parport_register_driver(&tipar_driver)) {
printk("tipar: unable to register with parport\n");
- return -EIO;
+ err = -EIO;
+ goto out;
}
- return 0;
+ err = 0;
+ goto out;
+
+out_chrdev:
+ unregister_chrdev(TIPAR_MAJOR, "tipar");
+out:
+ return err;
}
void __exit
@@ -510,8 +543,10 @@
if (table[i].dev == NULL)
continue;
parport_unregister_device(table[i].dev);
+ class_simple_device_remove(MKDEV(TIPAR_MAJOR, i));
devfs_remove("ticables/par/%d", i);
}
+ class_simple_destroy(tipar_class);
devfs_remove("ticables/par");
printk("tipar: module unloaded !\n");
next prev parent reply other threads:[~2004-05-14 23:28 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
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 [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: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=1084576042851@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