Skip to content

Commit

Permalink
staging: android: persistent_ram: Introduce persistent_ram_free()
Browse files Browse the repository at this point in the history
A corresponding function to persistent_ram_new().

Signed-off-by: Anton Vorontsov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Anton Vorontsov authored and gregkh committed May 14, 2012
1 parent 24c3d2f commit d3b4876
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/staging/android/persistent_ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ static void *persistent_ram_iomap(phys_addr_t start, size_t size)
static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
struct persistent_ram_zone *prz)
{
prz->paddr = start;
prz->size = size;

if (pfn_valid(start >> PAGE_SHIFT))
prz->vaddr = persistent_ram_vmap(start, size);
else
Expand Down Expand Up @@ -437,6 +440,18 @@ static int __init persistent_ram_post_init(struct persistent_ram_zone *prz, bool
return 0;
}

void persistent_ram_free(struct persistent_ram_zone *prz)
{
if (pfn_valid(prz->paddr >> PAGE_SHIFT)) {
vunmap(prz->vaddr);
} else {
iounmap(prz->vaddr);
release_mem_region(prz->paddr, prz->size);
}
persistent_ram_free_old(prz);
kfree(prz);
}

struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start,
size_t size,
bool ecc)
Expand Down
3 changes: 3 additions & 0 deletions drivers/staging/android/persistent_ram.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct persistent_ram {
};

struct persistent_ram_zone {
phys_addr_t paddr;
size_t size;
void *vaddr;
struct persistent_ram_buffer *buffer;
size_t buffer_size;
Expand Down Expand Up @@ -66,6 +68,7 @@ int persistent_ram_early_init(struct persistent_ram *ram);
struct persistent_ram_zone * __init persistent_ram_new(phys_addr_t start,
size_t size,
bool ecc);
void persistent_ram_free(struct persistent_ram_zone *prz);
struct persistent_ram_zone *persistent_ram_init_ringbuffer(struct device *dev,
bool ecc);

Expand Down

0 comments on commit d3b4876

Please sign in to comment.