hwrng: amd - simplify control flow in amd_rng_mod_init()
Subsystems (2)
PATCH 1/1 hwrng: amd - simplify control flow in amd_rng_mod_init()
Replace the goto found statement with a break and check pdev after the loop. Also consolidate the cleanup paths.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/char/hw_random/amd-rng.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/char/hw_random/amd-rng.c +9 -14
@@ -129,19 +129,15 @@ static int __init amd_rng_mod_init(void) {int err;struct pci_dev *pdev =NULL ; -const struct pci_device_id *ent;u32 pmbase;struct amd768_priv *priv; -for_each_pci_dev (pdev) { - ent =pci_match_id (pci_tbl, pdev); -if (ent) - goto found; - } -/* Device not found. */ -return -ENODEV ; +for_each_pci_dev (pdev) +if (pci_match_id (pci_tbl, pdev)) +break ; +if (!pdev) +return -ENODEV ; -found: err =pci_read_config_dword (pdev,0x58 , &pmbase);if (err) { err =pcibios_err_to_errno (err);
@@ -171,7 +167,7 @@ static int __init amd_rng_mod_init(void)if (!priv->iobase) {pr_err (DRV_NAME "Cannot map ioport\n" ); err = -EINVAL ; - goto err_iomap; + goto err; } amd_rng.priv = (unsigned long )priv;
@@ -182,13 +178,12 @@ static int __init amd_rng_mod_init(void) err =hwrng_register (&amd_rng);if (err) {pr_err (DRV_NAME " registering failed (%d)\n" , err); - goto err_hwrng; +ioport_unmap (priv->iobase); + goto err; }return 0 ; -err_hwrng: -ioport_unmap (priv->iobase); -err_iomap: +err:release_region (pmbase +PMBASE_OFFSET ,PMBASE_SIZE ); out:kfree (priv);
Herbert Xu
maintainerQuoted 7 lines · Thorsten Blum
Replace the goto found statement with a break and check pdev after the loop. Also consolidate the cleanup paths.
Signed-off-by Thorsten Blum <[email protected]>--- drivers/char/hw_random/amd-rng.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt