c - copy_to_user() and copy_from_user() for basic data type -
i'm writing linux kernel driver , every function sends data userspace or reads data userspace, using copy_to_user() , copy_from_user(). question is: need use these calls if copying basic data type such u32 or int? if function receives pointer user-space data, have use copy_from_user() copy pointed-to data user space kernel space (and vice versa). note pointer value passed value (like c parameters), don't have copy_from_user() obtain pointer value before can copy_from_user() data points to. numeric arguments work same way pointer arguments; in c terms, they're both scalars. don't have use copy_from_user() copy value of parameter; that's been copied. have use copy data that's pointed passed pointer. so if have parameter of type int , can use directly. if parameter points int , int object in user space, , need use copy_to_user copy value of object kernel space.