@@ -101,11 +101,21 @@ struct opp_table *_find_opp_table(struct device *dev)
101
101
* representation in the OPP table and manage the clock configuration themselves
102
102
* in an platform specific way.
103
103
*/
104
- static bool assert_single_clk (struct opp_table * opp_table )
104
+ static bool assert_single_clk (struct opp_table * opp_table ,
105
+ unsigned int __always_unused index )
105
106
{
106
107
return !WARN_ON (opp_table -> clk_count > 1 );
107
108
}
108
109
110
+ /*
111
+ * Returns true if clock table is large enough to contain the clock index.
112
+ */
113
+ static bool assert_clk_index (struct opp_table * opp_table ,
114
+ unsigned int index )
115
+ {
116
+ return opp_table -> clk_count > index ;
117
+ }
118
+
109
119
/**
110
120
* dev_pm_opp_get_voltage() - Gets the voltage corresponding to an opp
111
121
* @opp: opp for which voltage has to be returned for
@@ -499,12 +509,12 @@ static struct dev_pm_opp *_opp_table_find_key(struct opp_table *opp_table,
499
509
unsigned long (* read )(struct dev_pm_opp * opp , int index ),
500
510
bool (* compare )(struct dev_pm_opp * * opp , struct dev_pm_opp * temp_opp ,
501
511
unsigned long opp_key , unsigned long key ),
502
- bool (* assert )(struct opp_table * opp_table ))
512
+ bool (* assert )(struct opp_table * opp_table , unsigned int index ))
503
513
{
504
514
struct dev_pm_opp * temp_opp , * opp = ERR_PTR (- ERANGE );
505
515
506
516
/* Assert that the requirement is met */
507
- if (assert && !assert (opp_table ))
517
+ if (assert && !assert (opp_table , index ))
508
518
return ERR_PTR (- EINVAL );
509
519
510
520
mutex_lock (& opp_table -> lock );
@@ -532,7 +542,7 @@ _find_key(struct device *dev, unsigned long *key, int index, bool available,
532
542
unsigned long (* read )(struct dev_pm_opp * opp , int index ),
533
543
bool (* compare )(struct dev_pm_opp * * opp , struct dev_pm_opp * temp_opp ,
534
544
unsigned long opp_key , unsigned long key ),
535
- bool (* assert )(struct opp_table * opp_table ))
545
+ bool (* assert )(struct opp_table * opp_table , unsigned int index ))
536
546
{
537
547
struct opp_table * opp_table ;
538
548
struct dev_pm_opp * opp ;
@@ -555,7 +565,7 @@ _find_key(struct device *dev, unsigned long *key, int index, bool available,
555
565
static struct dev_pm_opp * _find_key_exact (struct device * dev ,
556
566
unsigned long key , int index , bool available ,
557
567
unsigned long (* read )(struct dev_pm_opp * opp , int index ),
558
- bool (* assert )(struct opp_table * opp_table ))
568
+ bool (* assert )(struct opp_table * opp_table , unsigned int index ))
559
569
{
560
570
/*
561
571
* The value of key will be updated here, but will be ignored as the
@@ -568,7 +578,7 @@ static struct dev_pm_opp *_find_key_exact(struct device *dev,
568
578
static struct dev_pm_opp * _opp_table_find_key_ceil (struct opp_table * opp_table ,
569
579
unsigned long * key , int index , bool available ,
570
580
unsigned long (* read )(struct dev_pm_opp * opp , int index ),
571
- bool (* assert )(struct opp_table * opp_table ))
581
+ bool (* assert )(struct opp_table * opp_table , unsigned int index ))
572
582
{
573
583
return _opp_table_find_key (opp_table , key , index , available , read ,
574
584
_compare_ceil , assert );
@@ -577,7 +587,7 @@ static struct dev_pm_opp *_opp_table_find_key_ceil(struct opp_table *opp_table,
577
587
static struct dev_pm_opp * _find_key_ceil (struct device * dev , unsigned long * key ,
578
588
int index , bool available ,
579
589
unsigned long (* read )(struct dev_pm_opp * opp , int index ),
580
- bool (* assert )(struct opp_table * opp_table ))
590
+ bool (* assert )(struct opp_table * opp_table , unsigned int index ))
581
591
{
582
592
return _find_key (dev , key , index , available , read , _compare_ceil ,
583
593
assert );
@@ -586,7 +596,7 @@ static struct dev_pm_opp *_find_key_ceil(struct device *dev, unsigned long *key,
586
596
static struct dev_pm_opp * _find_key_floor (struct device * dev ,
587
597
unsigned long * key , int index , bool available ,
588
598
unsigned long (* read )(struct dev_pm_opp * opp , int index ),
589
- bool (* assert )(struct opp_table * opp_table ))
599
+ bool (* assert )(struct opp_table * opp_table , unsigned int index ))
590
600
{
591
601
return _find_key (dev , key , index , available , read , _compare_floor ,
592
602
assert );
@@ -647,7 +657,8 @@ struct dev_pm_opp *
647
657
dev_pm_opp_find_freq_exact_indexed (struct device * dev , unsigned long freq ,
648
658
u32 index , bool available )
649
659
{
650
- return _find_key_exact (dev , freq , index , available , _read_freq , NULL );
660
+ return _find_key_exact (dev , freq , index , available , _read_freq ,
661
+ assert_clk_index );
651
662
}
652
663
EXPORT_SYMBOL_GPL (dev_pm_opp_find_freq_exact_indexed );
653
664
@@ -707,7 +718,8 @@ struct dev_pm_opp *
707
718
dev_pm_opp_find_freq_ceil_indexed (struct device * dev , unsigned long * freq ,
708
719
u32 index )
709
720
{
710
- return _find_key_ceil (dev , freq , index , true, _read_freq , NULL );
721
+ return _find_key_ceil (dev , freq , index , true, _read_freq ,
722
+ assert_clk_index );
711
723
}
712
724
EXPORT_SYMBOL_GPL (dev_pm_opp_find_freq_ceil_indexed );
713
725
@@ -760,7 +772,7 @@ struct dev_pm_opp *
760
772
dev_pm_opp_find_freq_floor_indexed (struct device * dev , unsigned long * freq ,
761
773
u32 index )
762
774
{
763
- return _find_key_floor (dev , freq , index , true, _read_freq , NULL );
775
+ return _find_key_floor (dev , freq , index , true, _read_freq , assert_clk_index );
764
776
}
765
777
EXPORT_SYMBOL_GPL (dev_pm_opp_find_freq_floor_indexed );
766
778
@@ -1703,7 +1715,7 @@ void dev_pm_opp_remove(struct device *dev, unsigned long freq)
1703
1715
if (IS_ERR (opp_table ))
1704
1716
return ;
1705
1717
1706
- if (!assert_single_clk (opp_table ))
1718
+ if (!assert_single_clk (opp_table , 0 ))
1707
1719
goto put_table ;
1708
1720
1709
1721
mutex_lock (& opp_table -> lock );
@@ -2055,7 +2067,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev,
2055
2067
unsigned long tol , u_volt = data -> u_volt ;
2056
2068
int ret ;
2057
2069
2058
- if (!assert_single_clk (opp_table ))
2070
+ if (!assert_single_clk (opp_table , 0 ))
2059
2071
return - EINVAL ;
2060
2072
2061
2073
new_opp = _opp_allocate (opp_table );
@@ -2922,7 +2934,7 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
2922
2934
return r ;
2923
2935
}
2924
2936
2925
- if (!assert_single_clk (opp_table )) {
2937
+ if (!assert_single_clk (opp_table , 0 )) {
2926
2938
r = - EINVAL ;
2927
2939
goto put_table ;
2928
2940
}
@@ -2998,7 +3010,7 @@ int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,
2998
3010
return r ;
2999
3011
}
3000
3012
3001
- if (!assert_single_clk (opp_table )) {
3013
+ if (!assert_single_clk (opp_table , 0 )) {
3002
3014
r = - EINVAL ;
3003
3015
goto put_table ;
3004
3016
}
0 commit comments