/* PE calls this function to check if the Present Contract is still valid.  */
static bool port0_policy_cb_present_contract_is_valid(const struct device *dev, const uint32_t present_contract)
/* PE calls this function to check if the Present Contract is still valid.  */
static bool port0_policy_cb_present_contract_is_valid(const struct device *dev, const uint32_t present_contract)
{
	struct port0_data_t *dpm_data = usbc_get_dpm_data(dev);
	union pd_fixed_supply_pdo_source pdo;
	union pd_rdo request;
	uint32_t obj_pos;
	uint32_t op_current;
	request.raw_value = present_contract;
	obj_pos = request.fixed.object_pos;
	op_current = PD_CONVERT_FIXED_PDO_CURRENT_TO_MA(request.fixed.operating_current);
	if (obj_pos == 0 || obj_pos > dpm_data->src_cap_cnt) {
		return false;
	}
	pdo.raw_value = dpm_data->src_caps[obj_pos - 1];
	if (request.fixed.operating_current > pdo.max_current) {
		return false;
	}
	return true;
}