xpp: fxo: update red alarms on span assignment

DAHDI gets notified of changes to battery status and hence to red alarm
on an FXO channel when the status changes. It thus needs to get notified
about it on "startup".

This startup was initially span registration. However following the
separation between device registration and span assignment, the
notification was sent after device registration, whereas it was ignored
if span was not assigned. It happened to work in most cases due to
delays.

This fix moves the startup notifications of battery status to the new
hook that is run on span assignment.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
Tzafrir Cohen 2017-06-20 14:41:14 +03:00
parent 7292c263ef
commit d4ac65d0c1

View File

@ -620,7 +620,6 @@ static int FXO_card_dahdi_postregistration(xpd_t *xpd, bool on)
BUG_ON(!priv);
XPD_DBG(GENERAL, xpd, "%s\n", (on) ? "ON" : "OFF");
for_each_line(xpd, i) {
dahdi_report_battery(xpd, i);
MARK_OFF(priv, i, LED_GREEN);
msleep(2);
MARK_OFF(priv, i, LED_RED);
@ -629,6 +628,23 @@ static int FXO_card_dahdi_postregistration(xpd_t *xpd, bool on)
return 0;
}
static int FXO_span_assigned(xpd_t *xpd)
{
xbus_t *xbus;
struct FXO_priv_data *priv;
int i;
BUG_ON(!xpd);
xbus = xpd->xbus;
BUG_ON(!xbus);
priv = xpd->priv;
BUG_ON(!priv);
XPD_DBG(GENERAL, xpd, "\n");
for_each_line(xpd, i)
dahdi_report_battery(xpd, i);
return 0;
}
static int FXO_card_hooksig(xpd_t *xpd, int pos, enum dahdi_txsig txsig)
{
struct FXO_priv_data *priv;
@ -1314,6 +1330,7 @@ static const struct phoneops fxo_phoneops = {
.card_ioctl = FXO_card_ioctl,
.card_open = FXO_card_open,
.card_state = FXO_card_state,
.span_assigned = FXO_span_assigned,
};
static xproto_table_t PROTO_TABLE(FXO) = {