[svn-commits] tzafrir: branch linux/tzafrir/sysfs r5758 - in /linux/team/tzafrir/sysfs: ./ ...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jan 19 15:07:42 CST 2009
Author: tzafrir
Date: Mon Jan 19 15:07:41 2009
New Revision: 5758
URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=5758
Log:
A seperate module for the channels bus. Channel attributes.
* Seperated channels bus to a separate source module, as otherwise there
are namespace collision problems with names of helper functions.
* And now I can set some channel attributes. As a sample, I exposed a
number of items from struct dahdi_chan as read-only attributes of the
channel.
* Update README to use /sys/bus/spans/devices , as we don't want to keep
our own top-level device node.
Added:
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c (with props)
Modified:
linux/team/tzafrir/sysfs/README
linux/team/tzafrir/sysfs/drivers/dahdi/Kbuild
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h
Modified: linux/team/tzafrir/sysfs/README
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/README?view=diff&rev=5758&r1=5757&r2=5758
==============================================================================
--- linux/team/tzafrir/sysfs/README (original)
+++ linux/team/tzafrir/sysfs/README Mon Jan 19 15:07:41 2009
@@ -406,45 +406,82 @@
above for more information.
-/sys/devices/dahdi/span-NNN
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+/sys/bus/spans/devices/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/devices/dahdi/span-NNN/desc
+===== /sys/bus/spans/devices/span-NNN/desc
String. The span description.
-===== /sys/devices/dahdi/span-NNN/devicetype
+===== /sys/bus/spans/devices/span-NNN/devicetype
String. The span's device's "device type".
-===== /sys/devices/dahdi/span-NNN/location
+===== /sys/bus/spans/devices/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/devices/dahdi/span-NNN/manufacturer
+===== /sys/bus/spans/devices/span-NNN/manufacturer
String. The span's device's manufacturer.
-===== /sys/devices/dahdi/span-NNN/name
+===== /sys/bus/spans/devices/span-NNN/name
String. The name of the span. More terse than the desc above.
-===== /sys/devices/dahdi/span-NNN/spantype
+===== /sys/bus/spans/devices/span-NNN/spantype
String. The type of the span. May be '<NULL>' for some analog spans.
-===== /sys/devices/dahdi/span-NNN/battery
-===== /sys/devices/dahdi/span-NNN/offhook
+===== /sys/bus/spans/devices/span-NNN/battery
+===== /sys/bus/spans/devices/span-NNN/offhook
Those are two example fields that are specific to the driver wcfxo.
-
-/sys/devices/dahdi/span-NNN/NNN:MM
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+===== /sys/bus/spans/devices/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
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A sysfs node (directory) that represents channel MM in span NNN. E.g.
for channel number 40 in dahdi span 3 you will get
-'/sys/devices/dahdi/span-003/40'. Note that the numbering of the
+'/sys/bus/spans/devices/span-003/40'. 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
+Yea, we really need this one.
+
+
+===== /sys/bus/spans/devices/span-NNN/NNN:MM/chan_alarms
+The current channel alarm this channel has.
+
+===== /sys/bus/spans/devices/span-NNN/NNN:MM/channo
+MM from above. The global numbering of this DAHDI channel.
+
+===== /sys/bus/spans/devices/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
+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
+The name of the channel.
+
+===== /sys/bus/spans/devices/span-NNN/NNN:MM/sig
+The current signalling of the channel (hex).
+
+===== /sys/bus/spans/devices/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
+The tonezone this number has (number. Is it meaningful?)
ABI Compatibility
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/Kbuild
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/Kbuild?view=diff&rev=5758&r1=5757&r2=5758
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/Kbuild (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/Kbuild Mon Jan 19 15:07:41 2009
@@ -56,7 +56,7 @@
EXTRA_CFLAGS+=-Drw_lock_t=rwlock_t
endif
-dahdi-objs := dahdi-base.o dahdi-sysfs.o
+dahdi-objs := dahdi-base.o dahdi-sysfs.o dahdi-sysfs-chan.o
dahdi_echocan_hpec-objs := hpec/dahdi_echocan_hpec.o
CFLAGS_dahdi_echocan_hpec.o := -I$(src)/hpec
Added: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c?view=auto&rev=5758
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c (added)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c Mon Jan 19 15:07:41 2009
@@ -1,0 +1,212 @@
+/*
+ * Written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+ * Copyright (C) 2008, Xorcom
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+# warning "This module is tested only with 2.6 kernels"
+#endif
+
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/proc_fs.h>
+#include <linux/workqueue.h>
+//#include <linux/device.h>
+#include <linux/delay.h> /* for msleep() to debug */
+#include <dahdi/kernel.h>
+
+/*
+ * Hotplug replaced with uevent in 2.6.16
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define OLD_HOTPLUG_SUPPORT // for older kernels
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+#define DEVICE_ATTR_READER(name,dev,buf) \
+ ssize_t name(struct device *dev, struct device_attribute *attr, char *buf)
+#define DEVICE_ATTR_WRITER(name,dev,buf, count) \
+ ssize_t name(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+#define BUS_ATTR_READER(name,dev,buf) \
+ ssize_t name(struct device *dev, struct device_attribute *attr, char *buf)
+#else
+#define DEVICE_ATTR_READER(name,dev,buf) \
+ ssize_t name(struct device *dev, char *buf)
+#define DEVICE_ATTR_WRITER(name,dev,buf, count) \
+ ssize_t name(struct device *dev, const char *buf, size_t count)
+#define BUS_ATTR_READER(name,dev,buf) \
+ ssize_t name(struct device *dev, char *buf)
+#endif
+
+static const char rcsid[] = "$Id$";
+
+/* Command line parameters */
+extern int debug;
+#ifndef BIT /* added in 2.6.24 */
+#define BIT(i) (1UL << (i))
+#endif
+#define DBG_GENERAL BIT(0)
+#define DBG_DEVICES BIT(7) /* instantiation/destruction etc. */
+#define PRINTK(level, category, fmt, ...) \
+ printk(KERN_ ## level "%s%s-%s: " fmt, #level, category, THIS_MODULE->name, ## __VA_ARGS__)
+#define SPAN_PRINTK(level, category, span, fmt, ...) \
+ printk(KERN_ ## level "%s%s-%s: span-%d: " fmt, #level, \
+ category, THIS_MODULE->name, (span)->spanno, ## __VA_ARGS__)
+#define CHAN_PRINTK(level, category, chan, fmt, ...) \
+ printk(KERN_ ## level "%s%s-%s: %d: " fmt, #level, \
+ category, THIS_MODULE->name, (chan)->channo, ## __VA_ARGS__)
+#define DBG(bits, fmt, ...) \
+ ((void)((debug & (DBG_ ## bits)) && PRINTK(DEBUG, "-" #bits, "%s: " fmt, __func__, ## __VA_ARGS__)))
+#define ERR(fmt, ...) PRINTK(ERR, "", fmt, ## __VA_ARGS__)
+#define SPAN_DBG(bits, span, fmt, ...) \
+ ((void)((debug & (DBG_ ## bits)) && SPAN_PRINTK(DEBUG, "-" #bits, span, "%s: " fmt, __func__, ## __VA_ARGS__)))
+#define SPAN_INFO(span, fmt, ...) SPAN_PRINTK(INFO, "", span, fmt, ## __VA_ARGS__)
+#define SPAN_ERR(span, fmt, ...) SPAN_PRINTK(ERR, "", span, fmt, ## __VA_ARGS__)
+#define CHAN_DBG(bits, chan, fmt, ...) \
+ ((void)((debug & (DBG_ ## bits)) && CHAN_PRINTK(DEBUG, "-" #bits, chan, "%s: " fmt, __func__, ## __VA_ARGS__)))
+#define CHAN_ERR(chan, fmt, ...) CHAN_PRINTK(ERR, "", chan, fmt, ## __VA_ARGS__)
+
+
+/*--------- 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) \
+{ \
+ struct dahdi_chan *chan; \
+ \
+ chan = dev_to_chan(dev); \
+ return sprintf (buf, format_string, chan->field); \
+}
+
+chan_attr(name, "%s\n");
+chan_attr(channo, "%d\n");
+chan_attr(chanpos, "%d\n");
+chan_attr(sig, "0x%x\n");
+chan_attr(sigcap, "0x%x\n");
+chan_attr(chan_alarms, "%d\n");
+chan_attr(blocksize, "%d\n");
+chan_attr(tonezone, "%d\n");
+chan_attr(echocancel, "%d\n");
+#ifdef OPTIMIZE_CHANMUTE
+chan_attr(chanmute, "%d\n");
+#endif
+
+static struct device_attribute chan_dev_attrs[] = {
+ __ATTR_RO(name),
+ __ATTR_RO(channo),
+ __ATTR_RO(chanpos),
+ __ATTR_RO(sig),
+ __ATTR_RO(sigcap),
+ __ATTR_RO(chan_alarms),
+ __ATTR_RO(blocksize),
+ __ATTR_RO(tonezone),
+ __ATTR_RO(echocancel),
+#ifdef OPTIMIZE_CHANMUTE
+ __ATTR_RO(chanmute),
+#endif
+ __ATTR_NULL,
+};
+
+static struct bus_type dahdi_chan_type = {
+ .name = "dahdi_chans",
+ .match = chan_match,
+ .dev_attrs = chan_dev_attrs,
+};
+
+static void chan_release(struct device *dev)
+{
+ struct dahdi_chan *chan;
+
+ BUG_ON(!dev);
+ chan = dev_to_chan(dev);
+ CHAN_DBG(DEVICES, chan, "SYSFS\n");
+ //chan_remove(chan);
+}
+
+int chan_device_register(struct dahdi_chan *chan)
+{
+ struct device *dev = &chan->chan_device;
+ struct dahdi_span *span;
+ int res;
+
+ BUG_ON(!chan);
+ span = chan->span;
+ BUG_ON(!span);
+ CHAN_DBG(DEVICES, chan, "SYSFS\n");
+ dev = &chan->chan_device;
+ dev->bus = &dahdi_chan_type;
+ dev->parent = &span->span_device;
+ snprintf(dev->bus_id, BUS_ID_SIZE, "%03d:%02d",
+ span->spanno, chan->channo);
+ dev->driver_data = chan;
+ dev->release = chan_release;
+ res = device_register(dev);
+ if(res) {
+ CHAN_ERR(chan, "%s: device_register failed: %d\n", __func__, res);
+ return res;
+ }
+ // FIXME: reference counting.
+ //get_xpd(__func__, xpd);
+ return 0;
+}
+
+void chan_device_unregister(struct dahdi_chan *chan)
+{
+ struct device *dev = &chan->chan_device;
+
+ CHAN_DBG(DEVICES, chan, "SYSFS\n");
+ dev = &chan->chan_device;
+ if(!dev->driver_data)
+ return;
+ BUG_ON(dev->driver_data != chan);
+ device_unregister(dev);
+ dev->driver_data = NULL;
+}
+
+/*--------- Sysfs Device handling ----*/
+
+int __init dahdi_driver_chan_init(void)
+{
+ int res;
+
+ DBG(DEVICES, "SYSFS\n");
+ if((res = bus_register(&dahdi_chan_type)) < 0) {
+ ERR("%s: bus_register(%s) failed. Error number %d",
+ __func__, dahdi_chan_type.name, res);
+ return res;
+ }
+ return 0;
+}
+//EXPORT_SYMBOL(dahdi_driver_chan_init);
+
+void dahdi_driver_chan_exit(void)
+{
+ DBG(DEVICES, "SYSFS\n");
+ bus_unregister(&dahdi_chan_type);
+}
+EXPORT_SYMBOL(dahdi_driver_chan_exit);
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c?view=diff&rev=5758&r1=5757&r2=5758
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c Mon Jan 19 15:07:41 2009
@@ -34,6 +34,7 @@
//#include <linux/device.h>
#include <linux/delay.h> /* for msleep() to debug */
#include <dahdi/kernel.h>
+#include "dahdi-sysfs.h"
/*
* Hotplug replaced with uevent in 2.6.16
@@ -245,6 +246,21 @@
span_attr(devicetype, "%s\n");
span_attr(location, "%s\n");
+static BUS_ATTR_READER(is_digital_show,dev,buf)
+{
+ struct dahdi_span *span;
+ int is_digital;
+
+ span = dev_to_span(dev);
+ is_digital = span->linecompat && (
+ /* TODO: is this mask too liberal? */
+ DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_D4 |
+ DAHDI_CONFIG_ESF |
+ DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CCS | DAHDI_CONFIG_CRC4
+ );
+ return sprintf (buf, "%d\n", is_digital);
+}
+
static struct device_attribute span_dev_attrs[] = {
__ATTR_RO(name),
__ATTR_RO(desc),
@@ -252,6 +268,7 @@
__ATTR_RO(manufacturer),
__ATTR_RO(devicetype),
__ATTR_RO(location),
+ __ATTR_RO(is_digital),
#if 0
__ATTR(cls, S_IWUSR, NULL, cls_store),
__ATTR(xbus_state, S_IRUGO | S_IWUSR, xbus_state_show, xbus_state_store),
@@ -438,232 +455,6 @@
.owner = THIS_MODULE
#endif
};
-
-/*--------- Sysfs channel handling ----*/
-#if 0
-static DEVICE_ATTR_READER(chipregs_show, dev, buf)
-{
- xpd_t *xpd;
- unsigned long flags;
- reg_cmd_t *regs;
- bool do_datah;
- char datah_str[50];
- int len = 0;
-
- BUG_ON(!dev);
- xpd = dev_to_xpd(dev);
- if(!xpd)
- return -ENODEV;
- spin_lock_irqsave(&xpd->lock, flags);
- regs = &xpd->last_reply;
- len += sprintf(buf + len, "# Writing bad data into this file may damage your hardware!\n");
- len += sprintf(buf + len, "# Consult firmware docs first\n");
- len += sprintf(buf + len, "#\n");
- do_datah = REG_FIELD(regs, do_datah) ? 1 : 0;
- if(do_datah) {
- snprintf(datah_str, ARRAY_SIZE(datah_str), "\t%02X",
- REG_FIELD(regs, data_high));
- } else
- datah_str[0] = '\0';
- if(REG_FIELD(regs, do_subreg)) {
- len += sprintf(buf + len, "#CH\tOP\tReg.\tSub\tDL%s\n",
- (do_datah) ? "\tDH" : "");
- len += sprintf(buf + len, "%2d\tRS\t%02X\t%02X\t%02X%s\n",
- regs->portnum,
- REG_FIELD(regs, regnum), REG_FIELD(regs, subreg),
- REG_FIELD(regs, data_low), datah_str);
- } else {
- len += sprintf(buf + len, "#CH\tOP\tReg.\tDL%s\n",
- (do_datah) ? "\tDH" : "");
- len += sprintf(buf + len, "%2d\tRD\t%02X\t%02X%s\n",
- regs->portnum,
- REG_FIELD(regs, regnum),
- REG_FIELD(regs, data_low), datah_str);
- }
- spin_unlock_irqrestore(&xpd->lock, flags);
- return len;
-}
-
-static DEVICE_ATTR_WRITER(chipregs_store, dev, buf, count)
-{
- xpd_t *xpd;
- const char *p;
- char tmp[MAX_PROC_WRITE];
- int i;
- int res;
-
- BUG_ON(!dev);
- xpd = dev_to_xpd(dev);
- //XPD_DBG(GENERAL, xpd, "%s\n", buf);
- if(!xpd)
- return -ENODEV;
- p = buf;
- while((p - buf) < count) {
- i = strcspn(p, "\r\n");
- if(i > 0) {
- if(i >= MAX_PROC_WRITE) {
- XPD_NOTICE(xpd, "Command too long (%d chars)\n", i);
- return -E2BIG;
- }
- memcpy(tmp, p, i);
- tmp[i] = '\0';
- res = parse_chip_command(xpd, tmp);
- if(res < 0) {
- XPD_NOTICE(xpd, "Failed writing command: '%s'\n", tmp);
- return res;
- }
- }
- p += i + 1;
- }
- return count;
-}
-
-static DEVICE_ATTR_READER(blink_show, dev, buf)
-{
- xpd_t *xpd;
- unsigned long flags;
- int len = 0;
-
- BUG_ON(!dev);
- xpd = dev_to_xpd(dev);
- if(!xpd)
- return -ENODEV;
- spin_lock_irqsave(&xpd->lock, flags);
- len += sprintf(buf, "0x%lX\n", xpd->blink_mode);
- spin_unlock_irqrestore(&xpd->lock, flags);
- return len;
-}
-
-static DEVICE_ATTR_WRITER(blink_store, dev, buf, count)
-{
- xpd_t *xpd;
- char *endp;
- unsigned long blink;
-
- BUG_ON(!dev);
- xpd = dev_to_xpd(dev);
- //XPD_DBG(GENERAL, xpd, "%s\n", buf);
- if(!xpd)
- return -ENODEV;
- blink = simple_strtoul(buf, &endp, 0);
- if(*endp != '\0' && *endp != '\n' && *endp != '\r')
- return -EINVAL;
- if(blink > 0xFFFF)
- return -EINVAL;
- XPD_DBG(GENERAL, xpd, "BLINK channels: 0x%lX\n", blink);
- xpd->blink_mode = blink;
- return count;
-}
-
-static DEVICE_ATTR_READER(span_show, dev, buf)
-{
- xpd_t *xpd;
- unsigned long flags;
- int len = 0;
-
- BUG_ON(!dev);
- xpd = dev_to_xpd(dev);
- if(!xpd)
- return -ENODEV;
- spin_lock_irqsave(&xpd->lock, flags);
- len += sprintf(buf, "%d\n", SPAN_REGISTERED(xpd) ? xpd->span.spanno : 0);
- spin_unlock_irqrestore(&xpd->lock, flags);
- return len;
-}
-
-static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
-{
- xpd_t *xpd;
- int dahdi_reg;
- int res;
-
- BUG_ON(!dev);
- xpd = dev_to_xpd(dev);
- if(!xpd)
- return -ENODEV;
- res = sscanf(buf, "%d", &dahdi_reg);
- if(res != 1)
- return -EINVAL;
- if(!XBUS_IS(xpd->xbus, READY))
- return -ENODEV;
- XPD_DBG(GENERAL, xpd, "%s\n", (dahdi_reg) ? "register" : "unregister");
- if(dahdi_reg)
- res = dahdi_register_xpd(xpd);
- else
- res = dahdi_unregister_xpd(xpd);
- return (res < 0) ? res : count;
-}
-#endif
-
-static int chan_match(struct device *dev, struct device_driver *driver)
-{
- return 1;
-}
-
-static struct device_attribute chan_dev_attrs[] = {
-#if 0
- __ATTR(chipregs, S_IRUGO | S_IWUSR, chipregs_show, chipregs_store),
- __ATTR(blink, S_IRUGO | S_IWUSR, blink_show, blink_store),
- __ATTR(span, S_IRUGO | S_IWUSR, span_show, span_store),
-#endif
- __ATTR_NULL,
-};
-
-static struct bus_type dahdi_chan_type = {
- .name = "dahdi_chans",
- .match = chan_match,
- .dev_attrs = chan_dev_attrs,
-};
-
-static void chan_release(struct device *dev)
-{
- struct dahdi_chan *chan;
-
- BUG_ON(!dev);
- chan = dev_to_chan(dev);
- CHAN_DBG(DEVICES, chan, "SYSFS\n");
- //chan_remove(chan);
-}
-
-static int chan_device_register(struct dahdi_chan *chan)
-{
- struct device *dev = &chan->chan_device;
- struct dahdi_span *span;
- int res;
-
- BUG_ON(!chan);
- span = chan->span;
- BUG_ON(!span);
- CHAN_DBG(DEVICES, chan, "SYSFS\n");
- dev = &chan->chan_device;
- dev->bus = &dahdi_chan_type;
- dev->parent = &span->span_device;
- snprintf(dev->bus_id, BUS_ID_SIZE, "%03d:%02d",
- span->spanno, chan->channo);
- dev->driver_data = chan;
- dev->release = chan_release;
- res = device_register(dev);
- if(res) {
- CHAN_ERR(chan, "%s: device_register failed: %d\n", __func__, res);
- return res;
- }
- // FIXME: reference counting.
- //get_xpd(__func__, xpd);
- return 0;
-}
-
-static void chan_device_unregister(struct dahdi_chan *chan)
-{
- struct device *dev = &chan->chan_device;
-
- CHAN_DBG(DEVICES, chan, "SYSFS\n");
- dev = &chan->chan_device;
- if(!dev->driver_data)
- return;
- BUG_ON(dev->driver_data != chan);
- device_unregister(dev);
- dev->driver_data = NULL;
-}
/*--------- Sysfs Device handling ----*/
@@ -794,9 +585,7 @@
__func__, span_driver.name, res);
goto failed_span_driver;
}
- if((res = bus_register(&dahdi_chan_type)) < 0) {
- ERR("%s: bus_register(%s) failed. Error number %d",
- __func__, dahdi_chan_type.name, res);
+ if((res = dahdi_driver_chan_init()) < 0) {
goto failed_chan_bus;
}
return 0;
@@ -814,7 +603,7 @@
void dahdi_driver_exit(void)
{
DBG(DEVICES, "SYSFS\n");
- bus_unregister(&dahdi_chan_type);
+ dahdi_driver_chan_exit();
driver_unregister(&span_driver);
device_unregister(&toplevel_device);
bus_unregister(&toplevel_bus_type);
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h?view=diff&rev=5758&r1=5757&r2=5758
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.h Mon Jan 19 15:07:41 2009
@@ -1,7 +1,13 @@
/* Global */
int __init dahdi_driver_init(void);
void dahdi_driver_exit(void);
+int __init dahdi_driver_chan_init(void);
+void dahdi_driver_chan_exit(void);
/* per-span */
int span_sysfs_create(struct dahdi_span *span);
void span_sysfs_remove(struct dahdi_span *span);
+
+/* For use in dahdi-base only: */
+int chan_device_register(struct dahdi_chan *chan);
+void chan_device_unregister(struct dahdi_chan *chan);
More information about the svn-commits
mailing list