[dahdi-commits] tzafrir: linux/trunk r8904 - /linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Jul 13 11:28:40 CDT 2010
Author: tzafrir
Date: Tue Jul 13 11:28:37 2010
New Revision: 8904
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8904
Log:
Create /sys/devices/astribanks:
* Astribank devices now reside under their own top-level device.
* The USB device is still used as the 'transport'.
* This means the astribanks parents are NOT the USB devices.
* As a result, even after a USB disconnect, we have valid sysfs representation.
Modified:
linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
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=8904&r1=8903&r2=8904
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c Tue Jul 13 11:28:37 2010
@@ -440,6 +440,16 @@
XBUS_INFO(xbus, "[%s] Astribank Release\n", xbus->label);
xbus_free(xbus);
}
+
+static void toplevel_release(struct device *dev)
+{
+ NOTICE("%s\n", __func__);
+}
+
+static struct device toplevel_device = {
+ .release = toplevel_release,
+ /* No Parent */
+};
static struct bus_type toplevel_bus_type = {
.name = "astribanks",
@@ -815,12 +825,19 @@
int xbus_sysfs_transport_create(xbus_t *xbus)
{
struct device *astribank;
+ struct device *transport_device;
int ret = 0;
BUG_ON(!xbus);
XBUS_DBG(DEVICES, xbus, "\n");
astribank = &xbus->astribank;
- ret = sysfs_create_link(&astribank->kobj, &astribank->parent->kobj,
+ BUG_ON(!astribank);
+ transport_device = xbus->transport.transport_device;
+ if (!transport_device) {
+ XBUS_ERR(xbus, "%s: Missing transport_device\n", __func__);
+ return -ENODEV;
+ }
+ ret = sysfs_create_link(&astribank->kobj, &transport_device->kobj,
"transport");
if (ret < 0) {
XBUS_ERR(xbus, "%s: sysfs_create_link failed: %d\n",
@@ -853,7 +870,7 @@
astribank = &xbus->astribank;
XBUS_DBG(DEVICES, xbus, "\n");
astribank->bus = &toplevel_bus_type;
- astribank->parent = xbus->transport.transport_device;
+ astribank->parent = &toplevel_device;
dev_set_name(astribank, "xbus-%02d", xbus->num);
dev_set_drvdata(astribank, xbus);
astribank->release = astribank_release;
@@ -870,6 +887,12 @@
int ret;
DBG(DEVICES, "SYSFS\n");
+ dev_set_name(&toplevel_device, "astribanks");
+ ret = device_register(&toplevel_device);
+ if (ret) {
+ ERR("%s: toplevel device_register failed: %d\n", __func__, ret);
+ goto failed_toplevel;
+ }
if((ret = bus_register(&toplevel_bus_type)) < 0) {
ERR("%s: bus_register(%s) failed. Error number %d",
__FUNCTION__, toplevel_bus_type.name, ret);
@@ -891,6 +914,8 @@
failed_xpp_driver:
bus_unregister(&toplevel_bus_type);
failed_bus:
+ device_unregister(&toplevel_device);
+failed_toplevel:
return ret;
}
@@ -900,6 +925,7 @@
bus_unregister(&xpd_type);
driver_unregister(&xpp_driver);
bus_unregister(&toplevel_bus_type);
+ device_unregister(&toplevel_device);
}
EXPORT_SYMBOL(xpd_driver_register);
More information about the dahdi-commits
mailing list