LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Subject: Re: [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init()
Date: Wed, 14 Jul 2021 03:44:31 -0700 [thread overview]
Message-ID: <91d4f67011eb83c4e4b17c7cfb4f4b8aef190978.camel@perches.com> (raw)
In-Reply-To: <20210713104026.58560-1-andriy.shevchenko@linux.intel.com>
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]) {
next prev parent reply other threads:[~2021-07-14 10:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
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
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 [this message]
2021-07-14 12:36 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=91d4f67011eb83c4e4b17c7cfb4f4b8aef190978.camel@perches.com \
--to=joe@perches.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--subject='Re: [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init()' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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).