summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-10-27 15:49:09 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-10-27 15:49:09 +0000
commit0bcecd62480492f36775bc90ed6e86389264c7f3 (patch)
tree75b99e7ec97bdab5372837937dcca36bd6ab352f
parent3cf9ba036795c56afa9a6262460e91134ceb64de (diff)
Fix xpp compile problems on kernel < 2.6.16
Support for kernels that use the older hotplug support rather than the newer uevent. Fixes the xpp issue from #13427. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5130 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/xpp/card_bri.c2
-rw-r--r--drivers/dahdi/xpp/card_fxo.c2
-rw-r--r--drivers/dahdi/xpp/card_fxs.c2
-rw-r--r--drivers/dahdi/xpp/card_pri.c2
-rw-r--r--drivers/dahdi/xpp/xbus-core.h14
-rw-r--r--drivers/dahdi/xpp/xbus-sysfs.c49
-rw-r--r--drivers/dahdi/xpp/xdefs.h8
7 files changed, 65 insertions, 14 deletions
diff --git a/drivers/dahdi/xpp/card_bri.c b/drivers/dahdi/xpp/card_bri.c
index cf0fdfa..571a10f 100644
--- a/drivers/dahdi/xpp/card_bri.c
+++ b/drivers/dahdi/xpp/card_bri.c
@@ -1505,7 +1505,9 @@ static struct xpd_driver bri_driver = {
.type = XPD_TYPE_BRI,
.driver = {
.name = "bri",
+#ifndef OLD_HOTPLUG_SUPPORT
.owner = THIS_MODULE,
+#endif
.probe = bri_xpd_probe,
.remove = bri_xpd_remove
}
diff --git a/drivers/dahdi/xpp/card_fxo.c b/drivers/dahdi/xpp/card_fxo.c
index 7bbf9b4..bc0590a 100644
--- a/drivers/dahdi/xpp/card_fxo.c
+++ b/drivers/dahdi/xpp/card_fxo.c
@@ -1341,7 +1341,9 @@ static struct xpd_driver fxo_driver = {
.type = XPD_TYPE_FXO,
.driver = {
.name = "fxo",
+#ifndef OLD_HOTPLUG_SUPPORT
.owner = THIS_MODULE,
+#endif
.probe = fxo_xpd_probe,
.remove = fxo_xpd_remove
}
diff --git a/drivers/dahdi/xpp/card_fxs.c b/drivers/dahdi/xpp/card_fxs.c
index 67fbd61..cbd4ddd 100644
--- a/drivers/dahdi/xpp/card_fxs.c
+++ b/drivers/dahdi/xpp/card_fxs.c
@@ -1492,7 +1492,9 @@ static struct xpd_driver fxs_driver = {
.type = XPD_TYPE_FXS,
.driver = {
.name = "fxs",
+#ifndef OLD_HOTPLUG_SUPPORT
.owner = THIS_MODULE,
+#endif
.probe = fxs_xpd_probe,
.remove = fxs_xpd_remove
}
diff --git a/drivers/dahdi/xpp/card_pri.c b/drivers/dahdi/xpp/card_pri.c
index a215b5c..98ec70e 100644
--- a/drivers/dahdi/xpp/card_pri.c
+++ b/drivers/dahdi/xpp/card_pri.c
@@ -2138,7 +2138,9 @@ static struct xpd_driver pri_driver = {
.type = XPD_TYPE_PRI,
.driver = {
.name = "pri",
+#ifndef OLD_HOTPLUG_SUPPORT
.owner = THIS_MODULE,
+#endif
.probe = pri_xpd_probe,
.remove = pri_xpd_remove
}
diff --git a/drivers/dahdi/xpp/xbus-core.h b/drivers/dahdi/xpp/xbus-core.h
index c563c88..92d9b12 100644
--- a/drivers/dahdi/xpp/xbus-core.h
+++ b/drivers/dahdi/xpp/xbus-core.h
@@ -319,6 +319,20 @@ int xpp_driver_init(void);
void xpp_driver_exit(void);
int xbus_sysfs_create(xbus_t *xbus);
void xbus_sysfs_remove(xbus_t *xbus);
+
+#ifdef OLD_HOTPLUG_SUPPORT
+/* Copy from new kernels lib/kobject_uevent.c */
+enum kobject_action {
+ KOBJ_ADD,
+ KOBJ_REMOVE,
+ KOBJ_CHANGE,
+ KOBJ_MOUNT,
+ KOBJ_UMOUNT,
+ KOBJ_OFFLINE,
+ KOBJ_ONLINE,
+};
+#endif
+
void astribank_uevent_send(xbus_t *xbus, enum kobject_action act);
#endif /* XBUS_CORE_H */
diff --git a/drivers/dahdi/xpp/xbus-sysfs.c b/drivers/dahdi/xpp/xbus-sysfs.c
index 5bb4f7d..86e22e0 100644
--- a/drivers/dahdi/xpp/xbus-sysfs.c
+++ b/drivers/dahdi/xpp/xbus-sysfs.c
@@ -49,14 +49,6 @@ static const char rcsid[] = "$Id$";
/* Command line parameters */
extern int debug;
-/* Kernel versions... */
-/*
- * Hotplug replaced with uevent in 2.6.16
- */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
-#define OLD_HOPLUG_SUPPORT // for older kernels
-#endif
-
/*--------- Sysfs Bus handling ----*/
static DEVICE_ATTR_READER(xbus_state_show, dev, buf)
{
@@ -198,7 +190,8 @@ static DEVICE_ATTR_READER(waitfor_xpds_show, dev, buf)
return len;
}
-#define xbus_attr(field, format_string) \
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
+#define xbus_attr(field, format_string) \
static ssize_t \
field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
{ \
@@ -207,6 +200,17 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
xbus = dev_to_xbus(dev); \
return sprintf (buf, format_string, xbus->field); \
}
+#else
+#define xbus_attr(field, format_string) \
+static ssize_t \
+field##_show(struct device *dev, char *buf) \
+{ \
+ xbus_t *xbus; \
+ \
+ xbus = dev_to_xbus(dev); \
+ return sprintf (buf, format_string, xbus->field); \
+}
+#endif
xbus_attr(connector, "%s\n");
xbus_attr(label, "%s\n");
@@ -233,7 +237,7 @@ static int astribank_match(struct device *dev, struct device_driver *driver)
return 1;
}
-#ifdef OLD_HOPLUG_SUPPORT
+#ifdef OLD_HOTPLUG_SUPPORT
static int astribank_hotplug(struct device *dev, char **envp, int envnum, char *buff, int bufsize)
{
xbus_t *xbus;
@@ -305,6 +309,8 @@ static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv)
#endif
+#endif /* OLD_HOTPLUG_SUPPORT */
+
void astribank_uevent_send(xbus_t *xbus, enum kobject_action act)
{
struct kobject *kobj;
@@ -312,11 +318,26 @@ void astribank_uevent_send(xbus_t *xbus, enum kobject_action act)
kobj = &xbus->astribank.kobj;
XBUS_DBG(DEVICES, xbus, "SYFS bus_id=%s action=%d\n",
xbus->astribank.bus_id, act);
+
+#ifdef OLD_HOTPLUG_SUPPORT
+ {
+ /* 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);
+ }
+#else
kobject_uevent(kobj, act);
+#endif
}
-#endif /* OLD_HOPLUG_SUPPORT */
-
static void xpp_release(struct device *dev)
{
DBG(DEVICES, "SYSFS %s\n", dev->bus_id);
@@ -340,7 +361,7 @@ static void astribank_release(struct device *dev)
static struct bus_type toplevel_bus_type = {
.name = "astribanks",
.match = astribank_match,
-#ifdef OLD_HOPLUG_SUPPORT
+#ifdef OLD_HOTPLUG_SUPPORT
.hotplug = astribank_hotplug,
#else
.uevent = astribank_uevent,
@@ -376,7 +397,7 @@ static struct device_driver xpp_driver = {
.bus = &toplevel_bus_type,
.probe = astribank_probe,
.remove = astribank_remove,
-#ifndef OLD_HOPLUG_SUPPORT
+#ifndef OLD_HOTPLUG_SUPPORT
.owner = THIS_MODULE
#endif
};
diff --git a/drivers/dahdi/xpp/xdefs.h b/drivers/dahdi/xpp/xdefs.h
index 5763679..430f8ef 100644
--- a/drivers/dahdi/xpp/xdefs.h
+++ b/drivers/dahdi/xpp/xdefs.h
@@ -101,6 +101,7 @@ typedef char *charp;
typedef unsigned char byte;
#ifdef __KERNEL__
+/* Kernel versions... */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
#define KMEM_CACHE_T kmem_cache_t
#else
@@ -113,6 +114,13 @@ typedef unsigned char byte;
kfree(p); \
} while(0);
+/*
+ * Hotplug replaced with uevent in 2.6.16
+ */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16)
+#define OLD_HOTPLUG_SUPPORT // for older kernels
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
#define DEVICE_ATTR_READER(name,dev,buf) \
ssize_t name(struct device *dev, struct device_attribute *attr, char *buf)