[dahdi-commits] tzafrir: branch linux/tzafrir/sysfs r5969 - in /linux/team/tzafrir/sysfs: bui...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Feb 2 20:10:42 CST 2009
Author: tzafrir
Date: Mon Feb 2 20:10:42 2009
New Revision: 5969
URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=5969
Log:
Send a udev event on span generation and span destruction.
Modified:
linux/team/tzafrir/sysfs/build_tools/live_dahdi
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
Modified: linux/team/tzafrir/sysfs/build_tools/live_dahdi
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/build_tools/live_dahdi?view=diff&rev=5969&r1=5968&r2=5969
==============================================================================
--- linux/team/tzafrir/sysfs/build_tools/live_dahdi (original)
+++ linux/team/tzafrir/sysfs/build_tools/live_dahdi Mon Feb 2 20:10:42 2009
@@ -39,6 +39,7 @@
# make sure Astribank initialization scripts are from our tree.
xpp_ARGS="$xpp_ARGS initdir=$FIRMWARE_DIR"
+dahdi_ARGS="$dahdi_ARGS initdir=$FIRMWARE_DIR"
# the same as xpp/utils/dahdi_drivers .
# With the remote mode, I can't rely on files in the source directory.
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c
URL: http://svn.digium.com/svn-view/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c?view=diff&rev=5969&r1=5968&r2=5969
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs.c Mon Feb 2 20:10:42 2009
@@ -87,6 +87,9 @@
((void)((debug & (DBG_ ## bits)) && CHAN_PRINTK(DEBUG, "-" #bits, chan, "%s: " fmt, __func__, ## __VA_ARGS__)))
#define CHAN_ERR(chan, fmt, ...) CHAN_PRINTK(ERR, "", chan, fmt, ## __VA_ARGS__)
+char *initdir = "/usr/share/dahdi";
+module_param(initdir, charp, 0644);
+
/*--------- Sysfs Bus handling ----*/
#if 0
static DEVICE_ATTR_READER(span_state_show, dev, buf)
@@ -307,18 +310,18 @@
return -ENODEV;
span = dev_to_span(dev);
envp[0] = buff;
- //if(snprintf(buff, bufsize, "SPAN_NAME=%s", span->name) >= bufsize)
- // return -ENOMEM;
+ if(snprintf(buff, bufsize, "SPAN_NAME=%s", span->name) >= bufsize)
+ return -ENOMEM;
envp[1] = NULL;
return 0;
}
#else
-#define XBUS_VAR_BLOCK \
+#define SPAN_VAR_BLOCK \
do { \
- XBUS_ADD_UEVENT_VAR("XPP_INIT_DIR=%s", initdir); \
- XBUS_ADD_UEVENT_VAR("XBUS_NUM=%02d", xbus->num); \
- XBUS_ADD_UEVENT_VAR("XBUS_NAME=%s", xbus->busname); \
+ XBUS_ADD_UEVENT_VAR("DAHDI_INIT_DIR=%s", initdir); \
+ XBUS_ADD_UEVENT_VAR("SPAN_NUM=%03d", span->spanno); \
+ XBUS_ADD_UEVENT_VAR("SPAN_NAME=%s", span->name); \
} while(0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
@@ -335,14 +338,13 @@
{
struct dahdi_span *span;
int i = 0;
- //int len = 0;
- //extern char *initdir;
+ int len = 0;
if(!dev)
return -ENODEV;
span = dev_to_span(dev);
DBG(GENERAL, "SYFS bus_id=%s span=%s\n", dev->bus_id, span->name);
- //XBUS_VAR_BLOCK;
+ SPAN_VAR_BLOCK;
envp[i] = NULL;
return 0;
}
@@ -358,13 +360,12 @@
static int span_uevent(struct device *dev, struct kobj_uevent_env *kenv)
{
struct dahdi_span *span;
- //extern char *initdir;
if(!dev)
return -ENODEV;
span = dev_to_span(dev);
DBG(GENERAL, "SYFS bus_id=%s span=%s\n", dev->bus_id, span->name);
- //XBUS_VAR_BLOCK;
+ SPAN_VAR_BLOCK;
return 0;
}
@@ -401,6 +402,36 @@
}
#endif
+
+static void span_uevent_send(struct dahdi_span *span, enum kobject_action act)
+{
+ struct kobject *kobj;
+
+ kobj = &span->span_device.kobj;
+ SPAN_DBG(DEVICES, span, "SYFS bus_id=%s action=%d\n",
+ span->span_device.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);
+ }
+#elif defined(OLD_HOTPLUG_SUPPORT)
+ kobject_hotplug(kobj, act);
+#else
+ kobject_uevent(kobj, act);
+#endif
+}
+
static void dahdi_release(struct device *dev)
{
DBG(DEVICES, "SYSFS %s\n", dev->bus_id);
@@ -526,6 +557,7 @@
if(!span_device->driver_data)
return;
BUG_ON(span_device->driver_data != span);
+ span_uevent_send(span, KOBJ_OFFLINE);
device_unregister(&span->span_device);
}
EXPORT_SYMBOL(span_sysfs_remove);
@@ -565,6 +597,7 @@
return res;
}
}
+ span_uevent_send(span, KOBJ_ONLINE);
return res;
err_span_attr:
More information about the dahdi-commits
mailing list