[PATCH 2/8] video: Provide screen_info_get_pci_dev() to find screen_info's PCI device

Thomas Zimmermann tzimmermann at suse.de
Tue Jan 30 10:12:32 UTC 2024


Hi

Am 29.01.24 um 12:04 schrieb Javier Martinez Canillas:
> Thomas Zimmermann <tzimmermann at suse.de> writes:
> 
>> Add screen_info_get_pci_dev() to find the PCI device of an instance
>> of screen_info. Does nothing on systems without PCI bus.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
>> ---
> 
> [...]
> 
>> +struct pci_dev *screen_info_pci_dev(const struct screen_info *si)
>> +{
>> +	struct resource res[SCREEN_INFO_MAX_RESOURCES];
>> +	size_t i, numres;
>> +	int ret;
>> +
>> +	ret = screen_info_resources(si, res, ARRAY_SIZE(res));
>> +	if (ret < 0)
>> +		return ERR_PTR(ret);
>> +	numres = ret;
>> +
> 
> I would just drop the ret variable and assign the screen_info_resources()
> return value to numres. I think that makes the code easier to follow.

The value of ret could be an errno code. We would effectively return 
NULL for errors. And I just noticed that the function docs imply this. 
But NULL is also a valid value if there is no PCI device. I'd prefer to 
keep the errno-pointer around.

Best regards
Thomas

> 
> Reviewed-by: Javier Martinez Canillas <javierm at redhat.com>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20240130/5b180bca/attachment.sig>


More information about the dri-devel mailing list