From: Thomas Zimmermann <tzimmermann@suse.de>
To: alexander.stein@ew.tq-group.com, javierm@redhat.com,
airlied@gmail.com, daniel@ffwll.ch
Cc: Thomas Zimmermann <tzimmermann@suse.de>,
dri-devel@lists.freedesktop.org,
kernel test robot <lkp@intel.com>
Subject: [PATCH v3 1/2] drm/ofdrm: Convert PCI IDs to CPU endianness for comparing
Date: Thu, 3 Nov 2022 11:16:26 +0100 [thread overview]
Message-ID: <20221103101627.32502-2-tzimmermann@suse.de> (raw)
In-Reply-To: <20221103101627.32502-1-tzimmermann@suse.de>
Properties of 32-bit integers are returned from the OF device tree
as type __be32. Convert PCI vendor and device IDs from __be32 to host
endianness before comparing them to constants. All relevant machines
are old, big-endian Macintosh systems; hence the bug never happened
in practice.
Fixes sparse warnings shown below.
drivers/gpu/drm/tiny/ofdrm.c:237:17: warning: restricted __be32 degrades to integer
drivers/gpu/drm/tiny/ofdrm.c:238:18: warning: restricted __be32 degrades to integer
drivers/gpu/drm/tiny/ofdrm.c:238:54: warning: restricted __be32 degrades to integer
See [1] for the bug report.
v2:
* convert endianness (Alex)
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/dri-devel/202210192208.D888I6X7-lkp@intel.com/ # [1]
---
drivers/gpu/drm/tiny/ofdrm.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c
index 0e1cc2369afcc..44f13a2b372be 100644
--- a/drivers/gpu/drm/tiny/ofdrm.c
+++ b/drivers/gpu/drm/tiny/ofdrm.c
@@ -231,7 +231,7 @@ static u64 display_get_address_of(struct drm_device *dev, struct device_node *of
return address;
}
-static bool is_avivo(__be32 vendor, __be32 device)
+static bool is_avivo(u32 vendor, u32 device)
{
/* This will match most R5xx */
return (vendor == PCI_VENDOR_ID_ATI) &&
@@ -265,8 +265,13 @@ static enum ofdrm_model display_get_model_of(struct drm_device *dev, struct devi
of_parent = of_get_parent(of_node);
vendor_p = of_get_property(of_parent, "vendor-id", NULL);
device_p = of_get_property(of_parent, "device-id", NULL);
- if (vendor_p && device_p && is_avivo(*vendor_p, *device_p))
- model = OFDRM_MODEL_AVIVO;
+ if (vendor_p && device_p) {
+ u32 vendor = be32_to_cpup(vendor_p);
+ u32 device = be32_to_cpup(device_p);
+
+ if (is_avivo(vendor, device))
+ model = OFDRM_MODEL_AVIVO;
+ }
of_node_put(of_parent);
} else if (of_device_is_compatible(of_node, "qemu,std-vga")) {
model = OFDRM_MODEL_QEMU;
--
2.38.0
next prev parent reply other threads:[~2022-11-03 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 10:16 [PATCH v3 0/2] drm/ofdrm: Fix sparse warnings Thomas Zimmermann
2022-11-03 10:16 ` Thomas Zimmermann [this message]
2022-11-03 10:16 ` [PATCH v3 2/2] drm/ofdrm: Cast error pointers to void __iomem * Thomas Zimmermann
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=20221103101627.32502-2-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=lkp@intel.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
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