[dahdi-commits] tzafrir: linux/trunk r5133 - /linux/trunk/drivers/dahdi/xpp/card_fxo.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Oct 27 11:00:50 CDT 2008
Author: tzafrir
Date: Mon Oct 27 11:00:49 2008
New Revision: 5133
URL: http://svn.digium.com/view/dahdi?view=rev&rev=5133
Log:
xpp fxo: Add sysfs battery attribute.
Modified:
linux/trunk/drivers/dahdi/xpp/card_fxo.c
Modified: linux/trunk/drivers/dahdi/xpp/card_fxo.c
URL: http://svn.digium.com/view/dahdi/linux/trunk/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=5133&r1=5132&r2=5133
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_fxo.c Mon Oct 27 11:00:49 2008
@@ -1313,9 +1313,44 @@
}
#endif
+static DEVICE_ATTR_READER(fxo_battery_show, dev, buf)
+{
+ xpd_t *xpd;
+ struct FXO_priv_data *priv;
+ unsigned long flags;
+ int len = 0;
+ int i;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ spin_lock_irqsave(&xpd->lock, flags);
+ for_each_line(xpd, i) {
+ char bat;
+
+ if(priv->battery[i] == BATTERY_ON)
+ bat = '+';
+ else if(priv->battery[i] == BATTERY_OFF)
+ bat = '-';
+ else
+ bat = '.';
+ len += sprintf(buf + len, "%c ", bat);
+ }
+ len += sprintf(buf + len, "\n");
+ spin_unlock_irqrestore(&xpd->lock, flags);
+ return len;
+}
+
+static DEVICE_ATTR(fxo_battery, S_IRUGO, fxo_battery_show, NULL);
+
+
static int fxo_xpd_probe(struct device *dev)
{
xpd_t *xpd;
+ int ret;
xpd = dev_to_xpd(dev);
/* Is it our device? */
@@ -1325,7 +1360,14 @@
return -EINVAL;
}
XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ ret = device_create_file(dev, &dev_attr_fxo_battery);
+ if(ret) {
+ XPD_ERR(xpd, "%s: device_create_file(fxo_battery) failed: %d\n", __FUNCTION__, ret);
+ goto fail_fxo_battery;
+ }
return 0;
+fail_fxo_battery:
+ return ret;
}
static int fxo_xpd_remove(struct device *dev)
@@ -1334,6 +1376,7 @@
xpd = dev_to_xpd(dev);
XPD_DBG(DEVICES, xpd, "SYSFS\n");
+ device_remove_file(dev, &dev_attr_fxo_battery);
return 0;
}
More information about the dahdi-commits
mailing list