struct ocmem_buf *ocmem_allocate_nb(int client_id, unsigned long size) { bool can_block = true; bool can_wait = false; if (!check_id(client_id)) { pr_err("ocmem: Invalid client id: %d\n", client_id); return NULL; } /* Asynchronous API requires notifier registration */ if (!check_notifier(client_id)) { pr_err("ocmem: No notifier registered for client %d\n", client_id); return NULL; } if (size < OCMEM_MIN_ALLOC) { pr_err("ocmem: requested size %lx must be at least %x\n", size, OCMEM_MIN_ALLOC); return NULL; } if (!IS_ALIGNED(size, OCMEM_MIN_ALIGN)) { pr_err("ocmem: Invalid alignment, args must be %x aligned\n", OCMEM_MIN_ALIGN); return NULL; } return __ocmem_allocate_range(client_id, 0, size, size, can_block, can_wait); }
struct ocmem_buf *ocmem_allocate(int client_id, unsigned long size) { bool can_block = false; bool can_wait = true; if (!check_id(client_id)) { pr_err("ocmem: Invalid client id: %d\n", client_id); return NULL; } if (size < OCMEM_MIN_ALLOC) { pr_err("ocmem: requested size %lx must be at least %x\n", size, OCMEM_MIN_ALLOC); return NULL; } if (!IS_ALIGNED(size, OCMEM_MIN_ALIGN)) { pr_err("ocmem: Invalid alignment, size must be %x aligned\n", OCMEM_MIN_ALIGN); return NULL; } return __ocmem_allocate_range(client_id, size, size, size, can_block, can_wait); }
struct ocmem_buf *ocmem_allocate_range(int client_id, unsigned long min, unsigned long goal, unsigned long step) { bool can_block = true; bool can_wait = false; if (!check_id(client_id)) { pr_err("ocmem: Invalid client id: %d\n", client_id); return NULL; } if (!zone_active(client_id)) { pr_err("ocmem: Client %s (id: %d) not allowed to use OCMEM\n", get_name(client_id), client_id); return NULL; } /* Asynchronous API requires notifier registration */ if (!check_notifier(client_id)) { pr_err("ocmem: No notifier registered for client %d\n", client_id); return NULL; } if (min < OCMEM_MIN_ALLOC) { pr_err("ocmem: requested min size %lx must be at least %x\n", min, OCMEM_MIN_ALLOC); return NULL; } if (!IS_ALIGNED(min | goal | step, OCMEM_MIN_ALIGN)) { pr_err("ocmem: Invalid alignment, args must be %x aligned\n", OCMEM_MIN_ALIGN); return NULL; } return __ocmem_allocate_range(client_id, min, goal, step, can_block, can_wait); }