Skip to content

Commit e52b78f

Browse files
imtangmengtiwai
authored andcommitted
sound: core: Remove redundant variable and return the last statement
Return the result from file->f_op->open() directly instead of taking this in another redundant variable. Make the typical return the last statement, return early and reduce the indentation too. Signed-off-by: Meng Tang <tangmeng@uniontech.com> Link: https://lore.kernel.org/r/20220228050253.1649-2-tangmeng@uniontech.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent d248b27 commit e52b78f

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

sound/sound_core.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -577,20 +577,20 @@ static int soundcore_open(struct inode *inode, struct file *file)
577577
new_fops = fops_get(s->unit_fops);
578578
}
579579
spin_unlock(&sound_loader_lock);
580-
if (new_fops) {
581-
/*
582-
* We rely upon the fact that we can't be unloaded while the
583-
* subdriver is there.
584-
*/
585-
int err = 0;
586-
replace_fops(file, new_fops);
587580

588-
if (file->f_op->open)
589-
err = file->f_op->open(inode,file);
581+
if (!new_fops)
582+
return -ENODEV;
590583

591-
return err;
592-
}
593-
return -ENODEV;
584+
/*
585+
* We rely upon the fact that we can't be unloaded while the
586+
* subdriver is there.
587+
*/
588+
replace_fops(file, new_fops);
589+
590+
if (!file->f_op->open)
591+
return -ENODEV;
592+
593+
return file->f_op->open(inode, file);
594594
}
595595

596596
MODULE_ALIAS_CHARDEV_MAJOR(SOUND_MAJOR);

0 commit comments

Comments
 (0)