Re: [PATCH 1/2] drm/ofdrm: Cast PCI IDs to u32 for comparing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Am 27.10.22 um 15:07 schrieb Alexander Stein:
Hello Thomas,

Am Donnerstag, 27. Oktober 2022, 13:57:06 CEST schrieb Thomas Zimmermann:
Properties of 32-bit integers are returned from the OF device tree
as type __be32. Cast PCI vendor and device IDs from __be32 to u32
before comparing them to constants. 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.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
Link: https://lore.kernel.org/dri-devel/202210192208.D888I6X7-lkp@xxxxxxxxx/
# [1] ---
  drivers/gpu/drm/tiny/ofdrm.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tiny/ofdrm.c b/drivers/gpu/drm/tiny/ofdrm.c
index 0e1cc2369afcc..0da8b248ccc6e 100644
--- a/drivers/gpu/drm/tiny/ofdrm.c
+++ b/drivers/gpu/drm/tiny/ofdrm.c
@@ -231,8 +231,11 @@ 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(__be32 vendor_id, __be32 device_id)
  {
+	u32 vendor = (__force u32)vendor_id;
+	u32 device = (__force u32)device_id;

I don't have much context, but just from reading this, shouldn't this be
be32_to_cpu() instead?

I should have explained that in the commit message. The values are supposed to be in big endian. We compare to PCI ids. The code originally was taken from [1], which does the right thing. The next version will add this info to the commit message.

Best regards
Thomas

[1] https://elixir.bootlin.com/linux/v6.0.5/source/drivers/video/fbdev/offb.c#L357


Best regards,
Alexander

+
  	/* This will match most R5xx */
  	return (vendor == PCI_VENDOR_ID_ATI) &&
  	       ((device >= PCI_VENDOR_ID_ATI_R520 && device < 0x7800) ||





--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux