Linux-EDAC Archive on lore.kernel.org
 help / color / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Enrico Weigelt, metux IT consult" <info@metux.net>,
	linux-kernel@vger.kernel.org
Cc: tim@buttersideup.com, james.morse@arm.com, rrichter@marvell.com,
	jdelvare@suse.com, 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: Re: [PATCH 6/6] (v3) drivers: hwmon: i5k_amb: simplify probing / device identification
Date: Thu, 28 Nov 2019 06:21:31 -0800
Message-ID: <bee7ba11-6b4a-1cc7-ee8c-ddf17cb8daca@roeck-us.net> (raw)
In-Reply-To: <20191128125406.10417-6-info@metux.net>

On 11/28/19 4:54 AM, Enrico Weigelt, metux IT consult wrote:
> 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 <info@metux.net>

I don't immediately see how this is better. I am not even sure if it is correct.

Guenter

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


      reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 12:54 [PATCH 1/6] include: linux: pci.h: introduce pci_get_device_by_id() Enrico Weigelt, metux IT consult
2019-11-28 12:54 ` [PATCH 2/6] mtd: maps: esb2rom: use pci_get_device_by_id() Enrico Weigelt, metux IT consult
2019-11-28 12:54 ` [PATCH 3/6] mtd: maps: amd76xrom: " Enrico Weigelt, metux IT consult
2019-11-28 12:54 ` [PATCH 4/6] edac: i82443bxgx_edac: " Enrico Weigelt, metux IT consult
2019-11-28 13:28   ` Robert Richter
2019-11-28 12:54 ` [PATCH 5/6] char: hw_random: intel-rng: " Enrico Weigelt, metux IT consult
2019-11-28 12:54 ` [PATCH 6/6] (v3) drivers: hwmon: i5k_amb: simplify probing / device identification Enrico Weigelt, metux IT consult
2019-11-28 14:21   ` Guenter Roeck [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bee7ba11-6b4a-1cc7-ee8c-ddf17cb8daca@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=info@metux.net \
    --cc=james.morse@arm.com \
    --cc=jdelvare@suse.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=rrichter@marvell.com \
    --cc=tim@buttersideup.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-EDAC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-edac/0 linux-edac/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-edac linux-edac/ https://lore.kernel.org/linux-edac \
		linux-edac@vger.kernel.org
	public-inbox-index linux-edac

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-edac


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git