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 <frankc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2843858
Reviewed-by: Ian Kaszubski <ikaszubski@nvidia.com>
Reviewed-by: Jonathan Hunter <jonathanh@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Frank Chen
2023-01-14 17:03:10 -08:00
committed by mobile promotions
parent 14032c34fb
commit 7514ddd6c0

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0 // 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 <linux/delay.h> #include <linux/delay.h>
#include <linux/fs.h> #include <linux/fs.h>
@@ -28,6 +28,7 @@
#include <media/cdi-mgr.h> #include <media/cdi-mgr.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/semaphore.h> #include <linux/semaphore.h>
#include <linux/version.h>
#include <asm/barrier.h> #include <asm/barrier.h>
@@ -1143,7 +1144,11 @@ static struct cdi_mgr_platform_data *of_cdi_mgr_pdata(struct platform_device
return pd; return pd;
} }
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)
static char *cdi_mgr_devnode(struct device *dev, umode_t *mode) 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) if (!mode)
return NULL; 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, cdi_mgr->gpio_arr[i].desc = devm_fwnode_get_gpiod_from_child(dev,
"devblk", &child->fwnode, GPIOD_ASIS, NULL); "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)) { if (IS_ERR(cdi_mgr->gpio_arr[i].desc)) {
ret = PTR_ERR(cdi_mgr->gpio_arr[i].desc); ret = PTR_ERR(cdi_mgr->gpio_arr[i].desc);
if (ret < 0) if (ret < 0)