Commit e67e865b authored by Thomas Zimmermann's avatar Thomas Zimmermann

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: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier 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
parent 47078311
...@@ -231,7 +231,7 @@ static u64 display_get_address_of(struct drm_device *dev, struct device_node *of ...@@ -231,7 +231,7 @@ static u64 display_get_address_of(struct drm_device *dev, struct device_node *of
return address; return address;
} }
static bool is_avivo(__be32 vendor, __be32 device) static bool is_avivo(u32 vendor, u32 device)
{ {
/* This will match most R5xx */ /* This will match most R5xx */
return (vendor == PCI_VENDOR_ID_ATI) && return (vendor == PCI_VENDOR_ID_ATI) &&
...@@ -265,8 +265,13 @@ static enum ofdrm_model display_get_model_of(struct drm_device *dev, struct devi ...@@ -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); of_parent = of_get_parent(of_node);
vendor_p = of_get_property(of_parent, "vendor-id", NULL); vendor_p = of_get_property(of_parent, "vendor-id", NULL);
device_p = of_get_property(of_parent, "device-id", NULL); device_p = of_get_property(of_parent, "device-id", NULL);
if (vendor_p && device_p && is_avivo(*vendor_p, *device_p)) 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; model = OFDRM_MODEL_AVIVO;
}
of_node_put(of_parent); of_node_put(of_parent);
} else if (of_device_is_compatible(of_node, "qemu,std-vga")) { } else if (of_device_is_compatible(of_node, "qemu,std-vga")) {
model = OFDRM_MODEL_QEMU; model = OFDRM_MODEL_QEMU;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment