[dahdi-commits] tzafrir: linux/trunk r8878 - /linux/trunk/drivers/dahdi/xpp/
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Jul 13 03:44:39 CDT 2010
Author: tzafrir
Date: Tue Jul 13 03:44:36 2010
New Revision: 8878
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8878
Log:
Cleanup: refcount_xpd()
* Change refcount_xpd(): instead of returning a pointer to the atomic
counter, return directly its value (just like refcount_xbus())
* Add a refcount_xbus and refcount_xpd attributes to sysfs (for debugging)
Modified:
linux/trunk/drivers/dahdi/xpp/xbus-core.c
linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
linux/trunk/drivers/dahdi/xpp/xpd.h
linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=8878&r1=8877&r2=8878
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.c Tue Jul 13 03:44:36 2010
@@ -148,6 +148,8 @@
XBUS_DBG(DEVICES, xbus, "%s: refcount_xbus=%d\n",
msg, refcount_xbus(xbus));
dev = get_device(&xbus->astribank);
+ if (!dev)
+ return NULL;
return dev_to_xbus(dev);
}
Modified: linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c?view=diff&rev=8878&r1=8877&r2=8878
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c Tue Jul 13 03:44:36 2010
@@ -202,6 +202,16 @@
xbus = dev_to_xbus(dev);
len = waitfor_xpds(xbus, buf);
+ return len;
+}
+
+static DEVICE_ATTR_READER(refcount_xbus_show, dev, buf)
+{
+ xbus_t *xbus;
+ int len;
+
+ xbus = dev_to_xbus(dev);
+ len = sprintf(buf, "%d\n", refcount_xbus(xbus));
return len;
}
@@ -290,6 +300,7 @@
__ATTR_RO(label),
__ATTR_RO(status),
__ATTR_RO(timing),
+ __ATTR_RO(refcount_xbus),
__ATTR_RO(waitfor_xpds),
__ATTR_RO(driftinfo),
__ATTR(cls, S_IWUSR, NULL, cls_store),
@@ -677,6 +688,19 @@
return len;
}
+static DEVICE_ATTR_READER(refcount_xpd_show, dev, buf)
+{
+ xpd_t *xpd;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if (!xpd)
+ return -ENODEV;
+ len += sprintf(buf + len, "%d\n", refcount_xpd(xpd));
+ return len;
+}
+
static int xpd_match(struct device *dev, struct device_driver *driver)
{
struct xpd_driver *xpd_driver;
@@ -701,6 +725,7 @@
__ATTR_RO(type),
__ATTR_RO(offhook),
__ATTR_RO(timing_priority),
+ __ATTR_RO(refcount_xpd),
__ATTR_NULL,
};
Modified: linux/trunk/drivers/dahdi/xpp/xpd.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xpd.h?view=diff&rev=8878&r1=8877&r2=8878
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpd.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xpd.h Tue Jul 13 03:44:36 2010
@@ -257,6 +257,7 @@
void xpd_driver_unregister(struct device_driver *driver);
xpd_t *get_xpd(const char *msg, xpd_t *xpd);
void put_xpd(const char *msg, xpd_t *xpd);
+int refcount_xpd(xpd_t *xpd);
#endif
Modified: linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c?view=diff&rev=8878&r1=8877&r2=8878
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xpp_dahdi.c Tue Jul 13 03:44:36 2010
@@ -122,11 +122,11 @@
/*------------------------- XPD Management -------------------------*/
-static atomic_t *refcount_xpd(xpd_t *xpd)
+int refcount_xpd(xpd_t *xpd)
{
struct kref *kref = &xpd->xpd_dev.kobj.kref;
- return &kref->refcount;
+ return atomic_read(&kref->refcount);
}
xpd_t *get_xpd(const char *msg, xpd_t *xpd)
@@ -134,15 +134,17 @@
struct device *dev;
XPD_DBG(DEVICES, xpd, "%s: refcount_xpd=%d\n",
- msg, atomic_read(refcount_xpd(xpd)));
+ msg, refcount_xpd(xpd));
dev = get_device(&xpd->xpd_dev);
+ if (!dev)
+ return NULL;
return dev_to_xpd(dev);
}
void put_xpd(const char *msg, xpd_t *xpd)
{
XPD_DBG(DEVICES, xpd, "%s: refcount_xpd=%d\n",
- msg, atomic_read(refcount_xpd(xpd)));
+ msg, refcount_xpd(xpd));
put_device(&xpd->xpd_dev);
}
@@ -331,7 +333,7 @@
len += sprintf(page + len, "xpd_state: %s (%d)\n",
xpd_statename(xpd->xpd_state), xpd->xpd_state);
len += sprintf(page + len, "open_counter=%d refcount=%d\n",
- atomic_read(&xpd->open_counter), atomic_read(refcount_xpd(xpd)));
+ atomic_read(&xpd->open_counter), refcount_xpd(xpd));
len += sprintf(page + len, "Address: U=%d S=%d\n", xpd->addr.unit, xpd->addr.subunit);
len += sprintf(page + len, "Subunits: %d\n", xpd->subunits);
len += sprintf(page + len, "Type: %d.%d\n\n", xpd->type, xpd->subtype);
More information about the dahdi-commits
mailing list