platform: tegra: rtcpu: Use conftest

Instead of relying on kernel version to determine if the 'remove'
callback for the 'bus_type' structure return an integer or void, add a
compile time test to the conftest.sh script to determine this at compile
time for the kernel being used. This is beneficial for working with 3rd
party Linux kernels that may have back-ported upstream changes into
their kernel and so the kernel version checks do not work.

Bug 4119327

Change-Id: I5457300619f5fb3b6afe61742bc6fce4cbefcd5d
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2985719
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-09-26 10:58:40 +01:00
committed by mobile promotions
parent 634e0c9734
commit 02d724565b
3 changed files with 27 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -388,10 +390,10 @@ static int tegra_ivc_bus_probe(struct device *dev)
return ret;
}
#if (KERNEL_VERSION(5, 15, 0) <= LINUX_VERSION_CODE)
static void tegra_ivc_bus_remove(struct device *dev)
#else
#if defined(NV_BUS_TYPE_STRUCT_REMOVE_HAS_INT_RETURN_TYPE) /* Linux v5.15 */
static int tegra_ivc_bus_remove(struct device *dev)
#else
static void tegra_ivc_bus_remove(struct device *dev)
#endif
{
if (dev->type == &tegra_ivc_channel_type) {
@@ -408,7 +410,7 @@ static int tegra_ivc_bus_remove(struct device *dev)
}
#if (KERNEL_VERSION(5, 15, 0) > LINUX_VERSION_CODE)
#if defined(NV_BUS_TYPE_STRUCT_REMOVE_HAS_INT_RETURN_TYPE) /* Linux v5.15 */
return 0;
#endif
}

View File

@@ -88,6 +88,7 @@ endef
# provided by the module-specific Kbuild files.
#
NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_remove_has_int_return_type
NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_struct_devnode_has_const_dev_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers_has_drm_driver_arg

View File

@@ -6293,6 +6293,25 @@ compile_test() {
compile_check_conftest "$CODE" "NV_CRYPTO_PRESENT" "" "symbols"
;;
bus_type_struct_remove_has_int_return_type)
#
# Determine if the 'remove' callback from the 'bus_type' structure
# has an integer return type.
#
# Commit fc7a6209d571 ("bus: Make remove callback return void") made
# the 'remove' callback return void instead of an integer in Linux
# v5.15.
#
CODE="
#include <linux/device/bus.h>
int conftest_bus_type_struct_remove_has_int_return_type(struct device *dev,
struct bus_type *bus) {
return bus->remove(dev);
}"
compile_check_conftest "$CODE" "NV_BUS_TYPE_STRUCT_REMOVE_HAS_INT_RETURN_TYPE" "" "types"
;;
class_struct_devnode_has_const_dev_arg)
#
# Determine if the 'class' structure devnode function pointer