From: Vladimir Sokolovsky Date: Sun, 3 Jun 2012 10:05:27 +0000 (+0300) Subject: compat: llist_add_batch was added in 3.2 X-Git-Tag: compat-2012-07-02~3 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=e30ad30017b92a50714971124cb442a357834b3c;p=~emulex%2Ffor-vlad%2Fold%2Fcompat.git compat: llist_add_batch was added in 3.2 Signed-off-by: Vladimir Sokolovsky --- diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c index 700cff7..5eda45f 100644 --- a/compat/compat-3.1.c +++ b/compat/compat-3.1.c @@ -29,32 +29,6 @@ #include -/** - * llist_add_batch - add several linked entries in batch - * @new_first: first entry in batch to be added - * @new_last: last entry in batch to be added - * @head: the head for your lock-less list - * - * Return whether list is empty before adding. - */ -bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, - struct llist_head *head) -{ - struct llist_node *entry, *old_entry; - - entry = head->first; - for (;;) { - old_entry = entry; - new_last->next = entry; - entry = cmpxchg(&head->first, old_entry, new_first); - if (entry == old_entry) - break; - } - - return old_entry == NULL; -} -EXPORT_SYMBOL_GPL(llist_add_batch); - /** * llist_del_first - delete the first entry of lock-less list * @head: the head for your lock-less list diff --git a/compat/compat-3.2.c b/compat/compat-3.2.c index dd85387..4569f73 100644 --- a/compat/compat-3.2.c +++ b/compat/compat-3.2.c @@ -13,6 +13,7 @@ #include #include #include +#include int __netdev_printk(const char *level, const struct net_device *dev, struct va_format *vaf) @@ -48,3 +49,30 @@ int __ethtool_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) return dev->ethtool_ops->get_settings(dev, cmd); } EXPORT_SYMBOL(__ethtool_get_settings); + +/** + * llist_add_batch - add several linked entries in batch + * @new_first: first entry in batch to be added + * @new_last: last entry in batch to be added + * @head: the head for your lock-less list + * + * Return whether list is empty before adding. + */ +bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, + struct llist_head *head) +{ + struct llist_node *entry, *old_entry; + + entry = head->first; + for (;;) { + old_entry = entry; + new_last->next = entry; + entry = cmpxchg(&head->first, old_entry, new_first); + if (entry == old_entry) + break; + } + + return old_entry == NULL; +} +EXPORT_SYMBOL_GPL(llist_add_batch); + diff --git a/include/linux/llist.h b/include/linux/llist.h index f6d8228..b15d0c7 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h @@ -1,6 +1,12 @@ #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include_next + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) +#include_next +extern bool llist_add_batch(struct llist_node *new_first, + struct llist_node *new_last, + struct llist_head *head); #else #ifndef LLIST_H @@ -190,4 +196,4 @@ extern bool llist_add_batch(struct llist_node *new_first, extern struct llist_node *llist_del_first(struct llist_head *head); #endif /* LLIST_H */ -#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */