spi: Fix build for Linux v6.13

Commit 0809a9ccac4a ("spi: remove {devm_}spi_alloc_master/slave()")
removed devm_spi_alloc_master() and this breaks building the Tegra124
and Tegra210 SPI drivers for Linux v6.13. Commit b8d3b056a78d ("spi:
introduce new helpers with using modern naming") previously added new
helpers in Linux v6.2 which should be instead. Add a test for conftest
to detect if the kernel supports the function devm_spi_alloc_host()
and if so use this function.

Bug 4991705

Change-Id: I1d639297ef7adfdcde50927360607639b45a4a60
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3261698
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
This commit is contained in:
Jon Hunter
2024-10-04 16:05:39 +01:00
parent a8777837dd
commit ef57537991
4 changed files with 26 additions and 0 deletions

View File

@@ -2017,7 +2017,11 @@ static int tegra_spi_probe(struct platform_device *pdev)
pdata->rx_trig_words != 4 && pdata->rx_trig_words != 8)
pdata->rx_trig_words = 0;
#if defined(NV_DEVM_SPI_ALLOC_HOST_PRESENT) /* Linux v6.2 */
controller = devm_spi_alloc_host(&pdev->dev, sizeof(*tspi));
#else
controller = devm_spi_alloc_master(&pdev->dev, sizeof(*tspi));
#endif
if (!controller) {
dev_err(&pdev->dev, "controller allocation failed\n");
return -ENOMEM;

View File

@@ -1660,7 +1660,11 @@ static int tegra_qspi_probe(struct platform_device *pdev)
int bus_num;
u32 as_delay;
#if defined(NV_DEVM_SPI_ALLOC_HOST_PRESENT) /* Linux v6.2 */
controller = devm_spi_alloc_host(&pdev->dev, sizeof(*tqspi));
#else
controller = devm_spi_alloc_master(&pdev->dev, sizeof(*tqspi));
#endif
if (!controller)
return -ENOMEM;

View File

@@ -110,6 +110,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += devfreq_dev_profile_has_is_cooling_device
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devfreq_has_freq_table
NV_CONFTEST_FUNCTION_COMPILE_TESTS += device_add_disk_has_int_return_type
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_pm_domain_attach_list
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_spi_alloc_host
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_tegra_core_dev_init_opp_table_common
NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register
NV_CONFTEST_FUNCTION_COMPILE_TESTS += disk_check_media_change

View File

@@ -6919,6 +6919,23 @@ compile_test() {
compile_check_conftest "$CODE" "NV_DEVM_PM_DOMAIN_ATTACH_LIST_PRESENT" "" "functions"
;;
devm_spi_alloc_host)
#
# Determine whether devm_spi_alloc_host() is present.
#
# Commit b8d3b056a78d ("spi: introduce new helpers with using modern
# naming") added devm_spi_alloc_host() in Linux v6.2.
#
CODE="
#undef CONFIG_ACPI
#include <linux/spi/spi.h>
void conftest_devm_spi_alloc_host(void) {
devm_spi_alloc_host();
}"
compile_check_conftest "$CODE" "NV_DEVM_SPI_ALLOC_HOST_PRESENT" "" "functions"
;;
devm_tegra_core_dev_init_opp_table_common)
#
# Determine whether devm_tegra_core_dev_init_opp_table_common is