dahdi: Completely stop spans when unassigning.

When spans are unassigned, dahdi_span_ops.shutdown was called, but the RUNNING
flag was never cleared. Now make sure all calls to the shutdown span ops
callback are the same.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
This commit is contained in:
Shaun Ruffell 2013-05-17 12:10:21 -05:00 committed by Russ Meyerriecks
parent a3ad32c370
commit 9b11847aee

View File

@ -5137,11 +5137,28 @@ static int dahdi_ioctl_startup(struct file *file, unsigned long data)
return res;
}
static int dahdi_shutdown_span(struct dahdi_span *s)
{
int res = 0;
int x;
/* Unconfigure channels */
for (x = 0; x < s->channels; x++)
s->chans[x]->sig = 0;
if (s->ops->shutdown)
res = s->ops->shutdown(s);
clear_bit(DAHDI_FLAGBIT_RUNNING, &s->flags);
return res;
}
static int dahdi_ioctl_shutdown(unsigned long data)
{
int res;
/* I/O CTL's for control interface */
int j;
int x;
struct dahdi_span *s;
if (get_user(j, (int __user *)data))
@ -5149,23 +5166,10 @@ static int dahdi_ioctl_shutdown(unsigned long data)
s = span_find_and_get(j);
if (!s)
return -ENXIO;
/* Unconfigure channels */
for (x = 0; x < s->channels; x++)
s->chans[x]->sig = 0;
if (s->ops->shutdown) {
int res = s->ops->shutdown(s);
if (res) {
res = dahdi_shutdown_span(s);
put_span(s);
return res;
}
}
s->flags &= ~DAHDI_FLAG_RUNNING;
put_span(s);
return 0;
}
/**
* dahdi_is_hwec_available - Is hardware echocan available on a channel?
@ -7424,6 +7428,7 @@ static void disable_span(struct dahdi_span *span)
*/
static int _dahdi_unassign_span(struct dahdi_span *span)
{
int res;
int x;
struct dahdi_span *new_master, *s;
unsigned long flags;
@ -7440,9 +7445,11 @@ static int _dahdi_unassign_span(struct dahdi_span *span)
span->spanno = 0;
clear_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags);
/* Shutdown the span if it's running */
if ((span->flags & DAHDI_FLAG_RUNNING) && span->ops->shutdown)
span->ops->shutdown(span);
res = dahdi_shutdown_span(span);
if (res) {
dev_err(span_device(span),
"Failed to shutdown when unassigning.\n");
}
if (debug & DEBUG_MAIN)
module_printk(KERN_NOTICE, "Unassigning Span '%s' with %d channels\n", span->name, span->channels);