4
4
* Authors: Joonyoung Shim <[email protected] >
5
5
*/
6
6
7
+ #include <linux/refcount.h>
7
8
#include <linux/clk.h>
8
9
#include <linux/component.h>
9
10
#include <linux/delay.h>
@@ -208,7 +209,7 @@ struct g2d_cmdlist_userptr {
208
209
struct page * * pages ;
209
210
unsigned int npages ;
210
211
struct sg_table * sgt ;
211
- atomic_t refcount ;
212
+ refcount_t refcount ;
212
213
bool in_pool ;
213
214
bool out_of_list ;
214
215
};
@@ -386,9 +387,9 @@ static void g2d_userptr_put_dma_addr(struct g2d_data *g2d,
386
387
if (force )
387
388
goto out ;
388
389
389
- atomic_dec (& g2d_userptr -> refcount );
390
+ refcount_dec (& g2d_userptr -> refcount );
390
391
391
- if (atomic_read (& g2d_userptr -> refcount ) > 0 )
392
+ if (refcount_read (& g2d_userptr -> refcount ) > 0 )
392
393
return ;
393
394
394
395
if (g2d_userptr -> in_pool )
@@ -436,7 +437,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct g2d_data *g2d,
436
437
* and different size.
437
438
*/
438
439
if (g2d_userptr -> size == size ) {
439
- atomic_inc (& g2d_userptr -> refcount );
440
+ refcount_inc (& g2d_userptr -> refcount );
440
441
* obj = g2d_userptr ;
441
442
442
443
return & g2d_userptr -> dma_addr ;
@@ -461,7 +462,7 @@ static dma_addr_t *g2d_userptr_get_dma_addr(struct g2d_data *g2d,
461
462
if (!g2d_userptr )
462
463
return ERR_PTR (- ENOMEM );
463
464
464
- atomic_set (& g2d_userptr -> refcount , 1 );
465
+ refcount_set (& g2d_userptr -> refcount , 1 );
465
466
g2d_userptr -> size = size ;
466
467
467
468
start = userptr & PAGE_MASK ;
@@ -897,13 +898,14 @@ static void g2d_runqueue_worker(struct work_struct *work)
897
898
ret = pm_runtime_resume_and_get (g2d -> dev );
898
899
if (ret < 0 ) {
899
900
dev_err (g2d -> dev , "failed to enable G2D device.\n" );
900
- return ;
901
+ goto out ;
901
902
}
902
903
903
904
g2d_dma_start (g2d , g2d -> runqueue_node );
904
905
}
905
906
}
906
907
908
+ out :
907
909
mutex_unlock (& g2d -> runqueue_mutex );
908
910
}
909
911
0 commit comments