[PATCH] staging: dgnc: Remove useless and deadly judgment
Valdis.Kletnieks at vt.edu
Valdis.Kletnieks at vt.edu
Mon Feb 29 02:58:16 EST 2016
On Mon, 29 Feb 2016 14:41:34 +0800, Navy Cheng said:
> pci_unregister_driver() should be used once dgnc module exit. It has
> nothing to do with dgnc_NumBoards. Remove the judgment of dgnc_NumBoards to
> avoid pci_unregister_driver() is not used when dgnc_NumBoards is 0.
> - if (dgnc_NumBoards)
> - pci_unregister_driver(&dgnc_driver);
> + pci_unregister_driver(&dgnc_driver);
Does pci_unregister_driver do the right thing if there are 0 boards
in the system?
If this logic is wrong, shouldn't there also be a patch fixing the
following in dgnc_init_module()?
/*
* Find and configure all the cards
*/
rc = pci_register_driver(&dgnc_driver);
/*
* If something went wrong in the scan, bail out of driver.
*/
if (rc < 0) {
/* Only unregister if it was actually registered. */
if (dgnc_NumBoards)
pci_unregister_driver(&dgnc_driver);
else
pr_warn("WARNING: dgnc driver load failed. No Digi Neo or Classic boards found.\n");
dgnc_cleanup_module();
While I'm at it, the entire NumBoards counting seems to be wonky - it looks
like a *lot* of off-by-one errors. Looks like the programmer(s) weren't sure
if they wanted to use that as a zero-based or one-based counter/index.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160229/4896e710/attachment.bin
More information about the Kernelnewbies
mailing list