media: i2c: Fix build for Linux v6.1+

The IMX390 driver was recently updated and this broke building the
driver for Linux v6.1+ kernels. Revert the specific changes that broke
the build and update the max929x driver so that it can also be built for
Linux v6.1+ kernels.

Finally, replace 'gpio_cansleep' with 'gpiod_cansleep' because
'gpio_cansleep' was removed in Linux v6.5. This also aligns with the
other camera drivers that use 'gpiod_cansleep' instead of
gpio_cansleep'.

Bug 4505240

Change-Id: I46960bca1e1e4aeff9bd9fdaed8b2db2be104b5b
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3149880
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Ankur Pawar <ankurp@nvidia.com>
Reviewed-by: Brad Griffis <bgriffis@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2024-06-03 11:55:27 +01:00
committed by mobile promotions
parent adc35280cb
commit 9cb00122ac
2 changed files with 27 additions and 3 deletions

View File

@@ -4,6 +4,8 @@
* max929x.c - max929x IO Expander driver
*/
#include <nvidia/conftest.h>
#include <linux/seq_file.h>
#include <linux/debugfs.h>
#include <media/camera_common.h>
@@ -82,8 +84,12 @@ static struct regmap_config max929x_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
#if defined(NV_I2C_DRIVER_STRUCT_PROBE_WITHOUT_I2C_DEVICE_ID_ARG) /* Linux 6.3 */
static int max929x_probe(struct i2c_client *client)
#else
static int max929x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
#endif
{
struct device dev = client->dev;
struct device_node *np = (&dev)->of_node;
@@ -142,14 +148,20 @@ static int max929x_probe(struct i2c_client *client,
return 0;
}
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
static int max929x_remove(struct i2c_client *client)
#else
static void max929x_remove(struct i2c_client *client)
#endif
{
struct device dev = client->dev;
gpio_set_value(priv->pwdn_gpio, 0);
dev_dbg(&dev, "%s: \n", __func__);
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
return 0;
#endif
}
static const struct i2c_device_id max929x_id[] = {

View File

@@ -6,6 +6,8 @@
*
*/
#include <nvidia/conftest.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/gpio.h>
@@ -215,7 +217,7 @@ static int imx390_power_on(struct camera_common_data *s_data)
}
if (gpio_is_valid(pw->reset_gpio)) {
if (gpio_cansleep(pw->reset_gpio))
if (gpiod_cansleep(gpio_to_desc(pw->reset_gpio)))
gpio_set_value_cansleep(pw->reset_gpio, 0);
else
gpio_set_value(pw->reset_gpio, 0);
@@ -248,7 +250,7 @@ static int imx390_power_on(struct camera_common_data *s_data)
skip_power_seqn:
if (gpio_is_valid(pw->reset_gpio)) {
if (gpio_cansleep(pw->reset_gpio))
if (gpiod_cansleep(gpio_to_desc(pw->reset_gpio)))
gpio_set_value_cansleep(pw->reset_gpio, 1);
else
gpio_set_value(pw->reset_gpio, 1);
@@ -291,7 +293,7 @@ static int imx390_power_off(struct camera_common_data *s_data)
}
} else {
if (pw->reset_gpio) {
if (gpio_cansleep(pw->reset_gpio))
if (gpiod_cansleep(gpio_to_desc(pw->reset_gpio)))
gpio_set_value_cansleep(pw->reset_gpio, 0);
else
gpio_set_value(pw->reset_gpio, 0);
@@ -516,8 +518,12 @@ static const struct v4l2_subdev_internal_ops imx390_subdev_internal_ops = {
.open = imx390_open,
};
#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,
const struct i2c_device_id *id)
#endif
{
struct device *dev = &client->dev;
struct tegracam_device *tc_dev;
@@ -572,7 +578,11 @@ static int imx390_probe(struct i2c_client *client,
return 0;
}
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
static int imx390_remove(struct i2c_client *client)
#else
static void imx390_remove(struct i2c_client *client)
#endif
{
struct camera_common_data *s_data = to_camera_common_data(&client->dev);
struct imx390 *priv = (struct imx390 *)s_data->priv;
@@ -580,7 +590,9 @@ static int imx390_remove(struct i2c_client *client)
tegracam_v4l2subdev_unregister(priv->tc_dev);
tegracam_device_unregister(priv->tc_dev);
#if defined(NV_I2C_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 6.1 */
return 0;
#endif
}
static const struct i2c_device_id imx390_id[] = {