summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/ov23850.c
diff options
context:
space:
mode:
authorNicolin Chen <nicolinc@nvidia.com>2017-11-15 21:30:25 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-11-16 14:16:44 -0500
commit819486a5e3f3655ddb410c6806e45cc49bf64b05 (patch)
treec9270774de779d3597c7dd70875699d356d50a4c /drivers/media/i2c/ov23850.c
parent4c7335145057b50a921a1917f878a79afa6a05e7 (diff)
media: ov23850: 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: Iff7cafa49cc8cdc0e910be144510054e0ca6c0ca Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1599189 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com> 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/i2c/ov23850.c')
-rw-r--r--drivers/media/i2c/ov23850.c93
1 files changed, 46 insertions, 47 deletions
diff --git a/drivers/media/i2c/ov23850.c b/drivers/media/i2c/ov23850.c
index 48e90c137..6f0dd4504 100644
--- a/drivers/media/i2c/ov23850.c
+++ b/drivers/media/i2c/ov23850.c
@@ -288,10 +288,11 @@ static int ov23850_write_reg(struct camera_common_data *s_data,
288{ 288{
289 int err; 289 int err;
290 struct ov23850 *priv = (struct ov23850 *)s_data->priv; 290 struct ov23850 *priv = (struct ov23850 *)s_data->priv;
291 struct device *dev = &priv->i2c_client->dev;
291 292
292 err = regmap_write(priv->regmap, addr, val); 293 err = regmap_write(priv->regmap, addr, val);
293 if (err) 294 if (err)
294 pr_err("%s:i2c write failed, %x = %x\n", 295 dev_err(dev, "%s: i2c write failed, %x = %x\n",
295 __func__, addr, val); 296 __func__, addr, val);
296 297
297 return err; 298 return err;
@@ -312,13 +313,14 @@ static int ov23850_power_on(struct camera_common_data *s_data)
312 int err = 0; 313 int err = 0;
313 struct ov23850 *priv = (struct ov23850 *)s_data->priv; 314 struct ov23850 *priv = (struct ov23850 *)s_data->priv;
314 struct camera_common_power_rail *pw = &priv->power; 315 struct camera_common_power_rail *pw = &priv->power;
316 struct device *dev = &priv->i2c_client->dev;
315 317
316 dev_dbg(&priv->i2c_client->dev, "%s: power on\n", __func__); 318 dev_dbg(dev, "%s: power on\n", __func__);
317 319
318 if (priv->pdata->power_on) { 320 if (priv->pdata->power_on) {
319 err = priv->pdata->power_on(pw); 321 err = priv->pdata->power_on(pw);
320 if (err) 322 if (err)
321 pr_err("%s failed.\n", __func__); 323 dev_err(dev, "%s failed.\n", __func__);
322 else 324 else
323 pw->state = SWITCH_ON; 325 pw->state = SWITCH_ON;
324 return err; 326 return err;
@@ -370,7 +372,7 @@ ov23850_dvdd_fail:
370 regulator_disable(pw->avdd); 372 regulator_disable(pw->avdd);
371 373
372ov23850_avdd_fail: 374ov23850_avdd_fail:
373 pr_err("%s failed.\n", __func__); 375 dev_err(dev, "%s failed.\n", __func__);
374 return -ENODEV; 376 return -ENODEV;
375} 377}
376 378
@@ -379,15 +381,16 @@ static int ov23850_power_off(struct camera_common_data *s_data)
379 int err = 0; 381 int err = 0;
380 struct ov23850 *priv = (struct ov23850 *)s_data->priv; 382 struct ov23850 *priv = (struct ov23850 *)s_data->priv;
381 struct camera_common_power_rail *pw = &priv->power; 383 struct camera_common_power_rail *pw = &priv->power;
384 struct device *dev = &priv->i2c_client->dev;
382 385
383 dev_dbg(&priv->i2c_client->dev, "%s: power off\n", __func__); 386 dev_dbg(dev, "%s: power off\n", __func__);
384 387
385 if (priv->pdata->power_off) { 388 if (priv->pdata->power_off) {
386 err = priv->pdata->power_off(pw); 389 err = priv->pdata->power_off(pw);
387 if (!err) 390 if (!err)
388 goto power_off_done; 391 goto power_off_done;
389 else 392 else
390 pr_err("%s failed.\n", __func__); 393 dev_err(dev, "%s failed.\n", __func__);
391 return err; 394 return err;
392 } 395 }
393 396
@@ -416,33 +419,33 @@ static int ov23850_power_get(struct ov23850 *priv)
416{ 419{
417 struct camera_common_power_rail *pw = &priv->power; 420 struct camera_common_power_rail *pw = &priv->power;
418 struct camera_common_pdata *pdata = priv->pdata; 421 struct camera_common_pdata *pdata = priv->pdata;
422 struct device *dev = &priv->i2c_client->dev;
419 const char *mclk_name; 423 const char *mclk_name;
420 struct clk *parent; 424 struct clk *parent;
421 int err = 0; 425 int err = 0;
422 426
423 mclk_name = priv->pdata->mclk_name ? 427 mclk_name = priv->pdata->mclk_name ?
424 priv->pdata->mclk_name : "cam_mclk1"; 428 priv->pdata->mclk_name : "cam_mclk1";
425 pw->mclk = devm_clk_get(&priv->i2c_client->dev, mclk_name); 429 pw->mclk = devm_clk_get(dev, mclk_name);
426 if (IS_ERR(pw->mclk)) { 430 if (IS_ERR(pw->mclk)) {
427 dev_err(&priv->i2c_client->dev, 431 dev_err(dev, "unable to get clock %s\n", mclk_name);
428 "unable to get clock %s\n", mclk_name);
429 return PTR_ERR(pw->mclk); 432 return PTR_ERR(pw->mclk);
430 } 433 }
431 434
432 parent = devm_clk_get(&priv->i2c_client->dev, "pllp_grtba"); 435 parent = devm_clk_get(dev, "pllp_grtba");
433 if (IS_ERR(parent)) 436 if (IS_ERR(parent))
434 dev_err(&priv->i2c_client->dev, "devm_clk_get failed for pllp_grtba"); 437 dev_err(dev, "devm_clk_get failed for pllp_grtba");
435 else 438 else
436 clk_set_parent(pw->mclk, parent); 439 clk_set_parent(pw->mclk, parent);
437 440
438 /* ananlog 2.7v */ 441 /* ananlog 2.7v */
439 err |= camera_common_regulator_get(&priv->i2c_client->dev, 442 err |= camera_common_regulator_get(dev,
440 &pw->avdd, pdata->regulators.avdd); 443 &pw->avdd, pdata->regulators.avdd);
441 /* digital 1.2v */ 444 /* digital 1.2v */
442 err |= camera_common_regulator_get(&priv->i2c_client->dev, 445 err |= camera_common_regulator_get(dev,
443 &pw->dvdd, pdata->regulators.dvdd); 446 &pw->dvdd, pdata->regulators.dvdd);
444 /* IO 1.8v */ 447 /* IO 1.8v */
445 err |= camera_common_regulator_get(&priv->i2c_client->dev, 448 err |= camera_common_regulator_get(dev,
446 &pw->iovdd, pdata->regulators.iovdd); 449 &pw->iovdd, pdata->regulators.iovdd);
447 450
448 if (!err) { 451 if (!err) {
@@ -609,6 +612,7 @@ static struct camera_common_sensor_ops ov23850_common_ops = {
609 612
610static int ov23850_set_group_hold(struct ov23850 *priv) 613static int ov23850_set_group_hold(struct ov23850 *priv)
611{ 614{
615 struct device *dev = &priv->i2c_client->dev;
612 int err; 616 int err;
613 int gh_prev = switch_ctrl_qmenu[priv->group_hold_prev]; 617 int gh_prev = switch_ctrl_qmenu[priv->group_hold_prev];
614 618
@@ -631,13 +635,13 @@ static int ov23850_set_group_hold(struct ov23850 *priv)
631 return 0; 635 return 0;
632 636
633fail: 637fail:
634 dev_dbg(&priv->i2c_client->dev, 638 dev_dbg(dev, "%s: Group hold control error\n", __func__);
635 "%s: Group hold control error\n", __func__);
636 return err; 639 return err;
637} 640}
638 641
639static int ov23850_set_gain(struct ov23850 *priv, s32 val) 642static int ov23850_set_gain(struct ov23850 *priv, s32 val)
640{ 643{
644 struct device *dev = &priv->i2c_client->dev;
641 ov23850_reg reg_list[2]; 645 ov23850_reg reg_list[2];
642 ov23850_reg reg_list_short[2]; 646 ov23850_reg reg_list_short[2];
643 int err; 647 int err;
@@ -647,8 +651,7 @@ static int ov23850_set_gain(struct ov23850 *priv, s32 val)
647 /* translate value */ 651 /* translate value */
648 gain = ov23850_to_gain((u32)val, OV23850_GAIN_SHIFT); 652 gain = ov23850_to_gain((u32)val, OV23850_GAIN_SHIFT);
649 653
650 dev_dbg(&priv->i2c_client->dev, 654 dev_dbg(dev, "%s: val: %d\n", __func__, gain);
651 "%s: val: %d\n", __func__, gain);
652 655
653 ov23850_get_gain_reg(reg_list, gain); 656 ov23850_get_gain_reg(reg_list, gain);
654 ov23850_get_gain_short_reg(reg_list_short, gain); 657 ov23850_get_gain_short_reg(reg_list_short, gain);
@@ -672,13 +675,13 @@ static int ov23850_set_gain(struct ov23850 *priv, s32 val)
672 return 0; 675 return 0;
673 676
674fail: 677fail:
675 dev_dbg(&priv->i2c_client->dev, 678 dev_dbg(dev, "%s: GAIN control error\n", __func__);
676 "%s: GAIN control error\n", __func__);
677 return err; 679 return err;
678} 680}
679 681
680static int ov23850_set_frame_length(struct ov23850 *priv, s32 val) 682static int ov23850_set_frame_length(struct ov23850 *priv, s32 val)
681{ 683{
684 struct device *dev = &priv->i2c_client->dev;
682 ov23850_reg reg_list[2]; 685 ov23850_reg reg_list[2];
683 int err; 686 int err;
684 u32 frame_length; 687 u32 frame_length;
@@ -686,8 +689,7 @@ static int ov23850_set_frame_length(struct ov23850 *priv, s32 val)
686 689
687 frame_length = val; 690 frame_length = val;
688 691
689 dev_dbg(&priv->i2c_client->dev, 692 dev_dbg(dev, "%s: val: %d\n", __func__, frame_length);
690 "%s: val: %d\n", __func__, frame_length);
691 693
692 ov23850_get_frame_length_regs(reg_list, frame_length); 694 ov23850_get_frame_length_regs(reg_list, frame_length);
693 ov23850_set_group_hold(priv); 695 ov23850_set_group_hold(priv);
@@ -704,13 +706,13 @@ static int ov23850_set_frame_length(struct ov23850 *priv, s32 val)
704 return 0; 706 return 0;
705 707
706fail: 708fail:
707 dev_dbg(&priv->i2c_client->dev, 709 dev_dbg(dev, "%s: FRAME_LENGTH control error\n", __func__);
708 "%s: FRAME_LENGTH control error\n", __func__);
709 return err; 710 return err;
710} 711}
711 712
712static int ov23850_set_coarse_time(struct ov23850 *priv, s32 val) 713static int ov23850_set_coarse_time(struct ov23850 *priv, s32 val)
713{ 714{
715 struct device *dev = &priv->i2c_client->dev;
714 ov23850_reg reg_list[2]; 716 ov23850_reg reg_list[2];
715 int err; 717 int err;
716 u32 coarse_time; 718 u32 coarse_time;
@@ -718,8 +720,7 @@ static int ov23850_set_coarse_time(struct ov23850 *priv, s32 val)
718 720
719 coarse_time = val; 721 coarse_time = val;
720 722
721 dev_dbg(&priv->i2c_client->dev, 723 dev_dbg(dev, "%s: val: %d\n", __func__, coarse_time);
722 "%s: val: %d\n", __func__, coarse_time);
723 724
724 ov23850_get_coarse_time_regs(reg_list, coarse_time); 725 ov23850_get_coarse_time_regs(reg_list, coarse_time);
725 ov23850_set_group_hold(priv); 726 ov23850_set_group_hold(priv);
@@ -734,13 +735,13 @@ static int ov23850_set_coarse_time(struct ov23850 *priv, s32 val)
734 return 0; 735 return 0;
735 736
736fail: 737fail:
737 dev_dbg(&priv->i2c_client->dev, 738 dev_dbg(dev, "%s: COARSE_TIME control error\n", __func__);
738 "%s: COARSE_TIME control error\n", __func__);
739 return err; 739 return err;
740} 740}
741 741
742static int ov23850_set_coarse_time_short(struct ov23850 *priv, s32 val) 742static int ov23850_set_coarse_time_short(struct ov23850 *priv, s32 val)
743{ 743{
744 struct device *dev = &priv->i2c_client->dev;
744 ov23850_reg reg_list[2]; 745 ov23850_reg reg_list[2];
745 int err; 746 int err;
746 struct v4l2_control hdr_control; 747 struct v4l2_control hdr_control;
@@ -753,8 +754,7 @@ static int ov23850_set_coarse_time_short(struct ov23850 *priv, s32 val)
753 754
754 err = camera_common_g_ctrl(priv->s_data, &hdr_control); 755 err = camera_common_g_ctrl(priv->s_data, &hdr_control);
755 if (err < 0) { 756 if (err < 0) {
756 dev_err(&priv->i2c_client->dev, 757 dev_err(dev, "could not find device ctrl.\n");
757 "could not find device ctrl.\n");
758 return err; 758 return err;
759 } 759 }
760 760
@@ -764,8 +764,7 @@ static int ov23850_set_coarse_time_short(struct ov23850 *priv, s32 val)
764 764
765 coarse_time_short = val; 765 coarse_time_short = val;
766 766
767 dev_dbg(&priv->i2c_client->dev, 767 dev_dbg(dev, "%s: val: %d\n", __func__, coarse_time_short);
768 "%s: val: %d\n", __func__, coarse_time_short);
769 768
770 ov23850_get_coarse_time_short_regs(reg_list, coarse_time_short); 769 ov23850_get_coarse_time_short_regs(reg_list, coarse_time_short);
771 ov23850_set_group_hold(priv); 770 ov23850_set_group_hold(priv);
@@ -780,8 +779,7 @@ static int ov23850_set_coarse_time_short(struct ov23850 *priv, s32 val)
780 return 0; 779 return 0;
781 780
782fail: 781fail:
783 dev_dbg(&priv->i2c_client->dev, 782 dev_dbg(dev, "%s: COARSE_TIME_SHORT control error\n", __func__);
784 "%s: COARSE_TIME_SHORT control error\n", __func__);
785 return err; 783 return err;
786} 784}
787 785
@@ -854,6 +852,7 @@ static int ov23850_read_eeprom(struct ov23850 *priv,
854static int ov23850_write_eeprom(struct ov23850 *priv, 852static int ov23850_write_eeprom(struct ov23850 *priv,
855 char *string) 853 char *string)
856{ 854{
855 struct device *dev = &priv->i2c_client->dev;
857 int err; 856 int err;
858 int i; 857 int i;
859 u8 curr[3]; 858 u8 curr[3];
@@ -866,8 +865,7 @@ static int ov23850_write_eeprom(struct ov23850 *priv,
866 865
867 err = kstrtol(curr, 16, &data); 866 err = kstrtol(curr, 16, &data);
868 if (err) { 867 if (err) {
869 dev_err(&priv->i2c_client->dev, 868 dev_err(dev, "invalid eeprom string\n");
870 "invalid eeprom string\n");
871 return -EINVAL; 869 return -EINVAL;
872 } 870 }
873 871
@@ -885,6 +883,7 @@ static int ov23850_write_eeprom(struct ov23850 *priv,
885static int ov23850_read_otp_manual(struct ov23850 *priv, 883static int ov23850_read_otp_manual(struct ov23850 *priv,
886 u8 *buf, u16 addr_start, u16 addr_end) 884 u8 *buf, u16 addr_start, u16 addr_end)
887{ 885{
886 struct device *dev = &priv->i2c_client->dev;
888 u8 status; 887 u8 status;
889 int i; 888 int i;
890 int err; 889 int err;
@@ -947,11 +946,10 @@ static int ov23850_read_otp_manual(struct ov23850 *priv,
947 return err; 946 return err;
948 947
949 if (status & OV23850_OTP_RD_BUSY_MASK) { 948 if (status & OV23850_OTP_RD_BUSY_MASK) {
950 dev_err(&priv->i2c_client->dev, 949 dev_err(dev, "another OTP read in progress\n");
951 "another OTP read in progress\n");
952 return err; 950 return err;
953 } else if (status & OV23850_OTP_BIST_ERROR_MASK) { 951 } else if (status & OV23850_OTP_BIST_ERROR_MASK) {
954 dev_err(&priv->i2c_client->dev, "fuse id read error\n"); 952 dev_err(dev, "fuse id read error\n");
955 return err; 953 return err;
956 } 954 }
957 } 955 }
@@ -974,6 +972,7 @@ static int ov23850_read_otp_manual(struct ov23850 *priv,
974 972
975static int ov23850_otp_setup(struct ov23850 *priv) 973static int ov23850_otp_setup(struct ov23850 *priv)
976{ 974{
975 struct device *dev = &priv->i2c_client->dev;
977 int err; 976 int err;
978 int i; 977 int i;
979 struct v4l2_ctrl *ctrl; 978 struct v4l2_ctrl *ctrl;
@@ -992,8 +991,7 @@ static int ov23850_otp_setup(struct ov23850 *priv)
992 991
993 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_OTP_DATA); 992 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_OTP_DATA);
994 if (!ctrl) { 993 if (!ctrl) {
995 dev_err(&priv->i2c_client->dev, 994 dev_err(dev, "could not find device ctrl.\n");
996 "could not find device ctrl.\n");
997 return -EINVAL; 995 return -EINVAL;
998 } 996 }
999 997
@@ -1011,6 +1009,7 @@ static int ov23850_otp_setup(struct ov23850 *priv)
1011 1009
1012static int ov23850_fuse_id_setup(struct ov23850 *priv) 1010static int ov23850_fuse_id_setup(struct ov23850 *priv)
1013{ 1011{
1012 struct device *dev = &priv->i2c_client->dev;
1014 int err; 1013 int err;
1015 int i; 1014 int i;
1016 struct v4l2_ctrl *ctrl; 1015 struct v4l2_ctrl *ctrl;
@@ -1029,8 +1028,7 @@ static int ov23850_fuse_id_setup(struct ov23850 *priv)
1029 1028
1030 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_FUSE_ID); 1029 ctrl = v4l2_ctrl_find(&priv->ctrl_handler, TEGRA_CAMERA_CID_FUSE_ID);
1031 if (!ctrl) { 1030 if (!ctrl) {
1032 dev_err(&priv->i2c_client->dev, 1031 dev_err(dev, "could not find device ctrl.\n");
1033 "could not find device ctrl.\n");
1034 return -EINVAL; 1032 return -EINVAL;
1035 } 1033 }
1036 1034
@@ -1050,6 +1048,7 @@ static int ov23850_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
1050{ 1048{
1051 struct ov23850 *priv = 1049 struct ov23850 *priv =
1052 container_of(ctrl->handler, struct ov23850, ctrl_handler); 1050 container_of(ctrl->handler, struct ov23850, ctrl_handler);
1051 struct device *dev = &priv->i2c_client->dev;
1053 int err = 0; 1052 int err = 0;
1054 1053
1055 if (priv->power.state == SWITCH_OFF) 1054 if (priv->power.state == SWITCH_OFF)
@@ -1064,7 +1063,7 @@ static int ov23850_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
1064#endif 1063#endif
1065 break; 1064 break;
1066 default: 1065 default:
1067 pr_err("%s: unknown ctrl id.\n", __func__); 1066 dev_err(dev, "%s: unknown ctrl id.\n", __func__);
1068 return -EINVAL; 1067 return -EINVAL;
1069 } 1068 }
1070 1069
@@ -1075,6 +1074,7 @@ static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl)
1075{ 1074{
1076 struct ov23850 *priv = 1075 struct ov23850 *priv =
1077 container_of(ctrl->handler, struct ov23850, ctrl_handler); 1076 container_of(ctrl->handler, struct ov23850, ctrl_handler);
1077 struct device *dev = &priv->i2c_client->dev;
1078 int err = 0; 1078 int err = 0;
1079 1079
1080 if (priv->power.state == SWITCH_OFF) 1080 if (priv->power.state == SWITCH_OFF)
@@ -1113,7 +1113,7 @@ static int ov23850_s_ctrl(struct v4l2_ctrl *ctrl)
1113 case TEGRA_CAMERA_CID_HDR_EN: 1113 case TEGRA_CAMERA_CID_HDR_EN:
1114 break; 1114 break;
1115 default: 1115 default:
1116 pr_err("%s: unknown ctrl id.\n", __func__); 1116 dev_err(dev, "%s: unknown ctrl id.\n", __func__);
1117 return -EINVAL; 1117 return -EINVAL;
1118 } 1118 }
1119 1119
@@ -1282,8 +1282,7 @@ static int ov23850_probe(struct i2c_client *client,
1282 struct ov23850 *priv; 1282 struct ov23850 *priv;
1283 int err; 1283 int err;
1284 1284
1285 pr_info("[OV23850]: probing v4l2 sensor at addr 0x%0x.\n", 1285 dev_info(&client->dev, "probing v4l2 sensor\n");
1286 client->addr);
1287 1286
1288 common_data = devm_kzalloc(&client->dev, 1287 common_data = devm_kzalloc(&client->dev,
1289 sizeof(struct camera_common_data), GFP_KERNEL); 1288 sizeof(struct camera_common_data), GFP_KERNEL);