Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9199418 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

mhi: core: Fix find_last_bit() usage



find_last_bit() relies on unsigned long pointer arguments. Driver
uses a type cast that generates the KASAN warning. Replace
find_last_bit() with __fls() to pass the value and avoid casting
pointer to make the warning go away.

Change-Id: I247e5c425ba0c44d04b518bd6d4f351f9c700b29
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent cf6a1b2d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. */
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. */

#include <linux/debugfs.h>
#include <linux/device.h>
@@ -89,9 +89,12 @@ struct mhi_controller *find_mhi_controller_by_name(const char *name)

const char *to_mhi_pm_state_str(enum MHI_PM_STATE state)
{
	int index = find_last_bit((unsigned long *)&state, 32);
	int index;

	if (index >= ARRAY_SIZE(mhi_pm_state_str))
	if (state)
		index = __fls(state);

	if (!state || index >= ARRAY_SIZE(mhi_pm_state_str))
		return "Invalid State";

	return mhi_pm_state_str[index];