Here is a patch to add class support to psdev.c.
I have verified it compiles and works.
Please consider for inclusion or further testing.
Thanks.
Hanna
IBM Linux Technology Center
-----
diff -Nrup linux-2.6.5/fs/coda/psdev.c linux-2.6.5p/fs/coda/psdev.c
--- linux-2.6.5/fs/coda/psdev.c 2004-04-03 19:37:36.000000000 -0800
+++ linux-2.6.5p/fs/coda/psdev.c 2004-04-08 13:44:56.000000000 -0700
@@ -37,6 +37,7 @@
#include <linux/init.h>
#include <linux/list.h>
#include <linux/smp_lock.h>
+#include <linux/device.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/poll.h>
@@ -61,6 +62,7 @@ unsigned long coda_timeout = 30; /* .. s
struct venus_comm coda_comms[MAX_CODADEVS];
+static struct class_simple coda_psdev_class;
/*
* Device operations
@@ -358,20 +360,38 @@ static struct file_operations coda_psdev
static int init_coda_psdev(void)
{
- int i;
+ int i, err = 0;
if (register_chrdev(CODA_PSDEV_MAJOR,"coda_psdev",
&coda_psdev_fops)) {
printk(KERN_ERR "coda_psdev: unable to get major %d\n",
CODA_PSDEV_MAJOR);
return -EIO;
}
+ coda_psdev_class = class_simple_create(THIS_MODULE, "coda_psdev");
+ if (IS_ERR(coda_psdev_class)) {
+ err = PTR_ERR(coda_psdev_class);
+ goto out_chrdev;
+ }
devfs_mk_dir ("coda");
for (i = 0; i < MAX_CODADEVS; i++) {
- devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
+ class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i),
+ NULL, "coda/%d", i);
+ err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
+ if (err)
+ goto out_class;
}
coda_sysctl_init();
- return 0;
+ goto out;
+
+out_class:
+ for (i = 0; i < MAX_CODADEVS; i++)
+ class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
+ class_simple_destroy(coda_psdev_class);
+out_chrdev:
+ unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
+out:
+ return err;
}
@@ -408,8 +428,11 @@ static int __init init_coda(void)
}
return 0;
out:
- for (i = 0; i < MAX_CODADEVS; i++)
+ for (i = 0; i < MAX_CODADEVS; i++) {
+ class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
devfs_remove("coda/%d", i);
+ }
+ class_simple_destroy(coda_psdev_class);
devfs_remove("coda");
unregister_chrdev(CODA_PSDEV_MAJOR,"coda_psdev");
coda_sysctl_clean();
@@ -427,8 +450,11 @@ static void __exit exit_coda(void)
if ( err != 0 ) {
printk("coda: failed to unregister filesystem\n");
}
- for (i = 0; i < MAX_CODADEVS; i++)
+ for (i = 0; i < MAX_CODADEVS; i++) {
+ class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
devfs_remove("coda/%d", i);
+ }
+ class_simple_destroy(coda_psdev_class);
devfs_remove("coda");
unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
coda_sysctl_clean();
Greg reminded me you can't put a / in a file name (duh).
> + class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i),
> + NULL, "coda/%d", i);
Here is the fixed patch:
diff -Nrup linux-2.6.5/fs/coda/psdev.c linux-2.6.5p/fs/coda/psdev.c
--- linux-2.6.5/fs/coda/psdev.c 2004-04-03 19:37:36.000000000 -0800
+++ linux-2.6.5p/fs/coda/psdev.c 2004-04-08 14:05:51.000000000 -0700
@@ -37,6 +37,7 @@
#include <linux/init.h>
#include <linux/list.h>
#include <linux/smp_lock.h>
+#include <linux/device.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/poll.h>
@@ -61,6 +62,7 @@ unsigned long coda_timeout = 30; /* .. s
struct venus_comm coda_comms[MAX_CODADEVS];
+static struct class_simple coda_psdev_class;
/*
* Device operations
@@ -358,20 +360,38 @@ static struct file_operations coda_psdev
static int init_coda_psdev(void)
{
- int i;
+ int i, err = 0;
if (register_chrdev(CODA_PSDEV_MAJOR,"coda_psdev",
&coda_psdev_fops)) {
printk(KERN_ERR "coda_psdev: unable to get major %d\n",
CODA_PSDEV_MAJOR);
return -EIO;
}
+ coda_psdev_class = class_simple_create(THIS_MODULE, "coda_psdev");
+ if (IS_ERR(coda_psdev_class)) {
+ err = PTR_ERR(coda_psdev_class);
+ goto out_chrdev;
+ }
devfs_mk_dir ("coda");
for (i = 0; i < MAX_CODADEVS; i++) {
- devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
+ class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i),
+ NULL, "cfs%d", i);
+ err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
+ if (err)
+ goto out_class;
}
coda_sysctl_init();
- return 0;
+ goto out;
+
+out_class:
+ for (i = 0; i < MAX_CODADEVS; i++)
+ class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
+ class_simple_destroy(coda_psdev_class);
+out_chrdev:
+ unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
+out:
+ return err;
}
@@ -408,8 +428,11 @@ static int __init init_coda(void)
}
return 0;
out:
- for (i = 0; i < MAX_CODADEVS; i++)
+ for (i = 0; i < MAX_CODADEVS; i++) {
+ class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
devfs_remove("coda/%d", i);
+ }
+ class_simple_destroy(coda_psdev_class);
devfs_remove("coda");
unregister_chrdev(CODA_PSDEV_MAJOR,"coda_psdev");
coda_sysctl_clean();
@@ -427,8 +450,11 @@ static void __exit exit_coda(void)
if ( err != 0 ) {
printk("coda: failed to unregister filesystem\n");
}
- for (i = 0; i < MAX_CODADEVS; i++)
+ for (i = 0; i < MAX_CODADEVS; i++) {
+ class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
devfs_remove("coda/%d", i);
+ }
+ class_simple_destroy(coda_psdev_class);
devfs_remove("coda");
unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
coda_sysctl_clean();
On Thu, Apr 08, 2004 at 02:13:01PM -0700, Hanna Linder wrote:
>
> Greg reminded me you can't put a / in a file name (duh).
>
> > + class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i),
> > + NULL, "coda/%d", i);
>
> Here is the fixed patch:
Applied, thanks.
greg k-h
Hi Hanna,
> Here is the fixed patch:
>
> diff -Nrup linux-2.6.5/fs/coda/psdev.c linux-2.6.5p/fs/coda/psdev.c
> --- linux-2.6.5/fs/coda/psdev.c 2004-04-03 19:37:36.000000000 -0800
> +++ linux-2.6.5p/fs/coda/psdev.c 2004-04-08 14:05:51.000000000 -0700
> @@ -37,6 +37,7 @@
> #include <linux/init.h>
> #include <linux/list.h>
> #include <linux/smp_lock.h>
> +#include <linux/device.h>
> #include <asm/io.h>
> #include <asm/system.h>
> #include <asm/poll.h>
> @@ -61,6 +62,7 @@ unsigned long coda_timeout = 30; /* .. s
>
>
> struct venus_comm coda_comms[MAX_CODADEVS];
> +static struct class_simple coda_psdev_class;
I think coda_psdev_class must be a pointer.
Regards
Marcel
--On Friday, April 09, 2004 12:02:19 AM +0200 Marcel Holtmann <[email protected]> wrote:
>> +static struct class_simple coda_psdev_class;
>
> I think coda_psdev_class must be a pointer.
>
> Regards
>
> Marcel
Doh! I tested on one system and fixed this there. Then accidentally mailed out the
original. Sorry about that. Here is a patch to fix it:
diff -Nrup -Xdontdiff linux-2.6.5/fs/coda/psdev.c linux-2.6.5p/fs/coda/psdev.c
--- linux-2.6.5/fs/coda/psdev.c 2004-04-08 15:37:06.000000000 -0700
+++ linux-2.6.5p/fs/coda/psdev.c 2004-04-08 15:37:15.000000000 -0700
@@ -62,7 +62,7 @@ unsigned long coda_timeout = 30; /* .. s
struct venus_comm coda_comms[MAX_CODADEVS];
-static struct class_simple coda_psdev_class;
+static struct class_simple *coda_psdev_class;
/*
* Device operations
On Thu, Apr 08, 2004 at 03:46:55PM -0700, Hanna Linder wrote:
> --On Friday, April 09, 2004 12:02:19 AM +0200 Marcel Holtmann <[email protected]> wrote:
>
> >> +static struct class_simple coda_psdev_class;
> >
> > I think coda_psdev_class must be a pointer.
> >
> > Regards
> >
> > Marcel
>
>
> Doh! I tested on one system and fixed this there. Then accidentally mailed out the
> original. Sorry about that. Here is a patch to fix it:
Applied, thanks.
greg k-h