refactored, added dev_open() and dev_close()