summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2024-02-23 09:42:38 +0100
committerTakashi Iwai <tiwai@suse.de>2024-02-23 10:57:49 +0100
commitd90950c6a2658ed8cffb4255a5ddba9c831389fe (patch)
tree303b9b82a2ce6df8d1e5fd3b9f17f3db904370a4 /sound/core
parentedbcf872c14690c2894b726b67a871b4d238eea8 (diff)
downloadlinux-d90950c6a2658ed8cffb4255a5ddba9c831389fe.tar.gz
linux-d90950c6a2658ed8cffb4255a5ddba9c831389fe.tar.bz2
linux-d90950c6a2658ed8cffb4255a5ddba9c831389fe.zip
ALSA: pcm: Use CLASS() for fdget()/fdput()
Now we have a nice definition of CLASS(fd) that can be applied as a clean up for the fdget/fdput pairs in snd_pcm_link(). No functional changes, only code refactoring. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://lore.kernel.org/r/20240223084241.3361-2-tiwai@suse.de
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/pcm_native.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index beee5249dae1..0e84de4b484d 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2265,28 +2265,22 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
struct snd_pcm_group *group __free(kfree) = NULL;
struct snd_pcm_group *target_group;
bool nonatomic = substream->pcm->nonatomic;
- struct fd f = fdget(fd);
+ CLASS(fd, f)(fd);
if (!f.file)
return -EBADFD;
- if (!is_pcm_file(f.file)) {
- res = -EBADFD;
- goto _badf;
- }
+ if (!is_pcm_file(f.file))
+ return -EBADFD;
pcm_file = f.file->private_data;
substream1 = pcm_file->substream;
- if (substream == substream1) {
- res = -EINVAL;
- goto _badf;
- }
+ if (substream == substream1)
+ return -EINVAL;
group = kzalloc(sizeof(*group), GFP_KERNEL);
- if (!group) {
- res = -ENOMEM;
- goto _badf;
- }
+ if (!group)
+ return -ENOMEM;
snd_pcm_group_init(group);
@@ -2318,8 +2312,6 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
snd_pcm_group_unlock_irq(target_group, nonatomic);
_end:
up_write(&snd_pcm_link_rwsem);
- _badf:
- fdput(f);
return res;
}