Changeset 3763

Show
Ignore:
Timestamp:
01/15/03 02:11:42 (10 years ago)
Author:
kmalkki
Message:

(Kyösti) Merge from lk2-5-km1

Ported 2.5 changes back to 2.4 and almost everything fits. Lot of
the code was actually 2.2 remains that should have gone away during
2.3 cycle.

In its current status, you cannot compile any of the i2c drivers
that do not come from the CVS, as the module refcounting is
different. We are porting these back from 2.5.53 also.

Location:
i2c/branches/lk2-4/kernel
Files:
2 removed
22 modified

Legend:

Unmodified
Added
Removed
  • i2c/branches/lk2-4/kernel/Module.mk

    r3743 r3763  
    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) 
  • i2c/branches/lk2-4/kernel/i2c-adap-ibm_ocp.c

    r3753 r3763  
    6262#include <asm/irq.h> 
    6363#include <asm/io.h> 
    64 #include <linux/i2c.h> 
    65 #include <linux/i2c-algo-ibm_ocp.h> 
    66 #include <linux/i2c-id.h> 
    6764#include <asm/ocp.h> 
     65 
     66#include "i2c.h" 
     67#include "i2c-algo-ibm_ocp.h" 
    6868 
    6969MODULE_LICENSE("GPL"); 
     
    259259 
    260260// 
    261 // Description: Does nothing 
    262 // 
    263 static int iic_ibmocp_reg(struct i2c_client *client) 
    264 { 
    265         return 0; 
    266 } 
    267  
    268  
    269 // 
    270 // Description: Does nothing 
    271 // 
    272 static int iic_ibmocp_unreg(struct i2c_client *client) 
    273 { 
    274         return 0; 
    275 } 
    276  
    277  
    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 } 
    298  
    299 // 
    300261// Description: Called when the module is loaded.  This function starts the 
    301262// cascade of calls up through the heirarchy of i2c modules (i.e. up to the 
    302263//  algorithm layer and into to the core layer) 
    303264// 
    304 int __init iic_ibmocp_init(void)  
     265static int __init iic_ibmocp_init(void)  
    305266{ 
    306267   int i; 
     
    341302      iic_ibmocp_data[i]->udelay = 80; 
    342303      iic_ibmocp_data[i]->mdelay = 80; 
    343       iic_ibmocp_data[i]->timeout = 100; 
     304      iic_ibmocp_data[i]->timeout = HZ; 
    344305       
    345306            iic_ibmocp_ops[i] = kmalloc(sizeof(struct i2c_adapter), GFP_KERNEL); 
     
    349310      memset(iic_ibmocp_ops[i], 0, sizeof(struct i2c_adapter)); 
    350311      strcpy(iic_ibmocp_ops[i]->name, "IBM OCP IIC adapter"); 
     312      iic_ibmocp_ops[i]->owner = THIS_MODULE; 
    351313      iic_ibmocp_ops[i]->id = I2C_HW_OCP; 
    352314      iic_ibmocp_ops[i]->algo = NULL; 
    353315      iic_ibmocp_ops[i]->algo_data = iic_ibmocp_data[i]; 
    354       iic_ibmocp_ops[i]->inc_use = iic_ibmocp_inc_use; 
    355       iic_ibmocp_ops[i]->dec_use = iic_ibmocp_dec_use; 
    356       iic_ibmocp_ops[i]->client_register = iic_ibmocp_reg; 
    357       iic_ibmocp_ops[i]->client_unregister = iic_ibmocp_unreg; 
    358316        
    359317       
     
    371329 
    372330 
    373 static void iic_ibmocp_exit(void) 
     331static void __exit iic_ibmocp_exit(void) 
    374332{ 
    375333   int i; 
     
    380338   iic_ibmocp_release(); 
    381339} 
    382  
    383 EXPORT_NO_SYMBOLS; 
    384340 
    385341// 
  • i2c/branches/lk2-4/kernel/i2c-algo-8xx.c

    r3753 r3763  
    4141#include <asm/commproc.h> 
    4242 
    43 #include <linux/i2c.h> 
    44 #include <linux/i2c-algo-8xx.h> 
     43#include "i2c.h" 
     44#include "i2c-algo-8xx.h" 
    4545 
    4646#define CPM_MAX_READ    513 
     
    582582 
    583583static struct i2c_algorithm cpm_algo = { 
    584         "MPC8xx CPM algorithm", 
    585         I2C_ALGO_MPC8XX, 
    586         cpm_xfer, 
    587         NULL, 
    588         NULL,                           /* slave_xmit           */ 
    589         NULL,                           /* slave_recv           */ 
    590         algo_control,                   /* ioctl                */ 
    591         cpm_func,                       /* functionality        */ 
     584        .name           = "MPC8xx CPM algorithm", 
     585        .id             = I2C_ALGO_MPC8XX, 
     586        .master_xfer    = cpm_xfer, 
     587        .algo_control   = algo_control, 
     588        .functionality  = cpm_func, 
    592589}; 
    593590 
     
    609606        adap->algo = &cpm_algo; 
    610607 
    611 #ifdef MODULE 
    612608        MOD_INC_USE_COUNT; 
    613 #endif 
    614  
    615609        i2c_add_adapter(adap); 
    616610        cpm_iic_init(cpm_adap); 
     
    643637        printk("i2c-algo-8xx.o: adapter unregistered: %s\n",adap->name); 
    644638 
    645 #ifdef MODULE 
    646639        MOD_DEC_USE_COUNT; 
    647 #endif 
    648640        return 0; 
    649641} 
     
    652644EXPORT_SYMBOL(i2c_8xx_del_bus); 
    653645 
    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 
    662646MODULE_AUTHOR("Brad Parker <brad@heeltoe.com>"); 
    663647MODULE_DESCRIPTION("I2C-Bus MPC8XX algorithm"); 
    664648MODULE_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/branches/lk2-4/kernel/i2c-algo-8xx.h

    r3639 r3763  
    2222#define I2C_ALGO_8XX_H 1 
    2323 
    24 #include <linux/i2c.h> 
     24#include "i2c.h" 
    2525 
    2626struct i2c_algo_8xx_data { 
  • i2c/branches/lk2-4/kernel/i2c-algo-bit.c

    r3753 r3763  
    3434#include <linux/errno.h> 
    3535#include <linux/sched.h> 
     36 
    3637#include "i2c.h" 
    3738#include "i2c-algo-bit.h" 
     
    547548 
    548549static struct i2c_algorithm i2c_bit_algo = { 
    549         "Bit-shift algorithm", 
    550         I2C_ALGO_BIT, 
    551         bit_xfer, 
    552         NULL, 
    553         NULL,                           /* slave_xmit           */ 
    554         NULL,                           /* slave_recv           */ 
    555         algo_control,                   /* ioctl                */ 
    556         bit_func,                       /* functionality        */ 
     550        .name           = "Bit-shift algorithm", 
     551        .id             = I2C_ALGO_BIT, 
     552        .master_xfer    = bit_xfer, 
     553        .algo_control   = algo_control, 
     554        .functionality  = bit_func, 
    557555}; 
    558556 
     
    599597        } 
    600598 
    601 #ifdef MODULE 
    602599        MOD_INC_USE_COUNT; 
    603 #endif 
    604600        i2c_add_adapter(i2c_adap); 
    605  
    606601        return 0; 
    607602} 
     
    617612        DEB2(printk(KERN_DEBUG "i2c-algo-bit.o: adapter unregistered: %s\n",i2c_adap->name)); 
    618613 
    619 #ifdef MODULE 
    620614        MOD_DEC_USE_COUNT; 
    621 #endif 
    622615        return 0; 
    623616} 
    624  
    625 int __init i2c_algo_bit_init (void) 
    626 { 
    627         printk(KERN_INFO "i2c-algo-bit.o: i2c bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    628         return 0; 
    629 } 
    630  
    631617 
    632618 
     
    634620EXPORT_SYMBOL(i2c_bit_del_bus); 
    635621 
    636 #ifdef MODULE 
    637622MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    638623MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); 
     
    647632MODULE_PARM_DESC(i2c_debug, 
    648633            "debug level - 0 off; 1 normal; 2,3 more verbose; 9 bit-protocol"); 
    649  
    650 int init_module(void)  
    651 { 
    652         return i2c_algo_bit_init(); 
    653 } 
    654  
    655 void cleanup_module(void)  
    656 { 
    657 } 
    658 #endif 
  • i2c/branches/lk2-4/kernel/i2c-algo-biths.c

    r3753 r3763  
    366366    if (flags & _HS_NAK) 
    367367        return -EREMOTEIO; 
     368 
     369    return -1; 
    368370} 
    369371 
     
    591593 
    592594static struct i2c_algorithm i2c_algo_biths = { 
    593         "Bit-shift algorithm", 
    594         I2C_ALGO_BIT, 
    595         bit_xfer, 
    596         NULL, 
    597         NULL,                           /* slave_xmit           */ 
    598         NULL,                           /* slave_recv           */ 
    599         algo_control,                   /* ioctl                */ 
    600         bit_func,                       /* functionality        */ 
     595        .name           = "Bit-shift algorithm", 
     596        .id             = I2C_ALGO_BIT, 
     597        .master_xfer    = bit_xfer, 
     598        .algo_control   = algo_control, 
     599        .functionality  = bit_func, 
    601600}; 
    602601 
     
    632631 
    633632static struct i2c_algo_biths_data _old_template = { 
    634     setstate: _old_setstate, 
    635     setsda: _old_setsda, 
    636     setscl: _old_setscl, 
    637     getsda: _old_getsda, 
    638     getscl: _old_getscl, 
     633        .setstate       = _old_setstate, 
     634        .setsda         = _old_setsda, 
     635        .setscl         = _old_setscl, 
     636        .getsda         = _old_getsda, 
     637        .getscl         = _old_getscl, 
    639638}; 
    640639 
     
    724723int i2c_biths_add_bus(struct i2c_adapter *i2c_adap) 
    725724{ 
    726         int i; 
    727725        struct i2c_algo_biths_data *adap = i2c_adap->algo_data; 
    728726 
     
    749747        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: hw routines for %s registered.\n", 
    750748                    i2c_adap->name)); 
    751          
    752         /* register new adapter to i2c module... */ 
    753  
    754         i2c_adap->id |= i2c_algo_biths.id; 
    755         i2c_adap->algo = &i2c_algo_biths; 
    756  
    757         i2c_adap->timeout = HZ; /* default values, should       */ 
    758         i2c_adap->retries = 3;  /* be replaced by defines       */ 
    759  
    760 #ifdef MODULE 
    761         MOD_INC_USE_COUNT; 
    762 #endif 
    763         i2c_add_adapter(i2c_adap); 
    764  
    765         return 0; 
    766 } 
    767  
    768  
    769 int i2c_biths_del_bus(struct i2c_adapter *i2c_adap) 
    770 { 
    771         int res; 
    772  
    773         if ((res = i2c_del_adapter(i2c_adap)) < 0) 
    774                 return res; 
    775  
    776         DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name)); 
    777  
    778 #ifdef MODULE 
    779         MOD_DEC_USE_COUNT; 
    780 #endif 
    781         return 0; 
    782 } 
    783  
    784 int __init i2c_algo_biths_init (void) 
    785 { 
    786         printk(KERN_INFO "i2c-algo-biths.o: i2c high-speed bit algorithm module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    787749#ifdef rdtscl 
    788750        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use rdtscl() for bus clock\n")); 
    789751#else 
    790         DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use udelay() for bus clock\n"); 
     752        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o:  ... will use udelay() for bus clock\n")); 
    791753#endif 
     754         
     755        /* register new adapter to i2c module... */ 
     756 
     757        i2c_adap->id |= i2c_algo_biths.id; 
     758        i2c_adap->algo = &i2c_algo_biths; 
     759 
     760        i2c_adap->timeout = HZ; /* default values, should       */ 
     761        i2c_adap->retries = 3;  /* be replaced by defines       */ 
     762 
     763        MOD_INC_USE_COUNT; 
     764        i2c_add_adapter(i2c_adap); 
     765 
    792766        return 0; 
    793767} 
    794768 
    795769 
     770int i2c_biths_del_bus(struct i2c_adapter *i2c_adap) 
     771{ 
     772        int res; 
     773 
     774        if ((res = i2c_del_adapter(i2c_adap)) < 0) 
     775                return res; 
     776 
     777        DEB1(printk(KERN_DEBUG "i2c-algo-biths.o: adapter unregistered: %s\n",i2c_adap->name)); 
     778        MOD_DEC_USE_COUNT; 
     779        return 0; 
     780} 
    796781 
    797782EXPORT_SYMBOL(i2c_biths_add_bus); 
    798783EXPORT_SYMBOL(i2c_biths_del_bus); 
    799784 
    800 #ifdef MODULE 
    801785MODULE_AUTHOR("Kyösti Mälkki <kmalkki@cc.hut.fi>"); 
    802786MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm"); 
     
    809793MODULE_PARM_DESC(i2c_debug, 
    810794            "debug level - 1 use; 2 fatal, 3 +proto; 4 all, 5 +proto"); 
    811  
    812 int init_module(void)  
    813 { 
    814         return i2c_algo_biths_init(); 
    815 } 
    816  
    817 void cleanup_module(void)  
    818 { 
    819 } 
    820 #endif 
  • i2c/branches/lk2-4/kernel/i2c-algo-ibm_ocp.c

    r3753 r3763  
    6363#include <linux/sched.h> 
    6464 
    65 #include <linux/i2c.h> 
    66 #include <linux/i2c-algo-ibm_ocp.h> 
     65#include "i2c.h" 
     66#include "i2c-algo-ibm_ocp.h" 
    6767#include <asm/ocp.h> 
    6868 
     
    857857 
    858858static struct i2c_algorithm iic_algo = { 
    859         "IBM on-chip IIC algorithm", 
    860         I2C_ALGO_OCP, 
    861         iic_xfer, 
    862         NULL, 
    863         NULL,                           /* slave_xmit           */ 
    864         NULL,                           /* slave_recv           */ 
    865         algo_control,                   /* ioctl                */ 
    866         iic_func,                       /* functionality        */ 
     859        .name           = "IBM on-chip IIC algorithm", 
     860        .id             = I2C_ALGO_OCP, 
     861        .master_xfer    = iic_xfer, 
     862        .algo_control   = algo_control, 
     863        .functionality  = iic_func, 
    867864}; 
    868  
    869865 
    870866/*  
     
    891887        adap->retries = 3;              /* be replaced by defines       */ 
    892888 
    893 #ifdef MODULE 
    894889        MOD_INC_USE_COUNT; 
    895 #endif 
    896  
    897890        iic_init(iic_adap); 
    898891        i2c_add_adapter(adap); 
     
    918911        DEB2(printk(KERN_DEBUG "i2c-algo-iic.o: adapter unregistered: %s\n",adap->name)); 
    919912 
    920 #ifdef MODULE 
    921913        MOD_DEC_USE_COUNT; 
    922 #endif 
    923914        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; 
    940915} 
    941916 
     
    960935        "debug level - 0 off; 1 normal; 2,3 more verbose; 9 iic-protocol"); 
    961936 
    962  
    963 module_init(i2c_algo_iic_init); 
    964 module_exit(i2c_algo_iic_exit); 
  • i2c/branches/lk2-4/kernel/i2c-algo-ibm_ocp.h

    r3714 r3763  
    2626   Changes made to support the IIC peripheral on the IBM PPC 405 */ 
    2727 
    28 #ifndef I2C_ALGO_IIC_H 
    29 #define I2C_ALGO_IIC_H 1 
     28#ifndef I2C_ALGO_IBM_OCP_H 
     29#define I2C_ALGO_IBM_OCP_H 1 
    3030 
    3131/* --- Defines for pcf-adapters --------------------------------------- */ 
    32 #include <linux/i2c.h> 
     32#include "i2c.h" 
    3333 
    3434struct i2c_algo_iic_data { 
     
    5353int i2c_ocp_del_bus(struct i2c_adapter *); 
    5454 
    55 #endif /* I2C_ALGO_IIC_H */ 
     55#endif /* I2C_ALGO_IBM_OCP_H */ 
  • i2c/branches/lk2-4/kernel/i2c-algo-pcf.c

    r3753 r3763  
    3838#include <linux/errno.h> 
    3939#include <linux/sched.h> 
     40 
    4041#include "i2c.h" 
    4142#include "i2c-algo-pcf.h" 
     
    442443 
    443444static struct i2c_algorithm pcf_algo = { 
    444         "PCF8584 algorithm", 
    445         I2C_ALGO_PCF, 
    446         pcf_xfer, 
    447         NULL, 
    448         NULL,                           /* slave_xmit           */ 
    449         NULL,                           /* slave_recv           */ 
    450         algo_control,                   /* ioctl                */ 
    451         pcf_func,                       /* functionality        */ 
     445        .name           = "PCF8584 algorithm", 
     446        .id             = I2C_ALGO_PCF, 
     447        .master_xfer    = pcf_xfer, 
     448        .algo_control   = algo_control, 
     449        .functionality  = pcf_func, 
    452450}; 
    453451 
     
    475473        } 
    476474 
    477 #ifdef MODULE 
    478475        MOD_INC_USE_COUNT; 
    479 #endif 
    480  
    481476        i2c_add_adapter(adap); 
    482477 
     
    510505int i2c_pcf_del_bus(struct i2c_adapter *adap) 
    511506{ 
    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 
    518507        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  
     508        return i2c_del_adapter(adap); 
     509} 
    529510 
    530511EXPORT_SYMBOL(i2c_pcf_add_bus); 
    531512EXPORT_SYMBOL(i2c_pcf_del_bus); 
    532513 
    533 #ifdef MODULE 
    534514MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>"); 
    535515MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm"); 
     
    542522MODULE_PARM_DESC(i2c_debug, 
    543523        "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/branches/lk2-4/kernel/i2c-core.c

    r3753 r3763  
    3737#include <linux/init.h> 
    3838 
    39  
    4039#include <asm/uaccess.h> 
    4140 
     
    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); 
     
    8882                           int *eof , void *private); 
    8983 
     84static int i2cproc_register(struct i2c_adapter *adap, int bus); 
     85static void i2cproc_remove(int bus); 
    9086/* To implement the dynamic /proc/bus/i2c-? files, we need our own  
    9187   implementation of the read hook */ 
     
    9389        .read           = i2cproc_bus_read, 
    9490}; 
    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  
    10491#endif /* CONFIG_PROC_FS */ 
    10592 
     
    139126 
    140127#ifdef CONFIG_PROC_FS 
    141  
    142         if (i2cproc_initialized) { 
    143                 char name[8]; 
    144                 struct proc_dir_entry *proc_entry; 
    145  
    146                 sprintf(name,"i2c-%d", i); 
    147  
    148                 proc_entry = create_proc_entry(name,0,proc_bus); 
    149                 if (! proc_entry) { 
    150                         printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/%s\n", 
    151                                name); 
    152                         res = -ENOENT; 
    153                         goto ERROR1; 
    154                 } 
    155  
    156                 proc_entry->proc_fops = &i2cproc_operations; 
    157                 proc_entry->owner = THIS_MODULE; 
    158                 adap->inode = proc_entry->low_ino; 
    159         } 
    160  
     128        res = i2cproc_register(adap, i); 
     129        if (res<0) 
     130            goto ERROR1; 
    161131#endif /* def CONFIG_PROC_FS */ 
    162132 
     
    237207        } 
    238208#ifdef CONFIG_PROC_FS 
    239         if (i2cproc_initialized) { 
    240                 char name[8]; 
    241                 sprintf(name,"i2c-%d", i); 
    242                 remove_proc_entry(name,proc_bus); 
    243         } 
     209        i2cproc_remove(i); 
    244210#endif /* def CONFIG_PROC_FS */ 
    245211 
     
    462428} 
    463429 
    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); 
     430static void i2c_inc_use_client(struct i2c_client *client) 
     431{ 
     432        __MOD_INC_USE_COUNT(client->driver->owner); 
     433        __MOD_INC_USE_COUNT(client->adapter->owner); 
     434} 
     435 
     436static void i2c_dec_use_client(struct i2c_client *client) 
     437{ 
     438        __MOD_DEC_USE_COUNT(client->driver->owner); 
     439        __MOD_DEC_USE_COUNT(client->adapter->owner); 
    482440} 
    483441 
     
    551509int i2c_use_client(struct i2c_client *client) 
    552510{ 
    553         if(client->flags & I2C_CLIENT_ALLOW_USE) { 
    554                 if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)  
     511        if (client->flags & I2C_CLIENT_ALLOW_USE) { 
     512                if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE) 
    555513                        client->usage_count++; 
    556                 else { 
    557                         if(client->usage_count > 0)  
    558                                 return -EBUSY; 
    559                          else  
    560                                 client->usage_count++; 
    561                 } 
     514                else if (client->usage_count > 0)  
     515                        return -EBUSY; 
     516                else  
     517                        client->usage_count++; 
    562518        } 
    563519 
     
    590546 
    591547#ifdef CONFIG_PROC_FS 
    592  
    593548 
    594549/* This function generates the output for /proc/bus/i2c */ 
     
    683638} 
    684639 
    685 int i2cproc_init(void) 
    686 { 
    687  
     640 
     641static int i2cproc_register(struct i2c_adapter *adap, int bus) 
     642{ 
     643        char name[8]; 
     644        struct proc_dir_entry *proc_entry; 
     645 
     646        sprintf(name,"i2c-%d", bus); 
     647        proc_entry = create_proc_entry(name,0,proc_bus); 
     648        if (! proc_entry) { 
     649                printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/%s\n", 
     650                       name); 
     651                return -ENOENT; 
     652        } 
     653             
     654        proc_entry->proc_fops = &i2cproc_operations; 
     655        proc_entry->owner = THIS_MODULE; 
     656        adap->inode = proc_entry->low_ino; 
     657        return 0; 
     658} 
     659 
     660static void i2cproc_remove(int bus) 
     661{ 
     662        char name[8]; 
     663        sprintf(name,"i2c-%d", bus); 
     664        remove_proc_entry(name, proc_bus); 
     665} 
     666 
     667static int __init i2cproc_init(void) 
     668{ 
    688669        struct proc_dir_entry *proc_bus_i2c; 
    689670 
    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         }  
    697671        proc_bus_i2c = create_proc_entry("i2c",0,proc_bus); 
    698672        if (!proc_bus_i2c) { 
    699673                printk(KERN_ERR "i2c-core.o: Could not create /proc/bus/i2c"); 
    700                 i2cproc_cleanup(); 
    701674                return -ENOENT; 
    702675        } 
     676 
    703677        proc_bus_i2c->read_proc = &read_bus_i2c; 
    704678        proc_bus_i2c->owner = THIS_MODULE; 
    705         i2cproc_initialized += 2; 
    706679        return 0; 
    707680} 
    708681 
    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  
     682static void __exit i2cproc_cleanup(void) 
     683{ 
     684        remove_proc_entry("i2c",proc_bus); 
     685} 
    720686#endif /* def CONFIG_PROC_FS */ 
     687 
    721688 
    722689/* ---------------------------------------------------- 
     
    14541421        init_MUTEX(&driver_lock); 
    14551422         
     1423#ifdef CONFIG_PROC_FS 
    14561424        i2cproc_init(); 
    1457          
     1425#endif 
     1426 
    14581427        return 0; 
    14591428} 
     
    14611430static void __exit i2c_exit(void)  
    14621431{ 
     1432#ifdef CONFIG_PROC_FS 
    14631433        i2cproc_cleanup(); 
    1464 } 
    1465  
    1466 #ifndef MODULE 
    1467 #ifdef CONFIG_I2C_CHARDEV 
    1468         extern int i2c_dev_init(void); 
    14691434#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  
     1435} 
    15901436 
    15911437EXPORT_SYMBOL(i2c_add_adapter); 
     
    15951441EXPORT_SYMBOL(i2c_attach_client); 
    15961442EXPORT_SYMBOL(i2c_detach_client); 
    1597 EXPORT_SYMBOL(i2c_inc_use_client); 
    1598 EXPORT_SYMBOL(i2c_dec_use_client); 
    15991443EXPORT_SYMBOL(i2c_get_client); 
    16001444EXPORT_SYMBOL(i2c_use_client); 
     
    16291473MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    16301474MODULE_DESCRIPTION("I2C-Bus main module"); 
     1475MODULE_LICENSE("GPL"); 
     1476 
    16311477MODULE_PARM(i2c_debug, "i"); 
    16321478MODULE_PARM_DESC(i2c_debug,"debug level"); 
    1633 MODULE_LICENSE("GPL"); 
    16341479 
    16351480module_init(i2c_init); 
  • i2c/branches/lk2-4/kernel/i2c-dev.c

    r3753 r3763  
    102102}; 
    103103 
    104 static int i2cdev_initialized; 
    105  
    106  
    107104static ssize_t i2cdev_read (struct file *file, char *buf, size_t count, 
    108105                            loff_t *offset) 
     
    126123 
    127124#ifdef DEBUG 
    128         printk(KERN_DEBUG "i2c-dev.o: i2c-%d reading %d bytes.\n",MINOR(inode->i_rdev), 
     125        printk(KERN_DEBUG "i2c-dev.o: i2c-%d reading %d bytes.\n",minor(inode->i_rdev), 
    129126               count); 
    130127#endif 
     
    161158 
    162159#ifdef DEBUG 
    163         printk(KERN_DEBUG "i2c-dev.o: i2c-%d writing %d bytes.\n",MINOR(inode->i_rdev), 
     160        printk(KERN_DEBUG "i2c-dev.o: i2c-%d writing %d bytes.\n",minor(inode->i_rdev), 
    164161               count); 
    165162#endif 
     
    182179#ifdef DEBUG 
    183180        printk(KERN_DEBUG "i2c-dev.o: i2c-%d ioctl, cmd: 0x%x, arg: %lx.\n",  
    184                MINOR(inode->i_rdev),cmd, arg); 
     181               minor(inode->i_rdev),cmd, arg); 
    185182#endif /* DEBUG */ 
    186183 
     
    355352int i2cdev_open (struct inode *inode, struct file *file) 
    356353{ 
    357         unsigned int minor = MINOR(inode->i_rdev); 
     354        unsigned int minor = minor(inode->i_rdev); 
    358355        struct i2c_client *client; 
    359356 
     
    374371        file->private_data = client; 
    375372 
    376         if (i2cdev_adaps[minor]->inc_use) 
    377                 i2cdev_adaps[minor]->inc_use(i2cdev_adaps[minor]); 
     373        __MOD_INC_USE_COUNT(i2cdev_adaps[minor]->owner); 
    378374 
    379375#ifdef DEBUG 
     
    385381static int i2cdev_release (struct inode *inode, struct file *file) 
    386382{ 
    387         unsigned int minor = MINOR(inode->i_rdev); 
     383        unsigned int minor = minor(inode->i_rdev); 
    388384        kfree(file->private_data); 
    389385        file->private_data=NULL; 
     
    391387        printk(KERN_DEBUG "i2c-dev.o: Closed: i2c-%d\n", minor); 
    392388#endif 
    393         lock_kernel(); 
    394         if (i2cdev_adaps[minor]->dec_use) 
    395                 i2cdev_adaps[minor]->dec_use(i2cdev_adaps[minor]); 
    396         unlock_kernel(); 
     389        __MOD_DEC_USE_COUNT(i2cdev_adaps[minor]->owner); 
    397390        return 0; 
    398391} 
     
    447440} 
    448441 
    449 static void i2cdev_cleanup(void) 
     442int __init i2c_dev_init(void) 
    450443{ 
    451444        int res; 
    452445 
    453         if (i2cdev_initialized >= 2) { 
    454                 if ((res = i2c_del_driver(&i2cdev_driver))) { 
    455                         printk(KERN_ERR "i2c-dev.o: Driver deregistration failed, " 
    456                                "module not removed.\n"); 
    457                 } 
    458         i2cdev_initialized --; 
    459         } 
    460  
    461         if (i2cdev_initialized >= 1) { 
    462 #ifdef CONFIG_DEVFS_FS 
    463                 devfs_unregister(devfs_handle); 
    464 #endif 
    465                 if ((res = unregister_chrdev(I2C_MAJOR,"i2c"))) { 
    466                         printk(KERN_ERR "i2c-dev.o: unable to release major %d for i2c bus\n", 
    467                                I2C_MAJOR); 
    468                 } 
    469                 i2cdev_initialized --; 
    470         } 
    471 } 
    472  
    473 int __init i2c_dev_init(void) 
    474 { 
    475         int res; 
    476  
    477446        printk(KERN_INFO "i2c-dev.o: i2c /dev entries driver module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    478447 
    479         i2cdev_initialized = 0; 
    480448#ifdef CONFIG_DEVFS_FS 
    481449        if (devfs_register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops)) { 
     
    490458        devfs_handle = devfs_mk_dir(NULL, "i2c", NULL); 
    491459#endif 
    492         i2cdev_initialized ++; 
    493  
    494460        if ((res = i2c_add_driver(&i2cdev_driver))) { 
    495461                printk(KERN_ERR "i2c-dev.o: Driver registration failed, module not inserted.\n"); 
    496                 i2cdev_cleanup(); 
     462#ifdef CONFIG_DEVFS_FS 
     463                devfs_unregister(devfs_handle); 
     464#endif 
     465                unregister_chrdev(I2C_MAJOR,"i2c"); 
    497466                return res; 
    498467        } 
    499         i2cdev_initialized ++; 
    500         return 0; 
    501 } 
    502  
    503 EXPORT_NO_SYMBOLS; 
     468        return 0; 
     469} 
     470 
     471static void __exit i2c_dev_exit(void) 
     472{ 
     473        i2c_del_driver(&i2cdev_driver); 
     474#ifdef CONFIG_DEVFS_FS 
     475        devfs_unregister(devfs_handle); 
     476#endif 
     477        unregister_chrdev(I2C_MAJOR,"i2c"); 
     478} 
    504479 
    505480MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
     
    508483 
    509484module_init(i2c_dev_init); 
    510 module_exit(i2cdev_cleanup); 
     485module_exit(i2c_dev_exit); 
  • i2c/branches/lk2-4/kernel/i2c-dev.h

    r3661 r3763  
    2222/* $Id$ */ 
    2323 
    24 #ifndef I2C_DEV_H 
    25 #define I2C_DEV_H 
    26  
    27  
     24#ifndef _LINUX_I2C_DEV_H 
     25#define _LINUX_I2C_DEV_H 
     26 
     27#include <linux/version.h> 
    2828#include <linux/types.h> 
    2929#include "i2c.h" 
     30 
     31#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) 
     32#define minor(d) MINOR(d) 
     33#endif 
    3034 
    3135/* Some IOCTL commands are defined in <linux/i2c.h> */ 
     
    216220#endif /* ndef __KERNEL__ */ 
    217221 
    218 #endif 
     222#endif /* _LINUX_I2C_DEV_H */ 
  • i2c/branches/lk2-4/kernel/i2c-elektor.c

    r3754 r3763  
    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/branches/lk2-4/kernel/i2c-elv.c

    r3753 r3763  
    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 
     
    148121 */ 
    149122static struct i2c_algo_bit_data bit_elv_data = { 
    150         NULL, 
    151         bit_elv_setsda, 
    152         bit_elv_setscl, 
    153         bit_elv_getsda, 
    154         bit_elv_getscl, 
    155         80, 80, HZ,             /*      waits, timeout */ 
     123        .setsda         = bit_elv_setsda, 
     124        .setscl         = bit_elv_setscl, 
     125        .getsda         = bit_elv_getsda, 
     126        .getscl         = bit_elv_getscl, 
     127        .udelay         = 80, 
     128        .mdelay         = 80, 
     129        .timeout        = HZ 
    156130}; 
    157131 
    158132static 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,   
     133        .owner          = THIS_MODULE, 
     134        .name           = "ELV Parallel port adaptor", 
     135        .id             = I2C_HW_B_ELV, 
     136        .algo_data      = &bit_elv_data, 
    167137}; 
    168138 
    169 int __init i2c_bitelv_init(void) 
     139static int __init i2c_bitelv_init(void) 
    170140{ 
    171141        printk(KERN_INFO "i2c-elv.o: i2c ELV parallel port adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
     
    193163} 
    194164 
     165static void __exit i2c_bitelv_exit(void) 
     166{ 
     167        i2c_bit_del_bus(&bit_elv_ops); 
     168        release_region(base , (base == 0x3bc) ? 3 : 8); 
     169} 
    195170 
    196171EXPORT_NO_SYMBOLS; 
    197172 
    198 #ifdef MODULE 
    199173MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    200174MODULE_DESCRIPTION("I2C-Bus adapter routines for ELV parallel port adapter"); 
     
    203177MODULE_PARM(base, "i"); 
    204178 
    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 
     179module_init(i2c_bitelv_init); 
     180module_exit(i2c_bitelv_exit); 
  • i2c/branches/lk2-4/kernel/i2c-frodo.c

    r3753 r3763  
    2323#include <asm/hardware.h> 
    2424 
    25 #include <linux/i2c.h> 
    26 #include <linux/i2c-algo-bit.h> 
     25#include "i2c.h" 
     26#include "i2c-algo-bit.h" 
    2727 
    2828static void frodo_setsda (void *data,int state) 
     
    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 
    94 int __init i2c_frodo_init (void) 
     71static 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/branches/lk2-4/kernel/i2c-pcf-epp.c

    r3754 r3763  
    175175} 
    176176 
    177  
    178 static void __exit pcf_epp_exit(void) 
    179 { 
    180   if (gpe.pe_irq > 0) { 
    181     disable_irq(gpe.pe_irq); 
    182     free_irq(gpe.pe_irq, 0); 
    183   } 
    184   release_region(gpe.pe_base , 5); 
    185 } 
    186  
    187  
    188 static int pcf_epp_reg(struct i2c_client *client) 
    189 { 
    190   return 0; 
    191 } 
    192  
    193  
    194 static int pcf_epp_unreg(struct i2c_client *client) 
    195 { 
    196   return 0; 
    197 } 
    198  
    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 } 
    212  
    213  
    214177/* ------------------------------------------------------------------------ 
    215178 * Encapsulate the above functions in the correct operations structure. 
     
    217180 */ 
    218181static struct i2c_algo_pcf_data pcf_epp_data = { 
    219   NULL, 
    220   pcf_epp_setbyte, 
    221   pcf_epp_getbyte, 
    222   pcf_epp_getown, 
    223   pcf_epp_getclock, 
    224   pcf_epp_waitforpin, 
    225   80, 80, 100,          /*      waits, timeout */ 
     182        .setpcf     = pcf_epp_setbyte, 
     183        .getpcf     = pcf_epp_getbyte, 
     184        .getown     = pcf_epp_getown, 
     185        .getclock   = pcf_epp_getclock, 
     186        .waitforpin = pcf_epp_waitforpin, 
     187        .udelay     = 80, 
     188        .mdelay     = 80, 
     189        .timeout    = HZ, 
    226190}; 
    227191 
    228192static struct i2c_adapter pcf_epp_ops = { 
    229   "PCF8584 EPP adapter", 
    230   I2C_HW_P_LP, 
    231   NULL, 
    232   &pcf_epp_data, 
    233   pcf_epp_inc_use, 
    234   pcf_epp_dec_use, 
    235   pcf_epp_reg, 
    236   pcf_epp_unreg, 
     193        .owner          = THIS_MODULE, 
     194        .name           = "PCF8584 EPP adapter", 
     195        .id             = I2C_HW_P_LP, 
     196        .algo_data      = &pcf_epp_data, 
    237197}; 
    238198 
    239 int __init i2c_pcfepp_init(void)  
     199static int __init i2c_pcfepp_init(void)  
    240200{ 
    241201  struct i2c_pcf_epp *pepp = &gpe; 
     
    282242} 
    283243 
    284  
    285 EXPORT_NO_SYMBOLS; 
    286  
    287 #ifdef MODULE 
     244static void __exit pcf_epp_exit(void) 
     245{ 
     246  i2c_pcf_del_bus(&pcf_epp_ops); 
     247  if (gpe.pe_irq > 0) { 
     248    disable_irq(gpe.pe_irq); 
     249    free_irq(gpe.pe_irq, 0); 
     250  } 
     251  release_region(gpe.pe_base , 5); 
     252} 
     253 
    288254MODULE_AUTHOR("Hans Berglund <hb@spacetec.no> \n modified by Ryosuke Tajima <rosk@jsk.t.u-tokyo.ac.jp>"); 
    289255MODULE_DESCRIPTION("I2C-Bus adapter routines for PCF8584 EPP parallel port adapter"); 
     
    295261MODULE_PARM(i2c_debug, "i"); 
    296262 
    297 int init_module(void)  
    298 { 
    299   return i2c_pcfepp_init(); 
    300 } 
    301  
    302 void cleanup_module(void)  
    303 { 
    304   i2c_pcf_del_bus(&pcf_epp_ops); 
    305   pcf_epp_exit(); 
    306 } 
    307  
    308 #endif 
    309  
    310  
     263module_init(i2c_pcfepp_init); 
     264module_exit(pcf_epp_exit); 
  • i2c/branches/lk2-4/kernel/i2c-philips-par.c

    r3753 r3763  
    130130} 
    131131 
    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; 
    150 } 
    151  
    152132/* ------------------------------------------------------------------------ 
    153133 * Encapsulate the above functions in the correct operations structure. 
     
    156136  
    157137static struct i2c_algo_bit_data bit_lp_data = { 
    158         NULL, 
    159         bit_lp_setsda, 
    160         bit_lp_setscl, 
    161         bit_lp_getsda, 
    162         bit_lp_getscl, 
    163         80, 80, HZ,             /*      waits, timeout */ 
     138        .setsda         = bit_lp_setsda, 
     139        .setscl         = bit_lp_setscl, 
     140        .getsda         = bit_lp_getsda, 
     141        .getscl         = bit_lp_getscl, 
     142        .udelay         = 80, 
     143        .mdelay         = 80, 
     144        .timeout        = HZ 
    164145};  
    165146 
    166147static struct i2c_algo_bit_data bit_lp_data2 = { 
    167         NULL, 
    168         bit_lp_setsda2, 
    169         bit_lp_setscl2, 
    170         bit_lp_getsda2, 
    171         NULL, 
    172         80, 80, HZ,             /*      waits, timeout */ 
     148        .setsda         = bit_lp_setsda2, 
     149        .setscl         = bit_lp_setscl2, 
     150        .getsda         = bit_lp_getsda2, 
     151        .udelay         = 80, 
     152        .mdelay         = 80, 
     153        .timeout        = HZ 
    173154};  
    174155 
    175156static 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, 
     157        .owner          = THIS_MODULE, 
     158        .name           = "Philips Parallel port adapter", 
     159        .id             = I2C_HW_B_LP, 
    185160}; 
    186161 
     
    284259MODULE_PARM(type, "i"); 
    285260 
    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 
     261module_init(i2c_bitlp_init); 
     262module_exit(i2c_bitlp_exit); 
  • i2c/branches/lk2-4/kernel/i2c-pport.c

    r3753 r3763  
    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/* ------------------------------------------------------------------------ 
     
    172148 */ 
    173149static struct i2c_algo_bit_data bit_pport_data = { 
    174         NULL, 
    175         bit_pport_setsda, 
    176         bit_pport_setscl, 
    177         bit_pport_getsda, 
    178         bit_pport_getscl, 
    179         //NULL, 
    180         40, 80, HZ,             /*      waits, timeout */ 
     150        .setsda         = bit_pport_setsda, 
     151        .setscl         = bit_pport_setscl, 
     152        .getsda         = bit_pport_getsda, 
     153        .getscl         = bit_pport_getscl, 
     154        .udelay         = 40, 
     155        .mdelay         = 80, 
     156        .timeout        = HZ 
    181157}; 
    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/branches/lk2-4/kernel/i2c-proc.c

    r3753 r3763  
    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, 
     
    5954 
    6055static struct i2c_client *i2c_clients[SENSORS_ENTRY_MAX]; 
    61 static unsigned short i2c_inodes[SENSORS_ENTRY_MAX]; 
    6256 
    6357static ctl_table sysctl_table[] = { 
     
    8983 
    9084static struct ctl_table_header *i2c_proc_header; 
    91 static int i2c_initialized; 
    9285 
    9386/* This returns a nice name for a new directory; for example lm78-isa-0310 
     
    199192        } 
    200193#endif                          /* DEBUG */ 
    201         i2c_inodes[id - 256] = 
    202             new_header->ctl_table->child->child->de->low_ino; 
    203194        new_header->ctl_table->child->child->de->owner = controlling_mod; 
    204195 
     
    221212                i2c_clients[id] = NULL; 
    222213        } 
    223 } 
    224  
    225 /* Monitor access for /proc/sys/dev/sensors; make unloading i2c-proc.o  
    226    impossible if some process still uses it or some file in it */ 
    227 void i2c_fill_inode(struct inode *inode, int fill) 
    228 { 
    229         if (fill) 
    230                 MOD_INC_USE_COUNT; 
    231         else 
    232                 MOD_DEC_USE_COUNT; 
    233 } 
    234  
    235 /* Monitor access for /proc/sys/dev/sensors/ directories; make unloading 
    236    the corresponding module impossible if some process still uses it or 
    237    some file in it */ 
    238 void i2c_dir_fill_inode(struct inode *inode, int fill) 
    239 { 
    240         int i; 
    241         struct i2c_client *client; 
    242  
    243 #ifdef DEBUG 
    244         if (!inode) { 
    245                 printk(KERN_ERR "i2c-proc.o: Warning: inode NULL in fill_inode()\n"); 
    246                 return; 
    247         } 
    248 #endif                          /* def DEBUG */ 
    249  
    250         for (i = 0; i < SENSORS_ENTRY_MAX; i++) 
    251                 if (i2c_clients[i] 
    252                     && (i2c_inodes[i] == inode->i_ino)) break; 
    253 #ifdef DEBUG 
    254         if (i == SENSORS_ENTRY_MAX) { 
    255                 printk 
    256                     (KERN_ERR "i2c-proc.o: Warning: inode (%ld) not found in fill_inode()\n", 
    257                      inode->i_ino); 
    258                 return; 
    259         } 
    260 #endif                          /* def DEBUG */ 
    261         client = i2c_clients[i]; 
    262         if (fill) 
    263                 client->driver->inc_use(client); 
    264         else 
    265                 client->driver->dec_use(client); 
    266214} 
    267215 
     
    656604 
    657605        for (addr = 0x00; addr <= (is_isa ? 0xffff : 0x7f); addr++) { 
     606                /* XXX: WTF is going on here??? */ 
    658607                if ((is_isa && check_region(addr, 1)) || 
    659608                    (!is_isa && i2c_check_addr(adapter, addr))) 
     
    856805} 
    857806 
    858 int __init sensors_init(void) 
     807static int __init i2c_proc_init(void) 
    859808{ 
    860809        printk(KERN_INFO "i2c-proc.o version %s (%s)\n", I2C_VERSION, I2C_DATE); 
    861         i2c_initialized = 0; 
    862810        if (! 
    863811            (i2c_proc_header = 
     
    867815        } 
    868816        i2c_proc_header->ctl_table->child->de->owner = THIS_MODULE; 
    869         i2c_initialized++; 
    870817        return 0; 
    871818} 
    872819 
    873 static void __exit i2c_cleanup(void) 
    874 { 
    875         if (i2c_initialized >= 1) { 
    876                 unregister_sysctl_table(i2c_proc_header); 
    877                 i2c_initialized--; 
    878         } 
     820static void __exit i2c_proc_exit(void) 
     821{ 
     822        unregister_sysctl_table(i2c_proc_header); 
    879823} 
    880824 
     
    889833MODULE_LICENSE("GPL"); 
    890834 
    891 module_init(sensors_init); 
    892 module_exit(i2c_cleanup); 
     835module_init(i2c_proc_init); 
     836module_exit(i2c_proc_exit); 
  • i2c/branches/lk2-4/kernel/i2c-rpx.c

    r3727 r3763  
    2222#include <asm/commproc.h> 
    2323 
    24 #include <linux/i2c.h> 
    25 #include <linux/i2c-algo-8xx.h> 
     24#include "i2c.h" 
     25#include "i2c-algo-8xx.h" 
    2626 
    2727static void 
     
    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/branches/lk2-4/kernel/i2c-velleman.c

    r3753 r3763  
    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 
     
    140106 
    141107static struct i2c_algo_bit_data bit_velle_data = { 
    142         NULL, 
    143         bit_velle_setsda, 
    144         bit_velle_setscl, 
    145         bit_velle_getsda, 
    146         bit_velle_getscl, 
    147         10, 10, HZ,             /*      waits, timeout */ 
     108        .setsda         = bit_velle_setsda, 
     109        .setscl         = bit_velle_setscl, 
     110        .getsda         = bit_velle_getsda, 
     111        .getscl         = bit_velle_getscl, 
     112        .udelay         = 10, 
     113        .mdelay         = 10, 
     114        .timeout        = HZ 
    148115}; 
    149116 
    150117static 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, 
     118        .owner          = THIS_MODULE, 
     119        .name           = "Velleman K8000", 
     120        .id             = I2C_HW_B_VELLE, 
     121        .algo_data      = &bit_velle_data, 
    159122}; 
    160123 
    161 int __init i2c_bitvelle_init(void) 
     124static int __init i2c_bitvelle_init(void) 
    162125{ 
    163126        printk(KERN_INFO "i2c-velleman.o: i2c Velleman K8000 adapter module version %s (%s)\n", I2C_VERSION, I2C_DATE); 
     
    185148} 
    186149 
    187 EXPORT_NO_SYMBOLS; 
     150static void __exit i2c_bitvelle_exit(void) 
     151{        
     152        i2c_bit_del_bus(&bit_velle_ops); 
     153        release_region(base, (base == 0x3bc) ? 3 : 8); 
     154} 
    188155 
    189 #ifdef MODULE 
    190156MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 
    191157MODULE_DESCRIPTION("I2C-Bus adapter routines for Velleman K8000 adapter"); 
     
    194160MODULE_PARM(base, "i"); 
    195161 
    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 
     162module_init(i2c_bitvelle_init); 
     163module_exit(i2c_bitvelle_exit); 
  • i2c/branches/lk2-4/kernel/i2c.h

    r3753 r3763  
    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  
    4543#include <linux/version.h> 
    46  
    47 #include <asm/page.h>                   /* for 2.2.xx                   */ 
     44#include <linux/config.h> 
    4845#include <asm/semaphore.h> 
    49 #include <linux/config.h> 
     46 
     47#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) 
     48#define MODULE_LICENSE(x) 
     49#endif 
    5050 
    5151/* --- General options ------------------------------------------------ */ 
     
    131131 
    132132struct i2c_driver { 
     133        struct module *owner; 
    133134        char name[32]; 
    134135        int id; 
     
    154155         */ 
    155156        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); 
    168157}; 
    169158 
     
    228217 */ 
    229218struct i2c_adapter { 
     219        struct module *owner; 
    230220        char name[32];  /* some useful name to identify the adapter     */ 
    231221        unsigned int id;/* == is algo->id | hwdep.struct->id,           */ 
     
    233223        struct i2c_algorithm *algo;/* the algorithm to access the bus   */ 
    234224        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 *); 
    239225 
    240226        /* --- administration stuff. */ 
     
    311297extern int i2c_attach_client(struct i2c_client *); 
    312298extern 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 *); 
    319299 
    320300/* New function: This is to get an i2c_client-struct for controlling the  
     
    593573 
    594574#endif /* def __KERNEL__ */ 
    595 #endif /* I2C_H */ 
     575#endif /* _LINUX_I2C_H */