Changeset 3917

Show
Ignore:
Timestamp:
07/18/04 21:32:35 (4 years ago)
Author:
khali
Message:

Code cleanups.

Do not test lines, i2c-algo-bit already does.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • i2c/trunk/CHANGES

    r3916 r3917  
    20202.8.8 (???) 
    2121  Makefile: Do not export i2c-dev.h 
     22  i2c-pport.c: Code cleanups 
     23               Do not test lines, i2c-algo-bit already does 
    2224 
    23252.8.7 (20040611) 
  • i2c/trunk/kernel/i2c-pport.c

    r3885 r3917  
    2424 
    2525        Cut & paste :-)  based on Velleman K8000 driver by Simon G. Vogl 
     26 
     27        Note that SDA is hardware inverted. 
    2628*/ 
    2729 
     
    4042 
    4143#define DEFAULT_BASE 0x378 
    42 static int base=0
     44static int base = DEFAULT_BASE
    4345static unsigned char PortData = 0; 
    4446 
     
    5557#define CTRL    (BASE+2)                /* Centronics control port      */ 
    5658 
    57 /* we will use SDA - Auto Linefeed(14)   bit 1  POUT  */ 
    58 /* we will use SCL - Initialize printer(16)    BUSY bit 2*/ 
     59/* we will use SDA - Auto Linefeed(14)       POUT (ctrl bit 1) */ 
     60/* we will use SCL - Initialize printer(16)  BUSY (ctrl bit 2) */ 
    5961 
    6062#define  SET_SCL    | 0x04 
    6163#define  CLR_SCL    & 0xFB 
    6264 
    63  
    64  
    65  
    66 #define  SET_SDA    & 0x04 
     65#define  SET_SDA    & 0xFD 
    6766#define  CLR_SDA    | 0x02 
    6867 
     
    7473{ 
    7574        if (state) { 
    76                 //high 
    7775                PortData = PortData SET_SCL; 
    7876        } else { 
    79                 //low 
    8077                PortData = PortData CLR_SCL;  
    8178        } 
     
    8683{ 
    8784        if (state) { 
    88                  
    8985                PortData = PortData SET_SDA; 
    9086        } else { 
    91  
    9287                PortData = PortData CLR_SDA; 
    9388        } 
     
    9792static int bit_pport_getscl(void *data) 
    9893{ 
    99  
    10094        return ( 4 == ( (inb_p(CTRL)) & 0x04 ) ); 
    10195} 
     
    110104        if (!request_region((base+2),1, "i2c (PPORT adapter)")) { 
    111105                return -ENODEV;  
    112         } else { 
    113                 /* test for PPORT adap.         */ 
    114          
     106        } 
    115107 
    116                PortData=inb(base+2); 
    117                PortData= (PortData SET_SDA) SET_SCL
    118                outb(PortData,base+2);                           
     108        PortData = inb(base+2); 
     109        bit_pport_setsda((void*)base, 1)
     110        bit_pport_setscl((void*)base, 1); 
    119111 
    120                 if (!(inb(base+2) | 0x06)) {    /* SDA and SCL will be high     */ 
    121                         DEBINIT(printk("i2c-pport.o: SDA and SCL was low.\n")); 
    122                         return -ENODEV; 
    123                 } else { 
    124                  
    125                         /*SCL high and SDA low*/ 
    126                         PortData = PortData SET_SCL CLR_SDA; 
    127                         outb(PortData,base+2);   
    128                         schedule_timeout(400); 
    129                         if ( !(inb(base+2) | 0x4) ) { 
    130                                 //outb(0x04,base+2); 
    131                                 DEBINIT(printk("i2c-port.o: SDA was high.\n")); 
    132                                 return -ENODEV; 
    133                         } 
    134                 } 
    135                 bit_pport_setsda((void*)base,1); 
    136                 bit_pport_setscl((void*)base,1); 
    137         } 
    138112        return 0; 
    139113} 
     
    165139        printk("i2c-pport.o: i2c Primitive parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    166140 
    167         if (base==0) { 
    168                 /* probe some values */ 
    169                 base=DEFAULT_BASE; 
    170                 bit_pport_data.data=(void*)DEFAULT_BASE; 
    171                 if (bit_pport_init()==0) { 
    172                         if(i2c_bit_add_bus(&bit_pport_ops) < 0) 
    173                                 return -ENODEV; 
    174                 } else { 
    175                         return -ENODEV; 
    176                 } 
    177         } else { 
    178                 bit_pport_data.data=(void*)base; 
    179                 if (bit_pport_init()==0) { 
    180                         if(i2c_bit_add_bus(&bit_pport_ops) < 0) 
    181                                 return -ENODEV; 
    182                 } else { 
    183                         return -ENODEV; 
    184                 } 
     141        bit_pport_data.data = (void*)base; 
     142        if (bit_pport_init() < 0) 
     143                return -ENODEV; 
     144 
     145        if (i2c_bit_add_bus(&bit_pport_ops) < 0) { 
     146                release_region(base+2, 1); 
     147                return -ENODEV; 
    185148        } 
     149 
    186150        printk("i2c-pport.o: found device at %#x.\n",base); 
    187151        return 0;