From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 5B547532C for ; Wed, 21 Jun 2017 14:11:07 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id F119B206FF; Wed, 21 Jun 2017 08:11:06 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 21 Jun 2017 08:11:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=R8tugTSiqHGc5SY U9rHg7X3IieTeyjuElN8bgwjFZKE=; b=okSyYDpf0nmVaG43R83gfBJs7Y1OTVf dMrsf2/iXmEUpGeTU0fxMMOzVxdf+G+/3WI7qyT1BZ4TDSg4o7XXrRJOd4zn9YuF LJfzeTU0ts7EMZGRONUwzNPeByK3zQeeqahEyLsVhQGaIySa2zn8jY6qhBe4xaAh N8YdB3nu4jvI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=R8tugTSiqHGc5SYU9rHg7X3IieTeyjuElN8bgwjFZKE=; b=lpqFqlrK NNlMQ8HZnZJcH8Oe0qdtLfvFSZCQqwWnSlG2QTIkFmL2QOwjIMXQ1p1fqfDygDnj MZERegfZMGsuk1DVK5pu1gQ5lAFqwGRXkTv8XuVA+6uv60WDepZNuAQhaYPjkvH/ 42JgGoSS/HD3q30vqiOxMbvWbJiHZx1MhpkbZQsAz4TIRZe8okZlHjHu27ye6yxe ZLoGIGFXpBONVXEfhI+aFk1Bx0WzQu0yazVQOwKfDmpClpv+RIb3xW3bKer35KA+ capY26TF4Lgm/PFkT1oLZBEwOabo3ECWPQP2URKKiwRdklYmpa4N1Z5uBQjqgIYl Fpd2nOGpHhdjBg== X-ME-Sender: X-Sasl-enc: /NZ7PKhUY3ndDnXSoX56nerFIXQJOu4ZAvQ9EsoxFmLC 1498047066 Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id A0B0E24753; Wed, 21 Jun 2017 08:11:06 -0400 (EDT) From: Thomas Monjalon To: Gaetan Rivet Cc: dev@dpdk.org, Jan Blunck Date: Wed, 21 Jun 2017 14:11:05 +0200 Message-ID: <2413014.VjuBF7ha8b@xps> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v4 3/9] bus: add helper to find bus for a particular device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 12:11:07 -0000 21/06/2017 01:29, Gaetan Rivet: > +static int > +cmp_rte_device(const struct rte_device *dev, const void *_dev2) Better to rename dev into dev1. > +{ > + const struct rte_device *dev2 = _dev2; > + > + return !(dev == dev2); simpler: return dev1 != dev2 [...] > +static int > +bus_find_device(const struct rte_bus *bus, const void *_dev) > +{ > + struct rte_device *dev; > + > + if (!bus->find_device) It is preferred to check pointers against NULL. > + return -1; > + dev = bus->find_device(cmp_rte_device, _dev); > + return !dev; Here also: return dev == NULL: > +} > + > +struct rte_bus *rte_bus_find_by_device(const struct rte_device *dev) > +{ > + return rte_bus_find(bus_find_device, (const void *)dev, NULL); > +} Nice