[svn-commits] tzafrir: linux/trunk r9625 - in /linux/trunk: drivers/dahdi/ include/dahdi/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jan 10 15:42:04 CST 2011
Author: tzafrir
Date: Mon Jan 10 15:42:00 2011
New Revision: 9625
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9625
Log:
span_sysfs_{create,remove}
* Separate out device generation in dahdi_[un]register to separate
functions.
* As we don't keep anywhere the information of whether or not
* there's
an existing device node for a channel, I abuse an unused flag:
DAHDI_FLAGBIT_DEVFILE (25), to mark if the channel has a sysfs node.
DAHDI_FLAGBIT_DEVFILE is expected to be replaced later on with a proper
pointer to the device (or embedding of the device). I prefer a simple
flag for now as it does not break ABI.
Signed-off-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Acked-by: Shaun Ruffell <sruffell at digium.com>
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
linux/trunk/include/dahdi/kernel.h
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9625&r1=9624&r2=9625
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Jan 10 15:42:00 2011
@@ -6445,6 +6445,54 @@
}
#endif
+static void span_sysfs_remove(struct dahdi_span *span)
+{
+ int x;
+ for (x = 0; x < span->channels; x++) {
+ struct dahdi_chan *chan = span->chans[x];
+ if (!test_bit(DAHDI_FLAGBIT_DEVFILE, &chan->flags))
+ continue;
+
+ CLASS_DEV_DESTROY(dahdi_class,
+ MKDEV(DAHDI_MAJOR, chan->channo));
+ clear_bit(DAHDI_FLAGBIT_DEVFILE, &chan->flags);
+ }
+}
+
+static int span_sysfs_create(struct dahdi_span *span)
+{
+ int res = 0;
+ int x;
+
+ for (x = 0; x < span->channels; x++) {
+ struct dahdi_chan *chan = span->chans[x];
+ char chan_name[32];
+ void *dummy;
+
+ if (chan->channo >= 250)
+ continue;
+ if (test_bit(DAHDI_FLAGBIT_DEVFILE, &chan->flags))
+ continue;
+
+ snprintf(chan_name, sizeof(chan_name), "dahdi!%d",
+ chan->channo);
+ dummy = (void *)CLASS_DEV_CREATE(dahdi_class,
+ MKDEV(DAHDI_MAJOR, chan->channo),
+ NULL, chan_name);
+ if (IS_ERR(dummy)) {
+ res = PTR_ERR(dummy);
+ goto cleanup;
+ }
+
+ set_bit(DAHDI_FLAGBIT_DEVFILE, &chan->flags);
+ }
+ return 0;
+
+cleanup:
+ span_sysfs_remove(span);
+ return res;
+}
+
/**
* _get_next_channo - Return the next taken channel number from the span list.
* @span: The span with which to start the search.
@@ -6518,6 +6566,7 @@
struct list_head *loc = &span_list;
unsigned long flags;
unsigned int channo;
+ int res = 0;
if (!span || !span->ops || !span->ops->owner)
return -EINVAL;
@@ -6560,15 +6609,7 @@
}
#endif
- for (x = 0; x < span->channels; x++) {
- if (span->chans[x]->channo < 250) {
- char chan_name[32];
- snprintf(chan_name, sizeof(chan_name), "dahdi!%d",
- span->chans[x]->channo);
- CLASS_DEV_CREATE(dahdi_class, MKDEV(DAHDI_MAJOR,
- span->chans[x]->channo), NULL, chan_name);
- }
- }
+ res = span_sysfs_create(span);
if (debug & DEBUG_MAIN) {
module_printk(KERN_NOTICE, "Registered Span %d ('%s') with "
@@ -6637,10 +6678,7 @@
remove_proc_entry(span->proc_entry->name, root_proc_entry);
#endif /* CONFIG_PROC_FS */
- for (x = 0; x < span->channels; x++) {
- if (span->chans[x]->channo < 250)
- CLASS_DEV_DESTROY(dahdi_class, MKDEV(DAHDI_MAJOR, span->chans[x]->channo));
- }
+ span_sysfs_remove(span);
for (x=0;x<span->channels;x++)
dahdi_chan_unreg(span->chans[x]);
Modified: linux/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/include/dahdi/kernel.h?view=diff&rev=9625&r1=9624&r2=9625
==============================================================================
--- linux/trunk/include/dahdi/kernel.h (original)
+++ linux/trunk/include/dahdi/kernel.h Mon Jan 10 15:42:00 2011
@@ -712,6 +712,7 @@
DAHDI_FLAGBIT_LOOPED = 18, /*!< Loopback the receive data from the channel to the transmit */
DAHDI_FLAGBIT_MTP2 = 19, /*!< Repeats last message in buffer and also discards repeating messages sent to us */
DAHDI_FLAGBIT_HDLC56 = 20, /*!< Sets the given channel (if in HDLC mode) to use 56K HDLC instead of 64K */
+ DAHDI_FLAGBIT_DEVFILE = 25, /*!< Channel has a sysfs dev file */
};
#ifdef CONFIG_DAHDI_NET
More information about the svn-commits
mailing list