Skip to content

Commit 17419a5

Browse files
committed
drm/vkms: Fix cpu_to_le16()/le16_to_cpu() warnings
Building with Sparse enabled prints this warning for cpu_to_le16() calls: warning: incorrect type in assignment (different base types) expected unsigned short [usertype] got restricted __le16 [usertype] And this warning for le16_to_cpu() calls: warning: cast to restricted __le16 Declare the target buffer as __le16 to fix both warnings. Reviewed-by: Thomas Zimmermann <[email protected]> Reviewed-by: Louis Chauvet <[email protected]> Acked-by: Maíra Canal <[email protected]> Signed-off-by: José Expósito <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f7f3ddb commit 17419a5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/gpu/drm/vkms/vkms_formats.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void XRGB8888_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixe
7575

7676
static void ARGB16161616_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel)
7777
{
78-
u16 *pixels = (u16 *)src_pixels;
78+
__le16 *pixels = (__force __le16 *)src_pixels;
7979

8080
out_pixel->a = le16_to_cpu(pixels[3]);
8181
out_pixel->r = le16_to_cpu(pixels[2]);
@@ -85,7 +85,7 @@ static void ARGB16161616_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_
8585

8686
static void XRGB16161616_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel)
8787
{
88-
u16 *pixels = (u16 *)src_pixels;
88+
__le16 *pixels = (__force __le16 *)src_pixels;
8989

9090
out_pixel->a = (u16)0xffff;
9191
out_pixel->r = le16_to_cpu(pixels[2]);
@@ -95,7 +95,7 @@ static void XRGB16161616_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_
9595

9696
static void RGB565_to_argb_u16(u8 *src_pixels, struct pixel_argb_u16 *out_pixel)
9797
{
98-
u16 *pixels = (u16 *)src_pixels;
98+
__le16 *pixels = (__force __le16 *)src_pixels;
9999

100100
s64 fp_rb_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(31));
101101
s64 fp_g_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(63));
@@ -178,7 +178,7 @@ static void argb_u16_to_XRGB8888(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel
178178

179179
static void argb_u16_to_ARGB16161616(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel)
180180
{
181-
u16 *pixels = (u16 *)dst_pixels;
181+
__le16 *pixels = (__force __le16 *)dst_pixels;
182182

183183
pixels[3] = cpu_to_le16(in_pixel->a);
184184
pixels[2] = cpu_to_le16(in_pixel->r);
@@ -188,17 +188,17 @@ static void argb_u16_to_ARGB16161616(u8 *dst_pixels, struct pixel_argb_u16 *in_p
188188

189189
static void argb_u16_to_XRGB16161616(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel)
190190
{
191-
u16 *pixels = (u16 *)dst_pixels;
191+
__le16 *pixels = (__force __le16 *)dst_pixels;
192192

193-
pixels[3] = 0xffff;
193+
pixels[3] = cpu_to_le16(0xffff);
194194
pixels[2] = cpu_to_le16(in_pixel->r);
195195
pixels[1] = cpu_to_le16(in_pixel->g);
196196
pixels[0] = cpu_to_le16(in_pixel->b);
197197
}
198198

199199
static void argb_u16_to_RGB565(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel)
200200
{
201-
u16 *pixels = (u16 *)dst_pixels;
201+
__le16 *pixels = (__force __le16 *)dst_pixels;
202202

203203
s64 fp_rb_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(31));
204204
s64 fp_g_ratio = drm_fixp_div(drm_int2fixp(65535), drm_int2fixp(63));

0 commit comments

Comments
 (0)