Skip to content

Commit 8cf5aff

Browse files
Anton Vorontsovgregkh
authored andcommitted
staging: android: persistent_ram: Introduce persistent_ram_new()
The routine just creates a persistent ram zone at a specified address. For persistent_ram_init_ringbuffer() we'd need to add a 'struct persistent_ram' to the global list, and associate it with a device. We don't need all this complexity in pstore_ram, so we introduce the simple function. Signed-off-by: Anton Vorontsov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bb4206f commit 8cf5aff

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

drivers/staging/android/persistent_ram.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,32 @@ static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool
412412
return 0;
413413
}
414414

415+
struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start,
416+
size_t size,
417+
bool ecc)
418+
{
419+
struct persistent_ram_zone *prz;
420+
int ret = -ENOMEM;
421+
422+
prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL);
423+
if (!prz) {
424+
pr_err("persistent_ram: failed to allocate persistent ram zone\n");
425+
goto err;
426+
}
427+
428+
ret = persistent_ram_buffer_map(start, size, prz);
429+
if (ret)
430+
goto err;
431+
432+
persistent_ram_post_init(prz, ecc);
433+
persistent_ram_update_header_ecc(prz);
434+
435+
return prz;
436+
err:
437+
kfree(prz);
438+
return ERR_PTR(ret);
439+
}
440+
415441
static __init
416442
struct persistent_ram_zone *__persistent_ram_init(struct device *dev, bool ecc)
417443
{

drivers/staging/android/persistent_ram.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/kernel.h>
2020
#include <linux/list.h>
2121
#include <linux/types.h>
22+
#include <linux/init.h>
2223

2324
struct persistent_ram_buffer;
2425

@@ -62,6 +63,9 @@ struct persistent_ram_zone {
6263

6364
int persistent_ram_early_init(struct persistent_ram *ram);
6465

66+
struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start,
67+
size_t size,
68+
bool ecc);
6569
struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,
6670
bool ecc);
6771

0 commit comments

Comments
 (0)