public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] raw1394: sysfs support via class_simple
@ 2004-11-14  3:37 Daniel Drake
  2004-11-14  6:42 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Drake @ 2004-11-14  3:37 UTC (permalink / raw)
  To: bcollins; +Cc: linux1394-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

Adds basic sysfs support for udev etc.
Ideally we should link into the ieee1394 sysfs class, but it doesn't seem 
extensible in that manner.
For now, class_simple will do.

Depends on the previous whitespace fix patch.

Signed-off-by: Daniel Drake <dsd@gentoo.org>

[-- Attachment #2: raw1394-03-sysfs-support.patch --]
[-- Type: text/plain, Size: 2674 bytes --]

--- linux/drivers/ieee1394/raw1394.c.orig	2004-11-14 03:12:12.000000000 +0000
+++ linux/drivers/ieee1394/raw1394.c	2004-11-14 03:22:44.623795368 +0000
@@ -78,6 +78,7 @@ static atomic_t iso_buffer_size;
 static const int iso_buffer_max = 4 * 1024 * 1024;	/* 4 MB */
 
 static struct hpsb_highlevel raw1394_highlevel;
+static struct class_simple *raw1394_class;
 
 static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
 		    u64 addr, size_t length, u16 flags);
@@ -2886,12 +2887,26 @@ static struct file_operations raw1394_fo
 
 static int __init init_raw1394(void)
 {
-	int ret;
+	int ret = 0;
 
 	hpsb_register_highlevel(&raw1394_highlevel);
 
-	devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
-		      S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
+	raw1394_class = class_simple_create(THIS_MODULE, "raw1394");
+	if (IS_ERR(raw1394_class)) {
+		ret = PTR_ERR(raw1394_class);
+		goto out_unreg;
+	}
+
+	class_simple_device_add(raw1394_class,
+				MKDEV(IEEE1394_MAJOR,
+				      IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL,
+				RAW1394_DEVICE_NAME);
+	ret =
+	    devfs_mk_cdev(MKDEV
+			  (IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
+			  S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
+	if (ret)
+		goto out_class;
 
 	cdev_init(&raw1394_cdev, &raw1394_fops);
 	raw1394_cdev.owner = THIS_MODULE;
@@ -2899,9 +2914,7 @@ static int __init init_raw1394(void)
 	ret = cdev_add(&raw1394_cdev, IEEE1394_RAW1394_DEV, 1);
 	if (ret) {
 		HPSB_ERR("raw1394 failed to register minor device block");
-		devfs_remove(RAW1394_DEVICE_NAME);
-		hpsb_unregister_highlevel(&raw1394_highlevel);
-		return ret;
+		goto out_dev;
 	}
 
 	HPSB_INFO("raw1394: /dev/%s device initialized", RAW1394_DEVICE_NAME);
@@ -2910,16 +2923,30 @@ static int __init init_raw1394(void)
 	if (ret) {
 		HPSB_ERR("raw1394: failed to register protocol");
 		cdev_del(&raw1394_cdev);
-		devfs_remove(RAW1394_DEVICE_NAME);
-		hpsb_unregister_highlevel(&raw1394_highlevel);
-		return ret;
+		goto out_dev;
 	}
 
-	return 0;
+	goto out;
+
+      out_dev:
+	devfs_remove(RAW1394_DEVICE_NAME);
+      out_class:
+	class_simple_device_remove(MKDEV
+				   (IEEE1394_MAJOR,
+				    IEEE1394_MINOR_BLOCK_RAW1394 * 16));
+	class_simple_destroy(raw1394_class);
+      out_unreg:
+	hpsb_unregister_highlevel(&raw1394_highlevel);
+      out:
+	return ret;
 }
 
 static void __exit cleanup_raw1394(void)
 {
+	class_simple_device_remove(MKDEV
+				   (IEEE1394_MAJOR,
+				    IEEE1394_MINOR_BLOCK_RAW1394 * 16));
+	class_simple_destroy(raw1394_class);
 	hpsb_unregister_protocol(&raw1394_driver);
 	cdev_del(&raw1394_cdev);
 	devfs_remove(RAW1394_DEVICE_NAME);

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

* Re: [PATCH 3/3] raw1394: sysfs support via class_simple
  2004-11-14  3:37 [PATCH 3/3] raw1394: sysfs support via class_simple Daniel Drake
@ 2004-11-14  6:42 ` Dmitry Torokhov
  2004-11-17 12:30   ` Daniel Drake
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2004-11-14  6:42 UTC (permalink / raw)
  To: linux-kernel; +Cc: Daniel Drake, bcollins, linux1394-devel

On Saturday 13 November 2004 10:37 pm, Daniel Drake wrote:
> Adds basic sysfs support for udev etc.
> Ideally we should link into the ieee1394 sysfs class, but it doesn't seem 
> extensible in that manner.

Hmm, with the exception of raw1394, the rest of ieee1394 subsystem does
not need its own classes as 1394 devices hook up into other subsystems
(SCSI, NET) and are classified with the rest of the devices in those
systems. After all userspace does not really care whether eth0 is on
PCI, ISA or IEEE1394, all it needs to know that it is just another network
interface. Am I missing something?
 
> For now, class_simple will do.
> 
> Depends on the previous whitespace fix patch.
> 
> Signed-off-by: Daniel Drake <dsd@gentoo.org>
> 

-- 
Dmitry

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

* Re: [PATCH 3/3] raw1394: sysfs support via class_simple
  2004-11-14  6:42 ` Dmitry Torokhov
@ 2004-11-17 12:30   ` Daniel Drake
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Drake @ 2004-11-17 12:30 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, bcollins, linux1394-devel

Dmitry Torokhov wrote:
> Hmm, with the exception of raw1394, the rest of ieee1394 subsystem does
> not need its own classes as 1394 devices hook up into other subsystems
> (SCSI, NET) and are classified with the rest of the devices in those
> systems. After all userspace does not really care whether eth0 is on
> PCI, ISA or IEEE1394, all it needs to know that it is just another network
> interface. Am I missing something?

No, I think I was. I was trying to follow the way that USB does it (e.g. usblp 
linking into the usb sysfs class) but I think you are right - IEEE1394 is in a 
different situation. raw1394 is the only ieee1394 driver (as far as I can see) 
that might benefit fitting into a generic class. I think we should stick with 
class_simple and possibly consider a generic class if more drivers might 
require it in the future.

Daniel

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

end of thread, other threads:[~2004-11-17 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-14  3:37 [PATCH 3/3] raw1394: sysfs support via class_simple Daniel Drake
2004-11-14  6:42 ` Dmitry Torokhov
2004-11-17 12:30   ` Daniel Drake

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