Subversion Repositories Kolibri OS

Rev

Rev 3391 | Rev 5056 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3391 Rev 4065
Line 46... Line 46...
46
	struct idr_layer __rcu	*hint;	/* the last layer allocated from */
46
	struct idr_layer __rcu	*hint;	/* the last layer allocated from */
47
	struct idr_layer __rcu *top;
47
	struct idr_layer __rcu *top;
48
	struct idr_layer *id_free;
48
	struct idr_layer *id_free;
49
	int			layers;	/* only valid w/o concurrent changes */
49
	int			layers;	/* only valid w/o concurrent changes */
50
	int		  id_free_cnt;
50
	int		  id_free_cnt;
-
 
51
	int			cur;	/* current pos for cyclic allocation */
51
	spinlock_t		lock;
52
	spinlock_t		lock;
52
};
53
};
Line 53... Line 54...
53
 
54
 
54
#define IDR_INIT(name)						\
55
#define IDR_INIT(name)						\
Line 77... Line 78...
77
/*
78
/*
78
 * This is what we export.
79
 * This is what we export.
79
 */
80
 */
Line 80... Line 81...
80
 
81
 
81
void *idr_find_slowpath(struct idr *idp, int id);
-
 
82
int idr_pre_get(struct idr *idp, gfp_t gfp_mask);
-
 
83
int idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
82
void *idr_find_slowpath(struct idr *idp, int id);
84
void idr_preload(gfp_t gfp_mask);
83
void idr_preload(gfp_t gfp_mask);
-
 
84
int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask);
85
int idr_alloc(struct idr *idp, void *ptr, int start, int end, gfp_t gfp_mask);
85
int idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end, gfp_t gfp_mask);
86
int idr_for_each(struct idr *idp,
86
int idr_for_each(struct idr *idp,
87
		 int (*fn)(int id, void *p, void *data), void *data);
87
		 int (*fn)(int id, void *p, void *data), void *data);
88
void *idr_get_next(struct idr *idp, int *nextid);
88
void *idr_get_next(struct idr *idp, int *nextid);
89
void *idr_replace(struct idr *idp, void *ptr, int id);
89
void *idr_replace(struct idr *idp, void *ptr, int id);
Line 103... Line 103...
103
//	preempt_enable();
103
//	preempt_enable();
104
}
104
}
Line 105... Line 105...
105
 
105
 
106
/**
106
/**
107
 * idr_find - return pointer for given id
107
 * idr_find - return pointer for given id
108
 * @idp: idr handle
108
 * @idr: idr handle
109
 * @id: lookup key
109
 * @id: lookup key
110
 *
110
 *
111
 * Return the pointer given the id it has been registered with.  A %NULL
111
 * Return the pointer given the id it has been registered with.  A %NULL
112
 * return indicates that @id is not valid or you passed %NULL in
112
 * return indicates that @id is not valid or you passed %NULL in
Line 124... Line 124...
124
 
124
 
125
	return idr_find_slowpath(idr, id);
125
	return idr_find_slowpath(idr, id);
Line 126... Line 126...
126
}
126
}
-
 
127
 
-
 
128
/**
-
 
129
 * idr_for_each_entry - iterate over an idr's elements of a given type
-
 
130
 * @idp:     idr handle
-
 
131
 * @entry:   the type * to use as cursor
-
 
132
 * @id:      id entry's key
-
 
133
 *
-
 
134
 * @entry and @id do not need to be initialized before the loop, and
-
 
135
 * after normal terminatinon @entry is left with the value NULL.  This
-
 
136
 * is convenient for a "not found" value.
-
 
137
 */
-
 
138
#define idr_for_each_entry(idp, entry, id)			\
-
 
139
	for (id = 0; ((entry) = idr_get_next(idp, &(id))) != NULL; ++id)
-
 
140
 
-
 
141
/*
-
 
142
 * Don't use the following functions.  These exist only to suppress
-
 
143
 * deprecated warnings on EXPORT_SYMBOL()s.
-
 
144
 */
-
 
145
int __idr_pre_get(struct idr *idp, gfp_t gfp_mask);
-
 
146
int __idr_get_new_above(struct idr *idp, void *ptr, int starting_id, int *id);
-
 
147
void __idr_remove_all(struct idr *idp);
-
 
148
 
-
 
149
/**
-
 
150
 * idr_pre_get - reserve resources for idr allocation
-
 
151
 * @idp:	idr handle
-
 
152
 * @gfp_mask:	memory allocation flags
-
 
153
 *
-
 
154
 * Part of old alloc interface.  This is going away.  Use
-
 
155
 * idr_preload[_end]() and idr_alloc() instead.
-
 
156
 */
-
 
157
static inline int __deprecated idr_pre_get(struct idr *idp, gfp_t gfp_mask)
-
 
158
{
-
 
159
	return __idr_pre_get(idp, gfp_mask);
-
 
160
}
127
 
161
 
128
/**
162
/**
129
 * idr_get_new - allocate new idr entry
163
 * idr_get_new_above - allocate new idr entry above or equal to a start id
-
 
164
 * @idp: idr handle
130
 * @idp: idr handle
165
 * @ptr: pointer you want associated with the id
131
 * @ptr: pointer you want associated with the id
166
 * @starting_id: id to start search at
132
 * @id: pointer to the allocated handle
167
 * @id: pointer to the allocated handle
-
 
168
 *
133
 *
169
 * Part of old alloc interface.  This is going away.  Use
134
 * Simple wrapper around idr_get_new_above() w/ @starting_id of zero.
170
 * idr_preload[_end]() and idr_alloc() instead.
-
 
171
 */
135
 */
172
static inline int __deprecated idr_get_new_above(struct idr *idp, void *ptr,
136
static inline int idr_get_new(struct idr *idp, void *ptr, int *id)
173
						 int starting_id, int *id)
137
{
174
{
Line 138... Line 175...
138
	return idr_get_new_above(idp, ptr, 0, id);
175
	return __idr_get_new_above(idp, ptr, starting_id, id);
139
}
176
}
140
 
177
 
141
/**
178
/**
142
 * idr_for_each_entry - iterate over an idr's elements of a given type
179
 * idr_get_new - allocate new idr entry
-
 
180
 * @idp:     idr handle
-
 
181
 * @ptr: pointer you want associated with the id
-
 
182
 * @id: pointer to the allocated handle
143
 * @idp:     idr handle
183
 *
144
 * @entry:   the type * to use as cursor
-
 
145
 * @id:      id entry's key
-
 
146
 */
-
 
147
#define idr_for_each_entry(idp, entry, id)				\
184
 * Part of old alloc interface.  This is going away.  Use
148
	for (id = 0, entry = (typeof(entry))idr_get_next((idp), &(id)); \
185
 * idr_preload[_end]() and idr_alloc() instead.
149
	     entry != NULL;                                             \
186
 */
-
 
187
static inline int __deprecated idr_get_new(struct idr *idp, void *ptr, int *id)
Line 150... Line 188...
150
	     ++id, entry = (typeof(entry))idr_get_next((idp), &(id)))
188
{
151
 
189
	return __idr_get_new_above(idp, ptr, 0, id);
152
void __idr_remove_all(struct idr *idp);	/* don't use */
190
}
153
 
191
 
Line 191... Line 229...
191
int ida_get_new_above(struct ida *ida, int starting_id, int *p_id);
229
int ida_get_new_above(struct ida *ida, int starting_id, int *p_id);
192
void ida_remove(struct ida *ida, int id);
230
void ida_remove(struct ida *ida, int id);
193
void ida_destroy(struct ida *ida);
231
void ida_destroy(struct ida *ida);
194
void ida_init(struct ida *ida);
232
void ida_init(struct ida *ida);
Line -... Line 233...
-
 
233
 
-
 
234
int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
195
 
235
		   gfp_t gfp_mask);
Line -... Line 236...
-
 
236
void ida_simple_remove(struct ida *ida, unsigned int id);
-
 
237
 
-
 
238
/**
-
 
239
 * ida_get_new - allocate new ID
-
 
240
 * @ida:	idr handle
-
 
241
 * @p_id:	pointer to the allocated handle
-
 
242
 *
-
 
243
 * Simple wrapper around ida_get_new_above() w/ @starting_id of zero.
-
 
244
 */
-
 
245
static inline int ida_get_new(struct ida *ida, int *p_id)
-
 
246
{
Line -... Line 247...
-
 
247
	return ida_get_new_above(ida, 0, p_id);
Line 196... Line 248...
196
void __init idr_init_cache(void);
248
}