Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25ee52e6 authored by Cyril Bur's avatar Cyril Bur Committed by Michael Ellerman
Browse files

mtd: powernv_flash: Don't treat OPAL_SUCCESS as an error



While this driver expects to interact asynchronously, OPAL is well
within its rights to return OPAL_SUCCESS to indicate that the operation
completed without the need for a callback. We shouldn't treat
OPAL_SUCCESS as an error rather we should wrap up and return promptly to
the caller.

Signed-off-by: default avatarCyril Bur <cyrilbur@gmail.com>
Acked-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 44e2aa2b
Loading
Loading
Loading
Loading
+10 −5
Original line number Original line Diff line number Diff line
@@ -63,7 +63,6 @@ static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op,
	if (token < 0) {
	if (token < 0) {
		if (token != -ERESTARTSYS)
		if (token != -ERESTARTSYS)
			dev_err(dev, "Failed to get an async token\n");
			dev_err(dev, "Failed to get an async token\n");

		return token;
		return token;
	}
	}


@@ -83,21 +82,25 @@ static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op,
		return -EIO;
		return -EIO;
	}
	}


	if (rc == OPAL_SUCCESS)
		goto out_success;

	if (rc != OPAL_ASYNC_COMPLETION) {
	if (rc != OPAL_ASYNC_COMPLETION) {
		dev_err(dev, "opal_flash_async_op(op=%d) failed (rc %d)\n",
		dev_err(dev, "opal_flash_async_op(op=%d) failed (rc %d)\n",
				op, rc);
				op, rc);
		opal_async_release_token(token);
		rc = -EIO;
		return -EIO;
		goto out;
	}
	}


	rc = opal_async_wait_response(token, &msg);
	rc = opal_async_wait_response(token, &msg);
	opal_async_release_token(token);
	if (rc) {
	if (rc) {
		dev_err(dev, "opal async wait failed (rc %d)\n", rc);
		dev_err(dev, "opal async wait failed (rc %d)\n", rc);
		return -EIO;
		rc = -EIO;
		goto out;
	}
	}


	rc = opal_get_async_rc(msg);
	rc = opal_get_async_rc(msg);
out_success:
	if (rc == OPAL_SUCCESS) {
	if (rc == OPAL_SUCCESS) {
		rc = 0;
		rc = 0;
		if (retlen)
		if (retlen)
@@ -106,6 +109,8 @@ static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op,
		rc = -EIO;
		rc = -EIO;
	}
	}


out:
	opal_async_release_token(token);
	return rc;
	return rc;
}
}