Changeset 3758

Show
Ignore:
Timestamp:
01/14/03 00:22:50 (10 years ago)
Author:
kmalkki
Message:

(Kyösti)

Check in changes from 2.5.53 to 2.5.54).
Apply respective changes to other drivers in CVS.

Location:
i2c/trunk/kernel
Files:
20 modified

Legend:

Unmodified
Added
Removed
  • i2c/trunk/kernel/Module.mk

    r3743 r3758  
    6161ifneq ($(shell if grep -q '^CONFIG_I2C_ELEKTOR=y' $(LINUX)/.config; then echo 1; fi),1) 
    6262KERNELTARGETS += $(MODULE_DIR)/i2c-elektor.o 
    63 KERNELINCLUDES += $(MODULE_DIR)/i2c-elektor.h $(MODULE_DIR)/i2c-pcf8584.h 
     63KERNELINCLUDES += $(MODULE_DIR)/i2c-pcf8584.h 
    6464endif 
    6565ifneq ($(shell if grep -q '^CONFIG_I2C_PROC=y' $(LINUX)/.config; then echo 1; fi),1) 
     
    7878# 
    7979#ifneq ($(shell if grep -q '^CONFIG_I2C_ALGO8XX=y' $(LINUX)/.config; then echo 1; fi),1) 
    80 #KERNELTARGETS += $(MODULE_DIR)/i2c-algo-8xx.o 
    81 #KERNELINCLUDES += $(MODULE_DIR)/i2c-algo-8xx.h 
     80KERNELTARGETS += $(MODULE_DIR)/i2c-algo-8xx.o 
     81KERNELINCLUDES += $(MODULE_DIR)/i2c-algo-8xx.h 
    8282#endif 
    8383#ifneq ($(shell if grep -q '^CONFIG_I2C_RPXLITE=y' $(LINUX)/.config; then echo 1; fi),1) 
    84 #KERNELTARGETS += $(MODULE_DIR)/i2c-rpx.o 
     84KERNELTARGETS += $(MODULE_DIR)/i2c-rpx.o 
    8585#endif 
    8686 
  • i2c/trunk/kernel/i2c-adap-ibm_ocp.c

    r3753 r3758  
    276276 
    277277 
    278 // 
    279 // Description: If this compiled as a module, then increment the count 
    280 // 
    281 static void iic_ibmocp_inc_use(struct i2c_adapter *adap) 
    282 { 
    283 #ifdef MODULE 
    284         MOD_INC_USE_COUNT; 
    285 #endif 
    286 } 
    287  
    288  
    289 // 
    290 // Description: If this is a module, then decrement the count 
    291 // 
    292 static void iic_ibmocp_dec_use(struct i2c_adapter *adap) 
    293 { 
    294 #ifdef MODULE 
    295         MOD_DEC_USE_COUNT; 
    296 #endif 
    297 } 
    298278 
    299279// 
  • i2c/trunk/kernel/i2c-algo-8xx.c

    r3753 r3758  
    609609        adap->algo = &cpm_algo; 
    610610 
    611 #ifdef MODULE 
    612         MOD_INC_USE_COUNT; 
    613 #endif 
    614  
    615611        i2c_add_adapter(adap); 
    616612        cpm_iic_init(cpm_adap); 
     
    643639        printk("i2c-algo-8xx.o: adapter unregistered: %s\n",adap->name); 
    644640 
    645 #ifdef MODULE 
    646         MOD_DEC_USE_COUNT; 
    647 #endif 
    648641        return 0; 
    649642} 
     
    652645EXPORT_SYMBOL(i2c_8xx_del_bus); 
    653646 
    654 int __init i2c_algo_8xx_init (void) 
    655 { 
    656         printk("i2c-algo-8xx.o: i2c mpc8xx algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    657         return 0; 
    658 } 
    659  
    660  
    661 #ifdef MODULE 
    662647MODULE_AUTHOR("Brad Parker <brad@heeltoe.com>"); 
    663648MODULE_DESCRIPTION("I2C-Bus MPC8XX algorithm"); 
    664649MODULE_LICENSE("GPL"); 
    665  
    666 int init_module(void)  
    667 { 
    668         return i2c_algo_8xx_init(); 
    669 } 
    670  
    671 void cleanup_module(void)  
    672 { 
    673 } 
    674 #endif 
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3757 r3758  
    543543 
    544544static struct i2c_algorithm i2c_bit_algo = { 
    545         "Bit-shift algorithm", 
    546         I2C_ALGO_BIT, 
    547         bit_xfer, 
    548         NULL, 
    549         NULL,                           /* slave_xmit           */ 
    550         NULL,                           /* slave_recv           */ 
    551         algo_control,                   /* ioctl                */ 
    552         bit_func,                       /* functionality        */ 
     545        .name           = "Bit-shift algorithm", 
     546        .id             = I2C_ALGO_BIT, 
     547        .master_xfer    = bit_xfer, 
     548        .algo_control   = algo_control, 
     549        .functionality  = bit_func, 
    553550}; 
    554551 
     
    595592        } 
    596593 
    597 #ifdef MODULE 
    598         MOD_INC_USE_COUNT; 
    599 #endif 
    600594        i2c_add_adapter(i2c_adap); 
    601  
    602595        return 0; 
    603596} 
     
    613606        DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",i2c_adap->name)); 
    614607 
    615 #ifdef MODULE 
    616         MOD_DEC_USE_COUNT; 
    617 #endif 
    618608        return 0; 
    619609} 
    620  
    621 int __init i2c_algo_bit_init (void) 
    622 { 
    623         printk(KERN_INFO "i2c-algo-bit.o: i2c bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    624         return 0; 
    625 } 
    626  
    627610 
    628611 
     
    630613EXPORT_SYMBOL(i2c_bit_del_bus); 
    631614 
    632 #ifdef MODULE 
    633615MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    634616MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); 
     
    643625MODULE_PARM_DESC(i2c_debug, 
    644626            "debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol"); 
    645  
    646 int init_module(void)  
    647 { 
    648         return i2c_algo_bit_init(); 
    649 } 
    650  
    651 void cleanup_module(void)  
    652 { 
    653 } 
    654 #endif 
  • i2c/trunk/kernel/i2c-algo-biths.c

    r3757 r3758  
    586586 
    587587static struct i2c_algorithm i2c_algo_biths = { 
    588         "Bit-shift algorithm", 
    589         I2C_ALGO_BIT, 
    590         bit_xfer, 
    591         NULL, 
    592         NULL,                           /* slave_xmit           */ 
    593         NULL,                           /* slave_recv           */ 
    594         algo_control,                   /* ioctl                */ 
    595         bit_func,                       /* functionality        */ 
     588        .name           = "Bit-shift algorithm", 
     589        .id             = I2C_ALGO_BIT, 
     590        .master_xfer    = bit_xfer, 
     591        .algo_control   = algo_control, 
     592        .functionality  = bit_func, 
    596593}; 
    597594 
     
    744741        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: hw routines for %s registered.\n", 
    745742                    i2c_adap->name)); 
    746          
    747         /* register new adapter to i2c module... */ 
    748  
    749         i2c_adap->id |= i2c_algo_biths.id; 
    750         i2c_adap->algo = &i2c_algo_biths; 
    751  
    752         i2c_adap->timeout = HZ; /* default values, should       */ 
    753         i2c_adap->retries = 3;  /* be replaced by defines       */ 
    754  
    755 #ifdef MODULE 
    756         MOD_INC_USE_COUNT; 
    757 #endif 
    758         i2c_add_adapter(i2c_adap); 
    759  
    760         return 0; 
    761 } 
    762  
    763  
    764 int i2c_biths_del_bus(struct i2c_adapter *i2c_adap) 
    765 { 
    766         int res; 
    767  
    768         if ((res = i2c_del_adapter(i2c_adap)) < 0) 
    769                 return res; 
    770  
    771         DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name)); 
    772  
    773 #ifdef MODULE 
    774         MOD_DEC_USE_COUNT; 
    775 #endif 
    776         return 0; 
    777 } 
    778  
    779 int __init i2c_algo_biths_init (void) 
    780 { 
    781         printk(KERN_INFO "i2c-algo-biths.o: i2c high-speed bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    782743#ifdef rdtscl 
    783744        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use rdtscl() for bus clock\n")); 
    784745#else 
    785         DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use udelay() for bus clock\n"); 
     746        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use udelay() for bus clock\n")); 
    786747#endif 
     748         
     749        /* register new adapter to i2c module... */ 
     750 
     751        i2c_adap->id |= i2c_algo_biths.id; 
     752        i2c_adap->algo = &i2c_algo_biths; 
     753 
     754        i2c_adap->timeout = HZ; /* default values, should       */ 
     755        i2c_adap->retries = 3;  /* be replaced by defines       */ 
     756 
     757        i2c_add_adapter(i2c_adap); 
     758 
    787759        return 0; 
    788760} 
    789761 
    790762 
     763int i2c_biths_del_bus(struct i2c_adapter *i2c_adap) 
     764{ 
     765        int res; 
     766 
     767        if ((res = i2c_del_adapter(i2c_adap)) < 0) 
     768                return res; 
     769 
     770        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name)); 
     771 
     772        return 0; 
     773} 
    791774 
    792775EXPORT_SYMBOL(i2c_biths_add_bus); 
    793776EXPORT_SYMBOL(i2c_biths_del_bus); 
    794777 
    795 #ifdef MODULE 
    796778MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>"); 
    797779MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); 
     
    804786MODULE_PARM_DESC(i2c_debug, 
    805787            "debug level - 1 use; 2 fatal, 3 +proto; 4 all, 5 +proto"); 
    806  
    807 int init_module(void)  
    808 { 
    809         return i2c_algo_biths_init(); 
    810 } 
    811  
    812 void cleanup_module(void)  
    813 { 
    814 } 
    815 #endif 
  • i2c/trunk/kernel/i2c-algo-ibm_ocp.c

    r3753 r3758  
    891891        adap->retries = 3;              /* be replaced by defines       */ 
    892892 
    893 #ifdef MODULE 
    894         MOD_INC_USE_COUNT; 
    895 #endif 
    896  
    897893        iic_init(iic_adap); 
    898894        i2c_add_adapter(adap); 
     
    918914        DEB2(printk(KERN_DEBUG "i2c-algo-iic.o: adapter unregistered: %s\n",adap->name)); 
    919915 
    920 #ifdef MODULE 
    921         MOD_DEC_USE_COUNT; 
    922 #endif 
    923916        return 0; 
    924 } 
    925  
    926  
    927 // 
    928 // Done 
    929 // 
    930 int __init i2c_algo_iic_init (void) 
    931 { 
    932         printk(KERN_INFO "IBM On-chip iic (i2c) algorithm module 2002.27.03\n"); 
    933         return 0; 
    934 } 
    935  
    936  
    937 void i2c_algo_iic_exit(void) 
    938 { 
    939         return; 
    940917} 
    941918 
     
    960937        "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol"); 
    961938 
    962  
    963 module_init(i2c_algo_iic_init); 
    964 module_exit(i2c_algo_iic_exit); 
  • i2c/trunk/kernel/i2c-algo-pcf.c

    r3753 r3758  
    3838#include <linux/errno.h> 
    3939#include <linux/sched.h> 
     40 
    4041#include "i2c.h" 
    4142#include "i2c-algo-pcf.h" 
     
    475476        } 
    476477 
    477 #ifdef MODULE 
    478         MOD_INC_USE_COUNT; 
    479 #endif 
    480  
    481478        i2c_add_adapter(adap); 
    482479 
     
    510507int i2c_pcf_del_bus(struct i2c_adapter *adap) 
    511508{ 
    512         int res; 
    513         if ((res = i2c_del_adapter(adap)) < 0) 
    514                 return res; 
    515         DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: adapter unregistered: %s\n",adap->name)); 
    516  
    517 #ifdef MODULE 
    518         MOD_DEC_USE_COUNT; 
    519 #endif 
    520         return 0; 
    521 } 
    522  
    523 int __init i2c_algo_pcf_init (void) 
    524 { 
    525         printk(KERN_INFO "i2c-algo-pcf.o: i2c pcf8584 algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    526         return 0; 
    527 } 
    528  
     509        return i2c_del_adapter(adap); 
     510} 
    529511 
    530512EXPORT_SYMBOL(i2c_pcf_add_bus); 
    531513EXPORT_SYMBOL(i2c_pcf_del_bus); 
    532514 
    533 #ifdef MODULE 
    534515MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 
    535516MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); 
     
    542523MODULE_PARM_DESC(i2c_debug, 
    543524        "debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol"); 
    544  
    545  
    546 int init_module(void)  
    547 { 
    548         return i2c_algo_pcf_init(); 
    549 } 
    550  
    551 void cleanup_module(void)  
    552 { 
    553 } 
    554 #endif 
  • i2c/trunk/kernel/i2c-core.c

    r3753 r3758  
    3737#include <linux/init.h> 
    3838 
    39  
    4039#include <asm/uaccess.h> 
    4140 
     
    5857 
    5958/**** lock for writing to global variables: the adapter & driver list */ 
    60 struct semaphore adap_lock; 
    61 struct semaphore driver_lock; 
     59DECLARE_MUTEX(adap_lock); 
     60DECLARE_MUTEX(driver_lock); 
    6261 
    6362/**** adapter list */ 
     
    7877 
    7978#ifdef CONFIG_PROC_FS 
    80  
    81 static int i2cproc_init(void); 
    82 static int i2cproc_cleanup(void); 
    83  
    84  
    8579static ssize_t i2cproc_bus_read(struct file * file, char * buf,size_t count,  
    8680                                loff_t *ppos); 
     
    9387        .read           = i2cproc_bus_read, 
    9488}; 
    95  
    96  
    97 static int i2cproc_initialized = 0; 
    98  
    99 #else /* undef CONFIG_PROC_FS */ 
    100  
    101 #define i2cproc_init() 0 
    102 #define i2cproc_cleanup() 0 
    103  
    10489#endif /* CONFIG_PROC_FS */ 
    10590 
     
    139124 
    140125#ifdef CONFIG_PROC_FS 
    141  
    142         if (i2cproc_initialized) { 
     126        { 
    143127                char name[8]; 
    144128                struct proc_dir_entry *proc_entry; 
     
    158142                adap->inode = proc_entry->low_ino; 
    159143        } 
    160  
    161144#endif /* def CONFIG_PROC_FS */ 
    162145 
     
    237220        } 
    238221#ifdef CONFIG_PROC_FS 
    239         if (i2cproc_initialized) { 
     222        { 
    240223                char name[8]; 
    241224                sprintf(name,"i2c-%d", i); 
    242                 remove_proc_entry(name,proc_bus); 
     225                remove_proc_entry(name, proc_bus); 
    243226        } 
    244227#endif /* def CONFIG_PROC_FS */ 
     
    462445} 
    463446 
    464 void i2c_inc_use_client(struct i2c_client *client) 
    465 { 
    466  
    467         if (client->driver->inc_use != NULL) 
    468                 client->driver->inc_use(client); 
    469  
    470         if (client->adapter->inc_use != NULL) 
    471                 client->adapter->inc_use(client->adapter); 
    472 } 
    473  
    474 void i2c_dec_use_client(struct i2c_client *client) 
    475 { 
    476          
    477         if (client->driver->dec_use != NULL) 
    478                 client->driver->dec_use(client); 
    479  
    480         if (client->adapter->dec_use != NULL) 
    481                 client->adapter->dec_use(client->adapter); 
     447static int i2c_inc_use_client(struct i2c_client *client) 
     448{ 
     449 
     450        if (!try_module_get(client->driver->owner)) 
     451                return -ENODEV; 
     452        if (!try_module_get(client->adapter->owner)) { 
     453                module_put(client->driver->owner); 
     454                return -ENODEV; 
     455        } 
     456 
     457        return 0; 
     458} 
     459 
     460static void i2c_dec_use_client(struct i2c_client *client) 
     461{ 
     462        module_put(client->driver->owner); 
     463        module_put(client->adapter->owner); 
    482464} 
    483465 
     
    551533int i2c_use_client(struct i2c_client *client) 
    552534{ 
    553         if(client->flags & I2C_CLIENT_ALLOW_USE) { 
    554                 if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)  
     535        if (!i2c_inc_use_client(client)) 
     536                return -ENODEV; 
     537 
     538        if (client->flags & I2C_CLIENT_ALLOW_USE) { 
     539                if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) 
    555540                        client->usage_count++; 
    556                 else { 
    557                         if(client->usage_count > 0)  
    558                                 return -EBUSY; 
    559                          else  
    560                                 client->usage_count++; 
    561                 } 
    562         } 
    563  
    564         i2c_inc_use_client(client); 
     541                else if (client->usage_count > 0)  
     542                        goto busy; 
     543                else  
     544                        client->usage_count++; 
     545        } 
    565546 
    566547        return 0; 
     548 busy: 
     549        i2c_dec_use_client(client); 
     550        return -EBUSY; 
    567551} 
    568552 
     
    590574 
    591575#ifdef CONFIG_PROC_FS 
    592  
    593576 
    594577/* This function generates the output for /proc/bus/i2c */ 
     
    683666} 
    684667 
    685 int i2cproc_init(void) 
     668static int i2cproc_init(void) 
    686669{ 
    687670 
    688671        struct proc_dir_entry *proc_bus_i2c; 
    689672 
    690         i2cproc_initialized = 0; 
    691  
    692         if (! proc_bus) { 
    693                 printk(KERN_ERR "i2c-core.o: /proc/bus/ does not exist"); 
    694                 i2cproc_cleanup(); 
    695                 return -ENOENT; 
    696         }  
    697673        proc_bus_i2c = create_proc_entry("i2c",0,proc_bus); 
    698674        if (!proc_bus_i2c) { 
    699675                printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c"); 
    700                 i2cproc_cleanup(); 
    701676                return -ENOENT; 
    702677        } 
     678 
    703679        proc_bus_i2c->read_proc = &read_bus_i2c; 
    704680        proc_bus_i2c->owner = THIS_MODULE; 
    705         i2cproc_initialized += 2; 
    706681        return 0; 
    707682} 
    708683 
    709 int i2cproc_cleanup(void) 
    710 { 
    711  
    712         if (i2cproc_initialized >= 1) { 
    713                 remove_proc_entry("i2c",proc_bus); 
    714                 i2cproc_initialized -= 2; 
    715         } 
    716         return 0; 
    717 } 
    718  
    719  
     684static void __exit i2cproc_cleanup(void) 
     685{ 
     686 
     687        remove_proc_entry("i2c",proc_bus); 
     688} 
     689 
     690module_init(i2cproc_init); 
     691module_exit(i2cproc_cleanup); 
    720692#endif /* def CONFIG_PROC_FS */ 
    721693 
     
    14641436} 
    14651437 
    1466 #ifndef MODULE 
    1467 #ifdef CONFIG_I2C_CHARDEV 
    1468         extern int i2c_dev_init(void); 
    1469 #endif 
    1470 #ifdef CONFIG_I2C_ALGOBIT 
    1471         extern int i2c_algo_bit_init(void); 
    1472 #endif 
    1473 #ifdef CONFIG_I2C_PHILIPSPAR 
    1474         extern int i2c_bitlp_init(void); 
    1475 #endif 
    1476 #ifdef CONFIG_I2C_ELV 
    1477         extern int i2c_bitelv_init(void); 
    1478 #endif 
    1479 #ifdef CONFIG_I2C_VELLEMAN 
    1480         extern int i2c_bitvelle_init(void); 
    1481 #endif 
    1482 #ifdef CONFIG_I2C_PPORT 
    1483         extern int i2c_bitpport_init(void); 
    1484 #endif 
    1485 #ifdef CONFIG_I2C_FRODO 
    1486         extern int i2c_frodo_init(void); 
    1487 #endif 
    1488 #ifdef CONFIG_I2C_BITVIA 
    1489         extern int i2c_bitvia_init(void); 
    1490 #endif 
    1491  
    1492 #ifdef CONFIG_I2C_ALGOPCF 
    1493         extern int i2c_algo_pcf_init(void);      
    1494 #endif 
    1495 #ifdef CONFIG_I2C_ELEKTOR 
    1496         extern int i2c_pcfisa_init(void); 
    1497 #endif 
    1498 #ifdef CONFIG_I2C_PCFEPP 
    1499         extern int i2c_pcfepp_init(void); 
    1500 #endif 
    1501  
    1502 #ifdef CONFIG_I2C_ALGO8XX 
    1503         extern int i2c_algo_8xx_init(void); 
    1504 #endif 
    1505 #ifdef CONFIG_I2C_RPXLITE 
    1506         extern int i2c_rpx_init(void); 
    1507 #endif 
    1508 #ifdef CONFIG_I2C_IBM_OCP_ALGO 
    1509         extern int i2c_algo_iic_init(void); 
    1510 #endif 
    1511 #ifdef CONFIG_I2C_IBM_OCP_ADAP 
    1512         extern int iic_ibmocp_init(void); 
    1513 #endif 
    1514 #ifdef CONFIG_I2C_PROC 
    1515         extern int sensors_init(void); 
    1516 #endif 
    1517  
    1518 /* This is needed for automatic patch generation: sensors code starts here */ 
    1519 /* This is needed for automatic patch generation: sensors code ends here   */ 
    1520  
    1521 int __init i2c_init_all(void) 
    1522 { 
    1523         /* --------------------- global ----- */ 
    1524         i2c_init(); 
    1525  
    1526 #ifdef CONFIG_I2C_CHARDEV 
    1527         i2c_dev_init(); 
    1528 #endif 
    1529         /* --------------------- bit -------- */ 
    1530 #ifdef CONFIG_I2C_ALGOBIT 
    1531         i2c_algo_bit_init(); 
    1532 #endif 
    1533 #ifdef CONFIG_I2C_PHILIPSPAR 
    1534         i2c_bitlp_init(); 
    1535 #endif 
    1536 #ifdef CONFIG_I2C_ELV 
    1537         i2c_bitelv_init(); 
    1538 #endif 
    1539 #ifdef CONFIG_I2C_VELLEMAN 
    1540         i2c_bitvelle_init(); 
    1541 #endif 
    1542 #ifdef CONFIG_I2C_PPORT 
    1543         i2c_bitpport_init(); 
    1544 #endif 
    1545 #ifdef CONFIG_I2C_FRODO 
    1546         i2c_frodo_init(); 
    1547 #endif 
    1548 #ifdef CONFIG_I2C_BITVIA 
    1549         i2c_bitvia_init(); 
    1550 #endif 
    1551  
    1552         /* --------------------- pcf -------- */ 
    1553 #ifdef CONFIG_I2C_ALGOPCF 
    1554         i2c_algo_pcf_init();     
    1555 #endif 
    1556 #ifdef CONFIG_I2C_ELEKTOR 
    1557         i2c_pcfisa_init(); 
    1558 #endif 
    1559 #ifdef CONFIG_I2C_PCFEPP 
    1560         i2c_pcfepp_init(); 
    1561 #endif 
    1562  
    1563         /* --------------------- 8xx -------- */ 
    1564 #ifdef CONFIG_I2C_ALGO8XX 
    1565         i2c_algo_8xx_init(); 
    1566 #endif 
    1567 #ifdef CONFIG_I2C_RPXLITE 
    1568         i2c_rpx_init(); 
    1569 #endif 
    1570 #ifdef CONFIG_I2C_IBM_OCP_ALGO 
    1571         i2c_algo_iic_init(); 
    1572 #endif 
    1573 #ifdef CONFIG_I2C_IBM_OCP_ADAP 
    1574         iic_ibmocp_init(); 
    1575 #endif 
    1576  
    1577         /* -------------- proc interface ---- */ 
    1578 #ifdef CONFIG_I2C_PROC 
    1579         sensors_init(); 
    1580 #endif 
    1581 /* This is needed for automatic patch generation: sensors code starts here */ 
    1582 /* This is needed for automatic patch generation: sensors code ends here */ 
    1583  
    1584         return 0; 
    1585 } 
    1586  
    1587 #endif 
    1588  
    1589  
    1590  
    15911438EXPORT_SYMBOL(i2c_add_adapter); 
    15921439EXPORT_SYMBOL(i2c_del_adapter); 
     
    15951442EXPORT_SYMBOL(i2c_attach_client); 
    15961443EXPORT_SYMBOL(i2c_detach_client); 
    1597 EXPORT_SYMBOL(i2c_inc_use_client); 
    1598 EXPORT_SYMBOL(i2c_dec_use_client); 
    15991444EXPORT_SYMBOL(i2c_get_client); 
    16001445EXPORT_SYMBOL(i2c_use_client); 
     
    16291474MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    16301475MODULE_DESCRIPTION("I2C-Bus main module"); 
     1476MODULE_LICENSE("GPL"); 
     1477 
    16311478MODULE_PARM(i2c_debug, "i"); 
    16321479MODULE_PARM_DESC(i2c_debug,"debug level"); 
    1633 MODULE_LICENSE("GPL"); 
    1634  
    1635 module_init(i2c_init); 
    1636 module_exit(i2c_exit); 
  • i2c/trunk/kernel/i2c-dev.c

    r3757 r3758  
    365365        file->private_data = client; 
    366366 
    367         if (i2cdev_adaps[minor]->inc_use) 
    368                 i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]); 
     367        if (!try_module_get(i2cdev_adaps[minor]->owner)) { 
     368                kfree(client); 
     369                return -ENODEV; 
     370        } 
    369371 
    370372#ifdef DEBUG 
     
    382384        printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor); 
    383385#endif 
    384         lock_kernel(); 
    385         if (i2cdev_adaps[minor]->dec_use) 
    386                 i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]); 
    387         unlock_kernel(); 
     386        module_put(i2cdev_adaps[minor]->owner); 
    388387        return 0; 
    389388} 
     
    434433} 
    435434 
    436 static void i2cdev_cleanup(void) 
    437 { 
    438         int res; 
    439  
    440         if ((res = i2c_del_driver(&i2cdev_driver))) { 
    441                 printk(KERN_ERR "i2c-dev.o: Driver deregistration failed, " 
    442                        "module not removed.\n"); 
    443         } 
    444  
    445         devfs_remove("i2c"); 
    446         unregister_chrdev(I2C_MAJOR,"i2c"); 
    447 } 
    448  
    449435int __init i2c_dev_init(void) 
    450436{ 
     
    468454} 
    469455 
    470 EXPORT_NO_SYMBOLS; 
     456static void __exit i2c_dev_exit(void) 
     457{ 
     458        i2c_del_driver(&i2cdev_driver); 
     459        devfs_remove("i2c"); 
     460        unregister_chrdev(I2C_MAJOR,"i2c"); 
     461} 
    471462 
    472463MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
     
    475466 
    476467module_init(i2c_dev_init); 
    477 module_exit(i2cdev_cleanup); 
     468module_exit(i2c_dev_exit); 
  • i2c/trunk/kernel/i2c-dev.h

    r3661 r3758  
    2222/* $Id$ */ 
    2323 
    24 #ifndef I2C_DEV_H 
    25 #define I2C_DEV_H 
    26  
     24#ifndef _LINUX_I2C_DEV_H 
     25#define _LINUX_I2C_DEV_H 
    2726 
    2827#include <linux/types.h> 
     
    216215#endif /* ndef __KERNEL__ */ 
    217216 
    218 #endif 
     217#endif /* _LINUX_I2C_DEV_H */ 
  • i2c/trunk/kernel/i2c-elektor.c

    r3754 r3758  
    3636#include <linux/pci.h> 
    3737#include <linux/wait.h> 
     38 
    3839#include "i2c.h" 
    3940#include "i2c-algo-pcf.h" 
    40 #include "i2c-elektor.h" 
    4141 
    4242#include <asm/io.h> 
     
    143143{ 
    144144        if (!mmapped) { 
    145                 if (check_region(base, 2) < 0 ) { 
    146                         printk(KERN_ERR "i2c-elektor.o: requested I/O region (0x%X:2) is in use.\n", base); 
     145                if (!request_region(base, 2, "i2c (isa bus adapter)")) { 
     146                        printk(KERN_ERR 
     147                               "i2c-elektor.o: requested I/O region (0x%X:2) " 
     148                               "is in use.\n", base); 
    147149                        return -ENODEV; 
    148                 } else { 
    149                         request_region(base, 2, "i2c (isa bus adapter)"); 
    150150                } 
    151151        } 
     
    158158        } 
    159159        return 0; 
    160 } 
    161  
    162  
    163 static void __exit pcf_isa_exit(void) 
    164 { 
    165         if (irq > 0) { 
    166                 disable_irq(irq); 
    167                 free_irq(irq, 0); 
    168         } 
    169         if (!mmapped) { 
    170                 release_region(base , 2); 
    171         } 
    172 } 
    173  
    174  
    175 static int pcf_isa_reg(struct i2c_client *client) 
    176 { 
    177         return 0; 
    178 } 
    179  
    180  
    181 static int pcf_isa_unreg(struct i2c_client *client) 
    182 { 
    183         return 0; 
    184 } 
    185  
    186 static void pcf_isa_inc_use(struct i2c_adapter *adap) 
    187 { 
    188 #ifdef MODULE 
    189         MOD_INC_USE_COUNT; 
    190 #endif 
    191 } 
    192  
    193 static void pcf_isa_dec_use(struct i2c_adapter *adap) 
    194 { 
    195 #ifdef MODULE 
    196         MOD_DEC_USE_COUNT; 
    197 #endif 
    198160} 
    199161 
     
    211173        .udelay     = 10, 
    212174        .mdelay     = 10, 
    213         .timeout    = 100, 
     175        .timeout    = HZ, 
    214176}; 
    215177 
    216178static struct i2c_adapter pcf_isa_ops = { 
     179        .owner             = THIS_MODULE, 
    217180        .name              = "PCF8584 ISA adapter", 
    218181        .id                = I2C_HW_P_ELEK, 
    219182        .algo_data         = &pcf_isa_data, 
    220         .inc_use           = pcf_isa_inc_use, 
    221         .dec_use           = pcf_isa_dec_use, 
    222         .client_register   = pcf_isa_reg, 
    223         .client_unregister = pcf_isa_unreg, 
    224183}; 
    225184 
    226 int __init i2c_pcfisa_init(void)  
     185static int __init i2c_pcfisa_init(void)  
    227186{ 
    228187#ifdef __alpha__ 
     
    282241 
    283242        init_waitqueue_head(&pcf_wait); 
    284         if (pcf_isa_init() == 0) { 
    285                 if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) { 
    286                         pcf_isa_exit(); 
    287                         return -ENODEV; 
    288                 } 
    289         } else { 
     243        if (pcf_isa_init()) 
    290244                return -ENODEV; 
    291         } 
     245        if (i2c_pcf_add_bus(&pcf_isa_ops) < 0) 
     246                goto fail; 
    292247         
    293248        printk(KERN_ERR "i2c-elektor.o: found device at %#x.\n", base); 
    294249 
    295250        return 0; 
    296 } 
    297  
    298  
    299 EXPORT_NO_SYMBOLS; 
    300  
    301 #ifdef MODULE 
     251 
     252 fail: 
     253        if (irq > 0) { 
     254                disable_irq(irq); 
     255                free_irq(irq, 0); 
     256        } 
     257 
     258        if (!mmapped) 
     259                release_region(base , 2); 
     260        return -ENODEV; 
     261} 
     262 
     263 
     264static void i2c_pcfisa_exit(void) 
     265{ 
     266        i2c_pcf_del_bus(&pcf_isa_ops); 
     267 
     268        if (irq > 0) { 
     269                disable_irq(irq); 
     270                free_irq(irq, 0); 
     271        } 
     272 
     273        if (!mmapped) 
     274                release_region(base , 2); 
     275} 
     276 
    302277MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 
    303278MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 ISA bus adapter"); 
     
    311286MODULE_PARM(i2c_debug, "i"); 
    312287 
    313 int init_module(void)  
    314 { 
    315         return i2c_pcfisa_init(); 
    316 } 
    317  
    318 void cleanup_module(void)  
    319 { 
    320         i2c_pcf_del_bus(&pcf_isa_ops); 
    321         pcf_isa_exit(); 
    322 } 
    323  
    324 #endif 
     288module_init(i2c_pcfisa_init); 
     289module_exit(i2c_pcfisa_exit); 
  • i2c/trunk/kernel/i2c-elv.c

    r3753 r3758  
    8989static int bit_elv_init(void) 
    9090{ 
    91         if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { 
    92                 return -ENODEV;  
    93         } else { 
    94                                                 /* test for ELV adap.   */ 
    95                 if (inb(base+1) & 0x80) {       /* BUSY should be high  */ 
    96                         DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); 
    97                         return -ENODEV; 
    98                 } else { 
    99                         outb(0x0c,base+2);      /* SLCT auf low         */ 
    100                         udelay(400); 
    101                         if ( !(inb(base+1) && 0x10) ) { 
    102                                 outb(0x04,base+2); 
    103                                 DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); 
    104                                 return -ENODEV; 
    105                         } 
    106                 } 
    107                 request_region(base,(base == 0x3bc)? 3 : 8, 
    108                         "i2c (ELV adapter)"); 
    109                 PortData = 0; 
    110                 bit_elv_setsda((void*)base,1); 
    111                 bit_elv_setscl((void*)base,1); 
     91        if (!request_region(base, (base == 0x3bc) ? 3 : 8, 
     92                                "i2c (ELV adapter)")) 
     93                return -ENODEV; 
     94 
     95        if (inb(base+1) & 0x80) {       /* BUSY should be high  */ 
     96                DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Busy was low.\n")); 
     97                goto fail; 
     98        }  
     99 
     100        outb(0x0c,base+2);      /* SLCT auf low         */ 
     101        udelay(400); 
     102        if (!(inb(base+1) && 0x10)) { 
     103                outb(0x04,base+2); 
     104                DEBINIT(printk(KERN_DEBUG "i2c-elv.o: Select was high.\n")); 
     105                goto fail; 
    112106        } 
     107 
     108        PortData = 0; 
     109        bit_elv_setsda((void*)base,1); 
     110        bit_elv_setscl((void*)base,1); 
    113111        return 0; 
    114 } 
    115112 
    116 static void __exit bit_elv_exit(void) 
    117 { 
    118         release_region( base , (base == 0x3bc)? 3 : 8 ); 
    119 } 
    120  
    121 static int bit_elv_reg(struct i2c_client *client) 
    122 { 
    123         return 0; 
    124 } 
    125  
    126 static int bit_elv_unreg(struct i2c_client *client) 
    127 { 
    128         return 0; 
    129 } 
    130  
    131 static void bit_elv_inc_use(struct i2c_adapter *adap) 
    132 { 
    133 #ifdef MODULE 
    134         MOD_INC_USE_COUNT; 
    135 #endif 
    136 } 
    137  
    138 static void bit_elv_dec_use(struct i2c_adapter *adap) 
    139 { 
    140 #ifdef MODULE 
    141         MOD_DEC_USE_COUNT; 
    142 #endif 
     113fail: 
     114        release_region(base , (base == 0x3bc) ? 3 : 8); 
     115        return -ENODEV; 
    143116} 
    144117 
     
    157130 
    158131static struct i2c_adapter bit_elv_ops = { 
    159         "ELV Parallel port adaptor", 
    160         I2C_HW_B_ELV, 
    161         NULL, 
    162         &bit_elv_data, 
    163         bit_elv_inc_use, 
    164         bit_elv_dec_use, 
    165         bit_elv_reg, 
    166         bit_elv_unreg,   
     132        .owner          = THIS_MODULE, 
     133        .name           = "ELV Parallel port adaptor", 
     134        .id             = I2C_HW_B_ELV, 
     135        .algo_data      = &bit_elv_data, 
    167136}; 
    168137 
    169 int __init i2c_bitelv_init(void) 
     138static int __init i2c_bitelv_init(void) 
    170139{ 
    171140        printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
     
    193162} 
    194163 
     164static void __exit i2c_bitelv_exit(void) 
     165{ 
     166        i2c_bit_del_bus(&bit_elv_ops); 
     167        release_region(base , (base == 0x3bc) ? 3 : 8); 
     168} 
    195169 
    196170EXPORT_NO_SYMBOLS; 
    197171 
    198 #ifdef MODULE 
    199172MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    200173MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter"); 
     
    203176MODULE_PARM(base, "i"); 
    204177 
    205 int init_module(void) 
    206 { 
    207         return i2c_bitelv_init(); 
    208 } 
    209  
    210 void cleanup_module(void) 
    211 { 
    212         i2c_bit_del_bus(&bit_elv_ops); 
    213         bit_elv_exit(); 
    214 } 
    215  
    216 #endif 
     178module_init(i2c_bitelv_init); 
     179module_exit(i2c_bitelv_exit); 
  • i2c/trunk/kernel/i2c-frodo.c

    r3757 r3758  
    6262}; 
    6363 
    64 static int frodo_client_register (struct i2c_client *client) 
    65 { 
    66         return (0); 
    67 } 
    68  
    69 static int frodo_client_unregister (struct i2c_client *client) 
    70 { 
    71         return (0); 
    72 } 
    73  
    74 static void frodo_inc_use (struct i2c_adapter *adapter) 
    75 { 
    76         MOD_INC_USE_COUNT; 
    77 } 
    78  
    79 static void frodo_dec_use (struct i2c_adapter *adapter) 
    80 { 
    81         MOD_DEC_USE_COUNT; 
    82 } 
    83  
    8464static struct i2c_adapter frodo_ops = { 
     65        .owner                  = THIS_MODULE, 
    8566        .name                   = "Frodo adapter driver", 
    8667        .id                     = I2C_HW_B_FRODO, 
    8768        .algo_data              = &bit_frodo_data, 
    88         .inc_use                = frodo_inc_use, 
    89         .dec_use                = frodo_dec_use, 
    90         .client_register        = frodo_client_register, 
    91         .client_unregister      = frodo_client_unregister 
    9269}; 
    9370 
    9471static int __init i2c_frodo_init (void) 
    9572{ 
    96         return (i2c_bit_add_bus (&frodo_ops)); 
     73        return i2c_bit_add_bus(&frodo_ops); 
    9774} 
    98  
    99 EXPORT_NO_SYMBOLS; 
    10075 
    10176static void __exit i2c_frodo_exit (void) 
    10277{ 
    103         i2c_bit_del_bus (&frodo_ops); 
     78        i2c_bit_del_bus(&frodo_ops); 
    10479} 
    10580 
     
    10883MODULE_LICENSE ("GPL"); 
    10984 
    110 EXPORT_NO_SYMBOLS; 
    111  
    11285module_init (i2c_frodo_init); 
    11386module_exit (i2c_frodo_exit); 
  • i2c/trunk/kernel/i2c-pcf-epp.c

    r3754 r3758  
    197197} 
    198198 
    199 static void pcf_epp_inc_use(struct i2c_adapter *adap) 
    200 { 
    201 #ifdef MODULE 
    202   MOD_INC_USE_COUNT; 
    203 #endif 
    204 } 
    205  
    206 static void pcf_epp_dec_use(struct i2c_adapter *adap) 
    207 { 
    208 #ifdef MODULE 
    209   MOD_DEC_USE_COUNT; 
    210 #endif 
    211 } 
    212199 
    213200 
     
    223210  pcf_epp_getclock, 
    224211  pcf_epp_waitforpin, 
    225   80, 80, 100,          /*      waits, timeout */ 
     212  80, 80, HZ,           /*      waits, timeout */ 
    226213}; 
    227214 
  • i2c/trunk/kernel/i2c-philips-par.c

    r3753 r3758  
    128128        return (parport_read_status((struct parport *) data) &  
    129129                                     PARPORT_STATUS_BUSY) ? 0 : 1; 
    130 } 
    131  
    132 static int bit_lp_reg(struct i2c_client *client) 
    133 { 
    134         return 0; 
    135 } 
    136  
    137 static int bit_lp_unreg(struct i2c_client *client) 
    138 { 
    139         return 0; 
    140 } 
    141  
    142 static void bit_lp_inc_use(struct i2c_adapter *adap) 
    143 { 
    144         MOD_INC_USE_COUNT; 
    145 } 
    146  
    147 static void bit_lp_dec_use(struct i2c_adapter *adap) 
    148 { 
    149         MOD_DEC_USE_COUNT; 
    150130} 
    151131 
     
    174154 
    175155static struct i2c_adapter bit_lp_ops = { 
    176         "Philips Parallel port adapter", 
    177         I2C_HW_B_LP, 
    178         NULL, 
    179         NULL, 
    180         bit_lp_inc_use, 
    181         bit_lp_dec_use, 
    182         bit_lp_reg, 
    183  
    184         bit_lp_unreg, 
     156        .owner          = THIS_MODULE, 
     157        .name           = "Philips Parallel port adapter", 
     158        .id             = I2C_HW_B_LP, 
    185159}; 
    186160 
     
    284258MODULE_PARM(type, "i"); 
    285259 
    286 #ifdef MODULE 
    287 int init_module(void) 
    288 { 
    289         return i2c_bitlp_init(); 
    290 } 
    291  
    292 void cleanup_module(void) 
    293 { 
    294         i2c_bitlp_exit(); 
    295 } 
    296 #endif 
     260module_init(i2c_bitlp_init); 
     261module_exit(i2c_bitlp_exit); 
  • i2c/trunk/kernel/i2c-pport.c

    r3753 r3758  
    142142} 
    143143 
    144 static int bit_pport_reg(struct i2c_client *client) 
    145 { 
    146         return 0; 
    147 } 
    148  
    149 static int bit_pport_unreg(struct i2c_client *client) 
    150 { 
    151         release_region((base+2),1); 
    152         return 0; 
    153 } 
    154  
    155 static void bit_pport_inc_use(struct i2c_adapter *adap) 
    156 { 
    157 #ifdef MODULE 
    158         MOD_INC_USE_COUNT; 
    159 #endif 
    160 } 
    161  
    162 static void bit_pport_dec_use(struct i2c_adapter *adap) 
    163 { 
    164 #ifdef MODULE 
    165         MOD_DEC_USE_COUNT; 
    166 #endif 
    167 } 
    168144 
    169145/* ------------------------------------------------------------------------ 
     
    182158 
    183159static struct i2c_adapter bit_pport_ops = { 
    184         "Primitive Parallel port adaptor", 
    185         I2C_HW_B_PPORT, 
    186         NULL, 
    187         &bit_pport_data, 
    188         bit_pport_inc_use, 
    189         bit_pport_dec_use, 
    190         bit_pport_reg, 
    191         bit_pport_unreg,         
     160        .owner          = THIS_MODULE, 
     161        .name           = "Primitive Parallel port adaptor", 
     162        .id             = I2C_HW_B_PPORT, 
     163        .algo_data      = &bit_pport_data, 
    192164}; 
    193165 
     
    228200 
    229201MODULE_AUTHOR("Daniel Smolik <marvin@sitour.cz>"); 
    230 MODULE_DESCRIPTION("I2C-Bus adapter routines for Primitive parallel port adapter") 
    231 ; 
     202MODULE_DESCRIPTION("I2C-Bus adapter routines for Primitive parallel port adapter"); 
    232203MODULE_PARM(base, "i"); 
    233204 
  • i2c/trunk/kernel/i2c-proc.c

    r3757 r3758  
    2424*/ 
    2525 
    26 #include <linux/version.h> 
    2726#include <linux/module.h> 
    2827#include <linux/kernel.h> 
     
    3231#include <linux/proc_fs.h> 
    3332#include <linux/ioport.h> 
    34 #include <asm/uaccess.h> 
    3533#include "i2c.h" 
    3634#include "i2c-proc.h" 
    3735#include <linux/init.h> 
    38  
    39 #ifndef THIS_MODULE 
    40 #define THIS_MODULE NULL 
    41 #endif 
     36#include <asm/uaccess.h> 
    4237 
    4338static int i2c_create_name(char **name, const char *prefix, 
     
    8883 
    8984static struct ctl_table_header *i2c_proc_header; 
    90 static int i2c_initialized; 
    9185 
    9286/* This returns a nice name for a new directory; for example lm78-isa-0310 
     
    610604 
    611605        for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { 
     606                /* XXX: WTF is going on here??? */ 
    612607                if ((is_isa && check_region(addr, 1)) || 
    613608                    (!is_isa && i2c_check_addr(adapter, addr))) 
     
    810805} 
    811806 
    812 int __init sensors_init(void) 
     807static int __init i2c_proc_init(void) 
    813808{ 
    814809        printk(KERN_INFO "i2c-proc.o version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    815         i2c_initialized = 0; 
    816810        if (! 
    817811            (i2c_proc_header = 
     
    821815        } 
    822816        i2c_proc_header->ctl_table->child->de->owner = THIS_MODULE; 
    823         i2c_initialized++; 
    824817        return 0; 
    825818} 
    826819 
    827 static void __exit i2c_cleanup(void) 
    828 { 
    829         if (i2c_initialized >= 1) { 
    830                 unregister_sysctl_table(i2c_proc_header); 
    831                 i2c_initialized--; 
    832         } 
     820static void __exit i2c_proc_exit(void) 
     821{ 
     822        unregister_sysctl_table(i2c_proc_header); 
    833823} 
    834824 
     
    843833MODULE_LICENSE("GPL"); 
    844834 
    845 module_init(sensors_init); 
    846 module_exit(i2c_cleanup); 
     835module_init(i2c_proc_init); 
     836module_exit(i2c_proc_exit); 
  • i2c/trunk/kernel/i2c-rpx.c

    r3727 r3758  
    6767} 
    6868 
    69 static int rpx_reg(struct i2c_client *client) 
    70 { 
    71         return 0; 
    72 } 
    73  
    74 static int rpx_unreg(struct i2c_client *client) 
    75 { 
    76         return 0; 
    77 } 
    78  
    79 static void rpx_inc_use(struct i2c_adapter *adap) 
    80 { 
    81 #ifdef MODULE 
    82         MOD_INC_USE_COUNT; 
    83 #endif 
    84 } 
    85  
    86 static void rpx_dec_use(struct i2c_adapter *adap) 
    87 { 
    88 #ifdef MODULE 
    89         MOD_DEC_USE_COUNT; 
    90 #endif 
    91 } 
    92  
    9369static struct i2c_algo_8xx_data rpx_data = { 
    9470        .setisr = rpx_install_isr 
    9571}; 
    9672 
    97  
    9873static struct i2c_adapter rpx_ops = { 
    99         "m8xx", 
    100         I2C_HW_MPC8XX_EPON, 
    101         NULL, 
    102         &rpx_data, 
    103         rpx_inc_use, 
    104         rpx_dec_use, 
    105         rpx_reg, 
    106         rpx_unreg, 
     74        .owner          = THIS_MODULE, 
     75        .name           = "m8xx", 
     76        .id             = I2C_HW_MPC8XX_EPON, 
     77        .algo_data      = &rpx_data, 
    10778}; 
    10879 
     
    12798} 
    12899 
    129 #ifdef MODULE 
    130100MODULE_AUTHOR("Dan Malek <dmalek@jlc.net>"); 
    131101MODULE_DESCRIPTION("I2C-Bus adapter routines for MPC8xx boards"); 
     
    133103module_init(i2c_rpx_init); 
    134104module_exit(i2c_rpx_exit); 
    135 #endif 
    136  
  • i2c/trunk/kernel/i2c-velleman.c

    r3753 r3758  
    9191static int bit_velle_init(void) 
    9292{ 
    93         if (check_region(base,(base == 0x3bc)? 3 : 8) < 0 ) { 
    94                 DEBE(printk(KERN_DEBUG "i2c-velleman.o: Port %#x already in use.\n", 
    95                      base)); 
     93        if (!request_region(base, (base == 0x3bc) ? 3 : 8,  
     94                        "i2c (Vellemann adapter)")) 
    9695                return -ENODEV; 
    97         } else { 
    98                 request_region(base, (base == 0x3bc)? 3 : 8,  
    99                         "i2c (Vellemann adapter)"); 
    100                 bit_velle_setsda((void*)base,1); 
    101                 bit_velle_setscl((void*)base,1); 
    102         } 
     96 
     97        bit_velle_setsda((void*)base,1); 
     98        bit_velle_setscl((void*)base,1); 
    10399        return 0; 
    104 } 
    105  
    106 static void __exit bit_velle_exit(void) 
    107 {        
    108         release_region( base , (base == 0x3bc)? 3 : 8 ); 
    109 } 
    110  
    111  
    112 static int bit_velle_reg(struct i2c_client *client) 
    113 { 
    114         return 0; 
    115 } 
    116  
    117 static int bit_velle_unreg(struct i2c_client *client) 
    118 { 
    119         return 0; 
    120 } 
    121  
    122 static void bit_velle_inc_use(struct i2c_adapter *adap) 
    123 { 
    124 #ifdef MODULE 
    125         MOD_INC_USE_COUNT; 
    126 #endif 
    127 } 
    128  
    129 static void bit_velle_dec_use(struct i2c_adapter *adap) 
    130 { 
    131 #ifdef MODULE 
    132         MOD_DEC_USE_COUNT; 
    133 #endif 
    134100} 
    135101 
     
    149115 
    150116static struct i2c_adapter bit_velle_ops = { 
    151         "Velleman K8000", 
    152         I2C_HW_B_VELLE, 
    153         NULL, 
    154         &bit_velle_data, 
    155         bit_velle_inc_use, 
    156         bit_velle_dec_use, 
    157         bit_velle_reg, 
    158         bit_velle_unreg, 
     117        .owner          = THIS_MODULE, 
     118        .name           = "Velleman K8000", 
     119        .id             = I2C_HW_B_VELLE, 
     120        .algo_data      = &bit_velle_data, 
    159121}; 
    160122 
    161 int __init i2c_bitvelle_init(void) 
     123static int __init i2c_bitvelle_init(void) 
    162124{ 
    163125        printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
     
    185147} 
    186148 
    187 EXPORT_NO_SYMBOLS; 
     149static void __exit i2c_bitvelle_exit(void) 
     150{        
     151        i2c_bit_del_bus(&bit_velle_ops); 
     152        release_region(base, (base == 0x3bc) ? 3 : 8); 
     153} 
    188154 
    189 #ifdef MODULE 
    190155MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    191156MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter"); 
     
    194159MODULE_PARM(base, "i"); 
    195160 
    196 int init_module(void)  
    197 { 
    198         return i2c_bitvelle_init(); 
    199 } 
    200  
    201 void cleanup_module(void)  
    202 { 
    203         i2c_bit_del_bus(&bit_velle_ops); 
    204         bit_velle_exit(); 
    205 } 
    206  
    207 #endif 
     161module_init(i2c_bitvelle_init); 
     162module_exit(i2c_bitvelle_exit); 
  • i2c/trunk/kernel/i2c.h

    r3753 r3758  
    2626/* $Id$ */ 
    2727 
    28 #ifndef I2C_H 
    29 #define I2C_H 
     28#ifndef _LINUX_I2C_H 
     29#define _LINUX_I2C_H 
    3030 
    3131#define I2C_DATE "20021208" 
     
    4141#ifdef __KERNEL__ 
    4242 
    43 /* --- Includes and compatibility declarations ------------------------ */ 
    44  
    45 #include <linux/version.h> 
    46  
    47 #include <asm/page.h>                   /* for 2.2.xx                   */ 
     43#include <linux/config.h> 
    4844#include <asm/semaphore.h> 
    49 #include <linux/config.h> 
     45 
    5046 
    5147/* --- General options ------------------------------------------------ */ 
     
    131127 
    132128struct i2c_driver { 
     129        struct module *owner; 
    133130        char name[32]; 
    134131        int id; 
     
    154151         */ 
    155152        int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 
    156          
    157         /* These two are mainly used for bookkeeping & dynamic unloading of  
    158          * kernel modules. inc_use tells the driver that a client is being   
    159          * used by another module & that it should increase its ref. counter. 
    160          * dec_use is the inverse operation. 
    161          * NB: Make sure you have no circular dependencies, or else you get a  
    162          * deadlock when trying to unload the modules. 
    163         * You should use the i2c_{inc,dec}_use_client functions instead of 
    164         * calling this function directly. 
    165          */ 
    166         void (*inc_use)(struct i2c_client *client); 
    167         void (*dec_use)(struct i2c_client *client); 
    168153}; 
    169154 
     
    228213 */ 
    229214struct i2c_adapter { 
     215        struct module *owner; 
    230216        char name[32];  /* some useful name to identify the adapter     */ 
    231217        unsigned int id;/* == is algo->id | hwdep.struct->id,           */ 
     
    233219        struct i2c_algorithm *algo;/* the algorithm to access the bus   */ 
    234220        void *algo_data; 
    235  
    236         /* --- These may be NULL, but should increase the module use count */ 
    237         void (*inc_use)(struct i2c_adapter *); 
    238         void (*dec_use)(struct i2c_adapter *); 
    239221 
    240222        /* --- administration stuff. */ 
     
    311293extern int i2c_attach_client(struct i2c_client *); 
    312294extern int i2c_detach_client(struct i2c_client *); 
    313  
    314 /* Only call these if you grab a resource that makes unloading the 
    315    client and the adapter it is on completely impossible. Like when a 
    316    /proc directory is entered. */ 
    317 extern void i2c_inc_use_client(struct i2c_client *); 
    318 extern void i2c_dec_use_client(struct i2c_client *); 
    319295 
    320296/* New function: This is to get an i2c_client-struct for controlling the  
     
    593569 
    594570#endif /* def __KERNEL__ */ 
    595 #endif /* I2C_H */ 
     571#endif /* _LINUX_I2C_H */