From: Sui Jingfeng <sui.jingfeng@linux.dev>
To: Thomas Zimmermann <tzimmermann@suse.de>,
javierm@redhat.com, pjones@redhat.com, deller@gmx.de,
ardb@kernel.org
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org
Subject: Re: [v2,2/8] video: Provide screen_info_get_pci_dev() to find screen_info's PCI device
Date: Sat, 3 Feb 2024 00:31:18 +0800 [thread overview]
Message-ID: <7f3b8c61-3266-4bba-b866-c3e5623b3893@linux.dev> (raw)
In-Reply-To: <20240202120140.3517-3-tzimmermann@suse.de>
Hi,
On 2024/2/2 19:58, Thomas Zimmermann wrote:
> diff --git a/drivers/video/screen_info_pci.c b/drivers/video/screen_info_pci.c
> new file mode 100644
> index 0000000000000..d959a4c6ba3d5
> --- /dev/null
> +++ b/drivers/video/screen_info_pci.c
> @@ -0,0 +1,52 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <linux/pci.h>
> +#include <linux/screen_info.h>
> +
> +static struct pci_dev *__screen_info_pci_dev(struct resource *res)
> +{
> + struct pci_dev *pdev;
> +
> + if (!(res->flags & IORESOURCE_MEM))
> + return NULL;
> +
> + for_each_pci_dev(pdev) {
> + const struct resource *r;
> +
> + if ((pdev->class >> 16) != PCI_BASE_CLASS_DISPLAY)
> + continue;
> +
> + r = pci_find_resource(pdev, res);
> + if (r)
> + return pdev;
> + }
> +
> + return NULL;
> +}
I recommend using the pci_get_base_class() or pci_get_class() helper function at here,
for example:
static struct pci_dev *__screen_info_pci_dev(struct resource *res)
{
struct pci_dev *pdev;
if (!(res->flags & IORESOURCE_MEM))
return NULL;
while ((pdev = pci_get_base_class(PCI_BASE_CLASS_DISPLAY, pdev))) {
if (pci_find_resource(pdev, res))
return pdev;
}
return NULL;
}
next prev parent reply other threads:[~2024-02-02 16:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 11:58 [PATCH v2 0/8] firmware/sysfb: Track parent device for screen_info Thomas Zimmermann
2024-02-02 11:58 ` [PATCH v2 1/8] video: Add helpers for decoding screen_info Thomas Zimmermann
2024-02-02 11:58 ` [PATCH v2 2/8] video: Provide screen_info_get_pci_dev() to find screen_info's PCI device Thomas Zimmermann
2024-02-02 16:31 ` Sui Jingfeng [this message]
2024-02-05 8:14 ` [v2,2/8] " Thomas Zimmermann
2024-02-02 17:03 ` Sui Jingfeng
2024-02-05 8:17 ` Thomas Zimmermann
2024-02-05 10:05 ` Sui Jingfeng
2024-02-05 12:32 ` Thomas Zimmermann
2024-02-04 1:53 ` [PATCH v2 2/8] " kernel test robot
2024-02-02 11:58 ` [PATCH v2 3/8] firmware/sysfb: Set firmware-framebuffer parent device Thomas Zimmermann
2024-02-02 14:40 ` [v2,3/8] " Sui Jingfeng
2024-02-02 15:23 ` Sui Jingfeng
2024-02-05 8:24 ` Thomas Zimmermann
2024-02-07 15:34 ` Sui Jingfeng
2024-02-03 19:12 ` [PATCH v2 3/8] " kernel test robot
2024-02-04 2:13 ` kernel test robot
2024-02-02 11:58 ` [PATCH v2 4/8] fbdev/efifb: Remove PM for " Thomas Zimmermann
2024-02-02 11:58 ` [PATCH v2 5/8] firmware/sysfb: Create firmware device only for enabled PCI devices Thomas Zimmermann
2024-02-02 17:50 ` [v2,5/8] " Sui Jingfeng
2024-02-05 8:25 ` [v2, 5/8] " Thomas Zimmermann
2024-02-02 11:58 ` [PATCH v2 6/8] fbdev/efifb: Do not track parent device status Thomas Zimmermann
2024-02-02 11:58 ` [PATCH v2 7/8] firmware/sysfb: Update screen_info for relocated EFI framebuffers Thomas Zimmermann
2024-02-02 17:54 ` [v2,7/8] " Sui Jingfeng
2024-02-05 10:11 ` Thomas Zimmermann
2024-02-02 18:00 ` Sui Jingfeng
2024-02-06 16:45 ` Thomas Zimmermann
2024-02-02 11:58 ` [PATCH v2 8/8] fbdev/efifb: Remove framebuffer relocation tracking Thomas Zimmermann
2024-02-02 18:07 ` [v2,8/8] " Sui Jingfeng
Reply instructions:
You may reply publicly 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=7f3b8c61-3266-4bba-b866-c3e5623b3893@linux.dev \
--to=sui.jingfeng@linux.dev \
--cc=ardb@kernel.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=pjones@redhat.com \
--cc=tzimmermann@suse.de \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).