Pradeep Goswami
Pradeep Goswami

Reputation: 1965

What is difference between __va() and phys_to_virt()?

What is difference between __va() and phys_to_virt() ,what is need of these two separate implementation for same purpose, any difference between these two?

Upvotes: 5

Views: 3945

Answers (1)

echo
echo

Reputation: 104

phys_to_virt and __va are preprocessor macros. phys_to_virt:

#if !defined(CONFIG_MMU)
#define virt_to_phys(address)   ((unsigned long)(address))
#define phys_to_virt(address)   ((void *)(address))
#else
#define virt_to_phys(address)   (__pa(address))
#define phys_to_virt(address)   (__va(address))
#endif

And __va

#define __va(x) ((void *)((unsigned long) (x)))

If CONFIG_MMU is not defined then are equals.

Upvotes: 4

Related Questions