spi: Fix build for Linux v6.8

For Linux v6.8, support for SPI controllers with multiple chip-selects
was added to the SPI core and this updated the 'chip_select' member of
the 'spi_device' structure to be an array. This breaks building the
Tegra124 SPI Slave driver and Tegra210 QUAD SPI driver.

A helper function, spi_get_chipselect(), was added for Linux v6.3 to
retrieve the chip-select for a SPI device and can be used for retrieving
the chip-select for all Linux v6.3+ kernels.

Add a conftest rule to detecting if spi_get_chipselect() is present and
if so use this for getting the chip-select. This fixes the build issues
for Linux v6.8.

Bug 4448428

Change-Id: Ia4f95ed96b9a18cc7da7a4a52305fc64bc31905c
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3050146
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2023-12-11 11:58:22 -08:00
committed by mobile promotions
parent df68c65bab
commit 9e2f7ecdf7
4 changed files with 60 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
###########################################################################
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Makefile file for NVIDIA Linux conftest
###########################################################################
@@ -151,6 +151,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_of_get_dai_name_has_index_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_rtd_to_codec
NV_CONFTEST_FUNCTION_COMPILE_TESTS += simple_util_dai_init
NV_CONFTEST_FUNCTION_COMPILE_TESTS += spi_driver_struct_remove_return_type_int
NV_CONFTEST_FUNCTION_COMPILE_TESTS += spi_get_chipselect
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tc_taprio_qopt_offload_struct_has_cmd
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_dev_iommu_get_stream_id
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_ivc_struct_has_iosys_map

View File

@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
PATH="${PATH}:/bin:/sbin:/usr/bin"
@@ -7463,6 +7463,28 @@ compile_test() {
compile_check_conftest "$CODE" "NV_SPI_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT" "" "types"
;;
spi_get_chipselect)
#
# Determine if the function 'spi_get_chip_select()' is present.
#
# In Linux v6.3, commit 303feb3cc06a ("spi: Add APIs in spi core to set/get
# spi->chip_select and spi->cs_gpiod") added a helper function,
# spi_get_chipselect(), so drivers did not need to access the
# 'spi_device->chip_select' directly. This Linux v6.8, commit 4d8ff6b0991d
# ("spi: Add multi-cs memories support in SPI core") updated the
# 'spi_device->chip_select' to be an array and so using spi_get_chipselect
# to retrieve the chipselect is required for Linux v6.8.
#
CODE="
#undef CONFIG_ACPI
#include <linux/spi/spi.h>
void conftest_spi_get_chipselect(void) {
spi_get_chipselect();
}"
compile_check_conftest "$CODE" "NV_SPI_GET_CHIPSELECT_PRESENT" "" "functions"
;;
tc_taprio_qopt_offload_struct_has_cmd)
#
# Determine if struct tc_taprio_qopt_offload has a member named cmd