From 7514ddd6c0f99e9d54e47b4d8e2c5cfcb9e27d6a Mon Sep 17 00:00:00 2001 From: Frank Chen Date: Sat, 14 Jan 2023 17:03:10 -0800 Subject: [PATCH] media: camera: Fix CDI MGR driver for Linux v6.2 Upstream Linux kernel commit ff62b8e6588f ("driver core: make struct class.devnode() take a const *") updated the 'devnode' function pointer under the class structure to take a const device struct. This breaks building the Tegra CDI MDR driver with Linux v6.2. Make the necessary changes to the CDI MGR driver to fix the build breakage. Also update CDI MGR GPIO code since devm_fwnode_get_gpiod_from_child() is deprecated in Linux v6.2. Switch to use devm_fwnode_gpiod_get_index() for Linux v6.2. Bug 3936429 Change-Id: I327ebe1fa42d89a63e0b483d3ce1ff1b8b168532 Signed-off-by: Frank Chen Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2843858 Reviewed-by: Ian Kaszubski Reviewed-by: Jonathan Hunter GVS: Gerrit_Virtual_Submit --- drivers/media/platform/tegra/cdi/cdi_mgr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/tegra/cdi/cdi_mgr.c b/drivers/media/platform/tegra/cdi/cdi_mgr.c index c2669d57..85b3d01c 100644 --- a/drivers/media/platform/tegra/cdi/cdi_mgr.c +++ b/drivers/media/platform/tegra/cdi/cdi_mgr.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (c) 2015-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// Copyright (c) 2015-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include #include @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -1143,7 +1144,11 @@ static struct cdi_mgr_platform_data *of_cdi_mgr_pdata(struct platform_device return pd; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) static char *cdi_mgr_devnode(struct device *dev, umode_t *mode) +#else +static char *cdi_mgr_devnode(const struct device *dev, umode_t *mode) +#endif { if (!mode) return NULL; @@ -1303,8 +1308,13 @@ static int cdi_mgr_configure_gpios(struct device *dev, struct cdi_mgr_priv *cdi_ } } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0) cdi_mgr->gpio_arr[i].desc = devm_fwnode_get_gpiod_from_child(dev, "devblk", &child->fwnode, GPIOD_ASIS, NULL); +#else + cdi_mgr->gpio_arr[i].desc = devm_fwnode_gpiod_get_index(dev, + &child->fwnode, "devblk", 0, GPIOD_ASIS, NULL); +#endif if (IS_ERR(cdi_mgr->gpio_arr[i].desc)) { ret = PTR_ERR(cdi_mgr->gpio_arr[i].desc); if (ret < 0)