Identify true error value for kernel API's like kmalloc() and ioremap()
Hi How to check for the error values for kernel API's like kmalloc() and ioremap(). If the call fails, the return value is NULL. So, how do I know what caused the failure? I have looked at examples in the kernel code. They are returning a hard-coded value of -ENOMEM if kmalloc() fails. Is there a way? Regards, Manty
On Mon, 23 Feb 2015 15:37:52 +0900, manty kuma said:
If the call fails, the return value is NULL. So, how do I know what caused the failure? I have looked at examples in the kernel code. They are returning a hard-coded value of -ENOMEM if kmalloc() fails.
Well.. say you call kmalloc() and it fails. Does it *matter* what caused the failure? What are the chances that there is (a) more than one reason for it to fail, and (b) the error is recoverable in one case but not in another? Similarly for ioremap() - under what conditions will the *reason* make a difference? Unless you plan to take different action and manage to recover based on the reason, *it doesn't matter*. And given the semantics of kmalloc() and ioremap() specifically, if your code's action will differ based on the reason, you're probably using the wrong API.....
participants (2)
-
manty kuma -
Valdis.Kletnieks@vt.edu