2 * Copyright 2007-2010 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compatibility file for Linux wireless for kernels 2.6.26.
10 * Copyright holders from ported work:
12 * Copyright (c) 2002-2003 Patrick Mochel <mochel@osdl.org>
13 * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com>
14 * Copyright (c) 2006-2007 Novell Inc.
17 #include <net/compat.h>
19 /* All things not in 2.6.25 */
20 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
23 /* 2.6.24 does not have the struct kobject with a name */
24 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
27 * kobject_set_name_vargs - Set the name of an kobject
28 * @kobj: struct kobject to set the name of
29 * @fmt: format string used to build the name
30 * @vargs: vargs to format the string.
33 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
36 const char *old_name = kobj->name;
39 if (kobj->name && !fmt)
42 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
46 /* ewww... some of these buggers have '/' in the name ... */
47 while ((s = strchr(kobj->name, '/')))
55 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
62 dev = container_of(kobj, struct device, kobj);
65 len = vsnprintf(NULL, 0, fmt, aq);
68 len = len < BUS_ID_SIZE ? (len + 1) : BUS_ID_SIZE;
70 vsnprintf(dev->bus_id, len, fmt, vargs);
76 * dev_set_name - set a device name
78 * @fmt: format string for the device's name
80 int dev_set_name(struct device *dev, const char *fmt, ...)
86 err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
90 EXPORT_SYMBOL_GPL(dev_set_name);
92 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */