From c04513ee6f787a70c9cc839117918e92e38ae9ff Mon Sep 17 00:00:00 2001 From: Josh Kergan Date: Tue, 24 Oct 2017 18:31:28 -0700 Subject: drivers:camera: Update cameras to use common init All cameras were doing the same setup and cleanup. This common code was moved to camera_common and now all cameras should behave the same after probe finishes. JIRA CHWI-1369 Change-Id: If45351cf051e08015d2edb118a0ee2d1630a72da Signed-off-by: Josh Kergan Reviewed-on: https://git-master.nvidia.com/r/1585024 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/media/i2c/imx185.c | 14 +++----------- drivers/media/i2c/imx214.c | 12 ++++-------- drivers/media/i2c/imx219.c | 9 ++++----- drivers/media/i2c/imx274.c | 14 +++----------- drivers/media/i2c/ov10823.c | 10 +++------- drivers/media/i2c/ov23850.c | 10 +++------- drivers/media/i2c/ov5693.c | 11 ++++------- drivers/media/i2c/ov9281.c | 8 ++------ drivers/media/spi/imx204.c | 13 +++---------- 9 files changed, 29 insertions(+), 72 deletions(-) (limited to 'drivers') diff --git a/drivers/media/i2c/imx185.c b/drivers/media/i2c/imx185.c index e8f6fa353..8c72aafdc 100644 --- a/drivers/media/i2c/imx185.c +++ b/drivers/media/i2c/imx185.c @@ -967,9 +967,6 @@ static struct camera_common_pdata *imx185_parse_dt(struct i2c_client *client, } board_priv_pdata->reset_gpio = (unsigned int)gpio; - if (s_data->sensor_props.num_modes == 0) - dev_err(&client->dev, "Failed to load mode info\n"); - return board_priv_pdata; } @@ -995,7 +992,6 @@ static int imx185_probe(struct i2c_client *client, { struct camera_common_data *common_data; struct imx185 *priv; - char debugfs_name[10]; int err; dev_info(&client->dev, "[IMX185]: probing v4l2 sensor at addr 0x%0x.\n", @@ -1059,15 +1055,11 @@ static int imx185_probe(struct i2c_client *client, if (err) return err; - err = camera_common_parse_ports(&client->dev, common_data); + err = camera_common_initialize(common_data, "imx185"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize imx185.\n"); return err; } - sprintf(debugfs_name, "imx185_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: name %s\n", __func__, debugfs_name); - - camera_common_create_debugfs(common_data, debugfs_name); v4l2_i2c_subdev_init(priv->subdev, client, &imx185_subdev_ops); @@ -1111,7 +1103,7 @@ imx185_remove(struct i2c_client *client) #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c index 3ba253451..5de57252e 100644 --- a/drivers/media/i2c/imx214.c +++ b/drivers/media/i2c/imx214.c @@ -1,7 +1,7 @@ /* * imx214.c - imx214 sensor driver * - * Copyright (c) 2013-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2013-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -1121,7 +1121,6 @@ static int imx214_probe(struct i2c_client *client, struct camera_common_data *common_data; struct device_node *node = client->dev.of_node; struct imx214 *priv; - char debugfs_name[10]; int err; pr_info("[IMX214]: probing v4l2 sensor.\n"); @@ -1186,14 +1185,11 @@ static int imx214_probe(struct i2c_client *client, if (err) return err; - err = camera_common_parse_ports(client, common_data); + err = camera_common_initialize(common_data, "imx214"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize imx214.\n"); return err; } - sprintf(debugfs_name, "imx214_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: name %s\n", __func__, debugfs_name); - camera_common_create_debugfs(common_data, debugfs_name); v4l2_i2c_subdev_init(priv->subdev, client, &imx214_subdev_ops); @@ -1242,7 +1238,7 @@ imx214_remove(struct i2c_client *client) media_entity_cleanup(&priv->subdev->entity); #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index f56787ac3..068214eb7 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -706,7 +706,6 @@ static int imx219_probe(struct i2c_client *client, struct device_node *node = client->dev.of_node; struct imx219 *priv; int err; - char debugfs_name[32]; if (!IS_ENABLED(CONFIG_OF) || !node) return -EINVAL; @@ -771,9 +770,9 @@ static int imx219_probe(struct i2c_client *client, if (err) return err; - snprintf(debugfs_name, sizeof(debugfs_name), "%s.%s", - dev_driver_string(&client->dev), dev_name(&client->dev)); - camera_common_create_debugfs(common_data, debugfs_name); + err = camera_common_initialize(common_data, "imx219"); + if (err) + return err; v4l2_i2c_subdev_init(&common_data->subdev, client, &imx219_subdev_ops); @@ -821,7 +820,7 @@ imx219_remove(struct i2c_client *client) #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c index d88e47039..07685992d 100644 --- a/drivers/media/i2c/imx274.c +++ b/drivers/media/i2c/imx274.c @@ -1222,9 +1222,6 @@ static struct camera_common_pdata *imx274_parse_dt(struct i2c_client *client, of_property_read_string(node, "iovdd-reg", &board_priv_pdata->regulators.iovdd); - if (s_data->sensor_props.num_modes == 0) - dev_err(&client->dev, "Failed to load mode info %d\n", err); - return board_priv_pdata; error: @@ -1257,7 +1254,6 @@ static int imx274_probe(struct i2c_client *client, struct camera_common_data *common_data; struct device_node *node = client->dev.of_node; struct imx274 *priv; - char debugfs_name[10]; int err; pr_info("[IMX274]: probing v4l2 sensor.\n"); @@ -1321,15 +1317,11 @@ static int imx274_probe(struct i2c_client *client, if (err) return err; - err = camera_common_parse_ports(&client->dev, common_data); + err = camera_common_initialize(common_data, "imx274"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize imx274.\n"); return err; } - sprintf(debugfs_name, "imx274_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: name %s\n", __func__, debugfs_name); - - camera_common_create_debugfs(common_data, "imx274"); v4l2_i2c_subdev_init(priv->subdev, client, &imx274_subdev_ops); @@ -1377,7 +1369,7 @@ imx274_remove(struct i2c_client *client) #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/ov10823.c b/drivers/media/i2c/ov10823.c index 753e4a7e5..4c36a0e63 100644 --- a/drivers/media/i2c/ov10823.c +++ b/drivers/media/i2c/ov10823.c @@ -1072,7 +1072,6 @@ static int ov10823_probe(struct i2c_client *client, { struct camera_common_data *common_data; struct ov10823 *priv; - char dev_name[10]; int err; pr_info("[OV10823]: probing v4l2 sensor.\n"); @@ -1150,14 +1149,11 @@ static int ov10823_probe(struct i2c_client *client, gpio_set_value(priv->mcu_reset_gpio, 1); } - err = camera_common_parse_ports(&client->dev, common_data); + err = camera_common_initialize(common_data, "ov10823"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize ov10823\n"); return err; } - sprintf(dev_name, "ov10823_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: name %s\n", __func__, dev_name); - camera_common_create_debugfs(common_data, dev_name); v4l2_i2c_subdev_init(&common_data->subdev, client, &ov10823_subdev_ops); @@ -1224,7 +1220,7 @@ ov10823_remove(struct i2c_client *client) #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); ov10823_power_put(priv); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/ov23850.c b/drivers/media/i2c/ov23850.c index 9ae11012a..05b9cc2ca 100644 --- a/drivers/media/i2c/ov23850.c +++ b/drivers/media/i2c/ov23850.c @@ -1280,7 +1280,6 @@ static int ov23850_probe(struct i2c_client *client, { struct camera_common_data *common_data; struct ov23850 *priv; - char debugfs_name[10]; int err; pr_info("[OV23850]: probing v4l2 sensor at addr 0x%0x.\n", @@ -1336,14 +1335,11 @@ static int ov23850_probe(struct i2c_client *client, if (err) return err; - err = camera_common_parse_ports(&client->dev, common_data); + err = camera_common_initialize(common_data, "ov23850"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize ov23850\n"); return err; } - sprintf(debugfs_name, "ov23850_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: dt node name %s\n", __func__, debugfs_name); - camera_common_create_debugfs(common_data, debugfs_name); v4l2_i2c_subdev_init(&common_data->subdev, client, &ov23850_subdev_ops); @@ -1395,7 +1391,7 @@ ov23850_remove(struct i2c_client *client) media_entity_cleanup(&priv->subdev->entity); #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index 9bc557298..eb6bb9447 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -1436,7 +1436,6 @@ static int ov5693_probe(struct i2c_client *client, struct camera_common_data *common_data; struct device_node *node = client->dev.of_node; struct ov5693 *priv; - char debugfs_name[10]; int err; const struct ov5693_soc *soc_data; const struct of_device_id *match; @@ -1506,14 +1505,12 @@ static int ov5693_probe(struct i2c_client *client, if (err) return err; - err = camera_common_parse_ports(&client->dev, common_data); + err = camera_common_initialize(common_data, "ov5693"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize ov5693.\n"); return err; } - sprintf(debugfs_name, "ov5693_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: name %s\n", __func__, debugfs_name); - camera_common_create_debugfs(common_data, debugfs_name); + v4l2_i2c_subdev_init(priv->subdev, client, &ov5693_subdev_ops); @@ -1564,7 +1561,7 @@ ov5693_remove(struct i2c_client *client) v4l2_ctrl_handler_free(&priv->ctrl_handler); ov5693_power_put(priv); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } diff --git a/drivers/media/i2c/ov9281.c b/drivers/media/i2c/ov9281.c index 2e505cb8a..aaa23b1bc 100644 --- a/drivers/media/i2c/ov9281.c +++ b/drivers/media/i2c/ov9281.c @@ -1081,7 +1081,6 @@ static int ov9281_probe(struct i2c_client *client, { struct camera_common_data *common_data; struct ov9281 *priv; - char dev_name[10]; int err; dev_info(&client->dev, "Probing v4l2 sensor.\n"); @@ -1162,14 +1161,11 @@ static int ov9281_probe(struct i2c_client *client, gpio_set_value(priv->mcu_reset_gpio, 1); } - err = camera_common_parse_ports(&client->dev, common_data); + err = camera_common_initialize(common_data, "ov9281"); if (err) { - dev_err(&client->dev, "Failed to find port info\n"); + dev_err(&client->dev, "Failed to initialize ov9281\n"); return err; } - sprintf(dev_name, "ov9281_%c", common_data->csi_port + 'a'); - dev_dbg(&client->dev, "%s: name %s\n", __func__, dev_name); - camera_common_create_debugfs(common_data, dev_name); v4l2_i2c_subdev_init(&common_data->subdev, client, &ov9281_subdev_ops); diff --git a/drivers/media/spi/imx204.c b/drivers/media/spi/imx204.c index 19c84bc5a..c42e02b2a 100644 --- a/drivers/media/spi/imx204.c +++ b/drivers/media/spi/imx204.c @@ -681,7 +681,6 @@ static int imx204_probe(struct spi_device *spi) struct camera_common_data *common_data; struct imx204 *priv; struct device_node *node = spi->dev.of_node; - char debugfs_name[10]; int err; int ret = 0; @@ -765,15 +764,9 @@ static int imx204_probe(struct spi_device *spi) if (err) return err; - err = camera_common_parse_ports(&spi->dev, common_data); - if (err) { - dev_err(&spi->dev, "Failed to find port info\n"); + err = camera_common_initialize(common_data, "imx204"); + if (err) return err; - } - - sprintf(debugfs_name, "imx204_%c", common_data->csi_port + 'a'); - dev_dbg(&spi->dev, "%s: name %s\n", __func__, debugfs_name); - camera_common_create_debugfs(common_data, "imx204"); v4l2_spi_subdev_init(&common_data->subdev, spi, &imx204_subdev_ops); @@ -821,7 +814,7 @@ imx204_remove(struct spi_device *spi) #endif v4l2_ctrl_handler_free(&priv->ctrl_handler); imx204_power_put(priv); - camera_common_remove_debugfs(s_data); + camera_common_cleanup(s_data); return 0; } -- cgit v1.2.2