Re: [PATCH v1 1/4] serial: 8250_pci: Refactor the loop in pci_ite887x_init()
From: Andy Shevchenko
Date: Wed Jul 14 2021 - 08:36:23 EST
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