Subject: [PATCH 4/6] edac: i82443bxgx_edac: use pci_get_device_by_id()

Use the new pci_get_device_by_id() helper in order to reduce
a bit of boilerplate.

Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
---
drivers/edac/i82443bxgx_edac.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/edac/i82443bxgx_edac.c b/drivers/edac/i82443bxgx_edac.c
index a2ca929e2168..c01f51a4848c 100644
--- a/drivers/edac/i82443bxgx_edac.c
+++ b/drivers/edac/i82443bxgx_edac.c
@@ -407,15 +407,13 @@ static int __init i82443bxgx_edacmc_init(void)
goto fail0;

if (mci_pdev == NULL) {
- const struct pci_device_id *id = &i82443bxgx_pci_tbl[0];
int i = 0;
i82443bxgx_registered = 0;

- while (mci_pdev == NULL && id->vendor != 0) {
- mci_pdev = pci_get_device(id->vendor,
- id->device, NULL);
+ while (mci_pdev == NULL && i82443bxgx_pci_tbl[i].vendor) {
+ mci_pdev = pci_get_device_by_id(
+ &i82443bxgx_pci_tbl[i]);
i++;
- id = &i82443bxgx_pci_tbl[i];
}
if (!mci_pdev) {
edac_dbg(0, "i82443bxgx pci_get_device fail\n");
--
2.11.0


2019-11-28 13:34:05

by Robert Richter

[permalink] [raw]
Subject: Re: [PATCH 4/6] edac: i82443bxgx_edac: use pci_get_device_by_id()

On 28.11.19 13:54:04, Enrico Weigelt, metux IT consult wrote:
> Use the new pci_get_device_by_id() helper in order to reduce
> a bit of boilerplate.

> - while (mci_pdev == NULL && id->vendor != 0) {
> - mci_pdev = pci_get_device(id->vendor,
> - id->device, NULL);
> + while (mci_pdev == NULL && i82443bxgx_pci_tbl[i].vendor) {
> + mci_pdev = pci_get_device_by_id(
> + &i82443bxgx_pci_tbl[i]);

I don't see how this is less boilerplate. Since this differs from the
typical pattern for this it is less readable now.

-Robert