diff options
author | Nicolin Chen <nicolinc@nvidia.com> | 2017-11-15 21:29:02 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-11-16 14:16:41 -0500 |
commit | 4c7335145057b50a921a1917f878a79afa6a05e7 (patch) | |
tree | 749353fe01f1f6bcbd72b9f82a1c96603caf5027 /drivers/media | |
parent | 44c4e1c512652adb56e372919a5147b3d4cba37e (diff) |
media: ov10823: Improve debug prints
This change does the below improvements:
1) Replace all pr_* with dev_* functions since the driver is
mixing the use of both types.
2) Cache dev pointer in some functions to improve readability.
It doesn't change any functionality.
Bug 200347360
Change-Id: I333e463de6be397e967dbe1773d41acb5591c76d
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1599188
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/i2c/ov10823.c | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/drivers/media/i2c/ov10823.c b/drivers/media/i2c/ov10823.c index e1b81ddc7..ca92e4194 100644 --- a/drivers/media/i2c/ov10823.c +++ b/drivers/media/i2c/ov10823.c | |||
@@ -272,10 +272,11 @@ static int ov10823_write_reg(struct camera_common_data *s_data, | |||
272 | { | 272 | { |
273 | int err; | 273 | int err; |
274 | struct ov10823 *priv = (struct ov10823 *)s_data->priv; | 274 | struct ov10823 *priv = (struct ov10823 *)s_data->priv; |
275 | struct device *dev = &priv->i2c_client->dev; | ||
275 | 276 | ||
276 | err = regmap_write(priv->regmap, addr, val); | 277 | err = regmap_write(priv->regmap, addr, val); |
277 | if (err) | 278 | if (err) |
278 | pr_err("%s:i2c write failed, %x = %x\n", | 279 | dev_err(dev, "%s: i2c write failed, %x = %x\n", |
279 | __func__, addr, val); | 280 | __func__, addr, val); |
280 | 281 | ||
281 | return err; | 282 | return err; |
@@ -296,13 +297,14 @@ static int ov10823_power_on(struct camera_common_data *s_data) | |||
296 | int err = 0; | 297 | int err = 0; |
297 | struct ov10823 *priv = (struct ov10823 *)s_data->priv; | 298 | struct ov10823 *priv = (struct ov10823 *)s_data->priv; |
298 | struct camera_common_power_rail *pw = &priv->power; | 299 | struct camera_common_power_rail *pw = &priv->power; |
300 | struct device *dev = &priv->i2c_client->dev; | ||
299 | 301 | ||
300 | dev_dbg(&priv->i2c_client->dev, "%s: power on\n", __func__); | 302 | dev_dbg(dev, "%s: power on\n", __func__); |
301 | 303 | ||
302 | if (priv->pdata->power_on) { | 304 | if (priv->pdata->power_on) { |
303 | err = priv->pdata->power_on(pw); | 305 | err = priv->pdata->power_on(pw); |
304 | if (err) | 306 | if (err) |
305 | pr_err("%s failed.\n", __func__); | 307 | dev_err(dev, "%s failed.\n", __func__); |
306 | else | 308 | else |
307 | pw->state = SWITCH_ON; | 309 | pw->state = SWITCH_ON; |
308 | return err; | 310 | return err; |
@@ -318,14 +320,15 @@ static int ov10823_power_off(struct camera_common_data *s_data) | |||
318 | int err = 0; | 320 | int err = 0; |
319 | struct ov10823 *priv = (struct ov10823 *)s_data->priv; | 321 | struct ov10823 *priv = (struct ov10823 *)s_data->priv; |
320 | struct camera_common_power_rail *pw = &priv->power; | 322 | struct camera_common_power_rail *pw = &priv->power; |
323 | struct device *dev = &priv->i2c_client->dev; | ||
321 | 324 | ||
322 | dev_dbg(&priv->i2c_client->dev, "%s: power off\n", __func__); | 325 | dev_dbg(dev, "%s: power off\n", __func__); |
323 | ov10823_write_table(priv, mode_table[OV10823_MODE_STOP_STREAM]); | 326 | ov10823_write_table(priv, mode_table[OV10823_MODE_STOP_STREAM]); |
324 | 327 | ||
325 | if (priv->pdata->power_off) { | 328 | if (priv->pdata->power_off) { |
326 | err = priv->pdata->power_off(pw); | 329 | err = priv->pdata->power_off(pw); |
327 | if (err) | 330 | if (err) |
328 | pr_err("%s failed.\n", __func__); | 331 | dev_err(dev, "%s failed.\n", __func__); |
329 | else | 332 | else |
330 | goto power_off_done; | 333 | goto power_off_done; |
331 | } | 334 | } |
@@ -345,15 +348,15 @@ static int ov10823_power_put(struct ov10823 *priv) | |||
345 | static int ov10823_power_get(struct ov10823 *priv) | 348 | static int ov10823_power_get(struct ov10823 *priv) |
346 | { | 349 | { |
347 | struct camera_common_power_rail *pw = &priv->power; | 350 | struct camera_common_power_rail *pw = &priv->power; |
351 | struct device *dev = &priv->i2c_client->dev; | ||
348 | const char *mclk_name; | 352 | const char *mclk_name; |
349 | int err = 0; | 353 | int err = 0; |
350 | 354 | ||
351 | mclk_name = priv->pdata->mclk_name ? | 355 | mclk_name = priv->pdata->mclk_name ? |
352 | priv->pdata->mclk_name : "cam_mclk1"; | 356 | priv->pdata->mclk_name : "cam_mclk1"; |
353 | pw->mclk = devm_clk_get(&priv->i2c_client->dev, mclk_name); | 357 | pw->mclk = devm_clk_get(dev, mclk_name); |
354 | if (IS_ERR(pw->mclk)) { | 358 | if (IS_ERR(pw->mclk)) { |
355 | dev_err(&priv->i2c_client->dev, | 359 | dev_err(dev, "unable to get clock %s\n", mclk_name); |
356 | "unable to get clock %s\n", mclk_name); | ||
357 | return PTR_ERR(pw->mclk); | 360 | return PTR_ERR(pw->mclk); |
358 | } | 361 | } |
359 | 362 | ||
@@ -580,6 +583,7 @@ static struct camera_common_sensor_ops ov10823_common_ops = { | |||
580 | 583 | ||
581 | static int ov10823_set_group_hold(struct ov10823 *priv) | 584 | static int ov10823_set_group_hold(struct ov10823 *priv) |
582 | { | 585 | { |
586 | struct device *dev = &priv->i2c_client->dev; | ||
583 | int err; | 587 | int err; |
584 | int gh_prev = switch_ctrl_qmenu[priv->group_hold_prev]; | 588 | int gh_prev = switch_ctrl_qmenu[priv->group_hold_prev]; |
585 | 589 | ||
@@ -605,13 +609,13 @@ static int ov10823_set_group_hold(struct ov10823 *priv) | |||
605 | return 0; | 609 | return 0; |
606 | 610 | ||
607 | fail: | 611 | fail: |
608 | dev_dbg(&priv->i2c_client->dev, | 612 | dev_dbg(dev, "%s: Group hold control error\n", __func__); |
609 | "%s: Group hold control error\n", __func__); | ||
610 | return err; | 613 | return err; |
611 | } | 614 | } |
612 | 615 | ||
613 | static int ov10823_set_gain(struct ov10823 *priv, s32 val) | 616 | static int ov10823_set_gain(struct ov10823 *priv, s32 val) |
614 | { | 617 | { |
618 | struct device *dev = &priv->i2c_client->dev; | ||
615 | ov10823_reg reg_list[3]; | 619 | ov10823_reg reg_list[3]; |
616 | int err; | 620 | int err; |
617 | u16 gain; | 621 | u16 gain; |
@@ -621,8 +625,7 @@ static int ov10823_set_gain(struct ov10823 *priv, s32 val) | |||
621 | /* translate value */ | 625 | /* translate value */ |
622 | gain = ov10823_to_gain((u32)val, OV10823_GAIN_SHIFT); | 626 | gain = ov10823_to_gain((u32)val, OV10823_GAIN_SHIFT); |
623 | 627 | ||
624 | dev_dbg(&priv->i2c_client->dev, | 628 | dev_dbg(dev, "%s: gain: %d\n", __func__, gain); |
625 | "%s: gain: %d\n", __func__, gain); | ||
626 | 629 | ||
627 | ov10823_get_gain_reg(reg_list, gain); | 630 | ov10823_get_gain_reg(reg_list, gain); |
628 | ov10823_set_group_hold(priv); | 631 | ov10823_set_group_hold(priv); |
@@ -633,21 +636,20 @@ static int ov10823_set_gain(struct ov10823 *priv, s32 val) | |||
633 | return 0; | 636 | return 0; |
634 | 637 | ||
635 | fail: | 638 | fail: |
636 | dev_dbg(&priv->i2c_client->dev, | 639 | dev_dbg(dev, "%s: GAIN control error\n", __func__); |
637 | "%s: GAIN control error\n", __func__); | ||
638 | return err; | 640 | return err; |
639 | } | 641 | } |
640 | 642 | ||
641 | static int ov10823_set_frame_length(struct ov10823 *priv, s32 val) | 643 | static int ov10823_set_frame_length(struct ov10823 *priv, s32 val) |
642 | { | 644 | { |
645 | struct device *dev = &priv->i2c_client->dev; | ||
643 | ov10823_reg reg_list[5]; | 646 | ov10823_reg reg_list[5]; |
644 | int err; | 647 | int err; |
645 | u16 frame_length; | 648 | u16 frame_length; |
646 | 649 | ||
647 | frame_length = (u16)val; | 650 | frame_length = (u16)val; |
648 | 651 | ||
649 | dev_dbg(&priv->i2c_client->dev, | 652 | dev_dbg(dev, "%s: frame_length: %d\n", __func__, frame_length); |
650 | "%s: frame_length: %d\n", __func__, frame_length); | ||
651 | 653 | ||
652 | ov10823_get_frame_length_regs(reg_list, frame_length, priv->fsync); | 654 | ov10823_get_frame_length_regs(reg_list, frame_length, priv->fsync); |
653 | ov10823_set_group_hold(priv); | 655 | ov10823_set_group_hold(priv); |
@@ -658,21 +660,20 @@ static int ov10823_set_frame_length(struct ov10823 *priv, s32 val) | |||
658 | return 0; | 660 | return 0; |
659 | 661 | ||
660 | fail: | 662 | fail: |
661 | dev_dbg(&priv->i2c_client->dev, | 663 | dev_dbg(dev, "%s: FRAME_LENGTH control error\n", __func__); |
662 | "%s: FRAME_LENGTH control error\n", __func__); | ||
663 | return err; | 664 | return err; |
664 | } | 665 | } |
665 | 666 | ||
666 | static int ov10823_set_coarse_time(struct ov10823 *priv, s32 val) | 667 | static int ov10823_set_coarse_time(struct ov10823 *priv, s32 val) |
667 | { | 668 | { |
669 | struct device *dev = &priv->i2c_client->dev; | ||
668 | ov10823_reg reg_list[4]; | 670 | ov10823_reg reg_list[4]; |
669 | int err; | 671 | int err; |
670 | u16 coarse_time; | 672 | u16 coarse_time; |
671 | 673 | ||
672 | coarse_time = (u16)val; | 674 | coarse_time = (u16)val; |
673 | 675 | ||
674 | dev_dbg(&priv->i2c_client->dev, | 676 | dev_dbg(dev, "%s: coarse_time: %d\n", __func__, coarse_time); |
675 | "%s: coarse_time: %d\n", __func__, coarse_time); | ||
676 | 677 | ||
677 | ov10823_get_coarse_time_regs(reg_list, coarse_time); | 678 | ov10823_get_coarse_time_regs(reg_list, coarse_time); |
678 | ov10823_set_group_hold(priv); | 679 | ov10823_set_group_hold(priv); |
@@ -683,8 +684,7 @@ static int ov10823_set_coarse_time(struct ov10823 *priv, s32 val) | |||
683 | return 0; | 684 | return 0; |
684 | 685 | ||
685 | fail: | 686 | fail: |
686 | dev_dbg(&priv->i2c_client->dev, | 687 | dev_dbg(dev, "%s: COARSE_TIME control error\n", __func__); |
687 | "%s: COARSE_TIME control error\n", __func__); | ||
688 | return err; | 688 | return err; |
689 | } | 689 | } |
690 | 690 | ||
@@ -724,6 +724,7 @@ static int ov10823_read_otp(struct ov10823 *priv, u8 *buf, | |||
724 | 724 | ||
725 | static int ov10823_otp_setup(struct ov10823 *priv) | 725 | static int ov10823_otp_setup(struct ov10823 *priv) |
726 | { | 726 | { |
727 | struct device *dev = &priv->i2c_client->dev; | ||
727 | int err; | 728 | int err; |
728 | int i; | 729 | int i; |
729 | struct v4l2_ctrl *ctrl; | 730 | struct v4l2_ctrl *ctrl; |
@@ -739,8 +740,7 @@ static int ov10823_otp_setup(struct ov10823 *priv) | |||
739 | 740 | ||
740 | ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_OTP_DATA); | 741 | ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_OTP_DATA); |
741 | if (!ctrl) { | 742 | if (!ctrl) { |
742 | dev_err(&priv->i2c_client->dev, | 743 | dev_err(dev, "could not find device ctrl.\n"); |
743 | "could not find device ctrl.\n"); | ||
744 | return -EINVAL; | 744 | return -EINVAL; |
745 | } | 745 | } |
746 | 746 | ||
@@ -758,6 +758,7 @@ static int ov10823_otp_setup(struct ov10823 *priv) | |||
758 | 758 | ||
759 | static int ov10823_fuse_id_setup(struct ov10823 *priv) | 759 | static int ov10823_fuse_id_setup(struct ov10823 *priv) |
760 | { | 760 | { |
761 | struct device *dev = &priv->i2c_client->dev; | ||
761 | int err; | 762 | int err; |
762 | int i; | 763 | int i; |
763 | struct v4l2_ctrl *ctrl; | 764 | struct v4l2_ctrl *ctrl; |
@@ -773,8 +774,7 @@ static int ov10823_fuse_id_setup(struct ov10823 *priv) | |||
773 | 774 | ||
774 | ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_FUSE_ID); | 775 | ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_FUSE_ID); |
775 | if (!ctrl) { | 776 | if (!ctrl) { |
776 | dev_err(&priv->i2c_client->dev, | 777 | dev_err(dev, "could not find device ctrl.\n"); |
777 | "could not find device ctrl.\n"); | ||
778 | return -EINVAL; | 778 | return -EINVAL; |
779 | } | 779 | } |
780 | 780 | ||
@@ -794,6 +794,7 @@ static int ov10823_g_volatile_ctrl(struct v4l2_ctrl *ctrl) | |||
794 | { | 794 | { |
795 | struct ov10823 *priv = | 795 | struct ov10823 *priv = |
796 | container_of(ctrl->handler, struct ov10823, ctrl_handler); | 796 | container_of(ctrl->handler, struct ov10823, ctrl_handler); |
797 | struct device *dev = &priv->i2c_client->dev; | ||
797 | int err = 0; | 798 | int err = 0; |
798 | 799 | ||
799 | if (priv->power.state == SWITCH_OFF) | 800 | if (priv->power.state == SWITCH_OFF) |
@@ -801,7 +802,7 @@ static int ov10823_g_volatile_ctrl(struct v4l2_ctrl *ctrl) | |||
801 | 802 | ||
802 | switch (ctrl->id) { | 803 | switch (ctrl->id) { |
803 | default: | 804 | default: |
804 | pr_err("%s: unknown ctrl id.\n", __func__); | 805 | dev_err(dev, "%s: unknown ctrl id.\n", __func__); |
805 | return -EINVAL; | 806 | return -EINVAL; |
806 | } | 807 | } |
807 | 808 | ||
@@ -812,6 +813,7 @@ static int ov10823_s_ctrl(struct v4l2_ctrl *ctrl) | |||
812 | { | 813 | { |
813 | struct ov10823 *priv = | 814 | struct ov10823 *priv = |
814 | container_of(ctrl->handler, struct ov10823, ctrl_handler); | 815 | container_of(ctrl->handler, struct ov10823, ctrl_handler); |
816 | struct device *dev = &priv->i2c_client->dev; | ||
815 | int err = 0; | 817 | int err = 0; |
816 | 818 | ||
817 | if (priv->power.state == SWITCH_OFF) | 819 | if (priv->power.state == SWITCH_OFF) |
@@ -845,7 +847,7 @@ static int ov10823_s_ctrl(struct v4l2_ctrl *ctrl) | |||
845 | case TEGRA_CAMERA_CID_HDR_EN: | 847 | case TEGRA_CAMERA_CID_HDR_EN: |
846 | break; | 848 | break; |
847 | default: | 849 | default: |
848 | pr_err("%s: unknown ctrl id.\n", __func__); | 850 | dev_err(dev, "%s: unknown ctrl id.\n", __func__); |
849 | return -EINVAL; | 851 | return -EINVAL; |
850 | } | 852 | } |
851 | 853 | ||
@@ -957,6 +959,7 @@ static int ov10823_parse_dt(struct i2c_client *client, struct ov10823 *priv) | |||
957 | 959 | ||
958 | static int ov10823_i2c_addr_assign(struct ov10823 *priv, u8 i2c_addr) | 960 | static int ov10823_i2c_addr_assign(struct ov10823 *priv, u8 i2c_addr) |
959 | { | 961 | { |
962 | struct device *dev = &priv->i2c_client->dev; | ||
960 | struct i2c_msg msg; | 963 | struct i2c_msg msg; |
961 | unsigned char data[3]; | 964 | unsigned char data[3]; |
962 | int err; | 965 | int err; |
@@ -992,16 +995,14 @@ static int ov10823_i2c_addr_assign(struct ov10823 *priv, u8 i2c_addr) | |||
992 | */ | 995 | */ |
993 | 996 | ||
994 | if (i2c_addr == OV10823_DEFAULT_I2C_ADDRESS_20) { | 997 | if (i2c_addr == OV10823_DEFAULT_I2C_ADDRESS_20) { |
995 | dev_info(&priv->i2c_client->dev, | 998 | dev_info(dev, "Using default I2C address 0x%02x\n", i2c_addr); |
996 | "Using default I2C address 0x%02x\n", i2c_addr); | ||
997 | if (gpio_is_valid(priv->cam_sid_gpio)) { | 999 | if (gpio_is_valid(priv->cam_sid_gpio)) { |
998 | gpio_set_value(priv->cam_sid_gpio, 0); | 1000 | gpio_set_value(priv->cam_sid_gpio, 0); |
999 | msleep_range(1); | 1001 | msleep_range(1); |
1000 | } | 1002 | } |
1001 | return 0; | 1003 | return 0; |
1002 | } else if (i2c_addr == OV10823_DEFAULT_I2C_ADDRESS_6C) { | 1004 | } else if (i2c_addr == OV10823_DEFAULT_I2C_ADDRESS_6C) { |
1003 | dev_info(&priv->i2c_client->dev, | 1005 | dev_info(dev, "Using default I2C address 0x%02x\n", i2c_addr); |
1004 | "Using default I2C address 0x%02x\n", i2c_addr); | ||
1005 | if (gpio_is_valid(priv->cam_sid_gpio)) { | 1006 | if (gpio_is_valid(priv->cam_sid_gpio)) { |
1006 | gpio_set_value(priv->cam_sid_gpio, 1); | 1007 | gpio_set_value(priv->cam_sid_gpio, 1); |
1007 | msleep_range(1); | 1008 | msleep_range(1); |
@@ -1014,16 +1015,14 @@ static int ov10823_i2c_addr_assign(struct ov10823 *priv, u8 i2c_addr) | |||
1014 | * slave address. We necessarily need to have a cam-sid-gpio for this. | 1015 | * slave address. We necessarily need to have a cam-sid-gpio for this. |
1015 | */ | 1016 | */ |
1016 | if (!gpio_is_valid(priv->cam_sid_gpio)) { | 1017 | if (!gpio_is_valid(priv->cam_sid_gpio)) { |
1017 | dev_err(&priv->i2c_client->dev, | 1018 | dev_err(dev, "Missing cam-sid-gpio, cannot program I2C addr\n"); |
1018 | "Missing cam-sid-gpio, cannot program I2C address\n"); | ||
1019 | return -EINVAL; | 1019 | return -EINVAL; |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | gpio_set_value(priv->cam_sid_gpio, 1); | 1022 | gpio_set_value(priv->cam_sid_gpio, 1); |
1023 | msleep_range(1); | 1023 | msleep_range(1); |
1024 | 1024 | ||
1025 | dev_info(&priv->i2c_client->dev, "Changing I2C address to 0x%02x\n", | 1025 | dev_info(dev, "Changing I2C address to 0x%02x\n", i2c_addr); |
1026 | i2c_addr); | ||
1027 | 1026 | ||
1028 | /* | 1027 | /* |
1029 | * Have to make the I2C message manually because we are using a | 1028 | * Have to make the I2C message manually because we are using a |
@@ -1084,7 +1083,7 @@ static int ov10823_probe(struct i2c_client *client, | |||
1084 | struct ov10823 *priv; | 1083 | struct ov10823 *priv; |
1085 | int err; | 1084 | int err; |
1086 | 1085 | ||
1087 | pr_info("[OV10823]: probing v4l2 sensor.\n"); | 1086 | dev_info(&client->dev, "probing v4l2 sensor.\n"); |
1088 | 1087 | ||
1089 | common_data = devm_kzalloc(&client->dev, | 1088 | common_data = devm_kzalloc(&client->dev, |
1090 | sizeof(struct camera_common_data), GFP_KERNEL); | 1089 | sizeof(struct camera_common_data), GFP_KERNEL); |