Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp275000pxv; Wed, 14 Jul 2021 03:46:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3ROztJPNqhrE7dL8rv4zLuya9cwSeDaSSTDY2DxBSeMZnBWEHlYdFM90F98OSiVXr84Yg X-Received: by 2002:a17:907:170c:: with SMTP id le12mr12045068ejc.288.1626259607462; Wed, 14 Jul 2021 03:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626259607; cv=none; d=google.com; s=arc-20160816; b=O90hQIgwfDNW6D6FWa8ia8614s8WU9QUZPYFBeke+Q4wFgpzyFIyW+acnNxlkGZz1g lU4+U1D7moDkvOlUfeyMgsp0zZe57cnHl2YRHXOpMmKHtacnqVOSb7neCrWGoER5tVy4 /Xa+OiloEtTJb0HsB3HV/hsJNX/nktg/b5OSVR9B6feCiBzFGj20QnJIYE+AEsUl7v1M b+tEPLvu/YVJJ1plXCPmAqXIIGJM3QXCQu3g6/ibhN3/zsjQCg5fDnSYpgvEkdMp3bzi eJWoZePT7tC8HkNhicGcROpJ9y0A12l9Yr8UgLI+GJVUCxZCEXPDmTF4LwnYzysg9H7l IbuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=Q0qRCqsGWLvGjMA2kWyRW8pCOyrplX1V4z0wQ+Cuge4=; b=RNVv0Uori3tAKZcj73idZMutwqFRssPuWHYadAgycSXW9/ZmfoaIAct3BU0asQSHgS KLxqCEnpFZrPPFrCAE8BtPtQSBXrJIyFDjZiyYMu+q/KySGbOiSt0a4v75FDITqaP5/Q pzoDjdhO05WvCTjwbeL7fId+YOJKXZMwxw9sNK4tKVSLMOGTyZ+3st9mPkFFdiEJ8ZAv 2Wf+4vXvPfjDNhsSOcKPPTDW3m6Vqz2/AGwUHK8BKRF6uNy4dYXBJaG1PLM62WsvitwF xQgOG5RGFwiugz6/lsiCraJ/+TNaZAX8xNQuB//m7RriZsEmOib5ZjYR4DFDVQqu7gIx DEOA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si2612479ejt.474.2021.07.14.03.46.24; Wed, 14 Jul 2021 03:46:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239147AbhGNKr2 (ORCPT + 99 others); Wed, 14 Jul 2021 06:47:28 -0400 Received: from smtprelay0009.hostedemail.com ([216.40.44.9]:60952 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239148AbhGNKr0 (ORCPT ); Wed, 14 Jul 2021 06:47:26 -0400 Received: from omf17.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id 4D6742AF17; Wed, 14 Jul 2021 10:44:33 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf17.hostedemail.com (Postfix) with ESMTPA id 5B78427DD3E; Wed, 14 Jul 2021 10:44:32 +0000 (UTC) Message-ID: <91d4f67011eb83c4e4b17c7cfb4f4b8aef190978.camel@perches.com> Subject: Re: [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init() From: Joe Perches To: Andy Shevchenko , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby Date: Wed, 14 Jul 2021 03:44:31 -0700 In-Reply-To: <20210713104026.58560-1-andriy.shevchenko@linux.intel.com> References: <20210713104026.58560-1-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.06 X-Stat-Signature: htenwmm663a1y4q5mmh17wpywfynss3u X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: 5B78427DD3E X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/8sEb/SnuH+4J1L45TBkLGiY5c7ic2qm8= X-HE-Tag: 1626259472-225770 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. [] > diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c [] > @@ -897,37 +897,31 @@ static int pci_netmos_init(struct pci_dev *dev) > ?/* enable IO_Space bit */ > ?#define ITE_887x_POSIO_ENABLE (1 << 31) > ? > > +/* 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? The trailing comma isn't necessary/useful and possibly confusing too. > ?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? > ? /* write POSIO0R - speed | size | ioport */ > ? pci_write_config_dword(dev, ITE_887x_POSIO0, > ? ITE_887x_POSIO_ENABLE | ITE_887x_POSIO_SPEED | > ? ITE_887x_POSIO_IOSIZE_32 | inta_addr[i]); > ? /* write INTCBAR - ioport */ > - pci_write_config_dword(dev, ITE_887x_INTCBAR, > - inta_addr[i]); > + pci_write_config_dword(dev, ITE_887x_INTCBAR, inta_addr[i]); > ? ret = inb(inta_addr[i]); > ? if (ret != 0xff) { > ? /* ioport connected */ > ? break; > ? } > ? release_region(iobase->start, ITE_887x_IOSIZE); > - iobase = NULL; > ? } > - i++; > ? } > ? > > ? if (!inta_addr[i]) {