From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754797AbbE1Uhc (ORCPT ); Thu, 28 May 2015 16:37:32 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:35529 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753291AbbE1UhX (ORCPT ); Thu, 28 May 2015 16:37:23 -0400 From: Dan Streetman To: Andrew Morton , "Paul E. McKenney" Cc: Steven Rostedt , Ken Helias , Mauro Carvalho Chehab , Andrey Utkin , Masahiro Yamada , linux-kernel@vger.kernel.org, Dan Streetman Subject: [PATCH 2/2] list: introduce list_last_entry_or_null Date: Thu, 28 May 2015 16:36:45 -0400 Message-Id: <1432845405-28062-1-git-send-email-ddstreet@ieee.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1432845328-27932-1-git-send-email-ddstreet@ieee.org> References: <1432845328-27932-1-git-send-email-ddstreet@ieee.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org non-rcu variant of list_last_or_null_rcu Signed-off-by: Dan Streetman --- include/linux/list.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index feb773c..38577f89 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -385,6 +385,17 @@ static inline void list_splice_tail_init(struct list_head *list, (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL) /** + * list_last_entry_or_null - get the last element from a list + * @ptr: the list head to take the element from. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_head within the struct. + * + * Note that if the list is empty, it returns NULL. + */ +#define list_last_entry_or_null(ptr, type, member) \ + (!list_empty(ptr) ? list_last_entry(ptr, type, member) : NULL) + +/** * list_next_entry - get the next element in list * @pos: the type * to cursor * @member: the name of the list_head within the struct. -- 2.1.0