xpp: prevent double dahdi un-registration

* It's currently harmless (just re-run the pre/post XPD registrations)
* But it's cleaner this way (as with xbus_register_dahdi_device())

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Oron Peled 2014-04-06 14:01:55 -04:00 committed by Tzafrir Cohen
parent 193c9e59a8
commit 5e24d501c5
1 changed files with 8 additions and 0 deletions

View File

@ -1040,6 +1040,13 @@ void xbus_unregister_dahdi_device(xbus_t *xbus)
XBUS_ERR(xbus, "dahdi_registration_mutex already taken\n");
return;
}
if (!xbus_is_registered(xbus)) {
/*
* Ignore duplicate unregistrations
*/
XBUS_DBG(DEVICES, xbus, "Already unregistered to DAHDI\n");
goto err;
}
for (i = 0; i < MAX_XPDS; i++) {
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_preunregister(xpd);
@ -1054,6 +1061,7 @@ void xbus_unregister_dahdi_device(xbus_t *xbus)
xpd_t *xpd = xpd_of(xbus, i);
xpd_dahdi_postunregister(xpd);
}
err:
mutex_unlock(&dahdi_registration_mutex);
}