Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp664570pxb; Fri, 14 Jan 2022 13:31:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFRGORYjcd7a08Uqq8vPzLZ9oXEPqV1EAcRCTeid0FImXEXPgSHfAF2a6EjkbPvgflH7OB X-Received: by 2002:a17:902:d505:b0:14a:77ac:1e8b with SMTP id b5-20020a170902d50500b0014a77ac1e8bmr11048944plg.1.1642195894025; Fri, 14 Jan 2022 13:31:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642195894; cv=none; d=google.com; s=arc-20160816; b=yxYBW1GYE3M3r/KqgpnYIYZ1o2yfSRpJOZGOshAIQwbRH9ML2iQ6qCu0ZoxQQpbpwA QBBQ01V23IZX/UOZB4ytYvYhie3/LdhIfmQmiSEU9M4lNeKDmlV0YDPks0Oac4sU7vPr bchDo4+AKi5Ajya+MOhxcgG3asaChrnvW9+Fnx7yAuexS50zlW7Q2pcN90vS7G2Rzze6 FPFn8M5ZKxLI6taf4AGSDdVO9mMFL+KMNGluI/ZSBqDqSrRwh9G4u/fwI8ZYoQ1x9HUM jPa4XQHUJmRk6LH6K2EAXMBTG9+KWt/m5uI3IVjO7w+vWU5QF/gZ5mgKJVgw2aMWWzml 2XJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=s2hfQN1V/BLyZO8HEcI4PFrlShsboJWHdrW2huvwgLI=; b=bBBaYeHS4GouwZrtWyvHutgegLHqTvRn2FBAeSr3iVLR4GoFti8X8PQH4V3ao5AYt2 Auwgt4IZoUBYAQCpaSypasE+8k0mse8vVY2eN1DPgPt0C+iG9HZQLt6QXrTYqzwGEeey X+mAt259ITH6vS3PzI4Fnl1QFO8dTe8nV9ciHpFz8wd4/ycS2Us8H4YdCwNIAEhsJb4p 8xSt5BrzVtR2fBoIghyuv907nlXuNJ6+TIMyYe9OIUH3SC/fYJXLvIhF/lHAkjLplf6e kXchVin0BYPTc7/I8eWLzsg8PgZqdWEKxr0a6zJOXMabz3lKvjW4nu29JtueM2UKk6n0 OeRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="l/FkJ0Ks"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jx3si5568262pjb.182.2022.01.14.13.31.24; Fri, 14 Jan 2022 13:31:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="l/FkJ0Ks"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241340AbiANNqg (ORCPT + 71 others); Fri, 14 Jan 2022 08:46:36 -0500 Received: from mga14.intel.com ([192.55.52.115]:45267 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241428AbiANNoh (ORCPT ); Fri, 14 Jan 2022 08:44:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642167877; x=1673703877; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/Kg1DuHEKRfRXUwMOMGd1Jl+AMgJ4KEURtXNTVWk4U8=; b=l/FkJ0KsfPVyp3N47ar7S24Ku9YCGAeutUSyyAlIBRnbDSGu3/9onqBb +rXXd1uRPWdHKs0wAhY+pJZ7MI4D1XIFUuFYxiT6XTUeHp2IuW81kxACY 2FKE51YvRUmXNoMaA85V1zSMY03OB5fbBGeOcGJh3M89r7wtegqpmLr+o 89xm49AQpo1KmcMBGWcHFZcLpJALbCZz1hZsJEpXIwy69X7Q7pQRqkpCE 5yPReMYRsRopDPo3Z4jBgOuwZVRmTOPB91a4zDz70gaVBjHcpPDsgoDk0 vmFQm1+OwysrnZx0+ZoW/d5dga6mIw/i21os7Z3BUtkTNcill3B8yon4L Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10226"; a="244447018" X-IronPort-AV: E=Sophos;i="5.88,288,1635231600"; d="scan'208";a="244447018" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2022 05:44:37 -0800 X-IronPort-AV: E=Sophos;i="5.88,288,1635231600"; d="scan'208";a="614342556" Received: from smile.fi.intel.com ([10.237.72.61]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jan 2022 05:44:32 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1n8Mr3-00Acul-Es; Fri, 14 Jan 2022 15:42:57 +0200 Date: Fri, 14 Jan 2022 15:42:34 +0200 From: Andy Shevchenko To: Ricardo Martinez Cc: netdev@vger.kernel.org, linux-wireless@vger.kernel.org, kuba@kernel.org, davem@davemloft.net, johannes@sipsolutions.net, ryazanov.s.a@gmail.com, loic.poulain@linaro.org, m.chetan.kumar@intel.com, chandrashekar.devegowda@intel.com, linuxwwan@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, amir.hanania@intel.com, dinesh.sharma@intel.com, eliot.lee@intel.com, ilpo.johannes.jarvinen@intel.com, moises.veleta@intel.com, pierre-louis.bossart@intel.com, muralidharan.sethuraman@intel.com, Soumya.Prakash.Mishra@intel.com, sreehari.kancharla@intel.com Subject: Re: [PATCH net-next v4 01/13] list: Add list_next_entry_circular() and list_prev_entry_circular() Message-ID: References: <20220114010627.21104-1-ricardo.martinez@linux.intel.com> <20220114010627.21104-2-ricardo.martinez@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220114010627.21104-2-ricardo.martinez@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, Jan 13, 2022 at 06:06:15PM -0700, Ricardo Martinez wrote: > Add macros to get the next or previous entries and wraparound if > needed. For example, calling list_next_entry_circular() on the last > element should return the first element in the list. FWIW, Reviewed-by: Andy Shevchenko > Signed-off-by: Ricardo Martinez > --- > include/linux/list.h | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/include/linux/list.h b/include/linux/list.h > index dd6c2041d09c..c147eeb2d39d 100644 > --- a/include/linux/list.h > +++ b/include/linux/list.h > @@ -563,6 +563,19 @@ static inline void list_splice_tail_init(struct list_head *list, > #define list_next_entry(pos, member) \ > list_entry((pos)->member.next, typeof(*(pos)), member) > > +/** > + * list_next_entry_circular - get the next element in list > + * @pos: the type * to cursor. > + * @head: the list head to take the element from. > + * @member: the name of the list_head within the struct. > + * > + * Wraparound if pos is the last element (return the first element). > + * Note, that list is expected to be not empty. > + */ > +#define list_next_entry_circular(pos, head, member) \ > + (list_is_last(&(pos)->member, head) ? \ > + list_first_entry(head, typeof(*(pos)), member) : list_next_entry(pos, member)) > + > /** > * list_prev_entry - get the prev element in list > * @pos: the type * to cursor > @@ -571,6 +584,19 @@ static inline void list_splice_tail_init(struct list_head *list, > #define list_prev_entry(pos, member) \ > list_entry((pos)->member.prev, typeof(*(pos)), member) > > +/** > + * list_prev_entry_circular - get the prev element in list > + * @pos: the type * to cursor. > + * @head: the list head to take the element from. > + * @member: the name of the list_head within the struct. > + * > + * Wraparound if pos is the first element (return the last element). > + * Note, that list is expected to be not empty. > + */ > +#define list_prev_entry_circular(pos, head, member) \ > + (list_is_first(&(pos)->member, head) ? \ > + list_last_entry(head, typeof(*(pos)), member) : list_prev_entry(pos, member)) > + > /** > * list_for_each - iterate over a list > * @pos: the &struct list_head to use as a loop cursor. > -- > 2.17.1 > -- With Best Regards, Andy Shevchenko