From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 25 Jun 2015 14:05:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,679,1427785200"; d="scan'208";a="750550326" Received: from orsmsx105.amr.corp.intel.com ([10.22.225.132]) by fmsmga002.fm.intel.com with ESMTP; 25 Jun 2015 14:05:06 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by ORSMSX105.amr.corp.intel.com (10.22.225.132) with Microsoft SMTP Server (TLS) id 14.3.224.2; Thu, 25 Jun 2015 14:05:05 -0700 Received: from FMSMSX110.amr.corp.intel.com ([169.254.14.199]) by fmsmsx118.amr.corp.intel.com ([10.18.116.18]) with mapi id 14.03.0224.002; Thu, 25 Jun 2015 14:05:05 -0700 From: "Wang, Liang-min" To: Stephen Hemminger Thread-Topic: [dpdk-dev] [PATCH v7 1/4] ethdev: add apis to support access device info Thread-Index: AQHQqUwVozUIsvKkqUKmtYbRXAZvJJ29vNuAgAAE93A= 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> In-Reply-To: <20150625094427.4cf32009@uryu.home.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.1.200.108] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v7 1/4] ethdev: add apis to support access device info X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jun 2015 21:05:07 -0000 > -----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?