]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
switch spufs_calls_{get,put}() to CLASS() use
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 23 Jul 2024 02:23:16 +0000 (22:23 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Nov 2024 06:28:07 +0000 (01:28 -0500)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
arch/powerpc/platforms/cell/spu_syscalls.c

index da4fad7fc8bf6172c2cffc048c41d2e6cb9a7ef8..64a4c9eac6e0b4425b2f0fab53d7c567773de62b 100644 (file)
@@ -36,6 +36,9 @@ static inline struct spufs_calls *spufs_calls_get(void)
 
 static inline void spufs_calls_put(struct spufs_calls *calls)
 {
+       if (!calls)
+               return;
+
        BUG_ON(calls != spufs_calls);
 
        /* 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) { }
 
 #endif /* CONFIG_SPU_FS_MODULE */
 
+DEFINE_CLASS(spufs_calls, struct spufs_calls *, spufs_calls_put(_T), spufs_calls_get(), void)
+
 SYSCALL_DEFINE4(spu_create, const char __user *, name, unsigned int, flags,
        umode_t, mode, int, neighbor_fd)
 {
-       long ret;
-       struct spufs_calls *calls;
-
-       calls = spufs_calls_get();
+       CLASS(spufs_calls, calls)();
        if (!calls)
                return -ENOSYS;
 
        if (flags & SPU_CREATE_AFFINITY_SPU) {
                CLASS(fd, neighbor)(neighbor_fd);
-               ret = -EBADF;
-               if (!fd_empty(neighbor))
-                       ret = calls->create_thread(name, flags, mode, fd_file(neighbor));
-       } else
-               ret = calls->create_thread(name, flags, mode, NULL);
-
-       spufs_calls_put(calls);
-       return ret;
+               if (fd_empty(neighbor))
+                       return -EBADF;
+               return calls->create_thread(name, flags, mode, fd_file(neighbor));
+       } else {
+               return calls->create_thread(name, flags, mode, NULL);
+       }
 }
 
 SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus)
 {
        long ret;
        struct fd arg;
-       struct spufs_calls *calls;
-
-       calls = spufs_calls_get();
+       CLASS(spufs_calls, calls)();
        if (!calls)
                return -ENOSYS;
 
@@ -91,42 +89,26 @@ SYSCALL_DEFINE3(spu_run,int, fd, __u32 __user *, unpc, __u32 __user *, ustatus)
                ret = calls->spu_run(fd_file(arg), unpc, ustatus);
                fdput(arg);
        }
-
-       spufs_calls_put(calls);
        return ret;
 }
 
 #ifdef CONFIG_COREDUMP
 int elf_coredump_extra_notes_size(void)
 {
-       struct spufs_calls *calls;
-       int ret;
-
-       calls = spufs_calls_get();
+       CLASS(spufs_calls, calls)();
        if (!calls)
                return 0;
 
-       ret = calls->coredump_extra_notes_size();
-
-       spufs_calls_put(calls);
-
-       return ret;
+       return calls->coredump_extra_notes_size();
 }
 
 int elf_coredump_extra_notes_write(struct coredump_params *cprm)
 {
-       struct spufs_calls *calls;
-       int ret;
-
-       calls = spufs_calls_get();
+       CLASS(spufs_calls, calls)();
        if (!calls)
                return 0;
 
-       ret = calls->coredump_extra_notes_write(cprm);
-
-       spufs_calls_put(calls);
-
-       return ret;
+       return calls->coredump_extra_notes_write(cprm);
 }
 #endif