sysfs: new driver attribute: master_span
* This changeset adds master_span as an attribute of the span's driver:
/sys/bus/dahdi_spans/drivers/generic_lowlevel/master_span
* This is mainly used for debugging.
* Reading from it the master span number (or 0 if there is no master
span).
* Writing a number to it, force specified span to be master
* Existing Alternatives:
- grep "MASTER" from /proc/dahdi/*
- cat /sys/bus/dahdi_spans/devices/span-*/is_sync_master
(Note: commit d8fe2af23d is also Acked-By
Tzafrir Cohen <tzafrir.cohen@xorcom.com>)
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
This commit is contained in:
committed by
Tzafrir Cohen
parent
d8fe2af23d
commit
dd944f3362
6
README
6
README
@@ -989,6 +989,12 @@ A very short type string.
|
||||
===== /sys/bus/dahdi_spans/devices/span-N/syncsrc
|
||||
Current sync source.
|
||||
|
||||
==== sys/bus/dahdi_spans/drivers/generic_lowlevel/master_span
|
||||
All spans in the bus are handled by a single driver. The driver has one
|
||||
non-standard attribute: master_span. printing it shows the current DAHDI
|
||||
master span writing a number to it forces setting this span as the master
|
||||
span.
|
||||
|
||||
|
||||
Channels Bus
|
||||
^^^^^^^^^^^^
|
||||
|
||||
@@ -3840,6 +3840,31 @@ void dahdi_alarm_channel(struct dahdi_chan *chan, int alarms)
|
||||
spin_unlock_irqrestore(&chan->lock, flags);
|
||||
}
|
||||
|
||||
struct dahdi_span *get_master_span(void)
|
||||
{
|
||||
return master_span;
|
||||
}
|
||||
|
||||
void set_master_span(int spanno)
|
||||
{
|
||||
struct dahdi_span *s;
|
||||
unsigned long flags;
|
||||
struct dahdi_span *old_master;
|
||||
|
||||
spin_lock_irqsave(&chan_lock, flags);
|
||||
old_master = master_span;
|
||||
list_for_each_entry(s, &span_list, spans_node) {
|
||||
if (spanno == s->spanno) {
|
||||
master_span = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&chan_lock, flags);
|
||||
if ((debug & DEBUG_MAIN) && (old_master != master_span))
|
||||
module_printk(KERN_NOTICE, "Master span is set to %d (%s)\n",
|
||||
master_span->spanno, master_span->name);
|
||||
}
|
||||
|
||||
static void __dahdi_find_master_span(void)
|
||||
{
|
||||
struct dahdi_span *s;
|
||||
|
||||
@@ -231,7 +231,30 @@ static struct device_attribute span_dev_attrs[] = {
|
||||
__ATTR_NULL,
|
||||
};
|
||||
|
||||
static ssize_t master_span_show(struct device_driver *driver, char *buf)
|
||||
{
|
||||
struct dahdi_span *s = get_master_span();
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", (s) ? s->spanno : 0);
|
||||
}
|
||||
|
||||
static ssize_t master_span_store(struct device_driver *driver, const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
int spanno;
|
||||
|
||||
if (sscanf(buf, "%d", &spanno) != 1) {
|
||||
module_printk(KERN_ERR, "non-numeric input '%s'\n", buf);
|
||||
return -EINVAL;
|
||||
}
|
||||
set_master_span(spanno);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static struct driver_attribute dahdi_attrs[] = {
|
||||
__ATTR(master_span, S_IRUGO | S_IWUSR, master_span_show,
|
||||
master_span_store),
|
||||
__ATTR_NULL,
|
||||
};
|
||||
|
||||
|
||||
@@ -1003,6 +1003,8 @@ struct dahdi_transcoder_channel {
|
||||
};
|
||||
|
||||
int dahdi_is_sync_master(const struct dahdi_span *span);
|
||||
struct dahdi_span *get_master_span(void);
|
||||
void set_master_span(int spanno);
|
||||
|
||||
static inline int
|
||||
dahdi_tc_is_built(struct dahdi_transcoder_channel *dtc) {
|
||||
|
||||
Reference in New Issue
Block a user