Skip to content

Commit a1f3898

Browse files
ij-intelgroeck
authored andcommitted
hwmon: (sis5595) Do PCI error checks on own line
Instead of if conditions with line splits, use the usual error handling pattern with a separate variable to improve readability. Handle error print with a label instead of trying to chain everything into a single if condition. No functional changes intended. Signed-off-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 1e3c3a7 commit a1f3898

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

drivers/hwmon/sis5595.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static int sis5595_pci_probe(struct pci_dev *dev,
798798
{
799799
u16 address;
800800
u8 enable;
801-
int *i;
801+
int *i, err;
802802

803803
for (i = blacklist; *i != 0; i++) {
804804
struct pci_dev *d;
@@ -818,8 +818,8 @@ static int sis5595_pci_probe(struct pci_dev *dev,
818818
pci_write_config_word(dev, SIS5595_BASE_REG, force_addr);
819819
}
820820

821-
if (PCIBIOS_SUCCESSFUL !=
822-
pci_read_config_word(dev, SIS5595_BASE_REG, &address)) {
821+
err = pci_read_config_word(dev, SIS5595_BASE_REG, &address);
822+
if (err != PCIBIOS_SUCCESSFUL) {
823823
dev_err(&dev->dev, "Failed to read ISA address\n");
824824
return -ENODEV;
825825
}
@@ -836,22 +836,23 @@ static int sis5595_pci_probe(struct pci_dev *dev,
836836
return -ENODEV;
837837
}
838838

839-
if (PCIBIOS_SUCCESSFUL !=
840-
pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable)) {
839+
err = pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable);
840+
if (err != PCIBIOS_SUCCESSFUL) {
841841
dev_err(&dev->dev, "Failed to read enable register\n");
842842
return -ENODEV;
843843
}
844844
if (!(enable & 0x80)) {
845-
if ((PCIBIOS_SUCCESSFUL !=
846-
pci_write_config_byte(dev, SIS5595_ENABLE_REG,
847-
enable | 0x80))
848-
|| (PCIBIOS_SUCCESSFUL !=
849-
pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable))
850-
|| (!(enable & 0x80))) {
851-
/* doesn't work for some chips! */
852-
dev_err(&dev->dev, "Failed to enable HWM device\n");
853-
return -ENODEV;
854-
}
845+
err = pci_write_config_byte(dev, SIS5595_ENABLE_REG, enable | 0x80);
846+
if (err != PCIBIOS_SUCCESSFUL)
847+
goto enable_fail;
848+
849+
err = pci_read_config_byte(dev, SIS5595_ENABLE_REG, &enable);
850+
if (err != PCIBIOS_SUCCESSFUL)
851+
goto enable_fail;
852+
853+
/* doesn't work for some chips! */
854+
if (!(enable & 0x80))
855+
goto enable_fail;
855856
}
856857

857858
if (platform_driver_register(&sis5595_driver)) {
@@ -871,6 +872,10 @@ static int sis5595_pci_probe(struct pci_dev *dev,
871872
*/
872873
return -ENODEV;
873874

875+
enable_fail:
876+
dev_err(&dev->dev, "Failed to enable HWM device\n");
877+
goto exit;
878+
874879
exit_unregister:
875880
pci_dev_put(dev);
876881
platform_driver_unregister(&sis5595_driver);

0 commit comments

Comments
 (0)