public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6] add class support to dsp56k.c
@ 2004-04-07 23:13 Hanna Linder
  2004-04-08  8:12 ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: Hanna Linder @ 2004-04-07 23:13 UTC (permalink / raw)
  To: linux-kernel, geert; +Cc: hannal, greg, noring, lars, tomas


Here is a patch that adds sysfs class support to /drivers/char/dsp56k.c

I dont have the hardware or a cross compiler... If someone could test it
I would appreciate it.

Thanks.

Hanna
IBM Linux Technology Center
-----
diff -Nrup linux-2.6.5/drivers/char/dsp56k.c linux-2.6.5p/drivers/char/dsp56k.c
--- linux-2.6.5/drivers/char/dsp56k.c	2004-04-03 19:37:07.000000000 -0800
+++ linux-2.6.5p/drivers/char/dsp56k.c	2004-04-07 14:44:28.000000000 -0700
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/smp_lock.h>
+#include <linux/device.h>
 
 #include <asm/atarihw.h>
 #include <asm/traps.h>
@@ -149,6 +150,8 @@ static struct dsp56k_device {
 	int tx_wsize, rx_wsize;
 } dsp56k;
 
+static struct class_simple *dsp56k_class;
+
 static int dsp56k_reset(void)
 {
 	u_char status;
@@ -502,6 +505,8 @@ static char banner[] __initdata = KERN_I
 
 static int __init dsp56k_init_driver(void)
 {
+	int err = 0;
+
 	if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) {
 		printk("DSP56k driver: Hardware not present\n");
 		return -ENODEV;
@@ -511,12 +516,28 @@ static int __init dsp56k_init_driver(voi
 		printk("DSP56k driver: Unable to register driver\n");
 		return -ENODEV;
 	}
+	dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k");
+	if (IS_ERR(dsp56k_class)) {
+		err = PTR_ERR(dsp56k_class);
+		goto out_chrdev;
+	}
+	class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
 
-	devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
+	err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
 		      S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
+	if(err)
+		goto out_class;
 
 	printk(banner);
-	return 0;
+	goto out;
+
+out_class:
+	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
+	class_simple_destroy(dsp56k_class);
+out_chrdev:
+	unregister_chrdev(DSP56K_MAJOR, "sdp56k");
+out:
+	return err;
 }
 module_init(dsp56k_init_driver);
 
@@ -524,6 +545,8 @@ static void __exit dsp56k_cleanup_driver
 {
 	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
 	devfs_remove("dsp56k");
+	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
+	class_simple_destroy(dsp56k_class);
 }
 module_exit(dsp56k_cleanup_driver);
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6] add class support to dsp56k.c
  2004-04-07 23:13 [PATCH 2.6] add class support to dsp56k.c Hanna Linder
@ 2004-04-08  8:12 ` Geert Uytterhoeven
  2004-04-08 16:59   ` Hanna Linder
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2004-04-08  8:12 UTC (permalink / raw)
  To: Hanna Linder, Linux/m68k
  Cc: Linux Kernel Development, Greg Kroah-Hartman, noring, lars, tomas

On Wed, 7 Apr 2004, Hanna Linder wrote:
> Here is a patch that adds sysfs class support to /drivers/char/dsp56k.c
>
> I dont have the hardware or a cross compiler... If someone could test it
> I would appreciate it.

Cross-compiles fine here, but further untested due to lack of hardware.

> Thanks.
>
> Hanna
> IBM Linux Technology Center
> -----
> diff -Nrup linux-2.6.5/drivers/char/dsp56k.c linux-2.6.5p/drivers/char/dsp56k.c
> --- linux-2.6.5/drivers/char/dsp56k.c	2004-04-03 19:37:07.000000000 -0800
> +++ linux-2.6.5p/drivers/char/dsp56k.c	2004-04-07 14:44:28.000000000 -0700
> @@ -35,6 +35,7 @@
>  #include <linux/init.h>
>  #include <linux/devfs_fs_kernel.h>
>  #include <linux/smp_lock.h>
> +#include <linux/device.h>
>
>  #include <asm/atarihw.h>
>  #include <asm/traps.h>
> @@ -149,6 +150,8 @@ static struct dsp56k_device {
>  	int tx_wsize, rx_wsize;
>  } dsp56k;
>
> +static struct class_simple *dsp56k_class;
> +
>  static int dsp56k_reset(void)
>  {
>  	u_char status;
> @@ -502,6 +505,8 @@ static char banner[] __initdata = KERN_I
>
>  static int __init dsp56k_init_driver(void)
>  {
> +	int err = 0;
> +
>  	if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) {
>  		printk("DSP56k driver: Hardware not present\n");
>  		return -ENODEV;
> @@ -511,12 +516,28 @@ static int __init dsp56k_init_driver(voi
>  		printk("DSP56k driver: Unable to register driver\n");
>  		return -ENODEV;
>  	}
> +	dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k");
> +	if (IS_ERR(dsp56k_class)) {
> +		err = PTR_ERR(dsp56k_class);
> +		goto out_chrdev;
> +	}
> +	class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
>
> -	devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
> +	err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
>  		      S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
> +	if(err)
> +		goto out_class;
>
>  	printk(banner);
> -	return 0;
> +	goto out;
> +
> +out_class:
> +	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
> +	class_simple_destroy(dsp56k_class);
> +out_chrdev:
> +	unregister_chrdev(DSP56K_MAJOR, "sdp56k");
> +out:
> +	return err;
>  }
>  module_init(dsp56k_init_driver);
>
> @@ -524,6 +545,8 @@ static void __exit dsp56k_cleanup_driver
>  {
>  	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
>  	devfs_remove("dsp56k");
> +	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
> +	class_simple_destroy(dsp56k_class);
>  }
>  module_exit(dsp56k_cleanup_driver);
>

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6] add class support to dsp56k.c
  2004-04-08  8:12 ` Geert Uytterhoeven
@ 2004-04-08 16:59   ` Hanna Linder
  2004-04-08 21:44     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Hanna Linder @ 2004-04-08 16:59 UTC (permalink / raw)
  To: Geert Uytterhoeven, Linux/m68k
  Cc: geert, Hanna Linder, Linux Kernel Development, Greg Kroah-Hartman,
	noring, lars, tomas

--On Thursday, April 08, 2004 10:12:19 AM +0200 Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> On Wed, 7 Apr 2004, Hanna Linder wrote:
>> Here is a patch that adds sysfs class support to /drivers/char/dsp56k.c
>> 
>> I dont have the hardware or a cross compiler... If someone could test it
>> I would appreciate it.
> 
> Cross-compiles fine here, but further untested due to lack of hardware.

Thanks!

>> +out_chrdev:
>> +	unregister_chrdev(DSP56K_MAJOR, "sdp56k");
>> +out:

I just noticed this error. Here is the fixed patch:

diff -Nrup -Xdontdiff linux-2.6.5/drivers/char/dsp56k.c linux-2.6.5p/drivers/char/dsp56k.c
--- linux-2.6.5/drivers/char/dsp56k.c	2004-04-03 19:37:07.000000000 -0800
+++ linux-2.6.5p/drivers/char/dsp56k.c	2004-04-08 09:53:57.000000000 -0700
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/smp_lock.h>
+#include <linux/device.h>
 
 #include <asm/atarihw.h>
 #include <asm/traps.h>
@@ -149,6 +150,8 @@ static struct dsp56k_device {
 	int tx_wsize, rx_wsize;
 } dsp56k;
 
+static struct class_simple *dsp56k_class;
+
 static int dsp56k_reset(void)
 {
 	u_char status;
@@ -502,6 +505,8 @@ static char banner[] __initdata = KERN_I
 
 static int __init dsp56k_init_driver(void)
 {
+	int err = 0;
+
 	if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) {
 		printk("DSP56k driver: Hardware not present\n");
 		return -ENODEV;
@@ -511,17 +516,35 @@ static int __init dsp56k_init_driver(voi
 		printk("DSP56k driver: Unable to register driver\n");
 		return -ENODEV;
 	}
+	dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k");
+	if (IS_ERR(dsp56k_class)) {
+		err = PTR_ERR(dsp56k_class);
+		goto out_chrdev;
+	}
+	class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
 
-	devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
+	err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
 		      S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
+	if(err)
+		goto out_class;
 
 	printk(banner);
-	return 0;
+	goto out;
+
+out_class:
+	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
+	class_simple_destroy(dsp56k_class);
+out_chrdev:
+	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
+out:
+	return err;
 }
 module_init(dsp56k_init_driver);
 
 static void __exit dsp56k_cleanup_driver(void)
 {
+	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
+	class_simple_destroy(dsp56k_class);
 	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
 	devfs_remove("dsp56k");
 }




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6] add class support to dsp56k.c
  2004-04-08 16:59   ` Hanna Linder
@ 2004-04-08 21:44     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-04-08 21:44 UTC (permalink / raw)
  To: Hanna Linder
  Cc: Geert Uytterhoeven, Linux/m68k, geert, Linux Kernel Development,
	noring, lars, tomas

On Thu, Apr 08, 2004 at 09:59:33AM -0700, Hanna Linder wrote:
> --On Thursday, April 08, 2004 10:12:19 AM +0200 Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> 
> > On Wed, 7 Apr 2004, Hanna Linder wrote:
> >> Here is a patch that adds sysfs class support to /drivers/char/dsp56k.c
> >> 
> >> I dont have the hardware or a cross compiler... If someone could test it
> >> I would appreciate it.
> > 
> > Cross-compiles fine here, but further untested due to lack of hardware.
> 
> Thanks!
> 
> >> +out_chrdev:
> >> +	unregister_chrdev(DSP56K_MAJOR, "sdp56k");
> >> +out:
> 
> I just noticed this error. Here is the fixed patch:

Thanks, I've applied this version.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-04-08 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-07 23:13 [PATCH 2.6] add class support to dsp56k.c Hanna Linder
2004-04-08  8:12 ` Geert Uytterhoeven
2004-04-08 16:59   ` Hanna Linder
2004-04-08 21:44     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox