diff mbox series

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

Message ID 20191128125406.10417-4-info@metux.net (mailing list archive)
State Not Applicable, archived
Delegated to: Bjorn Helgaas
Headers show
Series [1/6] include: linux: pci.h: introduce pci_get_device_by_id() | expand

Commit Message

Enrico Weigelt, metux IT consult Nov. 28, 2019, 12:54 p.m. UTC
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 <info@metux.net>
---
 drivers/edac/i82443bxgx_edac.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Robert Richter Nov. 28, 2019, 1:28 p.m. UTC | #1
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
diff mbox series

Patch

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");