From e6b16eace164d4b7edbeaf415965870fb7445cf9 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Mon, 23 Dec 2013 15:55:36 -0600 Subject: [PATCH] dahdi: Move clearing of DAHDI_ALARM_NOTOPEN to __dahdi_assign_span(). Previously this was in __dahdi_init_span(). The problem was that __dahdi_init_span() was only called when a spans' line mode was being changed. Therefore it was possible to unassign and resassign an analog span and leave it stuck in the 'NOP' alarm state. It also make the setting / clearing of DAHDI_ALARM_NOTOPEN symetrical about span unassignment / assignment in addition to updating the alarm states on all the channels on the span via the dahdi_alarm_notify() function. This is a better version of commit 496f81777323d309bd5c32afc2186bdc0055e5be. Signed-off-by: Shaun Ruffell --- drivers/dahdi/dahdi-base.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 6d61dad..908001a 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -7188,13 +7188,6 @@ static void __dahdi_init_span(struct dahdi_span *span) spin_lock_init(&span->lock); clear_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags); - /* DAHDI_ALARM_NOTOPEN can be set when a span is disabled, i.e. via - * sysfs, so when the span is being initialized again before - * reassignment we should make sure it's cleared. This eliminates the - * need for board drivers to re-report their alarm states on span - * reassignment. */ - span->alarms &= ~DAHDI_ALARM_NOTOPEN; - if (!span->deflaw) { module_printk(KERN_NOTICE, "Span %s didn't specify default " "law. Assuming mulaw, please fix driver!\n", @@ -7255,6 +7248,7 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno, { int res = 0; unsigned int x; + unsigned long flags; if (!span || !span->ops || !span->ops->owner) return -EFAULT; @@ -7266,6 +7260,16 @@ static int _dahdi_assign_span(struct dahdi_span *span, unsigned int spanno, return -EINVAL; } + /* DAHDI_ALARM_NOTOPEN can be set when a span is disabled, i.e. via + * sysfs, so when the span is being reassigned we should make sure it's + * cleared. This eliminates the need for board drivers to re-report + * their alarm states on span reassignment. */ + + spin_lock_irqsave(&span->lock, flags); + span->alarms &= ~DAHDI_ALARM_NOTOPEN; + dahdi_alarm_notify(span); + spin_unlock_irqrestore(&span->lock, flags); + if (span->ops->enable_hw_preechocan || span->ops->disable_hw_preechocan) { if ((NULL == span->ops->enable_hw_preechocan) ||