diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-03-21 20:17:14 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-03-21 20:17:14 +0000 |
commit | 9a4c983a982a430759000fe508c1722d04da9e66 (patch) | |
tree | 01e1310cfdcf661d70c0fb75ef8ae03e354984ef /drivers/dahdi/xpp/card_fxs.c | |
parent | 7138ef6d7d7ed536d440da8df79f1a4258044291 (diff) |
xpp: FXS: atomic vbat_h power handling
* In do_chan_power() make vbat_h changes atomic.
* As a result we can ignore duplicate requests.
This will allow cleaner logic in the next commit.
* Added proper debug messages.
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10573 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/card_fxs.c')
-rw-r--r-- | drivers/dahdi/xpp/card_fxs.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c index 43b822a..e8f0e2a 100644 --- a/drivers/dahdi/xpp/card_fxs.c +++ b/drivers/dahdi/xpp/card_fxs.c @@ -183,15 +183,23 @@ struct FXS_priv_data { static int do_chan_power(xbus_t *xbus, xpd_t *xpd, lineno_t chan, bool on) { struct FXS_priv_data *priv; + unsigned long *p; + int was; BUG_ON(!xbus); BUG_ON(!xpd); priv = xpd->priv; - LINE_DBG(SIGNAL, xpd, chan, "%s\n", (on) ? "up" : "down"); + p = (unsigned long *)&priv->vbat_h; if (on) - BIT_SET(priv->vbat_h, chan); + was = test_and_set_bit(chan, p) != 0; else - BIT_CLR(priv->vbat_h, chan); + was = test_and_clear_bit(chan, p) != 0; + if (was == on) { + LINE_DBG(SIGNAL, xpd, chan, + "%s (same, ignored)\n", (on) ? "up" : "down"); + return 0; + } + LINE_DBG(SIGNAL, xpd, chan, "%s\n", (on) ? "up" : "down"); return SLIC_DIRECT_REQUEST(xbus, xpd, chan, SLIC_WRITE, REG_BATTERY, (on) ? REG_BATTERY_BATSL : 0x00); } @@ -1728,7 +1736,7 @@ static int proc_fxs_info_read(char *page, char **start, off_t off, int count, len += sprintf(page + len, "\n%-12s", "vbat_h:"); for_each_line(xpd, i) { len += sprintf(page + len, "%4d", - IS_SET(priv->vbat_h, i)); + test_bit(i, (unsigned long *)&priv->vbat_h)); } len += sprintf(page + len, "\n"); for (led = 0; led < NUM_LEDS; led++) { |