···21132113}2114211421152115/**21162116+ * dev_pm_opp_adjust_voltage() - helper to change the voltage of an OPP21172117+ * @dev: device for which we do this operation21182118+ * @freq: OPP frequency to adjust voltage of21192119+ * @u_volt: new OPP target voltage21202120+ * @u_volt_min: new OPP min voltage21212121+ * @u_volt_max: new OPP max voltage21222122+ *21232123+ * Return: -EINVAL for bad pointers, -ENOMEM if no memory available for the21242124+ * copy operation, returns 0 if no modifcation was done OR modification was21252125+ * successful.21262126+ */21272127+int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,21282128+ unsigned long u_volt, unsigned long u_volt_min,21292129+ unsigned long u_volt_max)21302130+21312131+{21322132+ struct opp_table *opp_table;21332133+ struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);21342134+ int r = 0;21352135+21362136+ /* Find the opp_table */21372137+ opp_table = _find_opp_table(dev);21382138+ if (IS_ERR(opp_table)) {21392139+ r = PTR_ERR(opp_table);21402140+ dev_warn(dev, "%s: Device OPP not found (%d)\n", __func__, r);21412141+ return r;21422142+ }21432143+21442144+ mutex_lock(&opp_table->lock);21452145+21462146+ /* Do we have the frequency? */21472147+ list_for_each_entry(tmp_opp, &opp_table->opp_list, node) {21482148+ if (tmp_opp->rate == freq) {21492149+ opp = tmp_opp;21502150+ break;21512151+ }21522152+ }21532153+21542154+ if (IS_ERR(opp)) {21552155+ r = PTR_ERR(opp);21562156+ goto adjust_unlock;21572157+ }21582158+21592159+ /* Is update really needed? */21602160+ if (opp->supplies->u_volt == u_volt)21612161+ goto adjust_unlock;21622162+21632163+ opp->supplies->u_volt = u_volt;21642164+ opp->supplies->u_volt_min = u_volt_min;21652165+ opp->supplies->u_volt_max = u_volt_max;21662166+21672167+ dev_pm_opp_get(opp);21682168+ mutex_unlock(&opp_table->lock);21692169+21702170+ /* Notify the voltage change of the OPP */21712171+ blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADJUST_VOLTAGE,21722172+ opp);21732173+21742174+ dev_pm_opp_put(opp);21752175+ goto adjust_put_table;21762176+21772177+adjust_unlock:21782178+ mutex_unlock(&opp_table->lock);21792179+adjust_put_table:21802180+ dev_pm_opp_put_opp_table(opp_table);21812181+ return r;21822182+}21832183+21842184+/**21162185 * dev_pm_opp_enable() - Enable a specific OPP21172186 * @dev: device for which we do this operation21182187 * @freq: OPP frequency to enable
+13
include/linux/pm_opp.h
···22222323enum dev_pm_opp_event {2424 OPP_EVENT_ADD, OPP_EVENT_REMOVE, OPP_EVENT_ENABLE, OPP_EVENT_DISABLE,2525+ OPP_EVENT_ADJUST_VOLTAGE,2526};26272728/**···113112 unsigned long u_volt);114113void dev_pm_opp_remove(struct device *dev, unsigned long freq);115114void dev_pm_opp_remove_all_dynamic(struct device *dev);115115+116116+int dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,117117+ unsigned long u_volt, unsigned long u_volt_min,118118+ unsigned long u_volt_max);116119117120int dev_pm_opp_enable(struct device *dev, unsigned long freq);118121···245240246241static inline void dev_pm_opp_remove_all_dynamic(struct device *dev)247242{243243+}244244+245245+static inline int246246+dev_pm_opp_adjust_voltage(struct device *dev, unsigned long freq,247247+ unsigned long u_volt, unsigned long u_volt_min,248248+ unsigned long u_volt_max)249249+{250250+ return 0;248251}249252250253static inline int dev_pm_opp_enable(struct device *dev, unsigned long freq)