Show
Ignore:
Timestamp:
06/23/06 23:05:37 (7 years ago)
Author:
khali
Message:

Various cleanups to the i2c-i801 driver:
* Fix self file name reference.
* i801_setup can be marked devinit.
* Drop useless error local variable and label in i801_setup.
* Use symbolic names for SMBHSTCFG bits.
* Transmit the error code returned by i801_setup instead of forcing it

to an arbitrary value.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/kernel/busses/i2c-i801.c

    r4060 r4061  
    11/* 
    2     i801.c - Part of lm_sensors, Linux kernel modules for hardware 
     2    i2c-i801.c - Part of lm_sensors, Linux kernel modules for hardware 
    33              monitoring 
    44    Copyright (c) 1998 - 2002  Frodo Looijaard <frodol@dds.nl>, 
     
    162162static int isich5;      /* is i2c block read supported? */ 
    163163 
    164 static int i801_setup(struct pci_dev *dev) 
    165 { 
    166         int error_return = 0; 
     164static int __devinit i801_setup(struct pci_dev *dev) 
     165{ 
    167166        unsigned char temp; 
    168167 
     
    180179        isich5 = isich4 && dev->device != PCI_DEVICE_ID_INTEL_82801DB_3; 
    181180 
    182         /* Determine the address of the SMBus areas */ 
     181        /* Determine the address of the SMBus area */ 
    183182        if (force_addr) { 
    184183                i801_smba = force_addr & 0xfff0; 
     
    196195                dev_err(dev, "I801_smb region 0x%x already in use!\n", 
    197196                        i801_smba); 
    198                 error_return = -EBUSY; 
    199                 goto END; 
     197                return -EBUSY; 
    200198        } 
    201199 
     
    207205           sure, we disable the device first. */ 
    208206        if (force_addr) { 
    209                 pci_write_config_byte(I801_dev, SMBHSTCFG, temp & 0xfe); 
     207                pci_write_config_byte(I801_dev, SMBHSTCFG, 
     208                                      temp & ~SMBHSTCFG_HST_EN); 
    210209                pci_write_config_word(I801_dev, SMBBA, i801_smba); 
    211                 pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 0x01); 
     210                pci_write_config_byte(I801_dev, SMBHSTCFG, 
     211                                      temp | SMBHSTCFG_HST_EN); 
    212212                dev_warn(dev, "WARNING: I801 SMBus interface set to " 
    213213                        "new address %04x!\n", i801_smba); 
    214         } else if ((temp & 1) == 0) { 
    215                 pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 1); 
     214        } else if (!(temp & SMBHSTCFG_HST_EN)) { 
     215                pci_write_config_byte(I801_dev, SMBHSTCFG, 
     216                                      temp | SMBHSTCFG_HST_EN); 
    216217                dev_warn(dev, "enabling SMBus device\n"); 
    217218        } 
    218219 
    219         if (temp & 0x02) 
     220        if (temp & SMBHSTCFG_SMB_SMI_EN) 
    220221                dev_dbg(dev, "I801 using Interrupt SMI# for SMBus.\n"); 
    221222        else 
     
    226227        dev_dbg(dev, "I801_smba = 0x%X\n", i801_smba); 
    227228 
    228 END: 
    229         return error_return; 
     229        return 0; 
    230230} 
    231231 
     
    681681static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) 
    682682{ 
    683  
    684         if (i801_setup(dev)) { 
    685                 dev_warn(dev, 
    686                         "I801 not detected, module not inserted.\n"); 
    687                 return -ENODEV; 
    688         } 
     683        int err; 
     684 
     685        if ((err = i801_setup(dev))) 
     686                return err; 
    689687 
    690688        snprintf(i801_adapter.name, 32,