Changeset 1756

Show
Ignore:
Timestamp:
06/04/03 04:41:15 (10 years ago)
Author:
mds
Message:

backport from kernel 2.5.69. tested OK.

Files:
1 modified

Legend:

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

    r1705 r1756  
    6161/* Note: we assume there can only be one ALI15X3, with one SMBus interface */ 
    6262 
     63/* #define DEBUG 1 */ 
     64 
    6365#include <linux/module.h> 
    6466#include <linux/pci.h> 
     
    7072#include <linux/init.h> 
    7173#include <asm/io.h> 
    72 #include "version.h" 
     74#include "sensors_compat.h" 
    7375 
    7476/* ALI15X3 SMBus address offsets */ 
    75 #define SMBHSTSTS (0 + ali15x3_smba) 
    76 #define SMBHSTCNT (1 + ali15x3_smba) 
    77 #define SMBHSTSTART (2 + ali15x3_smba) 
    78 #define SMBHSTCMD (7 + ali15x3_smba) 
    79 #define SMBHSTADD (3 + ali15x3_smba) 
    80 #define SMBHSTDAT0 (4 + ali15x3_smba) 
    81 #define SMBHSTDAT1 (5 + ali15x3_smba) 
    82 #define SMBBLKDAT (6 + ali15x3_smba) 
     77#define SMBHSTSTS       (0 + ali15x3_smba) 
     78#define SMBHSTCNT       (1 + ali15x3_smba) 
     79#define SMBHSTSTART     (2 + ali15x3_smba) 
     80#define SMBHSTCMD       (7 + ali15x3_smba) 
     81#define SMBHSTADD       (3 + ali15x3_smba) 
     82#define SMBHSTDAT0      (4 + ali15x3_smba) 
     83#define SMBHSTDAT1      (5 + ali15x3_smba) 
     84#define SMBBLKDAT       (6 + ali15x3_smba) 
    8385 
    8486/* PCI Address Constants */ 
    85 #define SMBCOM    0x004 
    86 #define SMBBA     0x014 
    87 #define SMBATPC   0x05B         /* used to unlock xxxBA registers */ 
    88 #define SMBHSTCFG 0x0E0 
    89 #define SMBSLVC   0x0E1 
    90 #define SMBCLK    0x0E2 
    91 #define SMBREV    0x008 
     87#define SMBCOM          0x004 
     88#define SMBBA           0x014 
     89#define SMBATPC         0x05B   /* used to unlock xxxBA registers */ 
     90#define SMBHSTCFG       0x0E0 
     91#define SMBSLVC         0x0E1 
     92#define SMBCLK          0x0E2 
     93#define SMBREV          0x008 
    9294 
    9395/* Other settings */ 
    94 #define MAX_TIMEOUT 200         /* times 1/100 sec */ 
    95 #define ALI15X3_SMB_IOSIZE 32 
     96#define MAX_TIMEOUT             200     /* times 1/100 sec */ 
     97#define ALI15X3_SMB_IOSIZE      32 
    9698 
    9799/* this is what the Award 1004 BIOS sets them to on a ASUS P5A MB. 
     
    99101   tell user to upgrade BIOS and we fail. 
    100102*/ 
    101 #define ALI15X3_SMB_DEFAULTBASE 0xE800 
     103#define ALI15X3_SMB_DEFAULTBASE 0xE800 
    102104 
    103105/* ALI15X3 address lock bits */ 
    104 #define ALI15X3_LOCK    0x06 
     106#define ALI15X3_LOCK            0x06 
    105107 
    106108/* ALI15X3 command constants */ 
    107 #define ALI15X3_ABORT      0x02 
    108 #define ALI15X3_T_OUT      0x04 
    109 #define ALI15X3_QUICK      0x00 
    110 #define ALI15X3_BYTE       0x10 
    111 #define ALI15X3_BYTE_DATA  0x20 
    112 #define ALI15X3_WORD_DATA  0x30 
    113 #define ALI15X3_BLOCK_DATA 0x40 
    114 #define ALI15X3_BLOCK_CLR  0x80 
     109#define ALI15X3_ABORT           0x02 
     110#define ALI15X3_T_OUT           0x04 
     111#define ALI15X3_QUICK           0x00 
     112#define ALI15X3_BYTE            0x10 
     113#define ALI15X3_BYTE_DATA       0x20 
     114#define ALI15X3_WORD_DATA       0x30 
     115#define ALI15X3_BLOCK_DATA      0x40 
     116#define ALI15X3_BLOCK_CLR       0x80 
    115117 
    116118/* ALI15X3 status register bits */ 
     
    131133                 "Initialize the base address of the i2c controller"); 
    132134 
    133  
    134 static void ali15x3_do_pause(unsigned int amount); 
    135 static int ali15x3_transaction(void); 
    136  
    137135static unsigned short ali15x3_smba = 0; 
    138 static int locked=0; 
    139  
    140 /* Detect whether a ALI15X3 can be found, and initialize it, where necessary. 
    141    Note the differences between kernels with the old PCI BIOS interface and 
    142    newer kernels with the real PCI interface. In compat.h some things are 
    143    defined to make the transition easier. */ 
    144 int ali15x3_setup(void) 
     136 
     137static int ali15x3_setup(struct pci_dev *ALI15X3_dev) 
    145138{ 
    146139        u16 a; 
    147140        unsigned char temp; 
    148141 
    149         struct pci_dev *ALI15X3_dev; 
    150  
    151         /* First check whether we can access PCI at all */ 
    152         if (pci_present() == 0) { 
    153                 printk("i2c-ali15x3.o: Error: No PCI-bus found!\n"); 
    154                 return -ENODEV; 
    155         } 
    156  
    157         /* Look for the ALI15X3, M7101 device */ 
    158         ALI15X3_dev = NULL; 
    159         ALI15X3_dev = pci_find_device(PCI_VENDOR_ID_AL, 
    160                                       PCI_DEVICE_ID_AL_M7101, ALI15X3_dev); 
    161         if (ALI15X3_dev == NULL) { 
    162                 printk("i2c-ali15x3.o: Error: Can't detect ali15x3!\n"); 
    163                 return -ENODEV; 
    164         } 
    165  
    166 /* Check the following things: 
    167         - SMB I/O address is initialized 
    168         - Device is enabled 
    169         - We can use the addresses 
    170 */ 
    171  
    172 /* Unlock the register. 
    173    The data sheet says that the address registers are read-only 
    174    if the lock bits are 1, but in fact the address registers 
    175    are zero unless you clear the lock bits. 
    176 */ 
     142        /* Check the following things: 
     143                - SMB I/O address is initialized 
     144                - Device is enabled 
     145                - We can use the addresses 
     146        */ 
     147 
     148        /* Unlock the register. 
     149           The data sheet says that the address registers are read-only 
     150           if the lock bits are 1, but in fact the address registers 
     151           are zero unless you clear the lock bits. 
     152        */ 
    177153        pci_read_config_byte(ALI15X3_dev, SMBATPC, &temp); 
    178154        if (temp & ALI15X3_LOCK) { 
     
    181157        } 
    182158 
    183 /* Determine the address of the SMBus area */ 
     159        /* Determine the address of the SMBus area */ 
    184160        pci_read_config_word(ALI15X3_dev, SMBBA, &ali15x3_smba); 
    185161        ali15x3_smba &= (0xffff & ~(ALI15X3_SMB_IOSIZE - 1)); 
    186162        if (ali15x3_smba == 0 && force_addr == 0) { 
    187                 printk 
    188                     ("i2c-ali15x3.o: ALI15X3_smb region uninitialized - upgrade BIOS or use force_addr=0xaddr\n"); 
     163                dev_err(ALI15X3_dev, "ALI15X3_smb region uninitialized " 
     164                        "- upgrade BIOS or use force_addr=0xaddr\n"); 
    189165                return -ENODEV; 
    190166        } 
     
    193169                ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1); 
    194170 
    195         if (check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE)) { 
    196                 printk 
    197                     ("i2c-ali15x3.o: ALI15X3_smb region 0x%x already in use!\n", 
    198                      ali15x3_smba); 
     171        if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb")) { 
     172                dev_err(ALI15X3_dev, 
     173                        "ALI15X3_smb region 0x%x already in use!\n", 
     174                        ali15x3_smba); 
    199175                return -ENODEV; 
    200176        } 
    201177 
    202178        if(force_addr) { 
    203                 printk("i2c-ali15x3.o: forcing ISA address 0x%04X\n", ali15x3_smba); 
     179                dev_info(ALI15X3_dev, "forcing ISA address 0x%04X\n", 
     180                        ali15x3_smba); 
    204181                if (PCIBIOS_SUCCESSFUL != 
    205182                    pci_write_config_word(ALI15X3_dev, SMBBA, ali15x3_smba)) 
     
    210187                if ((a & ~(ALI15X3_SMB_IOSIZE - 1)) != ali15x3_smba) { 
    211188                        /* make sure it works */ 
    212                         printk("i2c-ali15x3.o: force address failed - not supported?\n"); 
     189                        dev_err(ALI15X3_dev, 
     190                                "force address failed - not supported?\n"); 
    213191                        return -ENODEV; 
    214192                } 
    215193        } 
    216 /* check if whole device is enabled */ 
     194        /* check if whole device is enabled */ 
    217195        pci_read_config_byte(ALI15X3_dev, SMBCOM, &temp); 
    218196        if ((temp & 1) == 0) { 
    219                 printk("i2c-ali15x3: enabling SMBus device\n"); 
     197                dev_info(ALI15X3_dev, "enabling SMBus device\n"); 
    220198                pci_write_config_byte(ALI15X3_dev, SMBCOM, temp | 0x01); 
    221199        } 
    222200 
    223 /* Is SMB Host controller enabled? */ 
     201        /* Is SMB Host controller enabled? */ 
    224202        pci_read_config_byte(ALI15X3_dev, SMBHSTCFG, &temp); 
    225203        if ((temp & 1) == 0) { 
    226                 printk("i2c-ali15x3: enabling SMBus controller\n"); 
     204                dev_info(ALI15X3_dev, "enabling SMBus controller\n"); 
    227205                pci_write_config_byte(ALI15X3_dev, SMBHSTCFG, temp | 0x01); 
    228206        } 
    229207 
    230 /* set SMB clock to 74KHz as recommended in data sheet */ 
     208        /* set SMB clock to 74KHz as recommended in data sheet */ 
    231209        pci_write_config_byte(ALI15X3_dev, SMBCLK, 0x20); 
    232210 
    233         /* Everything is happy, let's grab the memory and set things up. */ 
    234         request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE, "ali15x3-smb"); 
    235  
    236 #ifdef DEBUG 
    237 /* 
    238   The interrupt routing for SMB is set up in register 0x77 in the 
    239   1533 ISA Bridge device, NOT in the 7101 device. 
    240   Don't bother with finding the 1533 device and reading the register. 
    241   if ((....... & 0x0F) == 1) 
    242      printk("i2c-ali15x3.o: ALI15X3 using Interrupt 9 for SMBus.\n"); 
    243 */ 
     211        /* 
     212          The interrupt routing for SMB is set up in register 0x77 in the 
     213          1533 ISA Bridge device, NOT in the 7101 device. 
     214          Don't bother with finding the 1533 device and reading the register. 
     215        if ((....... & 0x0F) == 1) 
     216                dev_dbg(&ALI15X3_dev, "ALI15X3 using Interrupt 9 for SMBus.\n"); 
     217        */ 
    244218        pci_read_config_byte(ALI15X3_dev, SMBREV, &temp); 
    245         printk("i2c-ali15x3.o: SMBREV = 0x%X\n", temp); 
    246         printk("i2c-ali15x3.o: ALI15X3_smba = 0x%X\n", ali15x3_smba); 
    247 #endif                          /* DEBUG */ 
     219        dev_dbg(&ALI15X3_dev, "SMBREV = 0x%X\n", temp); 
     220        dev_dbg(&ALI15X3_dev, "iALI15X3_smba = 0x%X\n", ali15x3_smba); 
    248221 
    249222        return 0; 
    250223} 
    251224 
    252  
    253225/* Internally used pause function */ 
    254 void ali15x3_do_pause(unsigned int amount) 
     226static void ali15x3_do_pause(unsigned int amount) 
    255227{ 
    256228        current->state = TASK_INTERRUPTIBLE; 
     
    259231 
    260232/* Another internally used function */ 
    261 int ali15x3_transaction(void) 
     233static int ali15x3_transaction(struct i2c_adapter *adap) 
    262234{ 
    263235        int temp; 
     
    265237        int timeout = 0; 
    266238 
    267 #ifdef DEBUG 
    268         printk 
    269             ("i2c-ali15x3.o: Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, DAT0=%02x, " 
    270              "DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), 
    271              inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 
    272              inb_p(SMBHSTDAT1)); 
    273 #endif 
     239        dev_dbg(&adap, "Transaction (pre): STS=%02x, CNT=%02x, CMD=%02x, " 
     240                "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), 
     241                inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), 
     242                inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); 
    274243 
    275244        /* get status */ 
     
    279248        /* Check the busy bit first */ 
    280249        if (temp & ALI15X3_STS_BUSY) { 
    281 /* 
    282    If the host controller is still busy, it may have timed out in the previous transaction, 
    283    resulting in a "SMBus Timeout" printk. 
    284    I've tried the following to reset a stuck busy bit. 
    285         1. Reset the controller with an ABORT command. 
    286            (this doesn't seem to clear the controller if an external device is hung) 
    287         2. Reset the controller and the other SMBus devices with a T_OUT command. 
    288            (this clears the host busy bit if an external device is hung, 
    289            but it comes back upon a new access to a device) 
    290         3. Disable and reenable the controller in SMBHSTCFG 
    291    Worst case, nothing seems to work except power reset. 
    292 */ 
    293 /* Abort - reset the host controller */ 
    294 /* 
    295 #ifdef DEBUG 
    296     printk("i2c-ali15x3.o: Resetting host controller to clear busy condition\n",temp); 
    297 #endif 
    298     outb_p(ALI15X3_ABORT, SMBHSTCNT); 
    299     temp = inb_p(SMBHSTSTS); 
    300     if (temp & ALI15X3_STS_BUSY) { 
    301 */ 
    302  
    303 /* 
    304    Try resetting entire SMB bus, including other devices - 
    305    This may not work either - it clears the BUSY bit but 
    306    then the BUSY bit may come back on when you try and use the chip again. 
    307    If that's the case you are stuck. 
    308 */ 
    309                 printk 
    310                     ("i2c-ali15x3.o: Resetting entire SMB Bus to clear busy condition (%02x)\n", 
    311                      temp); 
     250        /* 
     251           If the host controller is still busy, it may have timed out in the 
     252           previous transaction, resulting in a "SMBus Timeout" Dev. 
     253           I've tried the following to reset a stuck busy bit. 
     254                1. Reset the controller with an ABORT command. 
     255                   (this doesn't seem to clear the controller if an external 
     256                   device is hung) 
     257                2. Reset the controller and the other SMBus devices with a 
     258                   T_OUT command.  (this clears the host busy bit if an 
     259                   external device is hung, but it comes back upon a new access 
     260                   to a device) 
     261                3. Disable and reenable the controller in SMBHSTCFG 
     262           Worst case, nothing seems to work except power reset. 
     263        */ 
     264        /* Abort - reset the host controller */ 
     265        /* 
     266           Try resetting entire SMB bus, including other devices - 
     267           This may not work either - it clears the BUSY bit but 
     268           then the BUSY bit may come back on when you try and use the chip again. 
     269           If that's the case you are stuck. 
     270        */ 
     271                dev_info(adap, "Resetting entire SMB Bus to " 
     272                        "clear busy condition (%02x)\n", temp); 
    312273                outb_p(ALI15X3_T_OUT, SMBHSTCNT); 
    313274                temp = inb_p(SMBHSTSTS); 
    314275        } 
    315 /* 
    316   } 
    317 */ 
    318276 
    319277        /* now check the error bits and the busy bit */ 
     
    326284                           as one of the bits now appears to be stuck */ 
    327285                        /* This may be a bus or device with electrical problems. */ 
    328                         printk 
    329                             ("i2c-ali15x3.o: SMBus reset failed! (0x%02x) - controller or device on bus is probably hung\n", 
    330                              temp); 
     286                        dev_err(adap, "SMBus reset failed! (0x%02x) - " 
     287                                "controller or device on bus is probably hung\n", 
     288                                temp); 
    331289                        return -1; 
    332290                } 
     
    352310        if (timeout >= MAX_TIMEOUT) { 
    353311                result = -1; 
    354                 printk("i2c-ali15x3.o: SMBus Timeout!\n"); 
     312                dev_err(adap, "SMBus Timeout!\n"); 
    355313        } 
    356314 
    357315        if (temp & ALI15X3_STS_TERM) { 
    358316                result = -1; 
    359 #ifdef DEBUG 
    360                 printk("i2c-ali15x3.o: Error: Failed bus transaction\n"); 
    361 #endif 
    362         } 
    363  
    364 /* 
    365   Unfortunately the ALI SMB controller maps "no response" and "bus collision" 
    366   into a single bit. No reponse is the usual case so don't 
    367   do a printk. 
    368   This means that bus collisions go unreported. 
    369 */ 
     317                dev_dbg(&adap, "Error: Failed bus transaction\n"); 
     318        } 
     319 
     320        /* 
     321          Unfortunately the ALI SMB controller maps "no response" and "bus 
     322          collision" into a single bit. No reponse is the usual case so don't 
     323          do a printk. 
     324          This means that bus collisions go unreported. 
     325        */ 
    370326        if (temp & ALI15X3_STS_COLL) { 
    371327                result = -1; 
    372 #ifdef DEBUG 
    373                 printk 
    374                     ("i2c-ali15x3.o: Error: no response or bus collision ADD=%02x\n", 
    375                      inb_p(SMBHSTADD)); 
    376 #endif 
    377         } 
    378  
    379 /* haven't ever seen this */ 
     328                dev_dbg(&adap, 
     329                        "Error: no response or bus collision ADD=%02x\n", 
     330                        inb_p(SMBHSTADD)); 
     331        } 
     332 
     333        /* haven't ever seen this */ 
    380334        if (temp & ALI15X3_STS_DEV) { 
    381335                result = -1; 
    382                 printk("i2c-ali15x3.o: Error: device error\n"); 
    383         } 
    384 #ifdef DEBUG 
    385         printk 
    386             ("i2c-ali15x3.o: Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, ADD=%02x, " 
    387              "DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), inb_p(SMBHSTCNT), 
    388              inb_p(SMBHSTCMD), inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), 
    389              inb_p(SMBHSTDAT1)); 
    390 #endif 
     336                dev_err(adap, "Error: device error\n"); 
     337        } 
     338        dev_dbg(&adap, "Transaction (post): STS=%02x, CNT=%02x, CMD=%02x, " 
     339                "ADD=%02x, DAT0=%02x, DAT1=%02x\n", inb_p(SMBHSTSTS), 
     340                inb_p(SMBHSTCNT), inb_p(SMBHSTCMD), inb_p(SMBHSTADD), 
     341                inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1)); 
    391342        return result; 
    392343} 
    393344 
    394345/* Return -1 on error. */ 
    395 s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, 
     346static s32 ali15x3_access(struct i2c_adapter * adap, u16 addr, 
    396347                   unsigned short flags, char read_write, u8 command, 
    397348                   int size, union i2c_smbus_data * data) 
     
    401352        int timeout; 
    402353 
    403 /* clear all the bits (clear-on-write) */ 
     354        /* clear all the bits (clear-on-write) */ 
    404355        outb_p(0xFF, SMBHSTSTS); 
    405 /* make sure SMBus is idle */ 
     356        /* make sure SMBus is idle */ 
    406357        temp = inb_p(SMBHSTSTS); 
    407358        for (timeout = 0; 
     
    412363        } 
    413364        if (timeout >= MAX_TIMEOUT) { 
    414                 printk("i2c-ali15x3.o: Idle wait Timeout! STS=0x%02x\n", 
    415                        temp); 
     365                dev_err(adap, "Idle wait Timeout! STS=0x%02x\n", temp); 
    416366        } 
    417367 
    418368        switch (size) { 
    419369        case I2C_SMBUS_PROC_CALL: 
    420                 printk 
    421                     ("i2c-ali15x3.o: I2C_SMBUS_PROC_CALL not supported!\n"); 
     370                dev_err(adap, "I2C_SMBUS_PROC_CALL not supported!\n"); 
    422371                return -1; 
    423372        case I2C_SMBUS_QUICK: 
     
    466415                        } 
    467416                        outb_p(len, SMBHSTDAT0); 
    468                         outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);        /* Reset SMBBLKDAT */ 
     417                        /* Reset SMBBLKDAT */ 
     418                        outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); 
    469419                        for (i = 1; i <= len; i++) 
    470420                                outb_p(data->block[i], SMBBLKDAT); 
     
    476426        outb_p(size, SMBHSTCNT);        /* output command */ 
    477427 
    478         if (ali15x3_transaction())      /* Error in transaction */ 
     428        if (ali15x3_transaction(adap))  /* Error in transaction */ 
    479429                return -1; 
    480430 
     
    498448                        len = 32; 
    499449                data->block[0] = len; 
    500                 outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT);        /* Reset SMBBLKDAT */ 
     450                /* Reset SMBBLKDAT */ 
     451                outb_p(inb_p(SMBHSTCNT) | ALI15X3_BLOCK_CLR, SMBHSTCNT); 
    501452                for (i = 1; i <= data->block[0]; i++) { 
    502453                        data->block[i] = inb_p(SMBBLKDAT); 
    503 #ifdef DEBUG 
    504                         printk 
    505                             ("i2c-ali15x3.o: Blk: len=%d, i=%d, data=%02x\n", 
    506                              len, i, data->block[i]); 
    507 #endif  /* DEBUG */ 
     454                        dev_dbg(&adap, "Blk: len=%d, i=%d, data=%02x\n", 
     455                                len, i, data->block[i]); 
    508456                } 
    509457                break; 
     
    512460} 
    513461 
    514  
    515 u32 ali15x3_func(struct i2c_adapter *adapter) 
     462static u32 ali15x3_func(struct i2c_adapter *adapter) 
    516463{ 
    517464        return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | 
     
    529476static struct i2c_adapter ali15x3_adapter = { 
    530477        .owner          = THIS_MODULE, 
    531         .name           = "unset", 
    532478        .id             = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3, 
    533479        .algo           = &smbus_algorithm, 
     480        .name   = "unset", 
    534481}; 
    535482 
    536  
    537  
    538483static struct pci_device_id ali15x3_ids[] __devinitdata = { 
     484        { 
     485        .vendor =       PCI_VENDOR_ID_AL, 
     486        .device =       PCI_DEVICE_ID_AL_M7101, 
     487        .subvendor =    PCI_ANY_ID, 
     488        .subdevice =    PCI_ANY_ID, 
     489        }, 
    539490        { 0, } 
    540491}; 
     
    542493static int __devinit ali15x3_probe(struct pci_dev *dev, const struct pci_device_id *id) 
    543494{ 
    544         if (ali15x3_setup()) { 
    545                 printk 
    546                     ("i2c-ali15x3.o: ALI15X3 not detected, module not inserted.\n"); 
    547  
     495        if (ali15x3_setup(dev)) { 
     496                dev_err(dev, 
     497                        "ALI15X3 not detected, module not inserted.\n"); 
    548498                return -ENODEV; 
    549499        } 
    550500 
    551         sprintf(ali15x3_adapter.name, "SMBus ALI15X3 adapter at %04x", 
    552                 ali15x3_smba); 
    553         i2c_add_adapter(&ali15x3_adapter); 
     501        snprintf(ali15x3_adapter.name, 32, 
     502                "SMBus ALI15X3 adapter at %04x", ali15x3_smba); 
     503        return i2c_add_adapter(&ali15x3_adapter); 
    554504} 
    555505 
     
    568518static int __init i2c_ali15x3_init(void) 
    569519{ 
    570         printk("i2c-ali15x3.o version %s (%s)\n", LM_VERSION, LM_DATE); 
     520        printk("i2c-ali15x3.o version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    571521        return pci_module_init(&ali15x3_driver); 
    572522} 
    573  
    574523 
    575524static void __exit i2c_ali15x3_exit(void) 
     
    579528} 
    580529 
    581  
    582  
    583 MODULE_AUTHOR 
    584     ("Frodo Looijaard <frodol@dds.nl>, Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker <mdsxyz123@yahoo.com>"); 
     530MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl>, " 
     531                "Philip Edelbrock <phil@netroedge.com>, " 
     532                "and Mark D. Studebaker <mdsxyz123@yahoo.com>"); 
    585533MODULE_DESCRIPTION("ALI15X3 SMBus driver"); 
    586534MODULE_LICENSE("GPL");