summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/clk/clk_prog.c
diff options
context:
space:
mode:
authorSrirangan <smadhavan@nvidia.com>2018-09-04 06:46:20 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-05 23:38:33 -0400
commitef851272e5201f343c9b287a9eacfc25d4912276 (patch)
tree2c7f85f168258e8b8779dd3ef32f1b18621fa6a7 /drivers/gpu/nvgpu/clk/clk_prog.c
parent78b4ab269f5d733c8b540a6a75db1f390172cc29 (diff)
gpu: nvgpu: clk: Fix MISRA 15.6 violations
MISRA Rule-15.6 requires that all if-else blocks be enclosed in braces, including single statement blocks. Fix errors due to single statement if blocks without braces by introducing the braces. JIRA NVGPU-671 Change-Id: I228f04adea809e1dd4e6826bf1a04f051a533102 Signed-off-by: Srirangan <smadhavan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1796831 Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/clk/clk_prog.c')
-rw-r--r--drivers/gpu/nvgpu/clk/clk_prog.c133
1 files changed, 87 insertions, 46 deletions
diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c
index 8926b9f5..5966d64a 100644
--- a/drivers/gpu/nvgpu/clk/clk_prog.c
+++ b/drivers/gpu/nvgpu/clk/clk_prog.c
@@ -76,8 +76,9 @@ static u32 _clk_progs_pmudata_instget(struct gk20a *g,
76 76
77 /*check whether pmuboardobjgrp has a valid boardobj in index*/ 77 /*check whether pmuboardobjgrp has a valid boardobj in index*/
78 if (((u32)BIT(idx) & 78 if (((u32)BIT(idx) &
79 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0) 79 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0) {
80 return -EINVAL; 80 return -EINVAL;
81 }
81 82
82 *ppboardobjpmudata = (struct nv_pmu_boardobj *) 83 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
83 &pgrp_set->objects[idx].data.board_obj; 84 &pgrp_set->objects[idx].data.board_obj;
@@ -119,8 +120,9 @@ u32 clk_prog_sw_setup(struct gk20a *g)
119 pboardobjgrp->pmudatainstget = _clk_progs_pmudata_instget; 120 pboardobjgrp->pmudatainstget = _clk_progs_pmudata_instget;
120 121
121 status = devinit_get_clk_prog_table(g, pclkprogobjs); 122 status = devinit_get_clk_prog_table(g, pclkprogobjs);
122 if (status) 123 if (status) {
123 goto done; 124 goto done;
125 }
124 126
125 status = clk_domain_clk_prog_link(g, &g->clk_pmu); 127 status = clk_domain_clk_prog_link(g, &g->clk_pmu);
126 if (status) { 128 if (status) {
@@ -143,8 +145,9 @@ u32 clk_prog_pmu_setup(struct gk20a *g)
143 145
144 pboardobjgrp = &g->clk_pmu.clk_progobjs.super.super; 146 pboardobjgrp = &g->clk_pmu.clk_progobjs.super.super;
145 147
146 if (!pboardobjgrp->bconstructed) 148 if (!pboardobjgrp->bconstructed) {
147 return -EINVAL; 149 return -EINVAL;
150 }
148 151
149 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp); 152 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
150 153
@@ -202,11 +205,11 @@ static u32 devinit_get_clk_prog_table(struct gk20a *g,
202 } 205 }
203 hszfmt = header.header_size; 206 hszfmt = header.header_size;
204 207
205 if (header.entry_size <= VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_05) 208 if (header.entry_size <= VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_05) {
206 szfmt = header.entry_size; 209 szfmt = header.entry_size;
207 else if (header.entry_size <= VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_0D) 210 } else if (header.entry_size <= VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_0D) {
208 szfmt = header.entry_size; 211 szfmt = header.entry_size;
209 else { 212 } else {
210 status = -EINVAL; 213 status = -EINVAL;
211 goto done; 214 goto done;
212 } 215 }
@@ -399,8 +402,9 @@ static u32 _clk_prog_pmudatainit_1x(struct gk20a *g,
399 nvgpu_log_info(g, " "); 402 nvgpu_log_info(g, " ");
400 403
401 status = _clk_prog_pmudatainit_super(g, board_obj_ptr, ppmudata); 404 status = _clk_prog_pmudatainit_super(g, board_obj_ptr, ppmudata);
402 if (status != 0) 405 if (status != 0) {
403 return status; 406 return status;
407 }
404 408
405 pclk_prog_1x = (struct clk_prog_1x *)board_obj_ptr; 409 pclk_prog_1x = (struct clk_prog_1x *)board_obj_ptr;
406 410
@@ -458,8 +462,9 @@ static u32 _clk_prog_pmudatainit_1x_master_ratio(struct gk20a *g,
458 nvgpu_log_info(g, " "); 462 nvgpu_log_info(g, " ");
459 463
460 status = _clk_prog_pmudatainit_1x_master(g, board_obj_ptr, ppmudata); 464 status = _clk_prog_pmudatainit_1x_master(g, board_obj_ptr, ppmudata);
461 if (status != 0) 465 if (status != 0) {
462 return status; 466 return status;
467 }
463 468
464 pclk_prog_1x_master_ratio = 469 pclk_prog_1x_master_ratio =
465 (struct clk_prog_1x_master_ratio *)board_obj_ptr; 470 (struct clk_prog_1x_master_ratio *)board_obj_ptr;
@@ -486,8 +491,9 @@ static u32 _clk_prog_pmudatainit_1x_master_table(struct gk20a *g,
486 nvgpu_log_info(g, " "); 491 nvgpu_log_info(g, " ");
487 492
488 status = _clk_prog_pmudatainit_1x_master(g, board_obj_ptr, ppmudata); 493 status = _clk_prog_pmudatainit_1x_master(g, board_obj_ptr, ppmudata);
489 if (status != 0) 494 if (status != 0) {
490 return status; 495 return status;
496 }
491 497
492 pclk_prog_1x_master_table = 498 pclk_prog_1x_master_table =
493 (struct clk_prog_1x_master_table *)board_obj_ptr; 499 (struct clk_prog_1x_master_table *)board_obj_ptr;
@@ -521,8 +527,9 @@ static u32 _clk_prog_1x_master_rail_construct_vf_point(struct gk20a *g,
521 &pclk->clk_vf_pointobjs.super.super, 527 &pclk->clk_vf_pointobjs.super.super,
522 &p_vf_point->super, 528 &p_vf_point->super,
523 *p_vf_point_idx); 529 *p_vf_point_idx);
524 if (status) 530 if (status) {
525 goto done; 531 goto done;
532 }
526 533
527 p_vf_rail->vf_point_idx_last = (*p_vf_point_idx)++; 534 p_vf_rail->vf_point_idx_last = (*p_vf_point_idx)++;
528 535
@@ -540,8 +547,9 @@ static u32 clk_prog_construct_super(struct gk20a *g,
540 547
541 status = boardobj_construct_super(g, ppboardobj, 548 status = boardobj_construct_super(g, ppboardobj,
542 size, pargs); 549 size, pargs);
543 if (status) 550 if (status) {
544 return -EINVAL; 551 return -EINVAL;
552 }
545 553
546 pclkprog = (struct clk_prog *)*ppboardobj; 554 pclkprog = (struct clk_prog *)*ppboardobj;
547 555
@@ -564,8 +572,9 @@ static u32 clk_prog_construct_1x(struct gk20a *g,
564 nvgpu_log_info(g, " "); 572 nvgpu_log_info(g, " ");
565 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X); 573 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X);
566 status = clk_prog_construct_super(g, ppboardobj, size, pargs); 574 status = clk_prog_construct_super(g, ppboardobj, size, pargs);
567 if (status) 575 if (status) {
568 return -EINVAL; 576 return -EINVAL;
577 }
569 578
570 pclkprog = (struct clk_prog_1x *)*ppboardobj; 579 pclkprog = (struct clk_prog_1x *)*ppboardobj;
571 580
@@ -596,8 +605,9 @@ static u32 clk_prog_construct_1x_master(struct gk20a *g,
596 605
597 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER); 606 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER);
598 status = clk_prog_construct_1x(g, ppboardobj, size, pargs); 607 status = clk_prog_construct_1x(g, ppboardobj, size, pargs);
599 if (status) 608 if (status) {
600 return -EINVAL; 609 return -EINVAL;
610 }
601 611
602 pclkprog = (struct clk_prog_1x_master *)*ppboardobj; 612 pclkprog = (struct clk_prog_1x_master *)*ppboardobj;
603 613
@@ -647,13 +657,15 @@ static u32 clk_prog_construct_1x_master_ratio(struct gk20a *g,
647 u32 slavesize = sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) * 657 u32 slavesize = sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) *
648 g->clk_pmu.clk_progobjs.slave_entry_count; 658 g->clk_pmu.clk_progobjs.slave_entry_count;
649 659
650 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO) 660 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO) {
651 return -EINVAL; 661 return -EINVAL;
662 }
652 663
653 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO); 664 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO);
654 status = clk_prog_construct_1x_master(g, ppboardobj, size, pargs); 665 status = clk_prog_construct_1x_master(g, ppboardobj, size, pargs);
655 if (status) 666 if (status) {
656 return -EINVAL; 667 return -EINVAL;
668 }
657 669
658 pclkprog = (struct clk_prog_1x_master_ratio *)*ppboardobj; 670 pclkprog = (struct clk_prog_1x_master_ratio *)*ppboardobj;
659 671
@@ -663,8 +675,9 @@ static u32 clk_prog_construct_1x_master_ratio(struct gk20a *g,
663 pclkprog->p_slave_entries = 675 pclkprog->p_slave_entries =
664 (struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *) 676 (struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *)
665 nvgpu_kzalloc(g, slavesize); 677 nvgpu_kzalloc(g, slavesize);
666 if (!pclkprog->p_slave_entries) 678 if (!pclkprog->p_slave_entries) {
667 return -ENOMEM; 679 return -ENOMEM;
680 }
668 681
669 memset(pclkprog->p_slave_entries, CTRL_CLK_CLK_DOMAIN_INDEX_INVALID, 682 memset(pclkprog->p_slave_entries, CTRL_CLK_CLK_DOMAIN_INDEX_INVALID,
670 slavesize); 683 slavesize);
@@ -688,13 +701,15 @@ static u32 clk_prog_construct_1x_master_table(struct gk20a *g,
688 701
689 nvgpu_log_info(g, "type - %x", BOARDOBJ_GET_TYPE(pargs)); 702 nvgpu_log_info(g, "type - %x", BOARDOBJ_GET_TYPE(pargs));
690 703
691 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE) 704 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE) {
692 return -EINVAL; 705 return -EINVAL;
706 }
693 707
694 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE); 708 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE);
695 status = clk_prog_construct_1x_master(g, ppboardobj, size, pargs); 709 status = clk_prog_construct_1x_master(g, ppboardobj, size, pargs);
696 if (status) 710 if (status) {
697 return -EINVAL; 711 return -EINVAL;
712 }
698 713
699 pclkprog = (struct clk_prog_1x_master_table *)*ppboardobj; 714 pclkprog = (struct clk_prog_1x_master_table *)*ppboardobj;
700 715
@@ -716,8 +731,9 @@ static u32 clk_prog_construct_1x_master_table(struct gk20a *g,
716 memcpy(pclkprog->p_slave_entries, ptmpprog->p_slave_entries, slavesize); 731 memcpy(pclkprog->p_slave_entries, ptmpprog->p_slave_entries, slavesize);
717 732
718exit: 733exit:
719 if (status) 734 if (status) {
720 (*ppboardobj)->destruct(*ppboardobj); 735 (*ppboardobj)->destruct(*ppboardobj);
736 }
721 737
722 return status; 738 return status;
723} 739}
@@ -749,8 +765,9 @@ static struct clk_prog *construct_clk_prog(struct gk20a *g, void *pargs)
749 } 765 }
750 766
751 if (status) { 767 if (status) {
752 if (board_obj_ptr) 768 if (board_obj_ptr) {
753 board_obj_ptr->destruct(board_obj_ptr); 769 board_obj_ptr->destruct(board_obj_ptr);
770 }
754 return NULL; 771 return NULL;
755 } 772 }
756 773
@@ -791,8 +808,9 @@ static u32 vfflatten_prog_1x_master(struct gk20a *g,
791 u8 i; 808 u8 i;
792 809
793 p_vf_rail = &p1xmaster->p_vf_entries[vf_rail_idx]; 810 p_vf_rail = &p1xmaster->p_vf_entries[vf_rail_idx];
794 if (p_vf_rail->vfe_idx == CTRL_BOARDOBJ_IDX_INVALID) 811 if (p_vf_rail->vfe_idx == CTRL_BOARDOBJ_IDX_INVALID) {
795 continue; 812 continue;
813 }
796 814
797 p_vf_rail->vf_point_idx_first = vf_point_idx; 815 p_vf_rail->vf_point_idx_first = vf_point_idx;
798 816
@@ -821,8 +839,9 @@ static u32 vfflatten_prog_1x_master(struct gk20a *g,
821 status = _clk_prog_1x_master_rail_construct_vf_point(g, pclk, 839 status = _clk_prog_1x_master_rail_construct_vf_point(g, pclk,
822 p1xmaster, p_vf_rail, 840 p1xmaster, p_vf_rail,
823 &vf_point_data.vf_point, &vf_point_idx); 841 &vf_point_data.vf_point, &vf_point_idx);
824 if (status) 842 if (status) {
825 goto done; 843 goto done;
844 }
826 } while (step_count-- > 0); 845 } while (step_count-- > 0);
827 break; 846 break;
828 847
@@ -841,8 +860,9 @@ static u32 vfflatten_prog_1x_master(struct gk20a *g,
841 status = _clk_prog_1x_master_rail_construct_vf_point(g, pclk, 860 status = _clk_prog_1x_master_rail_construct_vf_point(g, pclk,
842 p1xmaster, p_vf_rail, 861 p1xmaster, p_vf_rail,
843 &vf_point_data.vf_point, &vf_point_idx); 862 &vf_point_data.vf_point, &vf_point_idx);
844 if (status) 863 if (status) {
845 goto done; 864 goto done;
865 }
846 } 866 }
847 break; 867 break;
848 } 868 }
@@ -878,19 +898,22 @@ static u32 vflookup_prog_1x_master
878 int i; 898 int i;
879 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents; 899 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents;
880 900
881 if ((*pclkmhz != 0) && (*pvoltuv != 0)) 901 if ((*pclkmhz != 0) && (*pvoltuv != 0)) {
882 return -EINVAL; 902 return -EINVAL;
903 }
883 904
884 pclkprogobjs = &(pclk->clk_progobjs); 905 pclkprogobjs = &(pclk->clk_progobjs);
885 906
886 slaveentrycount = pclkprogobjs->slave_entry_count; 907 slaveentrycount = pclkprogobjs->slave_entry_count;
887 908
888 if (pclkprogobjs->vf_entry_count > 909 if (pclkprogobjs->vf_entry_count >
889 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES) 910 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES) {
890 return -EINVAL; 911 return -EINVAL;
912 }
891 913
892 if (rail >= pclkprogobjs->vf_entry_count) 914 if (rail >= pclkprogobjs->vf_entry_count) {
893 return -EINVAL; 915 return -EINVAL;
916 }
894 917
895 pvfentry = p1xmaster->p_vf_entries; 918 pvfentry = p1xmaster->p_vf_entries;
896 919
@@ -914,12 +937,14 @@ static u32 vflookup_prog_1x_master
914 pslaveents = p1xmasterratio->p_slave_entries; 937 pslaveents = p1xmasterratio->p_slave_entries;
915 for (i = 0; i < slaveentrycount; i++) { 938 for (i = 0; i < slaveentrycount; i++) {
916 if (pslaveents->clk_dom_idx == 939 if (pslaveents->clk_dom_idx ==
917 *slave_clk_domain) 940 *slave_clk_domain) {
918 break; 941 break;
942 }
919 pslaveents++; 943 pslaveents++;
920 } 944 }
921 if (i == slaveentrycount) 945 if (i == slaveentrycount) {
922 return -EINVAL; 946 return -EINVAL;
947 }
923 clkmhz = (clkmhz * 100)/pslaveents->ratio; 948 clkmhz = (clkmhz * 100)/pslaveents->ratio;
924 } else { 949 } else {
925 /* only support ratio for now */ 950 /* only support ratio for now */
@@ -944,32 +969,36 @@ static u32 vflookup_prog_1x_master
944 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, 969 pvfpoint = CLK_CLK_VF_POINT_GET(pclk,
945 pvfentry->vf_point_idx_last); 970 pvfentry->vf_point_idx_last);
946 /* above range? */ 971 /* above range? */
947 if (clkmhz > clkvfpointfreqmhzget(g, pvfpoint)) 972 if (clkmhz > clkvfpointfreqmhzget(g, pvfpoint)) {
948 return -EINVAL; 973 return -EINVAL;
974 }
949 975
950 for (j = pvfentry->vf_point_idx_last; 976 for (j = pvfentry->vf_point_idx_last;
951 j >= pvfentry->vf_point_idx_first; j--) { 977 j >= pvfentry->vf_point_idx_first; j--) {
952 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j); 978 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
953 if (clkmhz <= clkvfpointfreqmhzget(g, pvfpoint)) 979 if (clkmhz <= clkvfpointfreqmhzget(g, pvfpoint)) {
954 voltuv = clkvfpointvoltageuvget(g, pvfpoint); 980 voltuv = clkvfpointvoltageuvget(g, pvfpoint);
955 else 981 } else {
956 break; 982 break;
983 }
957 } 984 }
958 } else { /* looking for clk? */ 985 } else { /* looking for clk? */
959 986
960 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, 987 pvfpoint = CLK_CLK_VF_POINT_GET(pclk,
961 pvfentry->vf_point_idx_first); 988 pvfentry->vf_point_idx_first);
962 /* below range? */ 989 /* below range? */
963 if (voltuv < clkvfpointvoltageuvget(g, pvfpoint)) 990 if (voltuv < clkvfpointvoltageuvget(g, pvfpoint)) {
964 return -EINVAL; 991 return -EINVAL;
992 }
965 993
966 for (j = pvfentry->vf_point_idx_first; 994 for (j = pvfentry->vf_point_idx_first;
967 j <= pvfentry->vf_point_idx_last; j++) { 995 j <= pvfentry->vf_point_idx_last; j++) {
968 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j); 996 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
969 if (voltuv >= clkvfpointvoltageuvget(g, pvfpoint)) 997 if (voltuv >= clkvfpointvoltageuvget(g, pvfpoint)) {
970 clkmhz = clkvfpointfreqmhzget(g, pvfpoint); 998 clkmhz = clkvfpointfreqmhzget(g, pvfpoint);
971 else 999 } else {
972 break; 1000 break;
1001 }
973 } 1002 }
974 } 1003 }
975 1004
@@ -985,12 +1014,14 @@ static u32 vflookup_prog_1x_master
985 pslaveents = p1xmasterratio->p_slave_entries; 1014 pslaveents = p1xmasterratio->p_slave_entries;
986 for (i = 0; i < slaveentrycount; i++) { 1015 for (i = 0; i < slaveentrycount; i++) {
987 if (pslaveents->clk_dom_idx == 1016 if (pslaveents->clk_dom_idx ==
988 *slave_clk_domain) 1017 *slave_clk_domain) {
989 break; 1018 break;
1019 }
990 pslaveents++; 1020 pslaveents++;
991 } 1021 }
992 if (i == slaveentrycount) 1022 if (i == slaveentrycount) {
993 return -EINVAL; 1023 return -EINVAL;
1024 }
994 clkmhz = (clkmhz * pslaveents->ratio)/100; 1025 clkmhz = (clkmhz * pslaveents->ratio)/100;
995 } else { 1026 } else {
996 /* only support ratio for now */ 1027 /* only support ratio for now */
@@ -999,8 +1030,9 @@ static u32 vflookup_prog_1x_master
999 } 1030 }
1000 *pclkmhz = clkmhz; 1031 *pclkmhz = clkmhz;
1001 *pvoltuv = voltuv; 1032 *pvoltuv = voltuv;
1002 if ((clkmhz == 0) || (voltuv == 0)) 1033 if ((clkmhz == 0) || (voltuv == 0)) {
1003 return -EINVAL; 1034 return -EINVAL;
1035 }
1004 return 0; 1036 return 0;
1005} 1037}
1006 1038
@@ -1022,17 +1054,20 @@ static u32 getfpoints_prog_1x_master
1022 u8 j; 1054 u8 j;
1023 u32 fpointscount = 0; 1055 u32 fpointscount = 0;
1024 1056
1025 if (pfpointscount == NULL) 1057 if (pfpointscount == NULL) {
1026 return -EINVAL; 1058 return -EINVAL;
1059 }
1027 1060
1028 pclkprogobjs = &(pclk->clk_progobjs); 1061 pclkprogobjs = &(pclk->clk_progobjs);
1029 1062
1030 if (pclkprogobjs->vf_entry_count > 1063 if (pclkprogobjs->vf_entry_count >
1031 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES) 1064 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES) {
1032 return -EINVAL; 1065 return -EINVAL;
1066 }
1033 1067
1034 if (rail >= pclkprogobjs->vf_entry_count) 1068 if (rail >= pclkprogobjs->vf_entry_count) {
1035 return -EINVAL; 1069 return -EINVAL;
1070 }
1036 1071
1037 pvfentry = p1xmaster->p_vf_entries; 1072 pvfentry = p1xmaster->p_vf_entries;
1038 1073
@@ -1045,11 +1080,13 @@ static u32 getfpoints_prog_1x_master
1045 pvfentry->vf_point_idx_first + 1; 1080 pvfentry->vf_point_idx_first + 1;
1046 1081
1047 /* if pointer for freq data is NULL simply return count */ 1082 /* if pointer for freq data is NULL simply return count */
1048 if (*ppfreqpointsinmhz == NULL) 1083 if (*ppfreqpointsinmhz == NULL) {
1049 goto done; 1084 goto done;
1085 }
1050 1086
1051 if (fpointscount > *pfpointscount) 1087 if (fpointscount > *pfpointscount) {
1052 return -ENOMEM; 1088 return -ENOMEM;
1089 }
1053 for (j = pvfentry->vf_point_idx_first; 1090 for (j = pvfentry->vf_point_idx_first;
1054 j <= pvfentry->vf_point_idx_last; j++) { 1091 j <= pvfentry->vf_point_idx_last; j++) {
1055 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j); 1092 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
@@ -1075,11 +1112,13 @@ static int getslaveclk_prog_1x_master(struct gk20a *g,
1075 u8 i; 1112 u8 i;
1076 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents; 1113 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents;
1077 1114
1078 if (pclkmhz == NULL) 1115 if (pclkmhz == NULL) {
1079 return -EINVAL; 1116 return -EINVAL;
1117 }
1080 1118
1081 if (masterclkmhz == 0) 1119 if (masterclkmhz == 0) {
1082 return -EINVAL; 1120 return -EINVAL;
1121 }
1083 1122
1084 *pclkmhz = 0; 1123 *pclkmhz = 0;
1085 pclkprogobjs = &(pclk->clk_progobjs); 1124 pclkprogobjs = &(pclk->clk_progobjs);
@@ -1094,12 +1133,14 @@ static int getslaveclk_prog_1x_master(struct gk20a *g,
1094 pslaveents = p1xmasterratio->p_slave_entries; 1133 pslaveents = p1xmasterratio->p_slave_entries;
1095 for (i = 0; i < slaveentrycount; i++) { 1134 for (i = 0; i < slaveentrycount; i++) {
1096 if (pslaveents->clk_dom_idx == 1135 if (pslaveents->clk_dom_idx ==
1097 slave_clk_domain) 1136 slave_clk_domain) {
1098 break; 1137 break;
1138 }
1099 pslaveents++; 1139 pslaveents++;
1100 } 1140 }
1101 if (i == slaveentrycount) 1141 if (i == slaveentrycount) {
1102 return -EINVAL; 1142 return -EINVAL;
1143 }
1103 *pclkmhz = (masterclkmhz * pslaveents->ratio)/100; 1144 *pclkmhz = (masterclkmhz * pslaveents->ratio)/100;
1104 } else { 1145 } else {
1105 /* only support ratio for now */ 1146 /* only support ratio for now */