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
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Laxman Dewangan
2023-12-05 15:35:46 +00:00
committed by mobile promotions
parent 21a661c58f
commit 537a307ffd
7 changed files with 37 additions and 15 deletions

View File

@@ -40,9 +40,6 @@ ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_6); echo $$?),0)
export CONFIG_SND_SOC_MOVE_DAI_PROBE_TO_OPS=y
subdir-ccflags-y += -DNV_SND_SOC_DAI_OPS_STRUCT_HAS_PROBE_ARG
# probe_new is removed from i2c driver structure
subdir-ccflags-y += -DNV_I2C_LEGACY_PROBE_NEW_REMOVED
# API changes to replace u8 with unsigned char
subdir-ccflags-y += -DNV_TTY_SERIAL_TYPE_U8_CHANGE

View File

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

View File

@@ -5,6 +5,8 @@
* Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/device.h>
#include <linux/fwnode.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,
#endif
},
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED)
.probe = max_gmsl_dp_ser_probe,
#else
#if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe_new = max_gmsl_dp_ser_probe,
#else
.probe = max_gmsl_dp_ser_probe,
#endif
.remove = max_gmsl_dp_ser_remove,
};

View File

@@ -5,6 +5,8 @@
* Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/device.h>
#include <linux/fwnode.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,
#endif
},
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED)
.probe = maxim_gmsl_hdmi_ser_probe,
#else
#if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe_new = maxim_gmsl_hdmi_ser_probe,
#else
.probe = maxim_gmsl_hdmi_ser_probe,
#endif
.remove = maxim_gmsl_hdmi_ser_remove,
};

View File

@@ -5,6 +5,8 @@
* DS90UH983-Q1 DP to FPD-Link Serializer driver
*/
#include <nvidia/conftest.h>
#include <linux/device.h>
#include <linux/fwnode.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",
.of_match_table = of_match_ptr(ti_fpdlink_dp_ser_dt_ids),
},
#if defined(NV_I2C_LEGACY_PROBE_NEW_REMOVED)
.probe = ti_fpdlink_dp_ser_probe,
#else
#if defined(NV_I2C_DRIVER_STRUCT_HAS_PROBE_NEW) /* Dropped on Linux 6.6 */
.probe_new = ti_fpdlink_dp_ser_probe,
#else
.probe = ti_fpdlink_dp_ser_probe,
#endif
.remove = ti_fpdlink_dp_ser_remove,
};

View File

@@ -116,6 +116,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 += get_file_rcu_has_double_ptr_file_arg
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 += iommu_map_has_gfp_arg
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"
;;
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)
#
# Determine if of_get_named_gpio() function is present