Show
Ignore:
Timestamp:
07/18/99 14:40:50 (15 years ago)
Author:
frodo
Message:

Second part of Kyösti Mälkki's patches

MOD_{INC,DEC}_USE_COUNT should now really be fail-safe.

I wrote in email to Kyösti about this:

If I understand it correctly, the scheme you propose is as follows:

  • Each struct i2c_algorithm variable has inc_use and dec_use hooks in it.
  • The hooks should do a MOD_{INC,DEC}_USE_COUNT in the appropriate adapter modules (of course, these can only be done in the module which needs to be locked)
  • The struct i2c_driver had already similar hooks, for locking the client modules
  • The i2c_{inc,dec}_use_client function should *not* be called when a client is (de)registered; instead, it should only be called when a resource is used that makes it impossible to remove the client and its adapter. For example, the opening of a /proc file or the moving into a /proc directory owned by the client driver. I have applied the changes to i2c-core and i2c.h as in your patch, as well as to i2c-algo-bit. I saw you added MOD_INC_USE_COUNT to the algorithm drivers. That means we can't remove an algorithm module if an adapter module is still connected to it. Perhaps we should do the same as the in the case a driver module is deleted: scan for connected adapters and remove them one by one (including their clients, of course). What do you think? As i2c-algo-pcf is structured similar to i2c-algo-bit, I saw no reason not to apply the same patches to it, including the MOD_{INC,DEC}_USE_COUNT patch. If you know of a reason why I should not have done this, please tell me and/or revert the changes. I know this will break PCF adapter drivers; well, too bad :-) All included adapter drivers have been patched to do MOD_{INC,DEV}_USE_COUNT calls.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • i2c/trunk/kernel/i2c.h

    r3316 r3317  
    187187        int (*client_register)(struct i2c_client *); 
    188188        int (*client_unregister)(struct i2c_client *); 
     189 
     190        void (*inc_use)(struct i2c_adapter *); 
     191        void (*dec_use)(struct i2c_adapter *); 
    189192}; 
    190193 
     
    242245extern int i2c_attach_client(struct i2c_client *); 
    243246extern int i2c_detach_client(struct i2c_client *); 
     247 
     248extern void i2c_inc_use_client(struct i2c_client *); 
     249extern void i2c_dec_use_client(struct i2c_client *); 
    244250 
    245251