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/20230808223412.1743176-8-sui.jingfeng@linux.dev
Signed-off-by: Sui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Sui Jingfeng 2023-08-09 06:34:08 +08:00 committed by Bjorn Helgaas
parent b421364a90
commit 4582db1d0a

View File

@ -967,27 +967,22 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
*
* To unregister just call vga_client_unregister().
*
* Returns: 0 on success, -1 on failure
* Returns: 0 on success, -ENODEV on failure
*/
int vga_client_register(struct pci_dev *pdev,
unsigned int (*set_decode)(struct pci_dev *pdev, bool decode))
{
int ret = -ENODEV;
struct vga_device *vgadev;
unsigned long flags;
struct vga_device *vgadev;
spin_lock_irqsave(&vga_lock, flags);
vgadev = vgadev_find(pdev);
if (!vgadev)
goto bail;
vgadev->set_decode = set_decode;
ret = 0;
bail:
if (vgadev)
vgadev->set_decode = set_decode;
spin_unlock_irqrestore(&vga_lock, flags);
return ret;
if (!vgadev)
return -ENODEV;
return 0;
}
EXPORT_SYMBOL(vga_client_register);