Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230824132832.78705-14-ilpo.jarvinen@linux.intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Ilpo Järvinen and committed by
Guenter Roeck
a1f38987 1e3c3a79

+20 -15
+20 -15
drivers/hwmon/sis5595.c
··· 798 798 { 799 799 u16 address; 800 800 u8 enable; 801 - int *i; 801 + int *i, err; 802 802 803 803 for (i = blacklist; *i != 0; i++) { 804 804 struct pci_dev *d; ··· 818 818 pci_write_config_word(dev, SIS5595_BASE_REG, force_addr); 819 819 } 820 820 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) { 823 823 dev_err(&dev->dev, "Failed to read ISA address\n"); 824 824 return -ENODEV; 825 825 } ··· 836 836 return -ENODEV; 837 837 } 838 838 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) { 841 841 dev_err(&dev->dev, "Failed to read enable register\n"); 842 842 return -ENODEV; 843 843 } 844 844 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; 855 856 } 856 857 857 858 if (platform_driver_register(&sis5595_driver)) { ··· 871 870 * pci device, we only wanted to read as few register values from it. 872 871 */ 873 872 return -ENODEV; 873 + 874 + enable_fail: 875 + dev_err(&dev->dev, "Failed to enable HWM device\n"); 876 + goto exit; 874 877 875 878 exit_unregister: 876 879 pci_dev_put(dev);