Fix bugs in bridge and sysfs code introduced in return code refactoring

Correct return values from a number of functions.
Handle return code from poll correctly in bridge code.
Address issue with count not being returned from sysfs msg code.
Move buffer to stack allocation.
Update some code documentation.
Some minor improvements to debug.