1:The control flow was simplified by using else if statements instead of goto structure.
2:Error conditions are handled more clearly.
3:The device_unlock call at the end of the function is guaranteed in all cases.
// SPDX-License-Identifier: GPL-2.0-or-later