]> err.no Git - linux-2.6/blobdiff - include/linux/i2c.h
[PATCH] I2C: m41t00: Add support for the ST M41T81 and M41T85
[linux-2.6] / include / linux / i2c.h
index 3c16a8fb95f4459e2e465f20c93cbf24799e5019..0510430e00dbc88bcfc045bd4f7463ad32bbcc95 100644 (file)
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
 /* ------------------------------------------------------------------------- */
 
-/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
+/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
    Frodo Looijaard <frodol@dds.nl> */
 
 #ifndef _LINUX_I2C_H
 #define _LINUX_I2C_H
 
-#include <linux/module.h>
 #include <linux/types.h>
+#ifdef __KERNEL__ 
+#include <linux/module.h>
 #include <linux/i2c-id.h>
 #include <linux/mod_devicetable.h>
 #include <linux/device.h>      /* for struct device */
 #include <linux/sched.h>       /* for completion */
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 
 /* --- For i2c-isa ---------------------------------------------------- */
 
@@ -100,16 +101,20 @@ extern s32 i2c_smbus_write_block_data(struct i2c_client * client,
 /* Returns the number of read bytes */
 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client,
                                         u8 command, u8 *values);
+extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
+                                         u8 command, u8 length,
+                                         u8 *values);
 
 /*
  * A driver is capable of handling one or more physical devices present on
  * I2C adapters. This information is used to inform the driver of adapter
  * events.
+ *
+ * The driver.owner field should be set to the module owner of this driver.
+ * The driver.name field should be set to the name of this driver.
  */
 
 struct i2c_driver {
-       struct module *owner;
-       char name[32];
        int id;
        unsigned int class;
 
@@ -221,8 +226,8 @@ struct i2c_adapter {
        int (*client_unregister)(struct i2c_client *);
 
        /* data fields that are valid for all devices   */
-       struct semaphore bus_lock;
-       struct semaphore clist_lock;
+       struct mutex bus_lock;
+       struct mutex clist_lock;
 
        int timeout;
        int retries;
@@ -250,9 +255,6 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
 }
 
 /*flags for the client struct: */
-#define I2C_CLIENT_ALLOW_USE           0x01    /* Client allows access */
-#define I2C_CLIENT_ALLOW_MULTIPLE_USE  0x02    /* Allow multiple access-locks */
-                                               /* on an i2c_client */
 #define I2C_CLIENT_PEC  0x04                   /* Use Packet Error Checking */
 #define I2C_CLIENT_TEN 0x10                    /* we have a ten bit chip address       */
                                                /* Must equal I2C_M_TEN below */
@@ -293,26 +295,20 @@ struct i2c_client_address_data {
 extern int i2c_add_adapter(struct i2c_adapter *);
 extern int i2c_del_adapter(struct i2c_adapter *);
 
-extern int i2c_add_driver(struct i2c_driver *);
+extern int i2c_register_driver(struct module *, struct i2c_driver *);
 extern int i2c_del_driver(struct i2c_driver *);
 
+static inline int i2c_add_driver(struct i2c_driver *driver)
+{
+       return i2c_register_driver(THIS_MODULE, driver);
+}
+
 extern int i2c_attach_client(struct i2c_client *);
 extern int i2c_detach_client(struct i2c_client *);
 
-/* New function: This is to get an i2c_client-struct for controlling the 
-   client either by using i2c_control-function or having the 
-   client-module export functions that can be used with the i2c_client
-   -struct. */
-extern struct i2c_client *i2c_get_client(int driver_id, int adapter_id, 
-                                       struct i2c_client *prev);
-
-/* Should be used with new function
-   extern struct i2c_client *i2c_get_client(int,int,struct i2c_client *);
-   to make sure that client-struct is valid and that it is okay to access
-   the i2c-client. 
-   returns -EACCES if client doesn't allow use (default)
-   returns -EBUSY if client doesn't allow multiple use (default) and 
-   usage_count >0 */
+/* Should be used to make sure that client-struct is valid and that it
+   is okay to access the i2c-client.
+   returns -ENODEV if client has gone in the meantime */
 extern int i2c_use_client(struct i2c_client *);
 extern int i2c_release_client(struct i2c_client *);
 
@@ -359,6 +355,7 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
 {
        return adap->nr;
 }
+#endif /* __KERNEL__ */
 
 /*
  * I2C Message - used for pure i2c transaction, also from /dev interface
@@ -474,6 +471,7 @@ union i2c_smbus_data {
 #define I2C_SMBUS      0x0720  /* SMBus-level access */
 
 /* ----- I2C-DEV: char device interface stuff ------------------------- */
+#ifdef __KERNEL__
 
 #define I2C_MAJOR      89              /* Device major number          */
 
@@ -651,5 +649,5 @@ static unsigned short *forces[] = { force, force_##chip1,           \
                                    force_##chip6, force_##chip7,       \
                                    force_##chip8, NULL };              \
 I2C_CLIENT_INSMOD_COMMON
-
+#endif /* __KERNEL__ */
 #endif /* _LINUX_I2C_H */