[igt-dev] [PATCH i-g-t 1/2] lib/igt_device_scan: Remember vendor/device for pci devices

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Tue Nov 17 10:16:44 UTC 2020


On 17/11/2020 09:48, Zbigniew Kempczyński wrote:
> If we want to use pci device id for not opened device we need to
> keep it in card structure.
> 
> To avoid compiler warnings after adding vendor/device fields
> increase pci_slot_name length.

What was the warning? (I did not get it after a minute or two of staring.)

Regards,

Tvrtko

> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> Cc: Petri Latvala <petri.latvala at intel.com>
> ---
>   lib/igt_device_scan.c | 8 ++++++++
>   lib/igt_device_scan.h | 3 ++-
>   2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> index e97f7163..5793ef84 100644
> --- a/lib/igt_device_scan.c
> +++ b/lib/igt_device_scan.c
> @@ -463,6 +463,14 @@ __copy_dev_to_card(struct igt_device *dev, struct igt_device_card *card)
>   	if (dev->pci_slot_name != NULL)
>   		strncpy(card->pci_slot_name, dev->pci_slot_name,
>   			PCI_SLOT_NAME_SIZE + 1);
> +
> +	if (dev->vendor != NULL && strlen(dev->vendor) == 4)
> +		if (sscanf(dev->vendor, "%hx", &card->pci_vendor) != 1)
> +			card->pci_vendor = 0;
> +
> +	if (dev->device != NULL && strlen(dev->device) == 4)
> +		if (sscanf(dev->device, "%hx", &card->pci_device) != 1)
> +			card->pci_device = 0;
>   }
>   
>   /*
> diff --git a/lib/igt_device_scan.h b/lib/igt_device_scan.h
> index bb4be723..e96d8a25 100644
> --- a/lib/igt_device_scan.h
> +++ b/lib/igt_device_scan.h
> @@ -57,7 +57,8 @@ struct igt_device_card {
>   	char subsystem[NAME_MAX];
>   	char card[NAME_MAX];
>   	char render[NAME_MAX];
> -	char pci_slot_name[PCI_SLOT_NAME_SIZE+1];
> +	char pci_slot_name[PCI_SLOT_NAME_SIZE+2];
> +	uint16_t pci_vendor, pci_device;
>   };
>   
>   void igt_devices_scan(bool force);
> 


More information about the igt-dev mailing list