root/i2c/trunk/kernel/i2c-algo-bit.h @ 3317

Revision 3317, 1.1 KB (checked in by frodo, 15 years ago)

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.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
1#ifndef ALGO_BIT_H
2#define ALGO_BIT_H 1
4#include "i2c.h"
6/* --- Defines for bit-adapters --------------------------------------- */
8 * This struct contains the hw-dependent functions of bit-style adapters to
9 * manipulate the line states, and to init any hw-specific features. This is
10 * only used if you have more than one hw-type of adapter running.
11 */
12struct bit_adapter {
13        char name[32];          /* give it a nice name                  */
14        unsigned int id;        /* not used yet, maybe later            */
15        void *data;             /* private data for lowlevel routines   */
16        void (*setsda) (void *data, int state);
17        void (*setscl) (void *data, int state);
18        int  (*getsda) (void *data);
19        int  (*getscl) (void *data);
21        /* administrative calls */
22        int (*client_register)(struct i2c_client *);
23        int (*client_unregister)(struct i2c_client *);
25        void (*inc_use)(struct bit_adapter *);
26        void (*dec_use)(struct bit_adapter *);
28        /* local settings */
29        int udelay;
30        int mdelay;
31        int timeout;
35extern struct bit_adapter *bit_adaps[];
37#define BIT_ADAP_MAX    16
39int i2c_bit_add_bus(struct bit_adapter *);
40int i2c_bit_del_bus(struct bit_adapter *);
42#endif /* ALGO_BIT_H */
Note: See TracBrowser for help on using the browser.