ANDROID: cpufreq: add macro guard to protect vendor hook

To fix build fail of patch [1] by adding the macro guard to protect the
vendor hook register caller and its callback function.

The report log [2] shows build fail due to the absence of macro
definition of CONFIG_ANDROID_VENDOR_HOOKS.

[1] https://android-review.googlesource.com/c/kernel/common/+/2357403
[2] https://storage.tuxsuite.com/public/clangbuiltlinux/continuous-integration2/builds/2JGC8dCPsZEMPlkPuFiztM7k46n/build.log

Bug: 260537724
Change-Id: I33fe623e3cbe82647bda7c43d36e66ce8e22b11f
Signed-off-by: Jia-Wei Chang <jia-wei.chang@mediatek.com>
This commit is contained in:
Jia-Wei Chang
2022-12-29 13:59:53 +08:00
committed by Todd Kjos
parent 7a3d34495c
commit 0ef8ae8d3a
2 changed files with 12 additions and 0 deletions

View File

@@ -13,8 +13,10 @@
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/slab.h>
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
#include <linux/device.h>
#include <trace/hooks/cpufreq.h>
#endif
#define LUT_MAX_ENTRIES 32U
#define LUT_FREQ GENMASK(11, 0)
@@ -251,10 +253,12 @@ static void mtk_cpufreq_register_em(struct cpufreq_policy *policy)
&em_cb, policy->cpus, true);
}
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
static void mtk_cpufreq_suppress(void *data, struct device *dev, int val)
{
dev_set_uevent_suppress(dev, val);
}
#endif
static struct cpufreq_driver cpufreq_mtk_hw_driver = {
.flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
@@ -287,7 +291,9 @@ static int mtk_cpufreq_hw_driver_probe(struct platform_device *pdev)
if (ret)
dev_err(&pdev->dev, "CPUFreq HW driver failed to register\n");
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
ret = register_trace_android_vh_cpufreq_offline(mtk_cpufreq_suppress, NULL);
#endif
return ret;
}

View File

@@ -15,8 +15,10 @@
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/thermal.h>
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
#include <linux/device.h>
#include <trace/hooks/cpufreq.h>
#endif
#define MIN_VOLT_SHIFT (100000)
#define MAX_VOLT_SHIFT (200000)
@@ -464,10 +466,12 @@ static int mtk_cpufreq_exit(struct cpufreq_policy *policy)
return 0;
}
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
static void mtk_cpufreq_suppress(void *data, struct device *dev, int val)
{
dev_set_uevent_suppress(dev, val);
}
#endif
static struct cpufreq_driver mtk_cpufreq_driver = {
.flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK |
@@ -516,7 +520,9 @@ static int mtk_cpufreq_probe(struct platform_device *pdev)
goto release_dvfs_info_list;
}
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
ret = register_trace_android_vh_cpufreq_offline(mtk_cpufreq_suppress, NULL);
#endif
return 0;