if (token < 0) {
if (token != -ERESTARTSYS)
dev_err(dev, "Failed to get an async token\n");
-
return token;
}
return -EIO;
}
+ if (rc == OPAL_SUCCESS)
+ goto out_success;
+
if (rc != OPAL_ASYNC_COMPLETION) {
dev_err(dev, "opal_flash_async_op(op=%d) failed (rc %d)\n",
op, rc);
- opal_async_release_token(token);
- return -EIO;
+ rc = -EIO;
+ goto out;
}
rc = opal_async_wait_response(token, &msg);
- opal_async_release_token(token);
if (rc) {
dev_err(dev, "opal async wait failed (rc %d)\n", rc);
- return -EIO;
+ rc = -EIO;
+ goto out;
}
rc = opal_get_async_rc(msg);
+out_success:
if (rc == OPAL_SUCCESS) {
rc = 0;
if (retlen)
rc = -EIO;
}
+out:
+ opal_async_release_token(token);
return rc;
}