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

Commit bb4206f2 authored by Anton Vorontsov's avatar Anton Vorontsov Committed by Greg Kroah-Hartman
Browse files

staging: android: persistent_ram: Introduce persistent_ram_post_init()



Factor post init logic out of __persistent_ram_init(), we'll need
it for the new persistent_ram_new() routine.

Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 484dd30e
Loading
Loading
Loading
Loading
+27 −17
Original line number Original line Diff line number Diff line
@@ -378,28 +378,15 @@ static int __init persistent_ram_buffer_init(const char *name,
	return -EINVAL;
	return -EINVAL;
}
}


static  __init
static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool ecc)
struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
{
{
	struct persistent_ram_zone *prz;
	int ret;
	int ret = -ENOMEM;

	prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
	if (!prz) {
		pr_err("persistent_ram: failed to allocate persistent ram zone\n");
		goto err;
	}

	ret = persistent_ram_buffer_init(dev_name(dev), prz);
	if (ret) {
		pr_err("persistent_ram: failed to initialize buffer\n");
		goto err;
	}


	prz->ecc = ecc;
	prz->ecc = ecc;

	ret = persistent_ram_init_ecc(prz, prz->buffer_size);
	ret = persistent_ram_init_ecc(prz, prz->buffer_size);
	if (ret)
	if (ret)
		goto err;
		return ret;


	if (prz->buffer->sig == PERSISTENT_RAM_SIG) {
	if (prz->buffer->sig == PERSISTENT_RAM_SIG) {
		if (buffer_size(prz) > prz->buffer_size ||
		if (buffer_size(prz) > prz->buffer_size ||
@@ -422,6 +409,29 @@ struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
	atomic_set(&prz->buffer->start, 0);
	atomic_set(&prz->buffer->start, 0);
	atomic_set(&prz->buffer->size, 0);
	atomic_set(&prz->buffer->size, 0);


	return 0;
}

static  __init
struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
{
	struct persistent_ram_zone *prz;
	int ret = -ENOMEM;

	prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
	if (!prz) {
		pr_err("persistent_ram: failed to allocate persistent ram zone\n");
		goto err;
	}

	ret = persistent_ram_buffer_init(dev_name(dev), prz);
	if (ret) {
		pr_err("persistent_ram: failed to initialize buffer\n");
		goto err;
	}

	persistent_ram_post_init(prz, ecc);

	return prz;
	return prz;
err:
err:
	kfree(prz);
	kfree(prz);