diff options
author | Shaun Ruffell <sruffell@digium.com> | 2011-01-03 18:27:05 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2011-01-03 18:27:05 +0000 |
commit | 736d228e663b23f0182816d5b1257f0de3f4baa8 (patch) | |
tree | 0305ff5172e1d234265729e5b360fc4c3124983f /drivers | |
parent | 3155b01c0324eadfbb99b910134dc4fae1f77209 (diff) |
dahdi: Introduce dahdi_kasprintf for pre 2.6.12 kernels.
kasprintf will be used in upcoming changes and it's not supported on
RHEL4 kernels. This change essentially backports it.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Kinsey Moore <kmoore@digium.com>
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9593 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dahdi/dahdi-base.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index e6f2136..a03cbc8 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -9058,5 +9058,34 @@ static void __exit dahdi_cleanup(void) #endif } +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12) +char *dahdi_kasprintf(gfp_t gfp, const char *fmt, ...) +{ + va_list ap; + char *p; + char *temp; + unsigned int len; + + temp = kmalloc(PAGE_SIZE, GFP_KERNEL); + if (!temp) + return NULL; + + va_start(ap, fmt); + len = vsnprintf(temp, PAGE_SIZE, fmt, ap); + va_end(ap); + + p = kzalloc(len + 1, gfp); + if (!p) { + kfree(temp); + return NULL; + } + + memcpy(p, temp, len + 1); + kfree(temp); + return p; +} +EXPORT_SYMBOL(dahdi_kasprintf); +#endif + module_init(dahdi_init); module_exit(dahdi_cleanup); |