summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/xbus-sysfs.c
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-01-18 09:55:48 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-01-18 09:55:48 +0000
commitf89c302cbde0ea699009df9e5286be5001f16c20 (patch)
tree41fa4bf87faacf1979e54ac579c5dcc65e1c62aa /drivers/dahdi/xpp/xbus-sysfs.c
parent7d1e606f63ae5ce4c4932f3d65e18adf519b9aee (diff)
xpp.r6616: More sysfs migration, FXO enhancements, BRI fixes
* Fix cases where the command_queue overflowed during initialization. * More migrations to sysfs: - Add a 'transport' attribute to our astribank devices which points to the usb device we use. E.g: /sys/bus/astribanks/devices/xbus-00/transport is symlinked to ../../../../../../devices/pci0000:00/0000:00:10.4/usb5/5-4 - Move /proc/xpp/XBUS-??/XPD-??/span to /sys/bus/xpds/devices/??:?:?/span - Migrate from /proc/xpp/sync to: /sys/bus/astribanks/drivers/xppdrv/sync * PRI: change the "timing" priority to match the convention used by other PRI cards -- I.e: lower numbers (not 0) have higher priority. * FXO: - Power denial: create two module parameters instead of hard-coded constants (power_denial_safezone, power_denial_minlen). For sites that get non-standard power-denial signals from central office on offhook. - Don't hangup on power-denial, just notify Dahdi and wait for - Fix caller-id detection for the case central office sends it before first ring without any indication before. Asterisk's desicion. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5663 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/xbus-sysfs.c')
-rw-r--r--drivers/dahdi/xpp/xbus-sysfs.c91
1 files changed, 58 insertions, 33 deletions
diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index 4dd0f0d..8d1f35a 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -38,7 +38,6 @@
#include "xpd.h"
#include "xpp_dahdi.h"
#include "xbus-core.h"
-#include "card_global.h"
#ifdef XPP_DEBUGFS
#include "xpp_log.h"
#endif
@@ -49,6 +48,23 @@ static const char rcsid[] = "$Id$";
/* Command line parameters */
extern int debug;
+/*--------- xpp driver attributes -*/
+static ssize_t sync_show(struct device_driver *driver, char *buf)
+{
+ DBG(SYNC, "\n");
+ return fill_sync_string(buf, PAGE_SIZE);
+}
+
+static ssize_t sync_store(struct device_driver *driver, const char *buf, size_t count)
+{
+ /* DBG(SYNC, "%s\n", buf); */
+ return exec_sync_command(buf, count);
+}
+
+static struct driver_attribute xpp_attrs[] = {
+ __ATTR(sync, S_IRUGO | S_IWUSR, sync_show, sync_store),
+};
+
/*--------- Sysfs Bus handling ----*/
static DEVICE_ATTR_READER(xbus_state_show, dev, buf)
{
@@ -320,19 +336,19 @@ void astribank_uevent_send(xbus_t *xbus, enum kobject_action act)
xbus->astribank.bus_id, act);
#if defined(OLD_HOTPLUG_SUPPORT_269)
- {
- /* Copy from new kernels lib/kobject_uevent.c */
- static const char *str[] = {
- [KOBJ_ADD] "add",
- [KOBJ_REMOVE] "remove",
- [KOBJ_CHANGE] "change",
- [KOBJ_MOUNT] "mount",
- [KOBJ_UMOUNT] "umount",
- [KOBJ_OFFLINE] "offline",
- [KOBJ_ONLINE] "online"
- };
- kobject_hotplug(str[act], kobj);
- }
+ {
+ /* Copy from new kernels lib/kobject_uevent.c */
+ static const char *str[] = {
+ [KOBJ_ADD] "add",
+ [KOBJ_REMOVE] "remove",
+ [KOBJ_CHANGE] "change",
+ [KOBJ_MOUNT] "mount",
+ [KOBJ_UMOUNT] "umount",
+ [KOBJ_OFFLINE] "offline",
+ [KOBJ_ONLINE] "online"
+ };
+ kobject_hotplug(str[act], kobj);
+ }
#elif defined(OLD_HOTPLUG_SUPPORT)
kobject_hotplug(kobj, act);
#else
@@ -340,11 +356,6 @@ void astribank_uevent_send(xbus_t *xbus, enum kobject_action act)
#endif
}
-static void xpp_release(struct device *dev)
-{
- DBG(DEVICES, "SYSFS %s\n", dev->bus_id);
-}
-
static void astribank_release(struct device *dev)
{
xbus_t *xbus;
@@ -369,11 +380,7 @@ static struct bus_type toplevel_bus_type = {
.uevent = astribank_uevent,
#endif
.dev_attrs = xbus_dev_attrs,
-};
-
-static struct device toplevel_device = {
- .bus_id = "xpp",
- .release = xpp_release
+ .drv_attrs = xpp_attrs,
};
static int astribank_probe(struct device *dev)
@@ -479,6 +486,9 @@ static DEVICE_ATTR_WRITER(chipregs_store, dev, buf, count)
}
}
p += i + 1;
+ /* Don't flood command_queue */
+ if(xframe_queue_count(&xpd->xbus->command_queue) > 5)
+ msleep(6);
}
return count;
}
@@ -559,6 +569,19 @@ static DEVICE_ATTR_WRITER(span_store, dev, buf, count)
return (ret < 0) ? ret : count;
}
+static DEVICE_ATTR_READER(type_show, dev, buf)
+{
+ xpd_t *xpd;
+ int len = 0;
+
+ BUG_ON(!dev);
+ xpd = dev_to_xpd(dev);
+ if(!xpd)
+ return -ENODEV;
+ len += sprintf(buf, "%s\n", xpd->type_name);
+ return len;
+}
+
static int xpd_match(struct device *dev, struct device_driver *driver)
{
struct xpd_driver *xpd_driver;
@@ -580,6 +603,7 @@ static struct device_attribute xpd_dev_attrs[] = {
__ATTR(chipregs, S_IRUGO | S_IWUSR, chipregs_show, chipregs_store),
__ATTR(blink, S_IRUGO | S_IWUSR, blink_show, blink_store),
__ATTR(span, S_IRUGO | S_IWUSR, span_show, span_store),
+ __ATTR_RO(type),
__ATTR_NULL,
};
@@ -666,6 +690,7 @@ void xbus_sysfs_remove(xbus_t *xbus)
XBUS_DBG(DEVICES, xbus, "\n");
astribank = &xbus->astribank;
BUG_ON(!astribank);
+ sysfs_remove_link(&astribank->kobj, "transport");
if(!astribank->driver_data)
return;
BUG_ON(astribank->driver_data != xbus);
@@ -682,7 +707,7 @@ int xbus_sysfs_create(xbus_t *xbus)
BUG_ON(!astribank);
XBUS_DBG(DEVICES, xbus, "\n");
astribank->bus = &toplevel_bus_type;
- astribank->parent = &toplevel_device;
+ astribank->parent = xbus->transport.transport_device;
snprintf(astribank->bus_id, BUS_ID_SIZE, "xbus-%02d", xbus->num);
astribank->driver_data = xbus;
astribank->release = astribank_release;
@@ -690,7 +715,15 @@ int xbus_sysfs_create(xbus_t *xbus)
if(ret) {
XBUS_ERR(xbus, "%s: device_register failed: %d\n", __FUNCTION__, ret);
astribank->driver_data = NULL;
+ goto out;
}
+ ret = sysfs_create_link(&astribank->kobj, &astribank->parent->kobj, "transport");
+ if(ret < 0) {
+ XBUS_ERR(xbus, "%s: sysfs_create_link failed: %d\n", __FUNCTION__, ret);
+ astribank->driver_data = NULL;
+ goto out;
+ }
+out:
return ret;
}
@@ -704,11 +737,6 @@ int __init xpp_driver_init(void)
__FUNCTION__, toplevel_bus_type.name, ret);
goto failed_bus;
}
- if((ret = device_register(&toplevel_device)) < 0) {
- ERR("%s: device_register(%s) failed. Error number %d",
- __FUNCTION__, toplevel_device.bus_id, ret);
- goto failed_busdevice;
- }
if((ret = driver_register(&xpp_driver)) < 0) {
ERR("%s: driver_register(%s) failed. Error number %d",
__FUNCTION__, xpp_driver.name, ret);
@@ -723,8 +751,6 @@ int __init xpp_driver_init(void)
failed_xpd_bus:
driver_unregister(&xpp_driver);
failed_xpp_driver:
- device_unregister(&toplevel_device);
-failed_busdevice:
bus_unregister(&toplevel_bus_type);
failed_bus:
return ret;
@@ -735,7 +761,6 @@ void xpp_driver_exit(void)
DBG(DEVICES, "SYSFS\n");
bus_unregister(&xpd_type);
driver_unregister(&xpp_driver);
- device_unregister(&toplevel_device);
bus_unregister(&toplevel_bus_type);
}