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-core.c

    r3316 r3317  
    323323} 
    324324 
     325void i2c_inc_use_client(struct i2c_client *client) 
     326{ 
     327        struct i2c_adapter *adapter = client->adapter; 
     328        struct i2c_algorithm *algo  = adapter->algo; 
     329 
     330        if (client->driver->inc_use != NULL) 
     331                client->driver->inc_use(client); 
     332 
     333        if (algo->inc_use != NULL) 
     334                algo->inc_use(adapter); 
     335} 
     336 
     337void i2c_dec_use_client(struct i2c_client *client) 
     338{ 
     339        struct i2c_adapter *adapter = client->adapter; 
     340        struct i2c_algorithm *algo  = adapter->algo; 
     341 
     342        if (client->driver->dec_use != NULL) 
     343                client->driver->dec_use(client); 
     344 
     345        if (algo->dec_use != NULL) 
     346                algo->dec_use(adapter); 
     347} 
    325348 
    326349/* ---------------------------------------------------- 
     
    610633EXPORT_SYMBOL(i2c_attach_client); 
    611634EXPORT_SYMBOL(i2c_detach_client); 
     635EXPORT_SYMBOL(i2c_inc_use_client); 
     636EXPORT_SYMBOL(i2c_dec_use_client); 
     637 
    612638 
    613639EXPORT_SYMBOL(i2c_master_send);