From 15cb848eadd51323f34df76c8752dbd580f267a6 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Wed, 27 May 2009 13:15:29 +0000 Subject: xpp: Replaece member bus_id with dev_name() and set_dev_name() As of 2.6.26 the macros dev_name() and set_dev_name() are used to read and set (respectively) the bus_id member in sysfs. As of 2.6.30 bus_id is gone. This patch provides comaptiobility macros for older kernel versions and removes direct usage of bus_id. From dahdi-linux r6637. Regarding issue #14965 . git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4649 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- kernel/xpp/card_bri.c | 2 +- kernel/xpp/card_fxo.c | 2 +- kernel/xpp/card_fxs.c | 2 +- kernel/xpp/card_pri.c | 2 +- kernel/xpp/xbus-sysfs.c | 16 ++++++++-------- kernel/xpp/xdefs.h | 6 ++++++ 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/kernel/xpp/card_bri.c b/kernel/xpp/card_bri.c index d4698d9..cebab42 100644 --- a/kernel/xpp/card_bri.c +++ b/kernel/xpp/card_bri.c @@ -1785,7 +1785,7 @@ static int bri_xpd_probe(struct device *dev) /* Is it our device? */ if(xpd->type != XPD_TYPE_BRI) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", - dev->bus_id, xpd->type); + dev_name(dev), xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); diff --git a/kernel/xpp/card_fxo.c b/kernel/xpp/card_fxo.c index bc6b61d..2071611 100644 --- a/kernel/xpp/card_fxo.c +++ b/kernel/xpp/card_fxo.c @@ -1359,7 +1359,7 @@ static int fxo_xpd_probe(struct device *dev) /* Is it our device? */ if(xpd->type != XPD_TYPE_FXO) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", - dev->bus_id, xpd->type); + dev_name(dev), xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); diff --git a/kernel/xpp/card_fxs.c b/kernel/xpp/card_fxs.c index 450539a..7a0e293 100644 --- a/kernel/xpp/card_fxs.c +++ b/kernel/xpp/card_fxs.c @@ -1504,7 +1504,7 @@ static int fxs_xpd_probe(struct device *dev) /* Is it our device? */ if(xpd->type != XPD_TYPE_FXS) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", - dev->bus_id, xpd->type); + dev_name(dev), xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); diff --git a/kernel/xpp/card_pri.c b/kernel/xpp/card_pri.c index c018bcf..34b5824 100644 --- a/kernel/xpp/card_pri.c +++ b/kernel/xpp/card_pri.c @@ -2087,7 +2087,7 @@ static int pri_xpd_probe(struct device *dev) /* Is it our device? */ if(xpd->type != XPD_TYPE_PRI) { XPD_ERR(xpd, "drop suggestion for %s (%d)\n", - dev->bus_id, xpd->type); + dev_name(dev), xpd->type); return -EINVAL; } XPD_DBG(DEVICES, xpd, "SYSFS\n"); diff --git a/kernel/xpp/xbus-sysfs.c b/kernel/xpp/xbus-sysfs.c index 2c8c6f1..e43bc79 100644 --- a/kernel/xpp/xbus-sysfs.c +++ b/kernel/xpp/xbus-sysfs.c @@ -279,7 +279,7 @@ static struct device_attribute xbus_dev_attrs[] = { static int astribank_match(struct device *dev, struct device_driver *driver) { DBG(DEVICES, "SYSFS MATCH: dev->bus_id = %s, driver->name = %s\n", - dev->bus_id, driver->name); + dev_name(dev), driver->name); return 1; } @@ -326,7 +326,7 @@ static int astribank_uevent(struct device *dev, char **envp, int num_envp, char if(!dev) return -ENODEV; xbus = dev_to_xbus(dev); - DBG(GENERAL, "SYFS bus_id=%s xbus=%s\n", dev->bus_id, xbus->busname); + DBG(GENERAL, "SYFS bus_id=%s xbus=%s\n", dev_name(dev), xbus->busname); XBUS_VAR_BLOCK; envp[i] = NULL; return 0; @@ -348,7 +348,7 @@ static int astribank_uevent(struct device *dev, struct kobj_uevent_env *kenv) if(!dev) return -ENODEV; xbus = dev_to_xbus(dev); - DBG(GENERAL, "SYFS bus_id=%s xbus=%s\n", dev->bus_id, xbus->busname); + DBG(GENERAL, "SYFS bus_id=%s xbus=%s\n", dev_name(dev), xbus->busname); XBUS_VAR_BLOCK; return 0; } @@ -363,7 +363,7 @@ 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); + dev_name(&xbus->astribank), act); #if defined(OLD_HOTPLUG_SUPPORT_269) { @@ -649,7 +649,7 @@ static int xpd_match(struct device *dev, struct device_driver *driver) return 0; } XPD_DBG(DEVICES, xpd, "SYSFS MATCH: type=%d dev->bus_id = %s, driver->name = %s\n", - xpd->type, dev->bus_id, driver->name); + xpd->type, dev_name(dev), driver->name); return 1; } @@ -705,8 +705,8 @@ int xpd_device_register(xbus_t *xbus, xpd_t *xpd) XPD_DBG(DEVICES, xpd, "SYSFS\n"); dev->bus = &xpd_type; dev->parent = &xbus->astribank; - snprintf(dev->bus_id, BUS_ID_SIZE, "%02d:%1x:%1x", - xbus->num, xpd->addr.unit, xpd->addr.subunit); + dev_set_name(dev, "%02d:%1x:%1x", xbus->num, xpd->addr.unit, + xpd->addr.subunit); dev->driver_data = xpd; dev->release = xpd_release; ret = device_register(dev); @@ -763,7 +763,7 @@ int xbus_sysfs_create(xbus_t *xbus) XBUS_DBG(DEVICES, xbus, "\n"); astribank->bus = &toplevel_bus_type; astribank->parent = xbus->transport.transport_device; - snprintf(astribank->bus_id, BUS_ID_SIZE, "xbus-%02d", xbus->num); + dev_set_name(astribank, "xbus-%02d", xbus->num); astribank->driver_data = xbus; astribank->release = astribank_release; ret = device_register(astribank); diff --git a/kernel/xpp/xdefs.h b/kernel/xpp/xdefs.h index 1aadbe5..f3d5b58 100644 --- a/kernel/xpp/xdefs.h +++ b/kernel/xpp/xdefs.h @@ -143,6 +143,12 @@ typedef unsigned char byte; #define DRIVER_ATTR_READER(name,drv,buf) \ ssize_t name(struct device_driver *drv, char * buf) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) +#define dev_name(dev) (dev)->bus_id +#define dev_set_name(dev, format, ...) \ + snprintf((dev)->bus_id, BUS_ID_SIZE, format, ## __VA_ARGS__); +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) /* Also don't define this for later RHEL >= 5.2 . hex_asc is from the * same linux-2.6-net-infrastructure-updates-to-mac80211-iwl4965.patch -- cgit v1.2.3