i2c: Use conftest to find if i2c driver probe has i2c_device_i2d arg

Determine if probe of struct i2c_driver has i2c_device_id argument
or not.

This argument get removed from commit 03c835f498b5 ("i2c: Switch
.probe() to not take an id parameter") form Linux 6.3.

Bug 4346767

Change-Id: Ife73b29946246fce5bfcedcabe15992432d86348
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3030809
(cherry picked from commit 2884c4b380)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3054211
Tested-by: Jonathan Hunter <jonathanh@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Laxman Dewangan
2023-12-08 09:12:49 +00:00
committed by mobile promotions
parent 6ad6325734
commit 14abda2794
26 changed files with 90 additions and 26 deletions

View File

@@ -14,6 +14,8 @@
* };
*/
#include <nvidia/conftest.h>
#include <linux/device.h>
#include <linux/version.h>
#include <linux/i2c.h>
@@ -1627,7 +1629,7 @@ static int bmi_init(struct bmi_state *st, const struct i2c_device_id *id)
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int bmi_probe(struct i2c_client *client)
#else
static int bmi_probe(struct i2c_client *client, const struct i2c_device_id *id)

View File

@@ -5,6 +5,8 @@
* Copyright (C) 2022-2023 NVIDIA CORPORATION. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -242,7 +244,7 @@ static int nvvrs11_vendor_info(struct nvvrs11_chip *chip)
return 0;
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int nvvrs11_probe(struct i2c_client *client)
#else
static int nvvrs11_probe(struct i2c_client *client,

View File

@@ -5,6 +5,8 @@
* ar1335.c - AR1335 sensor driver
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -2361,7 +2363,7 @@ exit:
return ret;
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int cam_probe(struct i2c_client *client)
#else
static int cam_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* Lontium LT6911UXC HDMI-CSI bridge driver
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -442,7 +444,7 @@ static struct camera_common_sensor_ops lt6911uxc_common_ops = {
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int lt6911uxc_probe(struct i2c_client *client)
#else
static int lt6911uxc_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* max9295.c - max9295 GMSL Serializer driver
*/
#include <nvidia/conftest.h>
#include <media/camera_common.h>
#include <linux/module.h>
#include <media/max9295.h>
@@ -463,7 +465,7 @@ static struct regmap_config max9295_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int max9295_probe(struct i2c_client *client)
#else
static int max9295_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* max9296.c - max9296 GMSL Deserializer driver
*/
#include <nvidia/conftest.h>
#include <linux/gpio.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -846,7 +848,7 @@ static struct regmap_config max9296_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int max9296_probe(struct i2c_client *client)
#else
static int max9296_probe(struct i2c_client *client,

View File

@@ -7,6 +7,8 @@
/* #define DEBUG */
#include <nvidia/conftest.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <media/camera_common.h>
@@ -226,7 +228,7 @@ static struct regmap_config max96712_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int max96712_probe(struct i2c_client *client)
#else
static int max96712_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* ar0234.c - ar0234 sensor driver
*/
#include <nvidia/conftest.h>
#define DEBUG 1
#include <linux/slab.h>
#include <linux/uaccess.h>
@@ -1043,7 +1045,7 @@ static int ar0234_board_setup(struct ar0234 *priv)
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int ar0234_probe(struct i2c_client *client)
#else
static int ar0234_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* nv_hawk_owl.c.c - ar0234 sensor driver
*/
#include <nvidia/conftest.h>
#define DEBUG 0
#include <linux/slab.h>
#include <linux/uaccess.h>
@@ -1433,7 +1435,7 @@ static int ar0234_hawk_owl_deser_ser_program(struct ar0234 *priv)
return err;
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int ar0234_probe(struct i2c_client *client)
#else
static int ar0234_probe(struct i2c_client *client,

View File

@@ -5,6 +5,8 @@
* Copyright (c) 2016-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -775,7 +777,7 @@ static const struct v4l2_subdev_internal_ops imx185_subdev_internal_ops = {
.open = imx185_open,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int imx185_probe(struct i2c_client *client)
#else
static int imx185_probe(struct i2c_client *client,

View File

@@ -6,6 +6,8 @@
*
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -691,7 +693,7 @@ static const struct v4l2_subdev_internal_ops imx219_subdev_internal_ops = {
.open = imx219_open,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int imx219_probe(struct i2c_client *client)
#else
static int imx219_probe(struct i2c_client *client,

View File

@@ -5,6 +5,8 @@
* Copyright (c) 2015-2023, NVIDIA CORPORATION. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -1260,7 +1262,7 @@ static const struct v4l2_subdev_internal_ops imx274_subdev_internal_ops = {
.open = imx274_open,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int imx274_probe(struct i2c_client *client)
#else
static int imx274_probe(struct i2c_client *client,

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2017-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -695,7 +697,7 @@ static const struct v4l2_subdev_internal_ops imx318_subdev_internal_ops = {
.open = imx318_open,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int imx318_probe(struct i2c_client *client)
#else
static int imx318_probe(struct i2c_client *client,

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -752,7 +754,7 @@ error:
return err;
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int imx390_probe(struct i2c_client *client)
#else
static int imx390_probe(struct i2c_client *client,

View File

@@ -8,6 +8,8 @@
* nv_imx477.c - imx477 sensor driver
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -720,7 +722,7 @@ static const struct v4l2_subdev_internal_ops imx477_subdev_internal_ops = {
.open = imx477_open,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int imx477_probe(struct i2c_client *client)
#else
static int imx477_probe(struct i2c_client *client,

View File

@@ -6,6 +6,8 @@
*
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -1146,7 +1148,7 @@ static const struct v4l2_subdev_internal_ops ov5693_subdev_internal_ops = {
.open = ov5693_open,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int ov5693_probe(struct i2c_client *client)
#else
static int ov5693_probe(struct i2c_client *client,

View File

@@ -5,6 +5,8 @@
* Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <linux/i2c.h>
@@ -258,7 +260,7 @@ static struct regmap_config pca9570_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int pca9570_probe(struct i2c_client *client)
#else
static int pca9570_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* virtual_i2c_mux.c - virtual i2c mux driver for P3762 & P3783 GMSL boards.
*/
#include <nvidia/conftest.h>
#include <linux/i2c.h>
#include <linux/i2c-mux.h>
#include <linux/module.h>
@@ -47,7 +49,7 @@ static int virtual_i2c_mux_deselect(struct i2c_mux_core *muxc, u32 chan)
return ret;
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int virtual_i2c_mux_probe(struct i2c_client *client)
#else
static int virtual_i2c_mux_probe(struct i2c_client *client,

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/fs.h>
@@ -564,7 +566,7 @@ static void cdi_dev_get_cim_ver(struct device_node *np, struct cdi_dev_info *inf
}
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int cdi_dev_probe(struct i2c_client *client)
#else
static int cdi_dev_probe(struct i2c_client *client,

View File

@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
// Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#include <nvidia/conftest.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/fs.h>
@@ -427,7 +429,7 @@ static const struct file_operations isc_dev_fileops = {
.release = isc_dev_release,
};
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int isc_dev_probe(struct i2c_client *client)
#else
static int isc_dev_probe(struct i2c_client *client,

View File

@@ -4,6 +4,8 @@
* Maxim MAX77851 MFD Driver
*/
#include <nvidia/conftest.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mfd/core.h>
@@ -14,7 +16,6 @@
#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/version.h>
#define IS_MX_MASTER23(fps) ((fps == MX_FPS_MASTER2) || (fps == MX_FPS_MASTER3))
#define IS_MX_MASTER01(fps) ((fps == MX_FPS_MASTER0) || (fps == MX_FPS_MASTER1))
@@ -503,7 +504,7 @@ static void max77851_pm_power_off(void)
FPS_SW_COLD_RST, FPS_SW_COLD_RST);
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int max77851_probe(struct i2c_client *client)
#else
static int max77851_probe(struct i2c_client *client,

View File

@@ -5,6 +5,8 @@
* Copyright (C) 2020-2023 NVIDIA CORPORATION. All rights reserved.
*/
#include <nvidia/conftest.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/mfd/core.h>
@@ -16,7 +18,6 @@
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/version.h>
static const struct resource rtc_resources[] = {
DEFINE_RES_IRQ(NVVRS_PSEQ_INT_SRC1_RTC),
@@ -185,7 +186,7 @@ static int nvvrs_pseq_vendor_info(struct nvvrs_pseq_chip *chip)
return 0;
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int nvvrs_pseq_probe(struct i2c_client *client)
#else
static int nvvrs_pseq_probe(struct i2c_client *client,

View File

@@ -185,7 +185,7 @@ static bool is_pex9749(struct i2c_client *client)
}
}
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int pex9749_probe(struct i2c_client *client)
#else
static int pex9749_probe(struct i2c_client *client, const struct i2c_device_id *id)

View File

@@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <nvidia/conftest.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
@@ -1378,7 +1381,7 @@ static int fusb301_pm_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(fusb301_dev_pm_ops,
fusb301_pm_suspend, fusb301_pm_resume);
#if KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int fusb301_probe(struct i2c_client *client)
#else
static int fusb301_probe(struct i2c_client *client,

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 += get_file_rcu_has_double_ptr_file_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages
NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_driver_struct_probe_without_i2c_device_id_arg
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

View File

@@ -5400,6 +5400,24 @@ compile_test() {
compile_check_conftest "$CODE" "NV_I2C_UNREGISTER_DEVICE_PRESENT" "" "functions"
;;
i2c_driver_struct_probe_without_i2c_device_id_arg)
#
# Determine if function probe() of struct i2c_driver has
# struct i2c_device_id as argument or not.
#
# Removed by commit 03c835f498b54 ("i2c: Switch .probe() to not take an id parameter")
# Linux 6.3
#
CODE="
#define _LINUX_EFI_H
#include <linux/i2c.h>
void conftest_i2c_driver_struct_probe_without_i2c_device_id_arg(struct i2c_driver *i2cd) {
i2cd->probe(NULL);
}"
compile_check_conftest "$CODE" "NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG" "" "types"
;;
i2c_driver_struct_has_probe_new)
#
# Determine if struct i2c_driver has probe_new() present