Implement device locking to prevent concurrent access

Signed-off-by: Gray Remlin <gryrmln@gmail.com>