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 /* 2.6.24 does not have the struct kobject with a name */
20 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
23 * kobject_set_name_vargs - Set the name of an kobject
24 * @kobj: struct kobject to set the name of
25 * @fmt: format string used to build the name
26 * @vargs: vargs to format the string.
29 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
32 const char *old_name = kobj->name;
35 if (kobj->name && !fmt)
38 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
42 /* ewww... some of these buggers have '/' in the name ... */
43 while ((s = strchr(kobj->name, '/')))
51 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
58 dev = container_of(kobj, struct device, kobj);
61 len = vsnprintf(NULL, 0, fmt, aq);
64 len = len < BUS_ID_SIZE ? (len + 1) : BUS_ID_SIZE;
66 vsnprintf(dev->bus_id, len, fmt, vargs);
72 * dev_set_name - set a device name
74 * @fmt: format string for the device's name
76 int dev_set_name(struct device *dev, const char *fmt, ...)
82 err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
86 EXPORT_SYMBOL_GPL(dev_set_name);