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

Commit 7029705a authored by Chen Gang's avatar Chen Gang Committed by Benjamin Herrenschmidt
Browse files

powerpc/nvram64: Need return the related error code on failure occurs



When error occurs, need return the related error code to let upper
caller know about it.

ppc_md.nvram_size() can return the error code (e.g. core99_nvram_size()
in 'arch/powerpc/platforms/powermac/nvram.c').

Also set ret value when only need it, so can save structions for normal
cases.

Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent cce606fe
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
@@ -84,22 +84,30 @@ static ssize_t dev_nvram_read(struct file *file, char __user *buf,
	char *tmp = NULL;
	ssize_t size;

	if (!ppc_md.nvram_size) {
		ret = -ENODEV;
	if (!ppc_md.nvram_size)
		goto out;
	}

	ret = 0;
	size = ppc_md.nvram_size();
	if (*ppos >= size || size < 0)
	if (size < 0) {
		ret = size;
		goto out;
	}

	if (*ppos >= size) {
		ret = 0;
		goto out;
	}

	count = min_t(size_t, count, size - *ppos);
	count = min(count, PAGE_SIZE);

	ret = -ENOMEM;
	tmp = kmalloc(count, GFP_KERNEL);
	if (!tmp)
	if (!tmp) {
		ret = -ENOMEM;
		goto out;
	}

	ret = ppc_md.nvram_read(tmp, count, ppos);
	if (ret <= 0)