#ifndef _ASM_GENERIC_PGALLOC_H
#define _ASM_GENERIC_PGALLOC_H

static inline int ptep_test_and_clear_and_flush_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
{
	if (!ptep_test_and_clear_young(ptep))
		return 0;
	flush_tlb_page(vma, address);
	return 1;
}

static inline int ptep_test_and_clear_and_flush_dirty(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
{
	if (!ptep_test_and_clear_dirty(ptep))
		return 0;
	flush_tlb_page(vma, address);
	return 1;
}

static inline void ptep_establish(struct vm_area_struct *vma, unsigned long address, pte_t *ptep, pte_t entry)
{
	set_pte(ptep, entry);
	flush_tlb_page(vma, address);
	update_mmu_cache(vma, address, entry);
}

static inline pte_t ptep_invalidate(struct vm_area_struct *vma, unsigned long address, pte_t *ptep)
{
	pte_t pte;

	flush_cache_page(vma, address);
        pte = ptep_get_and_clear(ptep);
	flush_tlb_page(vma, address);
	return pte;
}

#endif /* _ASM_GENERIC_PGALLOC_H */
