Skip to content

Commit 4582db1

Browse files
Sui Jingfengbjorn-helgaas
authored andcommitted
PCI/VGA: Simplify vga_client_register()
Reorganize vga_client_register() to avoid the goto and the need to save the return value. Update the kernel-doc to reflect -ENODEV on failure. No functional change intended. [bhelgaas: drop "ret" variable, commit log] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sui Jingfeng <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent b421364 commit 4582db1

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

drivers/pci/vgaarb.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -967,27 +967,22 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
967967
*
968968
* To unregister just call vga_client_unregister().
969969
*
970-
* Returns: 0 on success, -1 on failure
970+
* Returns: 0 on success, -ENODEV on failure
971971
*/
972972
int vga_client_register(struct pci_dev *pdev,
973973
unsigned int (*set_decode)(struct pci_dev *pdev, bool decode))
974974
{
975-
int ret = -ENODEV;
976-
struct vga_device *vgadev;
977975
unsigned long flags;
976+
struct vga_device *vgadev;
978977

979978
spin_lock_irqsave(&vga_lock, flags);
980979
vgadev = vgadev_find(pdev);
981-
if (!vgadev)
982-
goto bail;
983-
984-
vgadev->set_decode = set_decode;
985-
ret = 0;
986-
987-
bail:
980+
if (vgadev)
981+
vgadev->set_decode = set_decode;
988982
spin_unlock_irqrestore(&vga_lock, flags);
989-
return ret;
990-
983+
if (!vgadev)
984+
return -ENODEV;
985+
return 0;
991986
}
992987
EXPORT_SYMBOL(vga_client_register);
993988

0 commit comments

Comments
 (0)