Changeset 4324

Show
Ignore:
Timestamp:
02/15/07 11:42:43 (8 years ago)
Author:
khali
Message:

i2c-ali1563: Fix device initialization (backported from Linux 2.6)

The i2c-ali1563 initialization looks quite broken to me:
* If the I/O space isn't enabled, we forcibly set 3 bits in

the PCI configuration space instead of just the one enabling
the I/O space.

* After that we pretend to check if the write worked, but we

don't actually read the new value from the register.

* It's probably not a good idea to enable the I/O space if no

base address has been set.

So I propose the following changes to that part of the driver:
* Merge ali1563_enable() into ali1563_setup().
* Check the base address before the I/O space enabled bit.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r4323 r4324  
    66  Module bmcsensors: Fix debugging messages 
    77  Module i2c-ali1563: Improve the status messages (2.6 backport) 
     8                      Fix device initialization (2.6 backport) 
    89  Module i2c-amd8111: Cleanups (2.6 backport) 
    910                      Fix initialization race (2.6 backport) 
  • lm-sensors/trunk/kernel/busses/i2c-ali1563.c

    r4323 r4324  
    327327 
    328328 
    329 static void ali1563_enable(struct pci_dev * dev) 
     329static int __devinit ali1563_setup(struct pci_dev * dev) 
    330330{ 
    331331        u16 ctrl; 
    332332 
    333333        pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); 
    334         ctrl |= 0x7; 
    335         pci_write_config_word(dev,ALI1563_SMBBA,ctrl); 
    336 } 
    337  
    338 static int __devinit ali1563_setup(struct pci_dev * dev) 
    339 { 
    340         u16 ctrl; 
    341  
    342         pci_read_config_word(dev,ALI1563_SMBBA,&ctrl); 
    343  
    344         /* Check if device is even enabled first */ 
    345         if (!(ctrl & ALI1563_SMB_IOEN)) { 
    346                 printk(KERN_WARNING "ali1563: I/O space not enabled, trying manually\n"); 
    347                 ali1563_enable(dev); 
    348         } 
    349         if (!(ctrl & ALI1563_SMB_IOEN)) { 
    350                 printk(KERN_WARNING "ali1563: I/O space still not enabled, giving up\n"); 
    351                 goto Err; 
    352         } 
    353         if (!(ctrl & ALI1563_SMB_HOSTEN)) { 
    354                 printk(KERN_WARNING "ali1563: Host Controller not enabled\n"); 
    355                 goto Err; 
    356         } 
    357334 
    358335        /* SMB I/O Base in high 12 bits and must be aligned with the 
     
    363340                goto Err; 
    364341        } 
     342 
     343        /* Check if device is enabled */ 
     344        if (!(ctrl & ALI1563_SMB_HOSTEN)) { 
     345                printk(KERN_WARNING "ali1563: Host Controller not enabled\n"); 
     346                goto Err; 
     347        } 
     348        if (!(ctrl & ALI1563_SMB_IOEN)) { 
     349                printk(KERN_WARNING "I/O space not enabled, trying manually\n"); 
     350                pci_write_config_word(dev, ALI1563_SMBBA, 
     351                                      ctrl | ALI1563_SMB_IOEN); 
     352                pci_read_config_word(dev, ALI1563_SMBBA, &ctrl); 
     353                if (!(ctrl & ALI1563_SMB_IOEN)) { 
     354                        printk(KERN_WARNING "I/O space still not enabled, " 
     355                               "giving up\n"); 
     356                        goto Err; 
     357                } 
     358        } 
     359 
    365360        if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE, 
    366361                            ali1563_pci_driver.name)) {