[svn-commits] tzafrir: branch linux/tzafrir/sysfs r7644 - in /linux/team/tzafrir/sysfs: ./ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 25 11:28:02 CST 2009


Author: tzafrir
Date: Wed Nov 25 11:28:00 2009
New Revision: 7644

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7644
Log:
Switch sysfs interface from busses to classes.

Spans are located under /sys/class/dahdi_span . Channels: under
/sys/class/dahdi_chan . As before, those do not generate device files.

See the changes in the README file for the exact pathes.

Modified:
    linux/team/tzafrir/sysfs/README
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c

Modified: linux/team/tzafrir/sysfs/README
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/README?view=diff&rev=7644&r1=7643&r2=7644
==============================================================================
--- linux/team/tzafrir/sysfs/README (original)
+++ linux/team/tzafrir/sysfs/README Wed Nov 25 11:28:00 2009
@@ -581,81 +581,81 @@
 above for more information.
 
 
-/sys/bus/spans/devices/span-NNN
+/sys/class/dahdi_span/span-NNN
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 This node (directory) represents dahdi span no. NNN (e.g. 'span-003' for 
 span 3). Spans may also have some span-specific attributes. Its 
 attributes include:
 
-===== /sys/bus/spans/devices/span-NNN/desc
+===== /sys/class/dahdi_span/span-NNN/desc
 String. The span description.
 
-===== /sys/bus/spans/devices/span-NNN/devicetype
+===== /sys/class/dahdi_span/span-NNN/devicetype
 String. The span's device's "device type".
 
-===== /sys/bus/spans/devices/span-NNN/location
+===== /sys/class/dahdi_span/span-NNN/location
 String. The span's device's location in the system. On most PCI devices
 this is something in the lines of 'PCI Bus 03 Slot 14'. On an Astribank
 this is the connector field.
 
-===== /sys/bus/spans/devices/span-NNN/manufacturer
+===== /sys/class/dahdi_span/span-NNN/manufacturer
 String. The span's device's manufacturer.
 
-===== /sys/bus/spans/devices/span-NNN/name
+===== /sys/class/dahdi_span/span-NNN/name
 String. The name of the span. More terse than the desc above.
 
-===== /sys/bus/spans/devices/span-NNN/spantype
+===== /sys/class/dahdi_span/span-NNN/spantype
 String. The type of the span. May be '<NULL>' for some analog spans.
 
-===== /sys/bus/spans/devices/span-NNN/battery
-===== /sys/bus/spans/devices/span-NNN/offhook
+===== /sys/class/dahdi_span/span-NNN/battery
+===== /sys/class/dahdi_span/span-NNN/offhook
 Those are two example fields that are specific to the driver wcfxo.
 
-===== /sys/bus/spans/devices/span-NNN/is_digital
+===== /sys/class/dahdi_span/span-NNN/is_digital
 1 if this span is capable of transporting digital calls. 0 otherwise.
 (0 is for analogs and also for dahdi_dummy).
 
-/sys/bus/spans/devices/span-NNN/NNN:MM
+/sys/class/dahdi_span/span-NNN/NNN:MM
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 A sysfs node (directory) that represents channel MM in span NNN. E.g.
 for the second channels in dahdi span 3 you will get
-'/sys/bus/spans/devices/span-003/02'. Note that the numbering of the
+'/sys/class/dahdi_span/span-003/02'. Note that the numbering of the
 channels is global rather than per-span.
 
 Channel attributes will need to be filled in here when there are some.
 
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/blocksize
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/blocksize
 Yea, we really need this one.
 
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/chan_alarms
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/chan_alarms
 The current channel alarm this channel has.
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/channo
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/channo
 MM from above. The global numbering of this DAHDI channel.
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/chanpos
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/chanpos
 The number of this channel in the span. E.g. for a system with two 
 8-channel spans, the third channel in the second span will have channo 
 11 (8+3) and chanpos 3.
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/echocancel
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/echocancel
 0 is the channel has no active echo canceller and 1 if the channel
 has an active echo canceller (that is: in the middle of a call and the 
 echo canceller is enabled).
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/name
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/name
 The name of the channel.
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/sig
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/sig
 The current signalling of the channel (hex).
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/sigcap
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/sigcap
 The signalling capability mask of the channel: all the possible 
 signalling bits the channel can used are set here.
 
-===== /sys/bus/spans/devices/span-NNN/NNN:MM/tonezone
+===== /sys/class/dahdi_span/span-NNN/NNN:MM/tonezone
 The tonezone this number has (number. Is it meaningful?)
 
 

Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c?view=diff&rev=7644&r1=7643&r2=7644
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c Wed Nov 25 11:28:00 2009
@@ -98,11 +98,6 @@
 
 /*--------- Sysfs channel handling ----*/
 
-static int chan_match(struct device *dev, struct device_driver *driver)
-{
-	return 1;
-}
-
 #define chan_attr(field, format_string)                                    \
 static BUS_ATTR_READER(field##_show,dev,buf)                               \
 {                                                                          \
@@ -135,11 +130,7 @@
 	__ATTR_NULL,
 };
 
-static struct bus_type dahdi_chan_type = {
-	.name           = "dahdi_chans",
-	.match          = chan_match,
-	.dev_attrs	= chan_dev_attrs,
-};
+static struct class *chan_class;
 
 static void chan_release(struct device *dev)
 {
@@ -162,7 +153,7 @@
 	BUG_ON(!span);
 	chan_dbg(DEVICES, chan, "SYSFS\n");
 	dev = &chan->chan_device;
-	dev->bus = &dahdi_chan_type;
+	dev->class = chan_class;
 	dev->parent = &span->span_device;
 	dev_set_name(dev, "%03d:%02d", span->spanno, chan->chanpos);
 	dev_set_drvdata(dev, chan);
@@ -197,11 +188,14 @@
 	int	res;
 
 	dahdi_dbg(DEVICES, "SYSFS\n");
-	if((res = bus_register(&dahdi_chan_type)) < 0) {
-		dahdi_err("%s: bus_register(%s) failed. Error number %d",
-			__func__, dahdi_chan_type.name, res);
+	chan_class = class_create(THIS_MODULE, "dahdi_chan");
+	if (IS_ERR(chan_class)) {
+		res = PTR_ERR(chan_class);
+		dahdi_err("%s: class_create(dahi_chan) failed. Error: %d\n",
+			__func__, res);
 		return res;
 	}
+	chan_class->dev_attrs = chan_dev_attrs;
 	return 0;
 }
 //EXPORT_SYMBOL(dahdi_driver_chan_init);
@@ -209,6 +203,6 @@
 void dahdi_driver_chan_exit(void)
 {
 	dahdi_dbg(DEVICES, "SYSFS\n");
-	bus_unregister(&dahdi_chan_type);
+	class_unregister(chan_class);
 }
 EXPORT_SYMBOL(dahdi_driver_chan_exit);

Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c?view=diff&rev=7644&r1=7643&r2=7644
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c Wed Nov 25 11:28:00 2009
@@ -461,6 +461,8 @@
 	//xbus_free(xbus);
 }
 
+static struct class *span_class;
+
 static struct bus_type toplevel_bus_type = {
 	.name           = "spans",
 	.match          = span_match,
@@ -477,33 +479,6 @@
 	.release	= dahdi_release
 };
 
-static int span_probe(struct device *dev)
-{
-        struct dahdi_span	*span;
-
-	span = dev_to_span(dev);
-	span_dbg(DEVICES, span, "SYSFS\n");
-	return 0;
-}
-
-static int span_remove(struct device *dev)
-{
-        struct dahdi_span	*span;
-
-	span = dev_to_span(dev);
-	span_info(span, "[%s] Atribank Remove\n", span->name);
-	return 0;
-}
-
-static struct device_driver span_driver = {
-	.name		= "spandrv",
-	.bus		= &toplevel_bus_type,
-	.probe		= span_probe,
-	.remove		= span_remove,
-#ifndef OLD_HOTPLUG_SUPPORT
-	.owner		= THIS_MODULE
-#endif
-};
 
 /*--------- Sysfs Device handling ----*/
 
@@ -581,7 +556,8 @@
 	span_device = &span->span_device;
 	BUG_ON(!span_device);
 	span_dbg(DEVICES, span, "\n");
-	span_device->bus = &toplevel_bus_type;
+
+	span_device->class = span_class;
 	span_device->parent = &toplevel_device;
 	dev_set_name(span_device, "span-%03d", span->spanno);
 	dev_set_drvdata(span_device, span);
@@ -621,6 +597,14 @@
 	int	res;
 
 	dahdi_dbg(DEVICES, "SYSFS\n");
+	span_class = class_create(THIS_MODULE, "dahdi_span");
+	if (IS_ERR(span_class)) {
+		res = PTR_ERR(span_class);
+		dahdi_err("%s: class_create(dahdi_span) failed. Error: %d\n",
+			__func__, res);
+		goto failed_class_create;
+	}
+	span_class->dev_attrs = span_dev_attrs;
 	if((res = bus_register(&toplevel_bus_type)) < 0) {
 		dahdi_err("%s: bus_register(%s) failed. Error number %d",
 			__func__, toplevel_bus_type.name, res);
@@ -632,22 +616,17 @@
 			__func__, dev_name(&toplevel_device), res);
 		goto failed_busdevice;
 	}
-	if((res = driver_register(&span_driver)) < 0) {
-		dahdi_err("%s: driver_register(%s) failed. Error number %d",
-			__func__, span_driver.name, res);
-		goto failed_span_driver;
-	}
 	if((res = dahdi_driver_chan_init()) < 0) {
 		goto failed_chan_bus;
 	}
 	return 0;
 failed_chan_bus:
-	driver_unregister(&span_driver);
-failed_span_driver:
 	device_unregister(&toplevel_device);
 failed_busdevice:
 	bus_unregister(&toplevel_bus_type);
 failed_bus:
+	class_destroy(span_class);
+failed_class_create:
 	return res;
 }
 //EXPORT_SYMBOL(dahdi_driver_init);
@@ -656,8 +635,8 @@
 {
 	dahdi_dbg(DEVICES, "SYSFS\n");
 	dahdi_driver_chan_exit();
-	driver_unregister(&span_driver);
 	device_unregister(&toplevel_device);
+	class_unregister(span_class);
 	bus_unregister(&toplevel_bus_type);
 }
 EXPORT_SYMBOL(dahdi_driver_exit);




More information about the svn-commits mailing list