diff options
author | Tim Gardner <timg@tpi.com> | 2008-07-11 10:16:14 -0600 |
---|---|---|
committer | Luis R. Rodriguez <lrodriguez@atheros.com> | 2008-07-11 09:45:35 -0700 |
commit | 6be32e902f8a303df0b23fb23f1805134656feb3 (patch) | |
tree | 459225fe860ccbe753ed9a25dd1508322284856a | |
parent | ae8988d4c647042bc23474bd21b7fbb99747bab0 (diff) | |
download | compat-wireless-2.6-old-6be32e902f8a303df0b23fb23f1805134656feb3.tar.gz |
Fix mac80211_hwsim build failure against wireless-testing master-2008-07-09
Added device_create_drvdata() and friends to support mac80211_hwsim for
kernels older then 2.6.26.
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
-rw-r--r-- | compat/compat.c | 99 | ||||
-rw-r--r-- | compat/compat.h | 9 |
2 files changed, 108 insertions, 0 deletions
diff --git a/compat/compat.c b/compat/compat.c index 44cca2f..c4c0ed3 100644 --- a/compat/compat.c +++ b/compat/compat.c @@ -640,6 +640,105 @@ int pci_try_set_mwi(struct pci_dev *dev) EXPORT_SYMBOL(pci_try_set_mwi); #endif +/* All things not in 2.6.25 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) +/** + * device_create_vargs - creates a device and registers it with sysfs + * @class: pointer to the struct class that this device should be registered to + * @parent: pointer to the parent struct device of this new device, if any + * @devt: the dev_t for the char device to be added + * @drvdata: the data to be added to the device for callbacks + * @fmt: string for the device's name + * @args: va_list for the device's name + * + * This function can be used by char device classes. A struct device + * will be created in sysfs, registered to the specified class. + * + * A "dev" file will be created, showing the dev_t for the device, if + * the dev_t is not 0,0. + * If a pointer to a parent struct device is passed in, the newly created + * struct device will be a child of that device in sysfs. + * The pointer to the struct device will be returned from the call. + * Any further sysfs files that might be required can be created using this + * pointer. + * + * Note: the struct class passed to this function must have previously + * been created with a call to class_create(). + */ +struct device *device_create_vargs(struct class *class, struct device *parent, + dev_t devt, void *drvdata, const char *fmt, + va_list args) +{ + struct device *dev = NULL; + int retval = -ENODEV; + + if (class == NULL || IS_ERR(class)) + goto error; + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) { + retval = -ENOMEM; + goto error; + } + + dev->devt = devt; + dev->class = class; + dev->parent = parent; + dev->release = device_create_release; + dev_set_drvdata(dev, drvdata); + + vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); + retval = device_register(dev); + if (retval) + goto error; + + return dev; + +error: + kfree(dev); + return ERR_PTR(retval); +} +EXPORT_SYMBOL_GPL(device_create_vargs); + +/** + * device_create_drvdata - creates a device and registers it with sysfs + * @class: pointer to the struct class that this device should be registered to + * @parent: pointer to the parent struct device of this new device, if any + * @devt: the dev_t for the char device to be added + * @drvdata: the data to be added to the device for callbacks + * @fmt: string for the device's name + * + * This function can be used by char device classes. A struct device + * will be created in sysfs, registered to the specified class. + * + * A "dev" file will be created, showing the dev_t for the device, if + * the dev_t is not 0,0. + * If a pointer to a parent struct device is passed in, the newly created + * struct device will be a child of that device in sysfs. + * The pointer to the struct device will be returned from the call. + * Any further sysfs files that might be required can be created using this + * pointer. + * + * Note: the struct class passed to this function must have previously + * been created with a call to class_create(). + */ +struct device *device_create_drvdata(struct class *class, + struct device *parent, + dev_t devt, + void *drvdata, + const char *fmt, ...) +{ + va_list vargs; + struct device *dev; + + va_start(vargs, fmt); + dev = device_create_vargs(class, parent, devt, drvdata, fmt, vargs); + va_end(vargs); + return dev; +} +EXPORT_SYMBOL_GPL(device_create_drvdata); +#endif + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) /* rfkill notification chain */ diff --git a/compat/compat.h b/compat/compat.h index 212c461..ac1e1c0 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -477,6 +477,15 @@ static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) +/* from include/linux/device.h */ +/* device_create_drvdata() is new */ +extern struct device *device_create_drvdata(struct class *cls, + struct device *parent, + dev_t devt, + void *drvdata, + const char *fmt, ...) +__attribute__((format(printf, 5, 6))); + /* This is from include/linux/list.h */ /** |