Changeset 3937

Show
Ignore:
Timestamp:
12/03/04 23:14:09 (4 years ago)
Author:
khali
Message:

Discard owner field of i2c_driver structure, restore inc_use
and dec_use instead (although they don't seem to really have users).

Files:

Legend:

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

    r3933 r3937  
    191191install :: all 
    192192ifeq ($(DESTDIR),) 
    193         @echo "*** If the depmod command below generates errors, you should pay particular" 
    194         @echo "*** attention to the note #1 below." 
    195193        -/sbin/depmod -a 
    196194else 
     
    208206        @echo "*** Installation successful!" 
    209207        @echo "*** Important notes:" 
    210         @echo "*** 1* Due to a change in our i2c structures, i2c-related drivers from" 
    211         @echo "***    the Linux kernel and from external sources won't work with this" 
    212         @echo "***    version of i2c. Such drivers include commonly used video drivers" 
    213         @echo "***    such as bttv and zoran, and less commonly used ones such as" 
    214         @echo "***    i2c-matroxfb. If you really need these, then you shouldn't use our" 
    215         @echo "***    i2c package. If you can live without them, you should make sure" 
    216         @echo "***    such drivers do not exist on your system anymore. Loading them" 
    217         @echo "***    now would result in a severe system crash. We are working on the" 
    218         @echo "***    problem and will soon submit a complete i2c patch for inclusion in" 
    219         @echo "***    the Linux 2.4 kernel." 
     208        @echo "*** 1* Compatibility with the Linux 2.4 kernel has been restored." 
    220209        @echo "*** 2* The i2c-elektor and i2c-pcf-epp modules were not built. If you" 
    221210        @echo "***    need them, you have to use compilation option 3 as described in" 
  • i2c/trunk/doc/writing-clients

    r3920 r3937  
    2626 
    2727static struct i2c_driver foo_driver = { 
    28         .owner          = THIS_MODULE, 
    2928        .name           = "Foo version 2.3 driver", 
    3029        .id             = I2C_DRIVERID_FOO, /* from i2c-id.h, optional */ 
    3130        .flags          = I2C_DF_NOTIFY, 
    32         .attach_adapter = &foo_attach_adapter, 
    33         .detach_client  = &foo_detach_client, 
    34         .command        = &foo_command /* may be NULL */ 
     31        .attach_adapter = foo_attach_adapter, 
     32        .detach_client  = foo_detach_client, 
     33        .command        = foo_command, /* may be NULL */ 
     34        .inc_use        = foo_inc_use, /* May be NULL */ 
     35        .dec_use        = foo_dec_use, /* May be NULL */ 
    3536} 
    3637  
     
    5152below. 
    5253 
    53 There use to be two additional fields in this structure, inc_use et dec_use, 
    54 for module usage count, but these fields were obsoleted and removed. 
     54 
     55Module usage count 
     56================== 
     57 
     58If your driver can also be compiled as a module, there are moments at  
     59which the module can not be removed from memory. For example, when you 
     60are doing a lengthy transaction, or when you create a /proc directory, 
     61and some process has entered that directory. 
     62 
     63i2c-core and i2c-proc will take care of properly counting the users 
     64of the client driver for the common cases. If however your driver has 
     65functions used by other parts of the kernel, you will have to implement 
     66the inc_use and dec_use callback functions and use them. 
     67 
     68To increase or decrease the module usage count, you can use the 
     69MOD_{INC,DEC}_USE_COUNT macros. They must be called from the module 
     70which needs to get its usage count changed; that is why each driver 
     71module has to implement its own callback functions. 
     72 
     73static void foo_inc_use (struct i2c_client *client) 
     74
     75#ifdef MODULE 
     76        MOD_INC_USE_COUNT; 
     77#endif 
     78
     79 
     80static void foo_dec_use (struct i2c_client *client) 
     81
     82#ifdef MODULE 
     83        MOD_DEC_USE_COUNT; 
     84#endif 
     85
     86 
     87Do not call these callback functions directly; instead, use the 
     88following functions defined in i2c.h: 
     89 
     90void i2c_inc_use_client(struct i2c_client *); 
     91void i2c_dec_use_client(struct i2c_client *); 
     92 
     93You should *not* increase the module count just because a device is 
     94detected and a client created. This would make it impossible to remove 
     95an adapter driver!  
    5596 
    5697 
  • i2c/trunk/kernel/i2c-core.c

    r3935 r3937  
    392392static void i2c_inc_use_client(struct i2c_client *client) 
    393393{ 
    394         if(client->driver->owner
    395                 __MOD_INC_USE_COUNT(client->driver->owner); 
     394        if (client->driver->inc_use != NULL
     395                client->driver->inc_use(client); 
    396396        if (client->adapter->inc_use != NULL) 
    397397                client->adapter->inc_use(client->adapter); 
     
    400400static void i2c_dec_use_client(struct i2c_client *client) 
    401401{ 
    402         if(client->driver->owner
    403                 __MOD_DEC_USE_COUNT(client->driver->owner); 
     402        if (client->driver->dec_use != NULL
     403                client->driver->dec_use(client); 
    404404        if (client->adapter->dec_use != NULL) 
    405405                client->adapter->dec_use(client->adapter); 
  • i2c/trunk/kernel/i2c-dev.c

    r3935 r3937  
    8484 
    8585static struct i2c_driver i2cdev_driver = { 
    86         .owner          = THIS_MODULE, /* not really used */ 
    8786        .name           = "i2c-dev dummy driver", 
    8887        .id             = I2C_DRIVERID_I2CDEV, 
  • i2c/trunk/kernel/i2c.h

    r3935 r3937  
    124124 
    125125struct i2c_driver { 
    126         struct module *owner; 
    127126        char name[32]; 
    128127        int id; 
     
    148147         */ 
    149148        int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 
     149         
     150        /* These two are used for bookkeeping & dynamic unloading of  
     151         * kernel modules. inc_use tells the driver that a client is being   
     152         * used by another module & that it should increase its ref. counter. 
     153         * dec_use is the inverse operation. 
     154         * NB: Make sure you have no circular dependencies, or else you get a  
     155         * deadlock when trying to unload the modules. 
     156         * You should use the i2c_{inc,dec}_use_client functions instead of 
     157         * calling this function directly. 
     158         * Note that most clients won't need to implement these, only those 
     159         * which have users inside the kernel (as opposed to only in 
     160         * user-space through i2c-proc). 
     161         */ 
     162        void (*inc_use)(struct i2c_client *client); 
     163        void (*dec_use)(struct i2c_client *client); 
    150164}; 
    151165