Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+7 -15
+7 -15
sound/core/pcm_native.c
··· 2265 2265 struct snd_pcm_group *group __free(kfree) = NULL; 2266 2266 struct snd_pcm_group *target_group; 2267 2267 bool nonatomic = substream->pcm->nonatomic; 2268 - struct fd f = fdget(fd); 2268 + CLASS(fd, f)(fd); 2269 2269 2270 2270 if (!f.file) 2271 2271 return -EBADFD; 2272 - if (!is_pcm_file(f.file)) { 2273 - res = -EBADFD; 2274 - goto _badf; 2275 - } 2272 + if (!is_pcm_file(f.file)) 2273 + return -EBADFD; 2276 2274 2277 2275 pcm_file = f.file->private_data; 2278 2276 substream1 = pcm_file->substream; 2279 2277 2280 - if (substream == substream1) { 2281 - res = -EINVAL; 2282 - goto _badf; 2283 - } 2278 + if (substream == substream1) 2279 + return -EINVAL; 2284 2280 2285 2281 group = kzalloc(sizeof(*group), GFP_KERNEL); 2286 - if (!group) { 2287 - res = -ENOMEM; 2288 - goto _badf; 2289 - } 2282 + if (!group) 2283 + return -ENOMEM; 2290 2284 2291 2285 snd_pcm_group_init(group); 2292 2286 ··· 2312 2318 snd_pcm_group_unlock_irq(target_group, nonatomic); 2313 2319 _end: 2314 2320 up_write(&snd_pcm_link_rwsem); 2315 - _badf: 2316 - fdput(f); 2317 2321 return res; 2318 2322 } 2319 2323