From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Wang, Liang-min" Subject: Re: [PATCH v7 1/4] ethdev: add apis to support access device info Date: Thu, 25 Jun 2015 21:05:04 +0000 Message-ID: References: <1432946276-9424-1-git-send-email-liang-min.wang@intel.com> <1434579735-15496-1-git-send-email-liang-min.wang@intel.com> <1434579735-15496-2-git-send-email-liang-min.wang@intel.com> <20150625094427.4cf32009@uryu.home.lan> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" To: Stephen Hemminger Return-path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 59F04C71E for ; Thu, 25 Jun 2015 23:05:07 +0200 (CEST) In-Reply-To: <20150625094427.4cf32009@uryu.home.lan> Content-Language: en-US List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Thursday, June 25, 2015 9:44 AM > To: Wang, Liang-min > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH v7 1/4] ethdev: add apis to support access > device info >=20 > On Wed, 17 Jun 2015 18:22:12 -0400 > Liang-Min Larry Wang wrote: >=20 > > +int > > +rte_eth_dev_reg_length(uint8_t port_id) > > +{ > > + struct rte_eth_dev *dev; > > + > > + if ((dev=3D &rte_eth_devices[port_id]) =3D=3D NULL) { > > + PMD_DEBUG_TRACE("Invalid port device\n"); > > + return -ENODEV; > > + } >=20 > Some minor nits: > * for consistency you should add valid port check here. > * style: > - don't do assignment in if() unless it really helps readability > - need whitespace >=20 > if (!rte_eth_dev_is_valid_port(portid)) { > PMD_DEBUG_TRACE("Invalid port_id=3D%d\n", port_id); > return -ENODEV; > } >=20 > dev =3D &rte_eth_devices[port_id]; > if (dev =3D=3D NULL) { > PMD_DEBUG("Invalid port device\n"); > return -ENODEV: > } > ... >=20 > This code pattern is so common it really should be a function. >=20 > dev =3D rte_eth_dev_get(port_id); > if (dev =3D=3D NULL) { > PMD_DEBUG("Invalid port device\n"); > return -ENODEV; > } >=20 > And then add a macro to generate this?? This is used through-out the rte_ethdev.c, should it be done to the entire = file?