wl1251: reduce eeprom read wait time
[pandora-wifi.git] / compat / compat-2.6.26.c
1 /*
2  * Copyright 2007-2010  Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
3  *
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.
7  *
8  * Compatibility file for Linux wireless for kernels 2.6.26.
9  *
10  * Copyright holders from ported work:
11  *
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.
15  */
16
17 #include <net/compat.h>
18
19 /* All things not in 2.6.25 */
20 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
21
22
23 /* 2.6.24 does not have the struct kobject with a name */
24 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25))
25
26 /**
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.
31  */
32 static
33 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
34                                   va_list vargs)
35 {
36         const char *old_name = kobj->name;
37         char *s;
38
39         if (kobj->name && !fmt)
40                 return 0;
41
42         kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
43         if (!kobj->name)
44                 return -ENOMEM;
45
46         /* ewww... some of these buggers have '/' in the name ... */
47         while ((s = strchr(kobj->name, '/')))
48                 s[0] = '!';
49
50         kfree(old_name);
51         return 0;
52 }
53 #else
54 static
55 int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
56                                   va_list vargs)
57 {
58         struct device *dev;
59         unsigned int len;
60         va_list aq;
61
62         dev = container_of(kobj, struct device, kobj);
63
64         va_copy(aq, vargs);
65         len = vsnprintf(NULL, 0, fmt, aq);
66         va_end(aq);
67
68         len = len < BUS_ID_SIZE ? (len + 1) : BUS_ID_SIZE;
69
70         vsnprintf(dev->bus_id, len, fmt, vargs);
71         return 0;
72 }
73 #endif
74
75 /**
76  * dev_set_name - set a device name
77  * @dev: device
78  * @fmt: format string for the device's name
79  */
80 int dev_set_name(struct device *dev, const char *fmt, ...)
81 {
82         va_list vargs;
83         int err;
84
85         va_start(vargs, fmt);
86         err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
87         va_end(vargs);
88         return err;
89 }
90 EXPORT_SYMBOL_GPL(dev_set_name);
91
92 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
93