Changeset 3748

Show
Ignore:
Timestamp:
12/20/02 15:13:18 (10 years ago)
Author:
kmalkki
Message:

(Kyösti)

Combatibility code with i2c-algo-bit. There is no need to modify
adapter code, but the feature is not compiled by default to avoid
collision in exported symbol names.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • i2c/trunk/kernel/i2c-algo-biths.c

    r3747 r3748  
    3939/* ----- global defines ----------------------------------------------- */ 
    4040 
     41/* If non-zero, adapter code written for original i2c-algo-bit can be used unmodified.  
     42 * As this export same symbols, you should either remove i2c-algo-bit.o from depmod 
     43 * directories, or load this module manually. 
     44 */ 
     45#define ALGO_BIT_COMPATIBILITY 0 
     46 
    4147#define FATAL_BUS       0 
    4248#define MODULE_STATUS   1 
     
    242248 
    243249        case -ENODEV: 
    244             return "SCL/SDA failure, cannot pull low"; 
     250            return "SCL/SDA failure"; 
    245251 
    246252        default: 
     
    507513}; 
    508514 
     515 
     516#if ALGO_BIT_COMPATIBILITY  
     517#include "i2c-algo-bit.h" 
     518 
     519static inline void _hw_setscl(struct i2c_algo_bit_data *old, int state) 
     520{ 
     521    old->setscl(old->data, state & _HS_SCL); 
     522} 
     523 
     524static inline void _hw_setsda(struct i2c_algo_bit_data *old, int state) 
     525{ 
     526    old->setsda(old->data, state & _HS_SDA); 
     527} 
     528 
     529static inline int _hw_getscl(struct i2c_algo_bit_data *old) 
     530{ 
     531    return old->getscl(old->data); 
     532} 
     533 
     534static inline int _hw_getsda(struct i2c_algo_bit_data *old) 
     535{ 
     536    return old->getsda(old->data); 
     537} 
     538 
     539static inline void _hw_timer(int dt) 
     540{ 
     541    udelay(dt); 
     542} 
     543 
     544#define INCLUDE_BITHS_INLINES 
     545#include "i2c-algo-biths.h" 
     546static void _ba_setscl(struct i2c_algo_biths_data *adap) 
     547{ 
     548    adap->state = adap->flags; 
     549    i2c_bit_setscl(adap); 
     550} 
     551static void _ba_setsda(struct i2c_algo_biths_data *adap) 
     552{ 
     553    adap->state = adap->flags; 
     554    i2c_bit_setsda(adap); 
     555} 
     556static int _ba_getscl(struct i2c_algo_biths_data *adap) 
     557{ 
     558    return i2c_bit_getscl(adap); 
     559} 
     560static int _ba_getsda(struct i2c_algo_biths_data *adap) 
     561{ 
     562    return i2c_bit_getsda(adap); 
     563} 
     564 
     565static struct i2c_algo_biths_data _ba_template = { 
     566        setsda:  _ba_setsda, 
     567        setscl:  _ba_setscl, 
     568        getsda:  _ba_getsda, 
     569        getscl:  _ba_getscl, 
     570}; 
     571 
     572/*  
     573 * registering functions to load algorithms at runtime  
     574 */ 
     575int i2c_bit_add_bus(struct i2c_adapter *i2c_adap) 
     576{ 
     577        int i; 
     578        struct i2c_algo_bit_data *old_adap = i2c_adap->algo_data; 
     579        struct i2c_algo_biths_data *adap; 
     580 
     581        adap = kmalloc(sizeof(struct i2c_algo_biths_data), GFP_KERNEL); 
     582        if (adap==NULL) 
     583            return -ENOMEM; 
     584 
     585        memcpy(adap, &_ba_template, sizeof(struct i2c_algo_biths_data)); 
     586        adap->data = old_adap; 
     587        adap->udelay = (old_adap->udelay+1)>>1; /* 1/4 vs 1/2 cycle */ 
     588        adap->timeout = old_adap->timeout; 
     589        i2c_adap->algo_data = adap; 
     590 
     591        return i2c_biths_add_bus(i2c_adap); 
     592} 
     593 
     594 
     595int i2c_bit_del_bus(struct i2c_adapter *i2c_adap) 
     596{ 
     597        int res; 
     598 
     599        if ((res = i2c_biths_del_bus(i2c_adap)) < 0) 
     600            return res; 
     601 
     602        kfree(i2c_adap->algo_data); 
     603        return 0; 
     604} 
     605 
     606EXPORT_SYMBOL(i2c_bit_add_bus); 
     607EXPORT_SYMBOL(i2c_bit_del_bus); 
     608 
     609#endif 
     610 
    509611/*  
    510612 * registering functions to load algorithms at runtime