On Tue, Mar 12, 2013 at 07:16:03PM +0800, Hongbo Zhang wrote:
[ .. ]
return -EINVAL;
You'll want to return the original error code, which for example can be ENOMEM where an error message is not needed. Also, I suspect abx500_hwmon_init might at some point return -EPROBE_DEFER. If that ever happens, you definitely want to fail silently and return the correct error code.
Yes, should return err in this probe function. Where to return -EPROBE_DEFER? when ab8500_gpadc_get() or ab8500_btemp_get() fails? In fact these two interfaces aren't so good, because we cannot tell the reason when they return fail. A solution I can imagine now is to send another separate patch for these two interfaces, letting them return -EPROBE_DEFER if they are not initialized when being called.
Guess the point I am trying to make is that this is an external API (ie it calls code in another module), and you don't know if and when -EPROBE_DEFER may be returned. So you should always pass errors up the chain, unless there is a well defined reason to not do so.
Thanks, Guenter