serial: 8250_pci: Refactor the loop in pci_ite887x_init()
[ Upstream commit 35b4f17231923e2f64521bdf7a2793ce2c3c74a6 ] 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> Reviewed-by: Jiri Slaby <jslaby@kernel.org> Link: https://lore.kernel.org/r/20211022135147.70965-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
3110e5a49b
commit
297e2fd08a
@@ -897,18 +897,16 @@ static int pci_netmos_init(struct pci_dev *dev)
|
|||||||
/* enable IO_Space bit */
|
/* enable IO_Space bit */
|
||||||
#define ITE_887x_POSIO_ENABLE (1 << 31)
|
#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)
|
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;
|
int ret, i, type;
|
||||||
struct resource *iobase = NULL;
|
struct resource *iobase = NULL;
|
||||||
u32 miscr, uartbar, ioport;
|
u32 miscr, uartbar, ioport;
|
||||||
|
|
||||||
/* search for the base-ioport */
|
/* search for the base-ioport */
|
||||||
i = 0;
|
for (i = 0; i < ARRAY_SIZE(inta_addr); i++) {
|
||||||
while (inta_addr[i] && iobase == NULL) {
|
|
||||||
iobase = request_region(inta_addr[i], ITE_887x_IOSIZE,
|
iobase = request_region(inta_addr[i], ITE_887x_IOSIZE,
|
||||||
"ite887x");
|
"ite887x");
|
||||||
if (iobase != NULL) {
|
if (iobase != NULL) {
|
||||||
@@ -925,12 +923,10 @@ static int pci_ite887x_init(struct pci_dev *dev)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
release_region(iobase->start, ITE_887x_IOSIZE);
|
release_region(iobase->start, ITE_887x_IOSIZE);
|
||||||
iobase = NULL;
|
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inta_addr[i]) {
|
if (i == ARRAY_SIZE(inta_addr)) {
|
||||||
dev_err(&dev->dev, "ite887x: could not find iobase\n");
|
dev_err(&dev->dev, "ite887x: could not find iobase\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user