Added device_write function implementation