From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet Subject: Re: [PATCH v5 02/12] bus: add device iterator method Date: Mon, 26 Jun 2017 23:13:49 +0200 Message-ID: <20170626211349.GO2344@bidouze.vm.6wind.com> References: <20170626162037.GB101992@bricha3-MOBL3.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Cc: dev@dpdk.org, Jan Blunck To: Bruce Richardson Return-path: Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 247B3374 for ; Mon, 26 Jun 2017 23:13:59 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id k67so149780745wrc.2 for ; Mon, 26 Jun 2017 14:13:59 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20170626162037.GB101992@bricha3-MOBL3.ger.corp.intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Jun 26, 2017 at 05:20:37PM +0100, Bruce Richardson wrote: > On Mon, Jun 26, 2017 at 02:22:00AM +0200, Gaetan Rivet wrote: > > From: Jan Blunck > > > > Signed-off-by: Jan Blunck > > Signed-off-by: Gaetan Rivet > > --- > > lib/librte_eal/common/include/rte_bus.h | 19 +++++++++++++++++++ > > lib/librte_eal/common/include/rte_dev.h | 21 +++++++++++++++++++++ > > 2 files changed, 40 insertions(+) > > > > diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h > > index ecf839b..5efb76e 100644 > > --- a/lib/librte_eal/common/include/rte_bus.h > > +++ b/lib/librte_eal/common/include/rte_bus.h > > @@ -82,6 +82,24 @@ typedef int (*rte_bus_scan_t)(void); > > typedef int (*rte_bus_probe_t)(void); > > > > /** > > + * Device iterator to find a device on a bus. > > + * > > + * This function returns an rte_device if one of those held by the bus > > + * matches the data passed as parameter. > > + * > > + * @param cmp > > + * Comparison function. > > + * > > + * @param data > > + * Data to compare each device against. > > + * > > + * @return > > + * The first device matching the data, NULL if none exists. > > + */ > > +typedef struct rte_device * (*rte_bus_find_device_t)(rte_dev_cmp_t cmp, > > + const void *data); > > + > > +/** > > The bus find function takes a third, start, parameter. Is it worthwhile > including such a parameter here, for consistency sake if nothing else? > I was wondering this actually. Doing so would deport the added complexity, to be repeated in each bus implementation. It would in turn simplify my own calls, ever so slightly. That means a few small-ish additional spots of complexity instead of a single one. I'm also thinking that maybe a few buses could avoid having linked lists for their containers (I know it's frowned upon to roll your own, but some might have good reasons for doing so), allowing random access, bypassing cycling through each. Well, I will do as you suggest, if anyone objects, please shout before I send the next version. > Otherwise: > > Acked-by: Bruce Richardson -- Gaëtan Rivet 6WIND