\r
static int rga_mmu_buf_get_try(struct rga_mmu_buf_t *t, uint32_t size)\r
{\r
- mutex_lock(&rga_service.lock);\r
- if((t->back - t->front) > t->size) {\r
- if(t->front + size > t->back - t->size)\r
- return -1;\r
- }\r
- else {\r
- if((t->front + size) > t->back)\r
- return -1;\r
-\r
- if(t->front + size > t->size) {\r
- if (size > (t->back - t->size)) {\r
- return -1;\r
- }\r
- t->front = 0;\r
- }\r
- }\r
- mutex_unlock(&rga_service.lock);\r
-\r
- return 0;\r
+ int ret = 0;\r
+\r
+ mutex_lock(&rga_service.lock);\r
+ if ((t->back - t->front) > t->size) {\r
+ if(t->front + size > t->back - t->size) {\r
+ ret = -ENOMEM;\r
+ goto out;\r
+ }\r
+ } else {\r
+ if ((t->front + size) > t->back) {\r
+ ret = -ENOMEM;\r
+ goto out;\r
+ }\r
+ if (t->front + size > t->size) {\r
+ if (size > (t->back - t->size)) {\r
+ ret = -ENOMEM;\r
+ goto out;\r
+ }\r
+ t->front = 0;\r
+ }\r
+ }\r
+\r
+out:\r
+ mutex_unlock(&rga_service.lock);\r
+ return ret;\r
}\r
\r
static int rga_mem_size_cal(unsigned long Mem, uint32_t MemSize, unsigned long *StartAddr)\r