History

Merge branch 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm into pm-opp

Pull operating performance points (OPP) framework changes for v5.2 from Viresh Kumar: "This pull request contains: - New helper in OPP core to find best matching frequency for a voltage value." * 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: OPP: Introduce dev_pm_opp_find_freq_ceil_by_volt()

Rafael J. Wysocki committed 7 years ago

Commit 5a286542 parents 37624b5 2f36bde2 files · +62 −0Browse files

Unified · Split

2 files
  1. drivers/opp/core.c +54 −0
  2. include/linux/pm_opp.h +8 −0
drivers/opp/core.c+54−0
@@ -526,6 +526,60 @@ struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, · 525 unmodified lines
526526 }
527527 EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor);
528528
529+/**
530+ * dev_pm_opp_find_freq_ceil_by_volt() - Find OPP with highest frequency for
531+ * target voltage.
532+ * @dev: Device for which we do this operation.
533+ * @u_volt: Target voltage.
534+ *
535+ * Search for OPP with highest (ceil) frequency and has voltage <= u_volt.
536+ *
537+ * Return: matching *opp, else returns ERR_PTR in case of error which should be
538+ * handled using IS_ERR.
539+ *
540+ * Error return values can be:
541+ * EINVAL: bad parameters
542+ *
543+ * The callers are required to call dev_pm_opp_put() for the returned OPP after
544+ * use.
545+ */
546+struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev,
547+ unsigned long u_volt)
548+{
549+ struct opp_table *opp_table;
550+ struct dev_pm_opp *temp_opp, *opp = ERR_PTR(-ERANGE);
551+
552+ if (!dev || !u_volt) {
553+ dev_err(dev, "%s: Invalid argument volt=%lu\n", __func__,
554+ u_volt);
555+ return ERR_PTR(-EINVAL);
556+ }
557+
558+ opp_table = _find_opp_table(dev);
559+ if (IS_ERR(opp_table))
560+ return ERR_CAST(opp_table);
561+
562+ mutex_lock(&opp_table->lock);
563+
564+ list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
565+ if (temp_opp->available) {
566+ if (temp_opp->supplies[0].u_volt > u_volt)
567+ break;
568+ opp = temp_opp;
569+ }
570+ }
571+
572+ /* Increment the reference count of OPP */
573+ if (!IS_ERR(opp))
574+ dev_pm_opp_get(opp);
575+
576+ mutex_unlock(&opp_table->lock);
577+ dev_pm_opp_put_opp_table(opp_table);
578+
579+ return opp;
580+}
581+EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil_by_volt);
582+
529583 static int _set_opp_voltage(struct device *dev, struct regulator *reg,
530584 struct dev_pm_opp_supply *supply)
531585 {
include/linux/pm_opp.h+8−0
@@ -102,6 +102,8 @@ struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, · 101 unmodified lines
102102
103103 struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev,
104104 unsigned long *freq);
105+struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev,
106+ unsigned long u_volt);
105107
106108 struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
107109 unsigned long *freq);
@@ -207,6 +209,12 @@ static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, · 99 unmodified lines
207209 return ERR_PTR(-ENOTSUPP);
208210 }
209211
212+static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil_by_volt(struct device *dev,
213+ unsigned long u_volt)
214+{
215+ return ERR_PTR(-ENOTSUPP);
216+}
217+
210218 static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
211219 unsigned long *freq)
212220 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t