@@ -36,6 +36,9 @@ static inline struct spufs_calls *spufs_calls_get(void)
36
36
37
37
static inline void spufs_calls_put (struct spufs_calls * calls )
38
38
{
39
+ if (!calls )
40
+ return ;
41
+
39
42
BUG_ON (calls != spufs_calls );
40
43
41
44
/* we don't need to rcu this, as we hold a reference to the module */
@@ -53,35 +56,30 @@ static inline void spufs_calls_put(struct spufs_calls *calls) { }
53
56
54
57
#endif /* CONFIG_SPU_FS_MODULE */
55
58
59
+ DEFINE_CLASS (spufs_calls , struct spufs_calls * , spufs_calls_put (_T ), spufs_calls_get (), void )
60
+
56
61
SYSCALL_DEFINE4 (spu_create , const char __user * , name , unsigned int , flags ,
57
62
umode_t , mode , int , neighbor_fd )
58
63
{
59
- long ret ;
60
- struct spufs_calls * calls ;
61
-
62
- calls = spufs_calls_get ();
64
+ CLASS (spufs_calls , calls )();
63
65
if (!calls )
64
66
return - ENOSYS ;
65
67
66
68
if (flags & SPU_CREATE_AFFINITY_SPU ) {
67
69
CLASS (fd , neighbor )(neighbor_fd );
68
- ret = - EBADF ;
69
- if (!fd_empty (neighbor ))
70
- ret = calls -> create_thread (name , flags , mode , fd_file (neighbor ));
71
- } else
72
- ret = calls -> create_thread (name , flags , mode , NULL );
73
-
74
- spufs_calls_put (calls );
75
- return ret ;
70
+ if (fd_empty (neighbor ))
71
+ return - EBADF ;
72
+ return calls -> create_thread (name , flags , mode , fd_file (neighbor ));
73
+ } else {
74
+ return calls -> create_thread (name , flags , mode , NULL );
75
+ }
76
76
}
77
77
78
78
SYSCALL_DEFINE3 (spu_run ,int , fd , __u32 __user * , unpc , __u32 __user * , ustatus )
79
79
{
80
80
long ret ;
81
81
struct fd arg ;
82
- struct spufs_calls * calls ;
83
-
84
- calls = spufs_calls_get ();
82
+ CLASS (spufs_calls , calls )();
85
83
if (!calls )
86
84
return - ENOSYS ;
87
85
@@ -91,42 +89,26 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus)
91
89
ret = calls -> spu_run (fd_file (arg ), unpc , ustatus );
92
90
fdput (arg );
93
91
}
94
-
95
- spufs_calls_put (calls );
96
92
return ret ;
97
93
}
98
94
99
95
#ifdef CONFIG_COREDUMP
100
96
int elf_coredump_extra_notes_size (void )
101
97
{
102
- struct spufs_calls * calls ;
103
- int ret ;
104
-
105
- calls = spufs_calls_get ();
98
+ CLASS (spufs_calls , calls )();
106
99
if (!calls )
107
100
return 0 ;
108
101
109
- ret = calls -> coredump_extra_notes_size ();
110
-
111
- spufs_calls_put (calls );
112
-
113
- return ret ;
102
+ return calls -> coredump_extra_notes_size ();
114
103
}
115
104
116
105
int elf_coredump_extra_notes_write (struct coredump_params * cprm )
117
106
{
118
- struct spufs_calls * calls ;
119
- int ret ;
120
-
121
- calls = spufs_calls_get ();
107
+ CLASS (spufs_calls , calls )();
122
108
if (!calls )
123
109
return 0 ;
124
110
125
- ret = calls -> coredump_extra_notes_write (cprm );
126
-
127
- spufs_calls_put (calls );
128
-
129
- return ret ;
111
+ return calls -> coredump_extra_notes_write (cprm );
130
112
}
131
113
#endif
132
114
0 commit comments