Firmware for MNT ZZ9000 graphics and ARM coprocessor card for Amiga computers.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list.h 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. #ifndef _LINUX_LIST_H
  2. #define _LINUX_LIST_H
  3. #include <linux/stddef.h>
  4. #ifndef ARCH_HAS_PREFETCH
  5. #define ARCH_HAS_PREFETCH
  6. static inline void prefetch(const void *x) {;}
  7. #endif
  8. /*
  9. * Simple doubly linked list implementation.
  10. *
  11. * Some of the internal functions ("__xxx") are useful when
  12. * manipulating whole lists rather than single entries, as
  13. * sometimes we already know the next/prev entries and we can
  14. * generate better code by using them directly rather than
  15. * using the generic single-entry routines.
  16. */
  17. #define LIST_POISON1 ((void *) 0x0)
  18. #define LIST_POISON2 ((void *) 0x0)
  19. #define min_t(type, x, y) ({ \
  20. type __min1 = (x); \
  21. type __min2 = (y); \
  22. __min1 < __min2 ? __min1: __min2; })
  23. /**
  24. * container_of - cast a member of a structure out to the containing structure
  25. * @ptr: the pointer to the member.
  26. * @type: the type of the container struct this is embedded in.
  27. * @member: the name of the member within the struct.
  28. *
  29. */
  30. #define container_of(ptr, type, member) ({ \
  31. const typeof( ((type *)0)->member ) *__mptr = (ptr); \
  32. (type *)( (char *)__mptr - offsetof(type,member) );})
  33. struct list_head {
  34. struct list_head *next, *prev;
  35. };
  36. #define LIST_HEAD_INIT(name) { &(name), &(name) }
  37. #define LIST_HEAD(name) \
  38. struct list_head name = LIST_HEAD_INIT(name)
  39. static inline void INIT_LIST_HEAD(struct list_head *list)
  40. {
  41. list->next = list;
  42. list->prev = list;
  43. }
  44. /*
  45. * Insert a new entry between two known consecutive entries.
  46. *
  47. * This is only for internal list manipulation where we know
  48. * the prev/next entries already!
  49. */
  50. static inline void __list_add(struct list_head *new,
  51. struct list_head *prev,
  52. struct list_head *next)
  53. {
  54. next->prev = new;
  55. new->next = next;
  56. new->prev = prev;
  57. prev->next = new;
  58. }
  59. /**
  60. * list_add - add a new entry
  61. * @new: new entry to be added
  62. * @head: list head to add it after
  63. *
  64. * Insert a new entry after the specified head.
  65. * This is good for implementing stacks.
  66. */
  67. static inline void list_add(struct list_head *new, struct list_head *head)
  68. {
  69. __list_add(new, head, head->next);
  70. }
  71. /**
  72. * list_add_tail - add a new entry
  73. * @new: new entry to be added
  74. * @head: list head to add it before
  75. *
  76. * Insert a new entry before the specified head.
  77. * This is useful for implementing queues.
  78. */
  79. static inline void list_add_tail(struct list_head *new, struct list_head *head)
  80. {
  81. __list_add(new, head->prev, head);
  82. }
  83. /*
  84. * Delete a list entry by making the prev/next entries
  85. * point to each other.
  86. *
  87. * This is only for internal list manipulation where we know
  88. * the prev/next entries already!
  89. */
  90. static inline void __list_del(struct list_head *prev, struct list_head *next)
  91. {
  92. next->prev = prev;
  93. prev->next = next;
  94. }
  95. /**
  96. * list_del - deletes entry from list.
  97. * @entry: the element to delete from the list.
  98. * Note: list_empty() on entry does not return true after this, the entry is
  99. * in an undefined state.
  100. */
  101. static inline void list_del(struct list_head *entry)
  102. {
  103. __list_del(entry->prev, entry->next);
  104. entry->next = LIST_POISON1;
  105. entry->prev = LIST_POISON2;
  106. }
  107. /**
  108. * list_replace - replace old entry by new one
  109. * @old : the element to be replaced
  110. * @new : the new element to insert
  111. *
  112. * If @old was empty, it will be overwritten.
  113. */
  114. static inline void list_replace(struct list_head *old,
  115. struct list_head *new)
  116. {
  117. new->next = old->next;
  118. new->next->prev = new;
  119. new->prev = old->prev;
  120. new->prev->next = new;
  121. }
  122. static inline void list_replace_init(struct list_head *old,
  123. struct list_head *new)
  124. {
  125. list_replace(old, new);
  126. INIT_LIST_HEAD(old);
  127. }
  128. /**
  129. * list_del_init - deletes entry from list and reinitialize it.
  130. * @entry: the element to delete from the list.
  131. */
  132. static inline void list_del_init(struct list_head *entry)
  133. {
  134. __list_del(entry->prev, entry->next);
  135. INIT_LIST_HEAD(entry);
  136. }
  137. /**
  138. * list_move - delete from one list and add as another's head
  139. * @list: the entry to move
  140. * @head: the head that will precede our entry
  141. */
  142. static inline void list_move(struct list_head *list, struct list_head *head)
  143. {
  144. __list_del(list->prev, list->next);
  145. list_add(list, head);
  146. }
  147. /**
  148. * list_move_tail - delete from one list and add as another's tail
  149. * @list: the entry to move
  150. * @head: the head that will follow our entry
  151. */
  152. static inline void list_move_tail(struct list_head *list,
  153. struct list_head *head)
  154. {
  155. __list_del(list->prev, list->next);
  156. list_add_tail(list, head);
  157. }
  158. /**
  159. * list_is_last - tests whether @list is the last entry in list @head
  160. * @list: the entry to test
  161. * @head: the head of the list
  162. */
  163. static inline int list_is_last(const struct list_head *list,
  164. const struct list_head *head)
  165. {
  166. return list->next == head;
  167. }
  168. /**
  169. * list_empty - tests whether a list is empty
  170. * @head: the list to test.
  171. */
  172. static inline int list_empty(const struct list_head *head)
  173. {
  174. return head->next == head;
  175. }
  176. /**
  177. * list_empty_careful - tests whether a list is empty and not being modified
  178. * @head: the list to test
  179. *
  180. * Description:
  181. * tests whether a list is empty _and_ checks that no other CPU might be
  182. * in the process of modifying either member (next or prev)
  183. *
  184. * NOTE: using list_empty_careful() without synchronization
  185. * can only be safe if the only activity that can happen
  186. * to the list entry is list_del_init(). Eg. it cannot be used
  187. * if another CPU could re-list_add() it.
  188. */
  189. static inline int list_empty_careful(const struct list_head *head)
  190. {
  191. struct list_head *next = head->next;
  192. return (next == head) && (next == head->prev);
  193. }
  194. /**
  195. * list_is_singular - tests whether a list has just one entry.
  196. * @head: the list to test.
  197. */
  198. static inline int list_is_singular(const struct list_head *head)
  199. {
  200. return !list_empty(head) && (head->next == head->prev);
  201. }
  202. static inline void __list_cut_position(struct list_head *list,
  203. struct list_head *head, struct list_head *entry)
  204. {
  205. struct list_head *new_first = entry->next;
  206. list->next = head->next;
  207. list->next->prev = list;
  208. list->prev = entry;
  209. entry->next = list;
  210. head->next = new_first;
  211. new_first->prev = head;
  212. }
  213. /**
  214. * list_cut_position - cut a list into two
  215. * @list: a new list to add all removed entries
  216. * @head: a list with entries
  217. * @entry: an entry within head, could be the head itself
  218. * and if so we won't cut the list
  219. *
  220. * This helper moves the initial part of @head, up to and
  221. * including @entry, from @head to @list. You should
  222. * pass on @entry an element you know is on @head. @list
  223. * should be an empty list or a list you do not care about
  224. * losing its data.
  225. *
  226. */
  227. static inline void list_cut_position(struct list_head *list,
  228. struct list_head *head, struct list_head *entry)
  229. {
  230. if (list_empty(head))
  231. return;
  232. if (list_is_singular(head) &&
  233. (head->next != entry && head != entry))
  234. return;
  235. if (entry == head)
  236. INIT_LIST_HEAD(list);
  237. else
  238. __list_cut_position(list, head, entry);
  239. }
  240. static inline void __list_splice(const struct list_head *list,
  241. struct list_head *prev,
  242. struct list_head *next)
  243. {
  244. struct list_head *first = list->next;
  245. struct list_head *last = list->prev;
  246. first->prev = prev;
  247. prev->next = first;
  248. last->next = next;
  249. next->prev = last;
  250. }
  251. /**
  252. * list_splice - join two lists, this is designed for stacks
  253. * @list: the new list to add.
  254. * @head: the place to add it in the first list.
  255. */
  256. static inline void list_splice(const struct list_head *list,
  257. struct list_head *head)
  258. {
  259. if (!list_empty(list))
  260. __list_splice(list, head, head->next);
  261. }
  262. /**
  263. * list_splice_tail - join two lists, each list being a queue
  264. * @list: the new list to add.
  265. * @head: the place to add it in the first list.
  266. */
  267. static inline void list_splice_tail(struct list_head *list,
  268. struct list_head *head)
  269. {
  270. if (!list_empty(list))
  271. __list_splice(list, head->prev, head);
  272. }
  273. /**
  274. * list_splice_init - join two lists and reinitialise the emptied list.
  275. * @list: the new list to add.
  276. * @head: the place to add it in the first list.
  277. *
  278. * The list at @list is reinitialised
  279. */
  280. static inline void list_splice_init(struct list_head *list,
  281. struct list_head *head)
  282. {
  283. if (!list_empty(list)) {
  284. __list_splice(list, head, head->next);
  285. INIT_LIST_HEAD(list);
  286. }
  287. }
  288. /**
  289. * list_splice_tail_init - join two lists and reinitialise the emptied list
  290. * @list: the new list to add.
  291. * @head: the place to add it in the first list.
  292. *
  293. * Each of the lists is a queue.
  294. * The list at @list is reinitialised
  295. */
  296. static inline void list_splice_tail_init(struct list_head *list,
  297. struct list_head *head)
  298. {
  299. if (!list_empty(list)) {
  300. __list_splice(list, head->prev, head);
  301. INIT_LIST_HEAD(list);
  302. }
  303. }
  304. /**
  305. * list_entry - get the struct for this entry
  306. * @ptr: the &struct list_head pointer.
  307. * @type: the type of the struct this is embedded in.
  308. * @member: the name of the list_struct within the struct.
  309. */
  310. #define list_entry(ptr, type, member) \
  311. container_of(ptr, type, member)
  312. /**
  313. * list_first_entry - get the first element from a list
  314. * @ptr: the list head to take the element from.
  315. * @type: the type of the struct this is embedded in.
  316. * @member: the name of the list_struct within the struct.
  317. *
  318. * Note, that list is expected to be not empty.
  319. */
  320. #define list_first_entry(ptr, type, member) \
  321. list_entry((ptr)->next, type, member)
  322. /**
  323. * list_last_entry - get the last element from a list
  324. * @ptr: the list head to take the element from.
  325. * @type: the type of the struct this is embedded in.
  326. * @member: the name of the list_struct within the struct.
  327. *
  328. * Note, that list is expected to be not empty.
  329. */
  330. #define list_last_entry(ptr, type, member) \
  331. list_entry((ptr)->prev, type, member)
  332. /**
  333. * list_for_each - iterate over a list
  334. * @pos: the &struct list_head to use as a loop cursor.
  335. * @head: the head for your list.
  336. */
  337. #define list_for_each(pos, head) \
  338. for (pos = (head)->next; prefetch(pos->next), pos != (head); \
  339. pos = pos->next)
  340. /**
  341. * __list_for_each - iterate over a list
  342. * @pos: the &struct list_head to use as a loop cursor.
  343. * @head: the head for your list.
  344. *
  345. * This variant differs from list_for_each() in that it's the
  346. * simplest possible list iteration code, no prefetching is done.
  347. * Use this for code that knows the list to be very short (empty
  348. * or 1 entry) most of the time.
  349. */
  350. #define __list_for_each(pos, head) \
  351. for (pos = (head)->next; pos != (head); pos = pos->next)
  352. /**
  353. * list_for_each_prev - iterate over a list backwards
  354. * @pos: the &struct list_head to use as a loop cursor.
  355. * @head: the head for your list.
  356. */
  357. #define list_for_each_prev(pos, head) \
  358. for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
  359. pos = pos->prev)
  360. /**
  361. * list_for_each_safe - iterate over a list safe against removal of list entry
  362. * @pos: the &struct list_head to use as a loop cursor.
  363. * @n: another &struct list_head to use as temporary storage
  364. * @head: the head for your list.
  365. */
  366. #define list_for_each_safe(pos, n, head) \
  367. for (pos = (head)->next, n = pos->next; pos != (head); \
  368. pos = n, n = pos->next)
  369. /**
  370. * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
  371. * @pos: the &struct list_head to use as a loop cursor.
  372. * @n: another &struct list_head to use as temporary storage
  373. * @head: the head for your list.
  374. */
  375. #define list_for_each_prev_safe(pos, n, head) \
  376. for (pos = (head)->prev, n = pos->prev; \
  377. prefetch(pos->prev), pos != (head); \
  378. pos = n, n = pos->prev)
  379. /**
  380. * list_for_each_entry - iterate over list of given type
  381. * @pos: the type * to use as a loop cursor.
  382. * @head: the head for your list.
  383. * @member: the name of the list_struct within the struct.
  384. */
  385. #define list_for_each_entry(pos, head, member) \
  386. for (pos = list_entry((head)->next, typeof(*pos), member); \
  387. prefetch(pos->member.next), &pos->member != (head); \
  388. pos = list_entry(pos->member.next, typeof(*pos), member))
  389. /**
  390. * list_for_each_entry_reverse - iterate backwards over list of given type.
  391. * @pos: the type * to use as a loop cursor.
  392. * @head: the head for your list.
  393. * @member: the name of the list_struct within the struct.
  394. */
  395. #define list_for_each_entry_reverse(pos, head, member) \
  396. for (pos = list_entry((head)->prev, typeof(*pos), member); \
  397. prefetch(pos->member.prev), &pos->member != (head); \
  398. pos = list_entry(pos->member.prev, typeof(*pos), member))
  399. /**
  400. * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
  401. * @pos: the type * to use as a start point
  402. * @head: the head of the list
  403. * @member: the name of the list_struct within the struct.
  404. *
  405. * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
  406. */
  407. #define list_prepare_entry(pos, head, member) \
  408. ((pos) ? : list_entry(head, typeof(*pos), member))
  409. /**
  410. * list_for_each_entry_continue - continue iteration over list of given type
  411. * @pos: the type * to use as a loop cursor.
  412. * @head: the head for your list.
  413. * @member: the name of the list_struct within the struct.
  414. *
  415. * Continue to iterate over list of given type, continuing after
  416. * the current position.
  417. */
  418. #define list_for_each_entry_continue(pos, head, member) \
  419. for (pos = list_entry(pos->member.next, typeof(*pos), member); \
  420. prefetch(pos->member.next), &pos->member != (head); \
  421. pos = list_entry(pos->member.next, typeof(*pos), member))
  422. /**
  423. * list_for_each_entry_continue_reverse - iterate backwards from the given point
  424. * @pos: the type * to use as a loop cursor.
  425. * @head: the head for your list.
  426. * @member: the name of the list_struct within the struct.
  427. *
  428. * Start to iterate over list of given type backwards, continuing after
  429. * the current position.
  430. */
  431. #define list_for_each_entry_continue_reverse(pos, head, member) \
  432. for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
  433. prefetch(pos->member.prev), &pos->member != (head); \
  434. pos = list_entry(pos->member.prev, typeof(*pos), member))
  435. /**
  436. * list_for_each_entry_from - iterate over list of given type from the current point
  437. * @pos: the type * to use as a loop cursor.
  438. * @head: the head for your list.
  439. * @member: the name of the list_struct within the struct.
  440. *
  441. * Iterate over list of given type, continuing from current position.
  442. */
  443. #define list_for_each_entry_from(pos, head, member) \
  444. for (; prefetch(pos->member.next), &pos->member != (head); \
  445. pos = list_entry(pos->member.next, typeof(*pos), member))
  446. /**
  447. * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  448. * @pos: the type * to use as a loop cursor.
  449. * @n: another type * to use as temporary storage
  450. * @head: the head for your list.
  451. * @member: the name of the list_struct within the struct.
  452. */
  453. #define list_for_each_entry_safe(pos, n, head, member) \
  454. for (pos = list_entry((head)->next, typeof(*pos), member), \
  455. n = list_entry(pos->member.next, typeof(*pos), member); \
  456. &pos->member != (head); \
  457. pos = n, n = list_entry(n->member.next, typeof(*n), member))
  458. /**
  459. * list_for_each_entry_safe_continue
  460. * @pos: the type * to use as a loop cursor.
  461. * @n: another type * to use as temporary storage
  462. * @head: the head for your list.
  463. * @member: the name of the list_struct within the struct.
  464. *
  465. * Iterate over list of given type, continuing after current point,
  466. * safe against removal of list entry.
  467. */
  468. #define list_for_each_entry_safe_continue(pos, n, head, member) \
  469. for (pos = list_entry(pos->member.next, typeof(*pos), member), \
  470. n = list_entry(pos->member.next, typeof(*pos), member); \
  471. &pos->member != (head); \
  472. pos = n, n = list_entry(n->member.next, typeof(*n), member))
  473. /**
  474. * list_for_each_entry_safe_from
  475. * @pos: the type * to use as a loop cursor.
  476. * @n: another type * to use as temporary storage
  477. * @head: the head for your list.
  478. * @member: the name of the list_struct within the struct.
  479. *
  480. * Iterate over list of given type from current point, safe against
  481. * removal of list entry.
  482. */
  483. #define list_for_each_entry_safe_from(pos, n, head, member) \
  484. for (n = list_entry(pos->member.next, typeof(*pos), member); \
  485. &pos->member != (head); \
  486. pos = n, n = list_entry(n->member.next, typeof(*n), member))
  487. /**
  488. * list_for_each_entry_safe_reverse
  489. * @pos: the type * to use as a loop cursor.
  490. * @n: another type * to use as temporary storage
  491. * @head: the head for your list.
  492. * @member: the name of the list_struct within the struct.
  493. *
  494. * Iterate backwards over list of given type, safe against removal
  495. * of list entry.
  496. */
  497. #define list_for_each_entry_safe_reverse(pos, n, head, member) \
  498. for (pos = list_entry((head)->prev, typeof(*pos), member), \
  499. n = list_entry(pos->member.prev, typeof(*pos), member); \
  500. &pos->member != (head); \
  501. pos = n, n = list_entry(n->member.prev, typeof(*n), member))
  502. /*
  503. * Double linked lists with a single pointer list head.
  504. * Mostly useful for hash tables where the two pointer list head is
  505. * too wasteful.
  506. * You lose the ability to access the tail in O(1).
  507. */
  508. struct hlist_head {
  509. struct hlist_node *first;
  510. };
  511. struct hlist_node {
  512. struct hlist_node *next, **pprev;
  513. };
  514. #define HLIST_HEAD_INIT { .first = NULL }
  515. #define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
  516. #define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
  517. static inline void INIT_HLIST_NODE(struct hlist_node *h)
  518. {
  519. h->next = NULL;
  520. h->pprev = NULL;
  521. }
  522. static inline int hlist_unhashed(const struct hlist_node *h)
  523. {
  524. return !h->pprev;
  525. }
  526. static inline int hlist_empty(const struct hlist_head *h)
  527. {
  528. return !h->first;
  529. }
  530. static inline void __hlist_del(struct hlist_node *n)
  531. {
  532. struct hlist_node *next = n->next;
  533. struct hlist_node **pprev = n->pprev;
  534. *pprev = next;
  535. if (next)
  536. next->pprev = pprev;
  537. }
  538. static inline void hlist_del(struct hlist_node *n)
  539. {
  540. __hlist_del(n);
  541. n->next = LIST_POISON1;
  542. n->pprev = LIST_POISON2;
  543. }
  544. static inline void hlist_del_init(struct hlist_node *n)
  545. {
  546. if (!hlist_unhashed(n)) {
  547. __hlist_del(n);
  548. INIT_HLIST_NODE(n);
  549. }
  550. }
  551. static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
  552. {
  553. struct hlist_node *first = h->first;
  554. n->next = first;
  555. if (first)
  556. first->pprev = &n->next;
  557. h->first = n;
  558. n->pprev = &h->first;
  559. }
  560. /* next must be != NULL */
  561. static inline void hlist_add_before(struct hlist_node *n,
  562. struct hlist_node *next)
  563. {
  564. n->pprev = next->pprev;
  565. n->next = next;
  566. next->pprev = &n->next;
  567. *(n->pprev) = n;
  568. }
  569. static inline void hlist_add_after(struct hlist_node *n,
  570. struct hlist_node *next)
  571. {
  572. next->next = n->next;
  573. n->next = next;
  574. next->pprev = &n->next;
  575. if(next->next)
  576. next->next->pprev = &next->next;
  577. }
  578. #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
  579. #define hlist_for_each(pos, head) \
  580. for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
  581. pos = pos->next)
  582. #define hlist_for_each_safe(pos, n, head) \
  583. for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
  584. pos = n)
  585. /**
  586. * hlist_for_each_entry - iterate over list of given type
  587. * @tpos: the type * to use as a loop cursor.
  588. * @pos: the &struct hlist_node to use as a loop cursor.
  589. * @head: the head for your list.
  590. * @member: the name of the hlist_node within the struct.
  591. */
  592. #define hlist_for_each_entry(tpos, pos, head, member) \
  593. for (pos = (head)->first; \
  594. pos && ({ prefetch(pos->next); 1;}) && \
  595. ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  596. pos = pos->next)
  597. /**
  598. * hlist_for_each_entry_continue - iterate over a hlist continuing after current point
  599. * @tpos: the type * to use as a loop cursor.
  600. * @pos: the &struct hlist_node to use as a loop cursor.
  601. * @member: the name of the hlist_node within the struct.
  602. */
  603. #define hlist_for_each_entry_continue(tpos, pos, member) \
  604. for (pos = (pos)->next; \
  605. pos && ({ prefetch(pos->next); 1;}) && \
  606. ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  607. pos = pos->next)
  608. /**
  609. * hlist_for_each_entry_from - iterate over a hlist continuing from current point
  610. * @tpos: the type * to use as a loop cursor.
  611. * @pos: the &struct hlist_node to use as a loop cursor.
  612. * @member: the name of the hlist_node within the struct.
  613. */
  614. #define hlist_for_each_entry_from(tpos, pos, member) \
  615. for (; pos && ({ prefetch(pos->next); 1;}) && \
  616. ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  617. pos = pos->next)
  618. /**
  619. * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
  620. * @tpos: the type * to use as a loop cursor.
  621. * @pos: the &struct hlist_node to use as a loop cursor.
  622. * @n: another &struct hlist_node to use as temporary storage
  623. * @head: the head for your list.
  624. * @member: the name of the hlist_node within the struct.
  625. */
  626. #define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
  627. for (pos = (head)->first; \
  628. pos && ({ n = pos->next; 1; }) && \
  629. ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
  630. pos = n)
  631. #endif