Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 306
Pradeep Goswami Avatar asked Sep 29 '22 19:09

Pradeep Goswami


1 Answers

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.

like image 99
echo Avatar answered Oct 08 '22 03:10

echo