From patchwork Thu Nov 28 12:54:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Enrico Weigelt, metux IT consult" X-Patchwork-Id: 11265975 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13E5C13A4 for ; Thu, 28 Nov 2019 12:59:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F16B321781 for ; Thu, 28 Nov 2019 12:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbfK1M64 (ORCPT ); Thu, 28 Nov 2019 07:58:56 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:38901 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726320AbfK1M64 (ORCPT ); Thu, 28 Nov 2019 07:58:56 -0500 Received: from orion.localdomain ([95.117.37.214]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M6lYs-1iS5a63Cne-008K9w; Thu, 28 Nov 2019 13:54:36 +0100 From: "Enrico Weigelt, metux IT consult" To: linux-kernel@vger.kernel.org Cc: tim@buttersideup.com, james.morse@arm.com, rrichter@marvell.com, jdelvare@suse.com, linux@roeck-us.net, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-crypto@vger.kernel.org, linux-edac@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mtd@lists.infradead.org, linux-pci@vger.kernel.org Subject: [PATCH 6/6] (v3) drivers: hwmon: i5k_amb: simplify probing / device identification Date: Thu, 28 Nov 2019 13:54:06 +0100 Message-Id: <20191128125406.10417-6-info@metux.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191128125406.10417-1-info@metux.net> References: <20191128125406.10417-1-info@metux.net> X-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Dl0DEHM0OtOype3sVEouk4o/iL4Bz0e5CQ 6r0xWGVcarWs/oo6BytEnXxzIx4kJJHZzuw3/b+wx/8U2olOwcBBBcPB3e1KJj4M+wy41x3Yr CXgcobIA+Wr+GV2MXlAQ== Sender: linux-edac-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-edac@vger.kernel.org Simpilify the probing by putting all chip-specific data directly into the pci match table, removing the redundant chipset_ids table. Changes v3: * use pci_get_device_by_id() introduces by a previous patch of this queue Changes v2: * use PCI_DEVICE_DATA() macro in the pci match table * directly pass the pci device id to i5k_channel_probe(), instead of computing it internally by extra offset parameter Submitted: 2019-06-06 Signed-off-by: Enrico Weigelt --- drivers/hwmon/i5k_amb.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index b09c39abd3a8..cb85607d104f 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c @@ -414,16 +414,14 @@ static int i5k_amb_add(void) } static int i5k_find_amb_registers(struct i5k_amb_data *data, - unsigned long devid) + const struct pci_device_id *devid) { struct pci_dev *pcidev; u32 val32; int res = -ENODEV; /* Find AMB register memory space */ - pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, - devid, - NULL); + pcidev = pci_get_device_by_id(devid); if (!pcidev) return -ENODEV; @@ -447,14 +445,15 @@ static int i5k_find_amb_registers(struct i5k_amb_data *data, return res; } -static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id) +static int i5k_channel_probe(u16 *amb_present, unsigned int vendor, + unsigned int device) { struct pci_dev *pcidev; u16 val16; int res = -ENODEV; /* Copy the DIMM presence map for these two channels */ - pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, NULL); + pcidev = pci_get_device(vendor, device, NULL); if (!pcidev) return -ENODEV; @@ -473,23 +472,12 @@ static int i5k_channel_probe(u16 *amb_present, unsigned long dev_id) return res; } -static struct { - unsigned long err; - unsigned long fbd0; -} chipset_ids[] = { - { PCI_DEVICE_ID_INTEL_5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0 }, - { PCI_DEVICE_ID_INTEL_5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0 }, - { 0, 0 } -}; - -#ifdef MODULE static const struct pci_device_id i5k_amb_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5000_ERR) }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5400_ERR) }, + { PCI_DEVICE_DATA(INTEL, 5000_ERR, PCI_DEVICE_ID_INTEL_5000_FBD0) }, + { PCI_DEVICE_DATA(INTEL, 5400_ERR, PCI_DEVICE_ID_INTEL_5400_FBD0) }, { 0, } }; MODULE_DEVICE_TABLE(pci, i5k_amb_ids); -#endif static int i5k_amb_probe(struct platform_device *pdev) { @@ -504,22 +492,26 @@ static int i5k_amb_probe(struct platform_device *pdev) /* Figure out where the AMB registers live */ i = 0; do { - res = i5k_find_amb_registers(data, chipset_ids[i].err); + res = i5k_find_amb_registers(data, &i5k_amb_ids[i]); if (res == 0) break; i++; - } while (chipset_ids[i].err); + } while (i5k_amb_ids[i].device); if (res) goto err; /* Copy the DIMM presence map for the first two channels */ - res = i5k_channel_probe(&data->amb_present[0], chipset_ids[i].fbd0); + res = i5k_channel_probe(&data->amb_present[0], + i5k_amb_ids[i].vendor, + i5k_amb_ids[i].driver_data); if (res) goto err; /* Copy the DIMM presence map for the optional second two channels */ - i5k_channel_probe(&data->amb_present[2], chipset_ids[i].fbd0 + 1); + i5k_channel_probe(&data->amb_present[2], + i5k_amb_ids[i].vendor, + i5k_amb_ids[i].driver_data+1); /* Set up resource regions */ reso = request_mem_region(data->amb_base, data->amb_len, DRVNAME);