diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2022-11-03 13:16:26 +0300 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2022-11-04 16:44:02 +0300 |
commit | e67e865b90b511bf78357ff36fdef99627d829c9 (patch) | |
tree | e4c6616f0053806cddfd5d561938b7ac328d9e83 /drivers/gpu/drm/tiny/ofdrm.c | |
parent | 47078311b8efebdefd5b3b2f87e2b02b14f49c66 (diff) | |
download | linux-e67e865b90b511bf78357ff36fdef99627d829c9.tar.xz |
drm/ofdrm: Convert PCI IDs to CPU endianness for comparing
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]
Link: https://patchwork.freedesktop.org/patch/msgid/20221103101627.32502-2-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/tiny/ofdrm.c')
-rw-r--r-- | drivers/gpu/drm/tiny/ofdrm.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c index 0e1cc2369afc..44f13a2b372b 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; |