linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init()
@ 2021-07-13 10:40 Andy Shevchenko
  2021-07-13 10:40 ` [PATCH v1 2/4] serial: 8250_pci: Get rid of redundant 'else' keyword Andy Shevchenko
                   ` (5 more replies)
  0 siblings, 6 replies; 23+ messages in thread
From: Andy Shevchenko @ 2021-07-13 10:40 UTC (permalink / raw)
  To: linux-serial, linux-kernel
  Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko

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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_pci.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 02985cf90ef2..b9138bd08b7f 100644
--- 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, };
 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) {
 			/* 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]) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2021-07-17 12:45 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13 10:40 [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init() Andy Shevchenko
2021-07-13 10:40 ` [PATCH v1 2/4] serial: 8250_pci: Get rid of redundant 'else' keyword Andy Shevchenko
2021-07-13 10:40 ` [PATCH v1 3/4] serial: 8250_pci: Always try MSI/MSI-X Andy Shevchenko
2021-07-14  6:54   ` Jiri Slaby
2021-07-14  7:58     ` Jiri Slaby
2021-07-14  9:31       ` Andy Shevchenko
2021-07-14  9:15     ` Andy Shevchenko
2021-07-14 16:56       ` rwright
2021-07-14 12:49     ` [EXT] " Ralf Ramsauer
2021-07-14 13:35       ` Andy Shevchenko
2021-07-14 16:49         ` Ralf Ramsauer
2021-07-16 13:07         ` Ralf Ramsauer
2021-07-16 15:01           ` Andy Shevchenko
2021-07-16 15:27             ` Ralf Ramsauer
2021-07-16 17:27               ` Andy Shevchenko
2021-07-17 12:44                 ` Ralf Ramsauer
2021-07-13 10:40 ` [PATCH v1 4/4] serial: 8250_pci: Replace dev_*() by pci_*() macros Andy Shevchenko
2021-07-13 21:05   ` Joe Perches
2021-07-14  6:57 ` [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init() Jiri Slaby
2021-07-14 12:37   ` Andy Shevchenko
2021-07-14  8:07 ` Dan Carpenter
2021-07-14 10:44 ` Joe Perches
2021-07-14 12:36   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).