From 9b11847aee6fd6100d8c0c8ca8b20893facda1aa Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 17 May 2013 12:10:21 -0500 Subject: [PATCH] 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 Signed-off-by: Russ Meyerriecks --- drivers/dahdi/dahdi-base.c | 45 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index dda06ef..72aa5e3 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -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,22 +5166,9 @@ 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) { - put_span(s); - return res; - } - } - - s->flags &= ~DAHDI_FLAG_RUNNING; + res = dahdi_shutdown_span(s); put_span(s); - return 0; + return res; } /** @@ -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);