Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp351838pxv; Wed, 14 Jul 2021 05:37:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9YNHXTHsv3dSJE5xBBIbQCxkFaCjWRoQ8bxgjAovSG7ZzUwlS9SEik6GRkA//yMpWLhCX X-Received: by 2002:a05:6e02:de6:: with SMTP id m6mr6634433ilj.203.1626266246926; Wed, 14 Jul 2021 05:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626266246; cv=none; d=google.com; s=arc-20160816; b=Z4N4p8u/sgpNBrnaEhBK5PPK0V/+eLFnwqZ0jAlEj7KKIaaA2c5A5PafrC43VaFSVP uS32h4MxJS5ZlsBq/GjBjflCilVBeL9U2Lv4p/SwaLclGmXavabW40AyXQvAQDNhl3H6 HcWMQohRHoKaz6LvI1hwSXhpKWjUq4Aqf81MW2x451U3E0A96QgUGq8nxeUCRx4BMVXM mx/bTLs7Q+futm7+hpGHHUNSjT0hqSHAcxovVdkwT1CD37pJgNSOD8hveEhBk8347DIs i2hJXbOGZkWHjQzTll0WIWELiuYTSkcsUmbsVc+EHSABCcgNnV+zKLvSdJsBZmsrKyWX 1KUw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=mVNIMgmc5vo45dujxbmw7GORQFsx6t3F/fj6FUJ3iVQ=; b=nMEN8VWkQMKX8HVY6sFBxYlZKlhInITq9hch5I3zLO/fKGZCZ762qs/40V0TurqzpP b22zhJ0CG+VQQlMHDSQZ6l2wuT1PgonEMcHzed0eFdZ5aR+JcIdJbPHwMUjHgEJbmXjt GqQu9HXPF5v4Eoi4FxJCYleOHIqLqOmuKva6l1G6FuiqgPIB2nOA7lblMN7nbXGSLYZ0 /3pSl+YBFAvqSKIIn0ShlOMerCpiZ0p75TJM9DStMfszcQwd7xb/60v4JbZycn14QJxX F87wMCpKK1lvH/BkRgTw5uy5k6tdyrADPvimvBCjHOBg4WUzW2pjaGLB9ilwsvztAhoW Sv7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (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 x4si2386639ilj.43.2021.07.14.05.37.12; Wed, 14 Jul 2021 05:37:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231226AbhGNMjM (ORCPT + 99 others); Wed, 14 Jul 2021 08:39:12 -0400 Received: from mga17.intel.com ([192.55.52.151]:27060 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231356AbhGNMjK (ORCPT ); Wed, 14 Jul 2021 08:39:10 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10044"; a="190713942" X-IronPort-AV: E=Sophos;i="5.84,239,1620716400"; d="scan'208";a="190713942" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 05:36:18 -0700 X-IronPort-AV: E=Sophos;i="5.84,239,1620716400"; d="scan'208";a="571161912" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jul 2021 05:36:16 -0700 Received: from andy by smile with local (Exim 4.94.2) (envelope-from ) id 1m3e7W-00DJfw-TX; Wed, 14 Jul 2021 15:36:10 +0300 Date: Wed, 14 Jul 2021 15:36:10 +0300 From: Andy Shevchenko To: Joe Perches Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Jiri Slaby Subject: Re: [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init() Message-ID: References: <20210713104026.58560-1-andriy.shevchenko@linux.intel.com> <91d4f67011eb83c4e4b17c7cfb4f4b8aef190978.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <91d4f67011eb83c4e4b17c7cfb4f4b8aef190978.camel@perches.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 14, 2021 at 03:44:31AM -0700, Joe Perches wrote: > On Tue, 2021-07-13 at 13:40 +0300, Andy Shevchenko wrote: > > The loop can be refactored by using ARRAY_SIZE() instead of NULL terminator. > > This reduces code base and makes it easier to read and understand. Thanks for review! My answers below. > > +/* inta_addr are the configuration addresses of the ITE */ > > +static const short inta_addr[] = { 0x2a0, 0x2c0, 0x220, 0x240, 0x1e0, 0x200, 0x280, }; > > Why move this outside the only function it's used in? Because it's a static one. I prefer to see global variables easily when reading the code. > The trailing comma isn't necessary/useful and possibly confusing too. True, since it's one line. > > ?static int pci_ite887x_init(struct pci_dev *dev) > > ?{ > > - /* inta_addr are the configuration addresses of the ITE */ > > - static const short inta_addr[] = { 0x2a0, 0x2c0, 0x220, 0x240, 0x1e0, > > - 0x200, 0x280, 0 }; > > ? int ret, i, type; > > ? struct resource *iobase = NULL; > > ? u32 miscr, uartbar, ioport; > > > > ? /* search for the base-ioport */ > > - i = 0; > > - while (inta_addr[i] && iobase == NULL) { > > - iobase = request_region(inta_addr[i], ITE_887x_IOSIZE, > > - "ite887x"); > > + for (i = 0; i < ARRAY_SIZE(inta_addr); i++) { > > + iobase = request_region(inta_addr[i], ITE_887x_IOSIZE, "ite887x"); > > ? if (iobase != NULL) { > > continue and unindent the block below? As a separate patch perhaps? -- With Best Regards, Andy Shevchenko