Thread (22 messages) flat view 22 messages, 2 authors, 2024-01-30

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

From: Javier Martinez Canillas <javierm@redhat.com>
Date: 2024-01-30 10:23:56
Also in: dri-devel

Thomas Zimmermann [off-list ref] writes:
Hi

Am 29.01.24 um 12:04 schrieb Javier Martinez Canillas:
quoted
Thomas Zimmermann [off-list ref] writes:
quoted
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@suse.de>
---
[...]
quoted
+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.
Yes. I meant making numres an int instead of size_t (SCREEN_INFO_MAX_RESOURCES
is only 3 after all). That way you could just return ERR_PTR(numres) if is < 0.

No strong preference, just think that the code is easier to read in that case.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help