[svn-commits] tzafrir: branch linux/2.5 r10577 - /linux/branches/2.5/drivers/dahdi/xpp/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 21 15:40:31 CDT 2012


Author: tzafrir
Date: Wed Mar 21 15:40:29 2012
New Revision: 10577

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10577
Log:
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 at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10573

Modified:
    linux/branches/2.5/drivers/dahdi/xpp/card_fxs.c

Modified: linux/branches/2.5/drivers/dahdi/xpp/card_fxs.c
URL: http://svnview.digium.com/svn/dahdi/linux/branches/2.5/drivers/dahdi/xpp/card_fxs.c?view=diff&rev=10577&r1=10576&r2=10577
==============================================================================
--- linux/branches/2.5/drivers/dahdi/xpp/card_fxs.c (original)
+++ linux/branches/2.5/drivers/dahdi/xpp/card_fxs.c Wed Mar 21 15:40:29 2012
@@ -161,15 +161,23 @@
 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;
+	p = (unsigned long *)&priv->vbat_h;
+	if (on)
+		was = test_and_set_bit(chan, p) != 0;
+	else
+		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");
-	if (on)
-		BIT_SET(priv->vbat_h, chan);
-	else
-		BIT_CLR(priv->vbat_h, chan);
 	return SLIC_DIRECT_REQUEST(xbus, xpd, chan, SLIC_WRITE, REG_BATTERY,
 			(on) ? REG_BATTERY_BATSL : 0x00);
 }
@@ -1566,7 +1574,7 @@
 	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++) {




More information about the svn-commits mailing list