Commit cda19bda authored by Rafael Laya's avatar Rafael Laya Committed by Carles Cufi
Browse files

drivers: regulator: API to get max regulator voltage

There is already a get_min_voltage() API, so let us add
an API to also query the max voltage

Signed-off-by: default avatarRafael Laya <rafael_laya97@hotmail.com.com>
parent a4adfc72
Loading
Loading
Loading
Loading
+22 −0
Changes for include/zephyr/drivers/regulator.h: 22 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -313,6 +313,28 @@ static inline int regulator_common_get_min_voltage(const struct device *dev, int
	return 0;
}

/**
 * @brief Get maximum supported voltage.
 *
 * @param dev Regulator device instance.
 * @param max_uv Where maximum voltage will be stored, in microvolts.
 *
 * @retval 0 If successful
 * @retval -ENOENT If maximum voltage is not specified.
 */
static inline int regulator_common_get_max_voltage(const struct device *dev, int32_t *max_uv)
{
	const struct regulator_common_config *config =
		(const struct regulator_common_config *)dev->config;

	if (config->max_uv == INT32_MAX) {
		return -ENOENT;
	}

	*max_uv = config->max_uv;
	return 0;
}

/** @endcond */

/**