Commit 7a4a04f4 authored by Maximilian Luz's avatar Maximilian Luz Committed by Hans de Goede
Browse files

platform/surface: tabletsw: Fix __le32 integer access



The sources.count field is a __le32 inside a packed struct. So use the
proper functions to access it.

Reported-by: default avatarkernel test robot <lkp@intel.com>
Fixes: 9f794056 ("platform/surface: Add KIP/POS tablet-mode switch driver")
Signed-off-by: default avatarMaximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20220717120735.2052160-1-luzmaximilian@gmail.com


Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 5c8b3f11
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -410,7 +410,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
	if (status)
		return status;

	if (sources.count == 0) {
	if (get_unaligned_le32(&sources.count) == 0) {
		dev_err(&sw->sdev->dev, "no posture sources found\n");
		return -ENODEV;
	}
@@ -422,7 +422,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
	 * is a device that provides multiple sources, at which point we can
	 * then try to figure out how to handle them.
	 */
	WARN_ON(sources.count > 1);
	WARN_ON(get_unaligned_le32(&sources.count) > 1);

	*source_id = get_unaligned_le32(&sources.id[0]);
	return 0;