i2c: Use conftest to find if i2c_driver struct has new_probe

Use conftest method to find if i2c_driver struct has the
member as new_probe. This is dropped from Linux 6.6 with
commit 5eb1e6e459cf ("i2c: Drop legacy callback .probe_new()")

Bug 4346767

Change-Id: I10b539dfa1bb363ad6cf5fc28a9ebd0ca4e88b48
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3028631
(cherry picked from commit 537a307ffd)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3053704
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
This commit is contained in:
Laxman Dewangan
2023-12-05 15:35:46 +00:00
committed by mobile promotions
parent a39a2be24e
commit 6ad6325734
7 changed files with 41 additions and 19 deletions

View File

@@ -24,9 +24,6 @@ endif
# Changes done in Linux 6.6 onwards # Changes done in Linux 6.6 onwards
ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_6); echo $$?),0) ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_6); echo $$?),0)
# probe_new is removed from i2c driver structure
subdir-ccflags-y += -DNV_I2C_LEGACY_PROBE_NEW_REMOVED
# v4l2_async_subdev is renamed to v4l2_async_connection. # v4l2_async_subdev is renamed to v4l2_async_connection.
subdir-ccflags-y += -DNV_V4L2_ASYNC_SUBDEV_RENAME subdir-ccflags-y += -DNV_V4L2_ASYNC_SUBDEV_RENAME

View File

@@ -1,5 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
// Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/hwmon-sysfs.h> #include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
@@ -1256,10 +1258,10 @@ static struct i2c_driver f75308_driver = {
.of_match_table = of_match_ptr(f75308_match_table), .of_match_table = of_match_ptr(f75308_match_table),
}, },
.detect = f75308_detect, .detect = f75308_detect,
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED) #if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe = f75308_probe,
#else
.probe_new = f75308_probe, .probe_new = f75308_probe,
#else
.probe = f75308_probe,
#endif #endif
.remove = f75308_remove, .remove = f75308_remove,
.address_list = f75308_addr, .address_list = f75308_addr,

View File

@@ -2,9 +2,11 @@
/* /*
* MAXIM DP Serializer driver for MAXIM GMSL Serializers * MAXIM DP Serializer driver for MAXIM GMSL Serializers
* *
* Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
*/ */
#include <nvidia/conftest.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/fwnode.h> #include <linux/fwnode.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
@@ -1373,10 +1375,10 @@ static struct i2c_driver max_gmsl_dp_ser_i2c_driver = {
.pm = &max_gmsl_dp_ser_pm_ops, .pm = &max_gmsl_dp_ser_pm_ops,
#endif #endif
}, },
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED) #if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe = max_gmsl_dp_ser_probe,
#else
.probe_new = max_gmsl_dp_ser_probe, .probe_new = max_gmsl_dp_ser_probe,
#else
.probe = max_gmsl_dp_ser_probe,
#endif #endif
.remove = max_gmsl_dp_ser_remove, .remove = max_gmsl_dp_ser_remove,
}; };

View File

@@ -2,9 +2,11 @@
/* /*
* MAXIM HDMI Serializer driver for MAXIM GMSL Serializers * MAXIM HDMI Serializer driver for MAXIM GMSL Serializers
* *
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. * Copyright (c) 2023-2024, NVIDIA CORPORATION. All rights reserved.
*/ */
#include <nvidia/conftest.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/fwnode.h> #include <linux/fwnode.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
@@ -366,10 +368,10 @@ static struct i2c_driver maxim_gmsl_hdmi_ser_i2c_driver = {
.pm = &maxim_gmsl_hdmi_ser_pm_ops, .pm = &maxim_gmsl_hdmi_ser_pm_ops,
#endif #endif
}, },
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED) #if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe = maxim_gmsl_hdmi_ser_probe,
#else
.probe_new = maxim_gmsl_hdmi_ser_probe, .probe_new = maxim_gmsl_hdmi_ser_probe,
#else
.probe = maxim_gmsl_hdmi_ser_probe,
#endif #endif
.remove = maxim_gmsl_hdmi_ser_remove, .remove = maxim_gmsl_hdmi_ser_remove,
}; };

View File

@@ -1,10 +1,12 @@
// SPDX-License-Identifier: GPL-2.0-only // SPDX-License-Identifier: GPL-2.0-only
/* /*
* Copyright (C) 2022-2023, NVIDIA Corporation. All rights reserved. * Copyright (C) 2022-2024, NVIDIA Corporation. All rights reserved.
* *
* DS90UH983-Q1 DP to FPD-Link Serializer driver * DS90UH983-Q1 DP to FPD-Link Serializer driver
*/ */
#include <nvidia/conftest.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/fwnode.h> #include <linux/fwnode.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
@@ -1039,10 +1041,10 @@ static struct i2c_driver ti_fpdlink_dp_ser_i2c_driver = {
.name = "ti_fpdlink_dp_ser", .name = "ti_fpdlink_dp_ser",
.of_match_table = of_match_ptr(ti_fpdlink_dp_ser_dt_ids), .of_match_table = of_match_ptr(ti_fpdlink_dp_ser_dt_ids),
}, },
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED) #if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe = ti_fpdlink_dp_ser_probe,
#else
.probe_new = ti_fpdlink_dp_ser_probe, .probe_new = ti_fpdlink_dp_ser_probe,
#else
.probe = ti_fpdlink_dp_ser_probe,
#endif #endif
.remove = ti_fpdlink_dp_ser_remove, .remove = ti_fpdlink_dp_ser_remove,
}; };

View File

@@ -117,6 +117,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_coalesce_has_coal_and_
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_ringparam_has_ringparam_and_extack_args
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_file_rcu_has_double_ptr_file_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_has_probe_new
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock
NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit

View File

@@ -5400,6 +5400,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_I2C_UNREGISTER_DEVICE_PRESENT" "" "functions" compile_check_conftest "$CODE" "NV_I2C_UNREGISTER_DEVICE_PRESENT" "" "functions"
;; ;;
i2c_driver_struct_has_probe_new)
#
# Determine if struct i2c_driver has probe_new() present
#
# Added by commit 5eb1e6e459cf ("i2c: Drop legacy callback .probe_new()")
#
CODE="
#define _LINUX_EFI_H
#include <linux/i2c.h>
int conftest_i2c_driver_struct_has_probe_new(void) {
return offsetof(struct i2c_driver, probe_new);
}"
compile_check_conftest "$CODE" "NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW" "" "types"
;;
of_get_named_gpio) of_get_named_gpio)
# #
# Determine if of_get_named_gpio() function is present # Determine if of_get_named_gpio() function is present