aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt8
-rw-r--r--Documentation/i2c/busses/i2c-i8017
-rw-r--r--Documentation/i2c/porting-clients160
-rw-r--r--Documentation/i2c/writing-clients491
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c21
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/i2c-elektor.c3
-rw-r--r--drivers/i2c/busses/i2c-hydra.c2
-rw-r--r--drivers/i2c/busses/i2c-i801.c3
-rw-r--r--drivers/i2c/chips/Kconfig2
-rw-r--r--drivers/i2c/chips/Makefile3
-rw-r--r--drivers/i2c/i2c-core.c3
-rw-r--r--include/linux/device.h2
-rw-r--r--include/linux/i2c-algo-pcf.h5
-rw-r--r--include/linux/i2c.h163
15 files changed, 243 insertions, 631 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index f5f812daf9f4..05d71b4b9430 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -359,3 +359,11 @@ Why: The 2.6 kernel supports direct writing to ide CD drives, which
359 eliminates the need for ide-scsi. The new method is more 359 eliminates the need for ide-scsi. The new method is more
360 efficient in every way. 360 efficient in every way.
361Who: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> 361Who: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
362
363---------------------------
364
365What: i2c_attach_client(), i2c_detach_client(), i2c_driver->detach_client()
366When: 2.6.29 (ideally) or 2.6.30 (more likely)
367Why: Deprecated by the new (standard) device driver binding model. Use
368 i2c_driver->probe() and ->remove() instead.
369Who: Jean Delvare <khali@linux-fr.org>
diff --git a/Documentation/i2c/busses/i2c-i801 b/Documentation/i2c/busses/i2c-i801
index c31e0291e167..81c0c59a60ea 100644
--- a/Documentation/i2c/busses/i2c-i801
+++ b/Documentation/i2c/busses/i2c-i801
@@ -13,8 +13,9 @@ Supported adapters:
13 * Intel 631xESB/632xESB (ESB2) 13 * Intel 631xESB/632xESB (ESB2)
14 * Intel 82801H (ICH8) 14 * Intel 82801H (ICH8)
15 * Intel 82801I (ICH9) 15 * Intel 82801I (ICH9)
16 * Intel Tolapai 16 * Intel EP80579 (Tolapai)
17 * Intel ICH10 17 * Intel 82801JI (ICH10)
18 * Intel PCH
18 Datasheets: Publicly available at the Intel website 19 Datasheets: Publicly available at the Intel website
19 20
20Authors: 21Authors:
@@ -32,7 +33,7 @@ Description
32----------- 33-----------
33 34
34The ICH (properly known as the 82801AA), ICH0 (82801AB), ICH2 (82801BA), 35The ICH (properly known as the 82801AA), ICH0 (82801AB), ICH2 (82801BA),
35ICH3 (82801CA/CAM) and later devices are Intel chips that are a part of 36ICH3 (82801CA/CAM) and later devices (PCH) are Intel chips that are a part of
36Intel's '810' chipset for Celeron-based PCs, '810E' chipset for 37Intel's '810' chipset for Celeron-based PCs, '810E' chipset for
37Pentium-based PCs, '815E' chipset, and others. 38Pentium-based PCs, '815E' chipset, and others.
38 39
diff --git a/Documentation/i2c/porting-clients b/Documentation/i2c/porting-clients
deleted file mode 100644
index 7bf82c08f6ca..000000000000
--- a/Documentation/i2c/porting-clients
+++ /dev/null
@@ -1,160 +0,0 @@
1Revision 7, 2007-04-19
2Jean Delvare <khali@linux-fr.org>
3Greg KH <greg@kroah.com>
4
5This is a guide on how to convert I2C chip drivers from Linux 2.4 to
6Linux 2.6. I have been using existing drivers (lm75, lm78) as examples.
7Then I converted a driver myself (lm83) and updated this document.
8Note that this guide is strongly oriented towards hardware monitoring
9drivers. Many points are still valid for other type of drivers, but
10others may be irrelevant.
11
12There are two sets of points below. The first set concerns technical
13changes. The second set concerns coding policy. Both are mandatory.
14
15Although reading this guide will help you porting drivers, I suggest
16you keep an eye on an already ported driver while porting your own
17driver. This will help you a lot understanding what this guide
18exactly means. Choose the chip driver that is the more similar to
19yours for best results.
20
21Technical changes:
22
23* [Driver type] Any driver that was relying on i2c-isa has to be
24 converted to a proper isa, platform or pci driver. This is not
25 covered by this guide.
26
27* [Includes] Get rid of "version.h" and <linux/i2c-proc.h>.
28 Includes typically look like that:
29 #include <linux/module.h>
30 #include <linux/init.h>
31 #include <linux/slab.h>
32 #include <linux/jiffies.h>
33 #include <linux/i2c.h>
34 #include <linux/hwmon.h> /* for hardware monitoring drivers */
35 #include <linux/hwmon-sysfs.h>
36 #include <linux/hwmon-vid.h> /* if you need VRM support */
37 #include <linux/err.h> /* for class registration */
38 Please respect this inclusion order. Some extra headers may be
39 required for a given driver (e.g. "lm75.h").
40
41* [Addresses] SENSORS_I2C_END becomes I2C_CLIENT_END, ISA addresses
42 are no more handled by the i2c core. Address ranges are no more
43 supported either, define each individual address separately.
44 SENSORS_INSMOD_<n> becomes I2C_CLIENT_INSMOD_<n>.
45
46* [Client data] Get rid of sysctl_id. Try using standard names for
47 register values (for example, temp_os becomes temp_max). You're
48 still relatively free here, but you *have* to follow the standard
49 names for sysfs files (see the Sysctl section below).
50
51* [Function prototypes] The detect functions loses its flags
52 parameter. Sysctl (e.g. lm75_temp) and miscellaneous functions
53 are off the list of prototypes. This usually leaves five
54 prototypes:
55 static int lm75_attach_adapter(struct i2c_adapter *adapter);
56 static int lm75_detect(struct i2c_adapter *adapter, int address,
57 int kind);
58 static void lm75_init_client(struct i2c_client *client);
59 static int lm75_detach_client(struct i2c_client *client);
60 static struct lm75_data lm75_update_device(struct device *dev);
61
62* [Sysctl] All sysctl stuff is of course gone (defines, ctl_table
63 and functions). Instead, you have to define show and set functions for
64 each sysfs file. Only define set for writable values. Take a look at an
65 existing 2.6 driver for details (it87 for example). Don't forget
66 to define the attributes for each file (this is that step that
67 links callback functions). Use the file names specified in
68 Documentation/hwmon/sysfs-interface for the individual files. Also
69 convert the units these files read and write to the specified ones.
70 If you need to add a new type of file, please discuss it on the
71 sensors mailing list <lm-sensors@lm-sensors.org> by providing a
72 patch to the Documentation/hwmon/sysfs-interface file.
73
74* [Attach] The attach function should make sure that the adapter's
75 class has I2C_CLASS_HWMON (or whatever class is suitable for your
76 driver), using the following construct:
77 if (!(adapter->class & I2C_CLASS_HWMON))
78 return 0;
79 Call i2c_probe() instead of i2c_detect().
80
81* [Detect] As mentioned earlier, the flags parameter is gone.
82 The type_name and client_name strings are replaced by a single
83 name string, which will be filled with a lowercase, short string.
84 The labels used for error paths are reduced to the number needed.
85 It is advised that the labels are given descriptive names such as
86 exit and exit_free. Don't forget to properly set err before
87 jumping to error labels. By the way, labels should be left-aligned.
88 Use kzalloc instead of kmalloc.
89 Use i2c_set_clientdata to set the client data (as opposed to
90 a direct access to client->data).
91 Use strlcpy instead of strcpy or snprintf to copy the client name.
92 Replace the sysctl directory registration by calls to
93 device_create_file. Move the driver initialization before any
94 sysfs file creation.
95 Register the client with the hwmon class (using hwmon_device_register)
96 if applicable.
97 Drop client->id.
98 Drop any 24RF08 corruption prevention you find, as this is now done
99 at the i2c-core level, and doing it twice voids it.
100 Don't add I2C_CLIENT_ALLOW_USE to client->flags, it's the default now.
101
102* [Init] Limits must not be set by the driver (can be done later in
103 user-space). Chip should not be reset default (although a module
104 parameter may be used to force it), and initialization should be
105 limited to the strictly necessary steps.
106
107* [Detach] Remove the call to i2c_deregister_entry. Do not log an
108 error message if i2c_detach_client fails, as i2c-core will now do
109 it for you.
110 Unregister from the hwmon class if applicable.
111
112* [Update] The function prototype changed, it is now
113 passed a device structure, which you have to convert to a client
114 using to_i2c_client(dev). The update function should return a
115 pointer to the client data.
116 Don't access client->data directly, use i2c_get_clientdata(client)
117 instead.
118 Use time_after() instead of direct jiffies comparison.
119
120* [Interface] Make sure there is a MODULE_LICENSE() line, at the bottom
121 of the file (after MODULE_AUTHOR() and MODULE_DESCRIPTION(), in this
122 order).
123
124* [Driver] The flags field of the i2c_driver structure is gone.
125 I2C_DF_NOTIFY is now the default behavior.
126 The i2c_driver structure has a driver member, which is itself a
127 structure, those name member should be initialized to a driver name
128 string. i2c_driver itself has no name member anymore.
129
130* [Driver model] Instead of shutdown or reboot notifiers, provide a
131 shutdown() method in your driver.
132
133* [Power management] Use the driver model suspend() and resume()
134 callbacks instead of the obsolete pm_register() calls.
135
136Coding policy:
137
138* [Copyright] Use (C), not (c), for copyright.
139
140* [Debug/log] Get rid of #ifdef DEBUG/#endif constructs whenever you
141 can. Calls to printk for debugging purposes are replaced by calls to
142 dev_dbg where possible, else to pr_debug. Here is an example of how
143 to call it (taken from lm75_detect):
144 dev_dbg(&client->dev, "Starting lm75 update\n");
145 Replace other printk calls with the dev_info, dev_err or dev_warn
146 function, as appropriate.
147
148* [Constants] Constants defines (registers, conversions) should be
149 aligned. This greatly improves readability.
150 Alignments are achieved by the means of tabs, not spaces. Remember
151 that tabs are set to 8 in the Linux kernel code.
152
153* [Layout] Avoid extra empty lines between comments and what they
154 comment. Respect the coding style (see Documentation/CodingStyle),
155 in particular when it comes to placing curly braces.
156
157* [Comments] Make sure that no comment refers to a file that isn't
158 part of the Linux source tree (typically doc/chips/<chip name>),
159 and that remaining comments still match the code. Merging comment
160 lines when possible is encouraged.
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index d73ee117a8ca..6b9af7d479c2 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -10,23 +10,21 @@ General remarks
10=============== 10===============
11 11
12Try to keep the kernel namespace as clean as possible. The best way to 12Try to keep the kernel namespace as clean as possible. The best way to
13do this is to use a unique prefix for all global symbols. This is 13do this is to use a unique prefix for all global symbols. This is
14especially important for exported symbols, but it is a good idea to do 14especially important for exported symbols, but it is a good idea to do
15it for non-exported symbols too. We will use the prefix `foo_' in this 15it for non-exported symbols too. We will use the prefix `foo_' in this
16tutorial, and `FOO_' for preprocessor variables. 16tutorial.
17 17
18 18
19The driver structure 19The driver structure
20==================== 20====================
21 21
22Usually, you will implement a single driver structure, and instantiate 22Usually, you will implement a single driver structure, and instantiate
23all clients from it. Remember, a driver structure contains general access 23all clients from it. Remember, a driver structure contains general access
24routines, and should be zero-initialized except for fields with data you 24routines, and should be zero-initialized except for fields with data you
25provide. A client structure holds device-specific information like the 25provide. A client structure holds device-specific information like the
26driver model device node, and its I2C address. 26driver model device node, and its I2C address.
27 27
28/* iff driver uses driver model ("new style") binding model: */
29
30static struct i2c_device_id foo_idtable[] = { 28static struct i2c_device_id foo_idtable[] = {
31 { "foo", my_id_for_foo }, 29 { "foo", my_id_for_foo },
32 { "bar", my_id_for_bar }, 30 { "bar", my_id_for_bar },
@@ -40,7 +38,6 @@ static struct i2c_driver foo_driver = {
40 .name = "foo", 38 .name = "foo",
41 }, 39 },
42 40
43 /* iff driver uses driver model ("new style") binding model: */
44 .id_table = foo_ids, 41 .id_table = foo_ids,
45 .probe = foo_probe, 42 .probe = foo_probe,
46 .remove = foo_remove, 43 .remove = foo_remove,
@@ -49,24 +46,19 @@ static struct i2c_driver foo_driver = {
49 .detect = foo_detect, 46 .detect = foo_detect,
50 .address_data = &addr_data, 47 .address_data = &addr_data,
51 48
52 /* else, driver uses "legacy" binding model: */
53 .attach_adapter = foo_attach_adapter,
54 .detach_client = foo_detach_client,
55
56 /* these may be used regardless of the driver binding model */
57 .shutdown = foo_shutdown, /* optional */ 49 .shutdown = foo_shutdown, /* optional */
58 .suspend = foo_suspend, /* optional */ 50 .suspend = foo_suspend, /* optional */
59 .resume = foo_resume, /* optional */ 51 .resume = foo_resume, /* optional */
60 .command = foo_command, /* optional */ 52 .command = foo_command, /* optional, deprecated */
61} 53}
62 54
63The name field is the driver name, and must not contain spaces. It 55The name field is the driver name, and must not contain spaces. It
64should match the module name (if the driver can be compiled as a module), 56should match the module name (if the driver can be compiled as a module),
65although you can use MODULE_ALIAS (passing "foo" in this example) to add 57although you can use MODULE_ALIAS (passing "foo" in this example) to add
66another name for the module. If the driver name doesn't match the module 58another name for the module. If the driver name doesn't match the module
67name, the module won't be automatically loaded (hotplug/coldplug). 59name, the module won't be automatically loaded (hotplug/coldplug).
68 60
69All other fields are for call-back functions which will be explained 61All other fields are for call-back functions which will be explained
70below. 62below.
71 63
72 64
@@ -74,34 +66,13 @@ Extra client data
74================= 66=================
75 67
76Each client structure has a special `data' field that can point to any 68Each client structure has a special `data' field that can point to any
77structure at all. You should use this to keep device-specific data, 69structure at all. You should use this to keep device-specific data.
78especially in drivers that handle multiple I2C or SMBUS devices. You
79do not always need this, but especially for `sensors' drivers, it can
80be very useful.
81 70
82 /* store the value */ 71 /* store the value */
83 void i2c_set_clientdata(struct i2c_client *client, void *data); 72 void i2c_set_clientdata(struct i2c_client *client, void *data);
84 73
85 /* retrieve the value */ 74 /* retrieve the value */
86 void *i2c_get_clientdata(struct i2c_client *client); 75 void *i2c_get_clientdata(const struct i2c_client *client);
87
88An example structure is below.
89
90 struct foo_data {
91 struct i2c_client client;
92 enum chips type; /* To keep the chips type for `sensors' drivers. */
93
94 /* Because the i2c bus is slow, it is often useful to cache the read
95 information of a chip for some time (for example, 1 or 2 seconds).
96 It depends of course on the device whether this is really worthwhile
97 or even sensible. */
98 struct mutex update_lock; /* When we are reading lots of information,
99 another process should not update the
100 below information */
101 char valid; /* != 0 if the following fields are valid. */
102 unsigned long last_updated; /* In jiffies */
103 /* Add the read information here too */
104 };
105 76
106 77
107Accessing the client 78Accessing the client
@@ -109,11 +80,9 @@ Accessing the client
109 80
110Let's say we have a valid client structure. At some time, we will need 81Let's say we have a valid client structure. At some time, we will need
111to gather information from the client, or write new information to the 82to gather information from the client, or write new information to the
112client. How we will export this information to user-space is less 83client.
113important at this moment (perhaps we do not need to do this at all for
114some obscure clients). But we need generic reading and writing routines.
115 84
116I have found it useful to define foo_read and foo_write function for this. 85I have found it useful to define foo_read and foo_write functions for this.
117For some cases, it will be easier to call the i2c functions directly, 86For some cases, it will be easier to call the i2c functions directly,
118but many chips have some kind of register-value idea that can easily 87but many chips have some kind of register-value idea that can easily
119be encapsulated. 88be encapsulated.
@@ -121,33 +90,33 @@ be encapsulated.
121The below functions are simple examples, and should not be copied 90The below functions are simple examples, and should not be copied
122literally. 91literally.
123 92
124 int foo_read_value(struct i2c_client *client, u8 reg) 93int foo_read_value(struct i2c_client *client, u8 reg)
125 { 94{
126 if (reg < 0x10) /* byte-sized register */ 95 if (reg < 0x10) /* byte-sized register */
127 return i2c_smbus_read_byte_data(client,reg); 96 return i2c_smbus_read_byte_data(client, reg);
128 else /* word-sized register */ 97 else /* word-sized register */
129 return i2c_smbus_read_word_data(client,reg); 98 return i2c_smbus_read_word_data(client, reg);
130 } 99}
131 100
132 int foo_write_value(struct i2c_client *client, u8 reg, u16 value) 101int foo_write_value(struct i2c_client *client, u8 reg, u16 value)
133 { 102{
134 if (reg == 0x10) /* Impossible to write - driver error! */ { 103 if (reg == 0x10) /* Impossible to write - driver error! */
135 return -1; 104 return -EINVAL;
136 else if (reg < 0x10) /* byte-sized register */ 105 else if (reg < 0x10) /* byte-sized register */
137 return i2c_smbus_write_byte_data(client,reg,value); 106 return i2c_smbus_write_byte_data(client, reg, value);
138 else /* word-sized register */ 107 else /* word-sized register */
139 return i2c_smbus_write_word_data(client,reg,value); 108 return i2c_smbus_write_word_data(client, reg, value);
140 } 109}
141 110
142 111
143Probing and attaching 112Probing and attaching
144===================== 113=====================
145 114
146The Linux I2C stack was originally written to support access to hardware 115The Linux I2C stack was originally written to support access to hardware
147monitoring chips on PC motherboards, and thus it embeds some assumptions 116monitoring chips on PC motherboards, and thus used to embed some assumptions
148that are more appropriate to SMBus (and PCs) than to I2C. One of these 117that were more appropriate to SMBus (and PCs) than to I2C. One of these
149assumptions is that most adapters and devices drivers support the SMBUS_QUICK 118assumptions was that most adapters and devices drivers support the SMBUS_QUICK
150protocol to probe device presence. Another is that devices and their drivers 119protocol to probe device presence. Another was that devices and their drivers
151can be sufficiently configured using only such probe primitives. 120can be sufficiently configured using only such probe primitives.
152 121
153As Linux and its I2C stack became more widely used in embedded systems 122As Linux and its I2C stack became more widely used in embedded systems
@@ -164,6 +133,9 @@ since the "legacy" model requires drivers to create "i2c_client" device
164objects after SMBus style probing, while the Linux driver model expects 133objects after SMBus style probing, while the Linux driver model expects
165drivers to be given such device objects in their probe() routines. 134drivers to be given such device objects in their probe() routines.
166 135
136The legacy model is deprecated now and will soon be removed, so we no
137longer document it here.
138
167 139
168Standard Driver Model Binding ("New Style") 140Standard Driver Model Binding ("New Style")
169------------------------------------------- 141-------------------------------------------
@@ -193,8 +165,8 @@ matches the device's name. It is passed the entry that was matched so
193the driver knows which one in the table matched. 165the driver knows which one in the table matched.
194 166
195 167
196Device Creation (Standard driver model) 168Device Creation
197--------------------------------------- 169---------------
198 170
199If you know for a fact that an I2C device is connected to a given I2C bus, 171If you know for a fact that an I2C device is connected to a given I2C bus,
200you can instantiate that device by simply filling an i2c_board_info 172you can instantiate that device by simply filling an i2c_board_info
@@ -221,8 +193,8 @@ in the I2C bus driver. You may want to save the returned i2c_client
221reference for later use. 193reference for later use.
222 194
223 195
224Device Detection (Standard driver model) 196Device Detection
225---------------------------------------- 197----------------
226 198
227Sometimes you do not know in advance which I2C devices are connected to 199Sometimes you do not know in advance which I2C devices are connected to
228a given I2C bus. This is for example the case of hardware monitoring 200a given I2C bus. This is for example the case of hardware monitoring
@@ -246,8 +218,8 @@ otherwise misdetections are likely to occur and things can get wrong
246quickly. 218quickly.
247 219
248 220
249Device Deletion (Standard driver model) 221Device Deletion
250--------------------------------------- 222---------------
251 223
252Each I2C device which has been created using i2c_new_device() or 224Each I2C device which has been created using i2c_new_device() or
253i2c_new_probed_device() can be unregistered by calling 225i2c_new_probed_device() can be unregistered by calling
@@ -256,264 +228,37 @@ called automatically before the underlying I2C bus itself is removed, as a
256device can't survive its parent in the device driver model. 228device can't survive its parent in the device driver model.
257 229
258 230
259Legacy Driver Binding Model 231Initializing the driver
260--------------------------- 232=======================
233
234When the kernel is booted, or when your foo driver module is inserted,
235you have to do some initializing. Fortunately, just registering the
236driver module is usually enough.
261 237
262Most i2c devices can be present on several i2c addresses; for some this 238static int __init foo_init(void)
263is determined in hardware (by soldering some chip pins to Vcc or Ground), 239{
264for others this can be changed in software (by writing to specific client 240 return i2c_add_driver(&foo_driver);
265registers). Some devices are usually on a specific address, but not always; 241}
266and some are even more tricky. So you will probably need to scan several 242
267i2c addresses for your clients, and do some sort of detection to see 243static void __exit foo_cleanup(void)
268whether it is actually a device supported by your driver. 244{
245 i2c_del_driver(&foo_driver);
246}
247
248/* Substitute your own name and email address */
249MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"
250MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices");
269 251
270To give the user a maximum of possibilities, some default module parameters 252/* a few non-GPL license types are also allowed */
271are defined to help determine what addresses are scanned. Several macros 253MODULE_LICENSE("GPL");
272are defined in i2c.h to help you support them, as well as a generic 254
273detection algorithm. 255module_init(foo_init);
274 256module_exit(foo_cleanup);
275You do not have to use this parameter interface; but don't try to use 257
276function i2c_probe() if you don't. 258Note that some functions are marked by `__init'. These functions can
277 259be removed after kernel booting (or module loading) is completed.
278 260Likewise, functions marked by `__exit' are dropped by the compiler when
279Probing classes (Legacy model) 261the code is built into the kernel, as they would never be called.
280------------------------------
281
282All parameters are given as lists of unsigned 16-bit integers. Lists are
283terminated by I2C_CLIENT_END.
284The following lists are used internally:
285
286 normal_i2c: filled in by the module writer.
287 A list of I2C addresses which should normally be examined.
288 probe: insmod parameter.
289 A list of pairs. The first value is a bus number (-1 for any I2C bus),
290 the second is the address. These addresses are also probed, as if they
291 were in the 'normal' list.
292 ignore: insmod parameter.
293 A list of pairs. The first value is a bus number (-1 for any I2C bus),
294 the second is the I2C address. These addresses are never probed.
295 This parameter overrules the 'normal_i2c' list only.
296 force: insmod parameter.
297 A list of pairs. The first value is a bus number (-1 for any I2C bus),
298 the second is the I2C address. A device is blindly assumed to be on
299 the given address, no probing is done.
300
301Additionally, kind-specific force lists may optionally be defined if
302the driver supports several chip kinds. They are grouped in a
303NULL-terminated list of pointers named forces, those first element if the
304generic force list mentioned above. Each additional list correspond to an
305insmod parameter of the form force_<kind>.
306
307Fortunately, as a module writer, you just have to define the `normal_i2c'
308parameter. The complete declaration could look like this:
309
310 /* Scan 0x4c to 0x4f */
311 static const unsigned short normal_i2c[] = { 0x4c, 0x4d, 0x4e, 0x4f,
312 I2C_CLIENT_END };
313
314 /* Magic definition of all other variables and things */
315 I2C_CLIENT_INSMOD;
316 /* Or, if your driver supports, say, 2 kind of devices: */
317 I2C_CLIENT_INSMOD_2(foo, bar);
318
319If you use the multi-kind form, an enum will be defined for you:
320 enum chips { any_chip, foo, bar, ... }
321You can then (and certainly should) use it in the driver code.
322
323Note that you *have* to call the defined variable `normal_i2c',
324without any prefix!
325
326
327Attaching to an adapter (Legacy model)
328--------------------------------------
329
330Whenever a new adapter is inserted, or for all adapters if the driver is
331being registered, the callback attach_adapter() is called. Now is the
332time to determine what devices are present on the adapter, and to register
333a client for each of them.
334
335The attach_adapter callback is really easy: we just call the generic
336detection function. This function will scan the bus for us, using the
337information as defined in the lists explained above. If a device is
338detected at a specific address, another callback is called.
339
340 int foo_attach_adapter(struct i2c_adapter *adapter)
341 {
342 return i2c_probe(adapter,&addr_data,&foo_detect_client);
343 }
344
345Remember, structure `addr_data' is defined by the macros explained above,
346so you do not have to define it yourself.
347
348The i2c_probe function will call the foo_detect_client
349function only for those i2c addresses that actually have a device on
350them (unless a `force' parameter was used). In addition, addresses that
351are already in use (by some other registered client) are skipped.
352
353
354The detect client function (Legacy model)
355-----------------------------------------
356
357The detect client function is called by i2c_probe. The `kind' parameter
358contains -1 for a probed detection, 0 for a forced detection, or a positive
359number for a forced detection with a chip type forced.
360
361Returning an error different from -ENODEV in a detect function will cause
362the detection to stop: other addresses and adapters won't be scanned.
363This should only be done on fatal or internal errors, such as a memory
364shortage or i2c_attach_client failing.
365
366For now, you can ignore the `flags' parameter. It is there for future use.
367
368 int foo_detect_client(struct i2c_adapter *adapter, int address,
369 int kind)
370 {
371 int err = 0;
372 int i;
373 struct i2c_client *client;
374 struct foo_data *data;
375 const char *name = "";
376
377 /* Let's see whether this adapter can support what we need.
378 Please substitute the things you need here! */
379 if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA |
380 I2C_FUNC_SMBUS_WRITE_BYTE))
381 goto ERROR0;
382
383 /* OK. For now, we presume we have a valid client. We now create the
384 client structure, even though we cannot fill it completely yet.
385 But it allows us to access several i2c functions safely */
386
387 if (!(data = kzalloc(sizeof(struct foo_data), GFP_KERNEL))) {
388 err = -ENOMEM;
389 goto ERROR0;
390 }
391
392 client = &data->client;
393 i2c_set_clientdata(client, data);
394
395 client->addr = address;
396 client->adapter = adapter;
397 client->driver = &foo_driver;
398
399 /* Now, we do the remaining detection. If no `force' parameter is used. */
400
401 /* First, the generic detection (if any), that is skipped if any force
402 parameter was used. */
403 if (kind < 0) {
404 /* The below is of course bogus */
405 if (foo_read(client, FOO_REG_GENERIC) != FOO_GENERIC_VALUE)
406 goto ERROR1;
407 }
408
409 /* Next, specific detection. This is especially important for `sensors'
410 devices. */
411
412 /* Determine the chip type. Not needed if a `force_CHIPTYPE' parameter
413 was used. */
414 if (kind <= 0) {
415 i = foo_read(client, FOO_REG_CHIPTYPE);
416 if (i == FOO_TYPE_1)
417 kind = chip1; /* As defined in the enum */
418 else if (i == FOO_TYPE_2)
419 kind = chip2;
420 else {
421 printk("foo: Ignoring 'force' parameter for unknown chip at "
422 "adapter %d, address 0x%02x\n",i2c_adapter_id(adapter),address);
423 goto ERROR1;
424 }
425 }
426
427 /* Now set the type and chip names */
428 if (kind == chip1) {
429 name = "chip1";
430 } else if (kind == chip2) {
431 name = "chip2";
432 }
433
434 /* Fill in the remaining client fields. */
435 strlcpy(client->name, name, I2C_NAME_SIZE);
436 data->type = kind;
437 mutex_init(&data->update_lock); /* Only if you use this field */
438
439 /* Any other initializations in data must be done here too. */
440
441 /* This function can write default values to the client registers, if
442 needed. */
443 foo_init_client(client);
444
445 /* Tell the i2c layer a new client has arrived */
446 if ((err = i2c_attach_client(client)))
447 goto ERROR1;
448
449 return 0;
450
451 /* OK, this is not exactly good programming practice, usually. But it is
452 very code-efficient in this case. */
453
454 ERROR1:
455 kfree(data);
456 ERROR0:
457 return err;
458 }
459
460
461Removing the client (Legacy model)
462==================================
463
464The detach_client call back function is called when a client should be
465removed. It may actually fail, but only when panicking. This code is
466much simpler than the attachment code, fortunately!
467
468 int foo_detach_client(struct i2c_client *client)
469 {
470 int err;
471
472 /* Try to detach the client from i2c space */
473 if ((err = i2c_detach_client(client)))
474 return err;
475
476 kfree(i2c_get_clientdata(client));
477 return 0;
478 }
479
480
481Initializing the module or kernel
482=================================
483
484When the kernel is booted, or when your foo driver module is inserted,
485you have to do some initializing. Fortunately, just attaching (registering)
486the driver module is usually enough.
487
488 static int __init foo_init(void)
489 {
490 int res;
491
492 if ((res = i2c_add_driver(&foo_driver))) {
493 printk("foo: Driver registration failed, module not inserted.\n");
494 return res;
495 }
496 return 0;
497 }
498
499 static void __exit foo_cleanup(void)
500 {
501 i2c_del_driver(&foo_driver);
502 }
503
504 /* Substitute your own name and email address */
505 MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl>"
506 MODULE_DESCRIPTION("Driver for Barf Inc. Foo I2C devices");
507
508 /* a few non-GPL license types are also allowed */
509 MODULE_LICENSE("GPL");
510
511 module_init(foo_init);
512 module_exit(foo_cleanup);
513
514Note that some functions are marked by `__init', and some data structures
515by `__initdata'. These functions and structures can be removed after
516kernel booting (or module loading) is completed.
517 262
518 263
519Power Management 264Power Management
@@ -548,33 +293,35 @@ Command function
548 293
549A generic ioctl-like function call back is supported. You will seldom 294A generic ioctl-like function call back is supported. You will seldom
550need this, and its use is deprecated anyway, so newer design should not 295need this, and its use is deprecated anyway, so newer design should not
551use it. Set it to NULL. 296use it.
552 297
553 298
554Sending and receiving 299Sending and receiving
555===================== 300=====================
556 301
557If you want to communicate with your device, there are several functions 302If you want to communicate with your device, there are several functions
558to do this. You can find all of them in i2c.h. 303to do this. You can find all of them in <linux/i2c.h>.
559 304
560If you can choose between plain i2c communication and SMBus level 305If you can choose between plain I2C communication and SMBus level
561communication, please use the last. All adapters understand SMBus level 306communication, please use the latter. All adapters understand SMBus level
562commands, but only some of them understand plain i2c! 307commands, but only some of them understand plain I2C!
563 308
564 309
565Plain i2c communication 310Plain I2C communication
566----------------------- 311-----------------------
567 312
568 extern int i2c_master_send(struct i2c_client *,const char* ,int); 313 int i2c_master_send(struct i2c_client *client, const char *buf,
569 extern int i2c_master_recv(struct i2c_client *,char* ,int); 314 int count);
315 int i2c_master_recv(struct i2c_client *client, char *buf, int count);
570 316
571These routines read and write some bytes from/to a client. The client 317These routines read and write some bytes from/to a client. The client
572contains the i2c address, so you do not have to include it. The second 318contains the i2c address, so you do not have to include it. The second
573parameter contains the bytes the read/write, the third the length of the 319parameter contains the bytes to read/write, the third the number of bytes
574buffer. Returned is the actual number of bytes read/written. 320to read/write (must be less than the length of the buffer.) Returned is
575 321the actual number of bytes read/written.
576 extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg, 322
577 int num); 323 int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msg,
324 int num);
578 325
579This sends a series of messages. Each message can be a read or write, 326This sends a series of messages. Each message can be a read or write,
580and they can be mixed in any way. The transactions are combined: no 327and they can be mixed in any way. The transactions are combined: no
@@ -583,49 +330,45 @@ for each message the client address, the number of bytes of the message
583and the message data itself. 330and the message data itself.
584 331
585You can read the file `i2c-protocol' for more information about the 332You can read the file `i2c-protocol' for more information about the
586actual i2c protocol. 333actual I2C protocol.
587 334
588 335
589SMBus communication 336SMBus communication
590------------------- 337-------------------
591 338
592 extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 339 s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
593 unsigned short flags, 340 unsigned short flags, char read_write, u8 command,
594 char read_write, u8 command, int size, 341 int size, union i2c_smbus_data *data);
595 union i2c_smbus_data * data); 342
596 343This is the generic SMBus function. All functions below are implemented
597 This is the generic SMBus function. All functions below are implemented 344in terms of it. Never use this function directly!
598 in terms of it. Never use this function directly! 345
599 346 s32 i2c_smbus_read_byte(struct i2c_client *client);
600 347 s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value);
601 extern s32 i2c_smbus_read_byte(struct i2c_client * client); 348 s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command);
602 extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 349 s32 i2c_smbus_write_byte_data(struct i2c_client *client,
603 extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 350 u8 command, u8 value);
604 extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, 351 s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command);
605 u8 command, u8 value); 352 s32 i2c_smbus_write_word_data(struct i2c_client *client,
606 extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 353 u8 command, u16 value);
607 extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 354 s32 i2c_smbus_process_call(struct i2c_client *client,
608 u8 command, u16 value); 355 u8 command, u16 value);
609 extern s32 i2c_smbus_process_call(struct i2c_client *client, 356 s32 i2c_smbus_read_block_data(struct i2c_client *client,
610 u8 command, u16 value); 357 u8 command, u8 *values);
611 extern s32 i2c_smbus_read_block_data(struct i2c_client * client, 358 s32 i2c_smbus_write_block_data(struct i2c_client *client,
612 u8 command, u8 *values); 359 u8 command, u8 length, const u8 *values);
613 extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 360 s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client,
614 u8 command, u8 length, 361 u8 command, u8 length, u8 *values);
615 u8 *values); 362 s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
616 extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 363 u8 command, u8 length,
617 u8 command, u8 length, u8 *values); 364 const u8 *values);
618 extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client,
619 u8 command, u8 length,
620 u8 *values);
621 365
622These ones were removed from i2c-core because they had no users, but could 366These ones were removed from i2c-core because they had no users, but could
623be added back later if needed: 367be added back later if needed:
624 368
625 extern s32 i2c_smbus_write_quick(struct i2c_client * client, u8 value); 369 s32 i2c_smbus_write_quick(struct i2c_client *client, u8 value);
626 extern s32 i2c_smbus_block_process_call(struct i2c_client *client, 370 s32 i2c_smbus_block_process_call(struct i2c_client *client,
627 u8 command, u8 length, 371 u8 command, u8 length, u8 *values);
628 u8 *values)
629 372
630All these transactions return a negative errno value on failure. The 'write' 373All these transactions return a negative errno value on failure. The 'write'
631transactions return 0 on success; the 'read' transactions return the read 374transactions return 0 on success; the 'read' transactions return the read
@@ -642,7 +385,5 @@ General purpose routines
642Below all general purpose routines are listed, that were not mentioned 385Below all general purpose routines are listed, that were not mentioned
643before. 386before.
644 387
645 /* This call returns a unique low identifier for each registered adapter. 388 /* Return the adapter number for a specific adapter */
646 */ 389 int i2c_adapter_id(struct i2c_adapter *adap);
647 extern int i2c_adapter_id(struct i2c_adapter *adap);
648
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 1e328d19cd6d..3e01992230b8 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -135,7 +135,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) {
135 *status = get_pcf(adap, 1); 135 *status = get_pcf(adap, 1);
136#ifndef STUB_I2C 136#ifndef STUB_I2C
137 while (timeout-- && (*status & I2C_PCF_PIN)) { 137 while (timeout-- && (*status & I2C_PCF_PIN)) {
138 adap->waitforpin(); 138 adap->waitforpin(adap->data);
139 *status = get_pcf(adap, 1); 139 *status = get_pcf(adap, 1);
140 } 140 }
141 if (*status & I2C_PCF_LAB) { 141 if (*status & I2C_PCF_LAB) {
@@ -208,7 +208,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
208 return -ENXIO; 208 return -ENXIO;
209 } 209 }
210 210
211 printk(KERN_DEBUG "i2c-algo-pcf.o: deteted and initialized PCF8584.\n"); 211 printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n");
212 212
213 return 0; 213 return 0;
214} 214}
@@ -331,13 +331,16 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
331 int i; 331 int i;
332 int ret=0, timeout, status; 332 int ret=0, timeout, status;
333 333
334 if (adap->xfer_begin)
335 adap->xfer_begin(adap->data);
334 336
335 /* Check for bus busy */ 337 /* Check for bus busy */
336 timeout = wait_for_bb(adap); 338 timeout = wait_for_bb(adap);
337 if (timeout) { 339 if (timeout) {
338 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: " 340 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
339 "Timeout waiting for BB in pcf_xfer\n");) 341 "Timeout waiting for BB in pcf_xfer\n");)
340 return -EIO; 342 i = -EIO;
343 goto out;
341 } 344 }
342 345
343 for (i = 0;ret >= 0 && i < num; i++) { 346 for (i = 0;ret >= 0 && i < num; i++) {
@@ -359,12 +362,14 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
359 if (timeout) { 362 if (timeout) {
360 if (timeout == -EINTR) { 363 if (timeout == -EINTR) {
361 /* arbitration lost */ 364 /* arbitration lost */
362 return (-EINTR); 365 i = -EINTR;
366 goto out;
363 } 367 }
364 i2c_stop(adap); 368 i2c_stop(adap);
365 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting " 369 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
366 "for PIN(1) in pcf_xfer\n");) 370 "for PIN(1) in pcf_xfer\n");)
367 return (-EREMOTEIO); 371 i = -EREMOTEIO;
372 goto out;
368 } 373 }
369 374
370#ifndef STUB_I2C 375#ifndef STUB_I2C
@@ -372,7 +377,8 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
372 if (status & I2C_PCF_LRB) { 377 if (status & I2C_PCF_LRB) {
373 i2c_stop(adap); 378 i2c_stop(adap);
374 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");) 379 DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
375 return (-EREMOTEIO); 380 i = -EREMOTEIO;
381 goto out;
376 } 382 }
377#endif 383#endif
378 384
@@ -404,6 +410,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
404 } 410 }
405 } 411 }
406 412
413out:
414 if (adap->xfer_end)
415 adap->xfer_end(adap->data);
407 return (i); 416 return (i);
408} 417}
409 418
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index acadbc51fc0f..7f95905bbb9d 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -97,6 +97,7 @@ config I2C_I801
97 ICH9 97 ICH9
98 Tolapai 98 Tolapai
99 ICH10 99 ICH10
100 PCH
100 101
101 This driver can also be built as a module. If so, the module 102 This driver can also be built as a module. If so, the module
102 will be called i2c-i801. 103 will be called i2c-i801.
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 7f38c01fb3a0..0ed3ccb81b63 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -104,7 +104,8 @@ static int pcf_isa_getclock(void *data)
104 return (clock); 104 return (clock);
105} 105}
106 106
107static void pcf_isa_waitforpin(void) { 107static void pcf_isa_waitforpin(void *data)
108{
108 DEFINE_WAIT(wait); 109 DEFINE_WAIT(wait);
109 int timeout = 2; 110 int timeout = 2;
110 unsigned long flags; 111 unsigned long flags;
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index 1098f21ace13..648aa7baff83 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -123,7 +123,7 @@ static int __devinit hydra_probe(struct pci_dev *dev,
123 hydra_adap.name)) 123 hydra_adap.name))
124 return -EBUSY; 124 return -EBUSY;
125 125
126 hydra_bit_data.data = ioremap(base, pci_resource_len(dev, 0)); 126 hydra_bit_data.data = pci_ioremap_bar(dev, 0);
127 if (hydra_bit_data.data == NULL) { 127 if (hydra_bit_data.data == NULL) {
128 release_mem_region(base+offsetof(struct Hydra, CachePD), 4); 128 release_mem_region(base+offsetof(struct Hydra, CachePD), 4);
129 return -ENODEV; 129 return -ENODEV;
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index dc7ea32b69a8..5123eb69a971 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -41,6 +41,7 @@
41 Tolapai 0x5032 32 hard yes yes yes 41 Tolapai 0x5032 32 hard yes yes yes
42 ICH10 0x3a30 32 hard yes yes yes 42 ICH10 0x3a30 32 hard yes yes yes
43 ICH10 0x3a60 32 hard yes yes yes 43 ICH10 0x3a60 32 hard yes yes yes
44 PCH 0x3b30 32 hard yes yes yes
44 45
45 Features supported by this driver: 46 Features supported by this driver:
46 Software PEC no 47 Software PEC no
@@ -576,6 +577,7 @@ static struct pci_device_id i801_ids[] = {
576 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) }, 577 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TOLAPAI_1) },
577 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) }, 578 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) },
578 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) }, 579 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) },
580 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PCH_SMBUS) },
579 { 0, } 581 { 0, }
580}; 582};
581 583
@@ -599,6 +601,7 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
599 case PCI_DEVICE_ID_INTEL_TOLAPAI_1: 601 case PCI_DEVICE_ID_INTEL_TOLAPAI_1:
600 case PCI_DEVICE_ID_INTEL_ICH10_4: 602 case PCI_DEVICE_ID_INTEL_ICH10_4:
601 case PCI_DEVICE_ID_INTEL_ICH10_5: 603 case PCI_DEVICE_ID_INTEL_ICH10_5:
604 case PCI_DEVICE_ID_INTEL_PCH_SMBUS:
602 i801_features |= FEATURE_I2C_BLOCK_READ; 605 i801_features |= FEATURE_I2C_BLOCK_READ;
603 /* fall through */ 606 /* fall through */
604 case PCI_DEVICE_ID_INTEL_82801DB_3: 607 case PCI_DEVICE_ID_INTEL_82801DB_3:
diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 17356827b93d..4c35702830ce 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -1,6 +1,8 @@
1# 1#
2# Miscellaneous I2C chip drivers configuration 2# Miscellaneous I2C chip drivers configuration
3# 3#
4# *** DEPRECATED! Do not add new entries! See Makefile ***
5#
4 6
5menu "Miscellaneous I2C Chip support" 7menu "Miscellaneous I2C Chip support"
6 8
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index ca520fa143d6..23d2a31b0a64 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -1,7 +1,8 @@
1# 1#
2# Makefile for miscellaneous I2C chip drivers. 2# Makefile for miscellaneous I2C chip drivers.
3# 3#
4# Think twice before you add a new driver to this directory. 4# Do not add new drivers to this directory! It is DEPRECATED.
5#
5# Device drivers are better grouped according to the functionality they 6# Device drivers are better grouped according to the functionality they
6# implement rather than to the bus they are connected to. In particular: 7# implement rather than to the bus they are connected to. In particular:
7# * Hardware monitoring chip drivers go to drivers/hwmon 8# * Hardware monitoring chip drivers go to drivers/hwmon
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 42e852d79ffa..5a485c22660a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -266,6 +266,9 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
266 266
267 client->dev.platform_data = info->platform_data; 267 client->dev.platform_data = info->platform_data;
268 268
269 if (info->archdata)
270 client->dev.archdata = *info->archdata;
271
269 client->flags = info->flags; 272 client->flags = info->flags;
270 client->addr = info->addr; 273 client->addr = info->addr;
271 client->irq = info->irq; 274 client->irq = info->irq;
diff --git a/include/linux/device.h b/include/linux/device.h
index 987f5912720a..1a3686d15f98 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -450,7 +450,7 @@ static inline void set_dev_node(struct device *dev, int node)
450} 450}
451#endif 451#endif
452 452
453static inline void *dev_get_drvdata(struct device *dev) 453static inline void *dev_get_drvdata(const struct device *dev)
454{ 454{
455 return dev->driver_data; 455 return dev->driver_data;
456} 456}
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
index 0177d280f733..0f91a957a690 100644
--- a/include/linux/i2c-algo-pcf.h
+++ b/include/linux/i2c-algo-pcf.h
@@ -31,7 +31,10 @@ struct i2c_algo_pcf_data {
31 int (*getpcf) (void *data, int ctl); 31 int (*getpcf) (void *data, int ctl);
32 int (*getown) (void *data); 32 int (*getown) (void *data);
33 int (*getclock) (void *data); 33 int (*getclock) (void *data);
34 void (*waitforpin) (void); 34 void (*waitforpin) (void *data);
35
36 void (*xfer_begin) (void *data);
37 void (*xfer_end) (void *data);
35 38
36 /* Multi-master lost arbitration back-off delay (msecs) 39 /* Multi-master lost arbitration back-off delay (msecs)
37 * This should be set by the bus adapter or knowledgable client 40 * This should be set by the bus adapter or knowledgable client
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 06115128047f..33a5992d4936 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -53,45 +53,44 @@ struct i2c_board_info;
53 * transmit one message at a time, a more complex version can be used to 53 * transmit one message at a time, a more complex version can be used to
54 * transmit an arbitrary number of messages without interruption. 54 * transmit an arbitrary number of messages without interruption.
55 */ 55 */
56extern int i2c_master_send(struct i2c_client *,const char* ,int); 56extern int i2c_master_send(struct i2c_client *client, const char *buf,
57extern int i2c_master_recv(struct i2c_client *,char* ,int); 57 int count);
58extern int i2c_master_recv(struct i2c_client *client, char *buf, int count);
58 59
59/* Transfer num messages. 60/* Transfer num messages.
60 */ 61 */
61extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num); 62extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
62 63 int num);
63 64
64/* This is the very generalized SMBus access routine. You probably do not 65/* This is the very generalized SMBus access routine. You probably do not
65 want to use this, though; one of the functions below may be much easier, 66 want to use this, though; one of the functions below may be much easier,
66 and probably just as fast. 67 and probably just as fast.
67 Note that we use i2c_adapter here, because you do not need a specific 68 Note that we use i2c_adapter here, because you do not need a specific
68 smbus adapter to call this function. */ 69 smbus adapter to call this function. */
69extern s32 i2c_smbus_xfer (struct i2c_adapter * adapter, u16 addr, 70extern s32 i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
70 unsigned short flags, 71 unsigned short flags, char read_write, u8 command,
71 char read_write, u8 command, int size, 72 int size, union i2c_smbus_data *data);
72 union i2c_smbus_data * data);
73 73
74/* Now follow the 'nice' access routines. These also document the calling 74/* Now follow the 'nice' access routines. These also document the calling
75 conventions of i2c_smbus_xfer. */ 75 conventions of i2c_smbus_xfer. */
76 76
77extern s32 i2c_smbus_read_byte(struct i2c_client * client); 77extern s32 i2c_smbus_read_byte(struct i2c_client *client);
78extern s32 i2c_smbus_write_byte(struct i2c_client * client, u8 value); 78extern s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value);
79extern s32 i2c_smbus_read_byte_data(struct i2c_client * client, u8 command); 79extern s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command);
80extern s32 i2c_smbus_write_byte_data(struct i2c_client * client, 80extern s32 i2c_smbus_write_byte_data(struct i2c_client *client,
81 u8 command, u8 value); 81 u8 command, u8 value);
82extern s32 i2c_smbus_read_word_data(struct i2c_client * client, u8 command); 82extern s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command);
83extern s32 i2c_smbus_write_word_data(struct i2c_client * client, 83extern s32 i2c_smbus_write_word_data(struct i2c_client *client,
84 u8 command, u16 value); 84 u8 command, u16 value);
85/* Returns the number of read bytes */ 85/* Returns the number of read bytes */
86extern s32 i2c_smbus_read_block_data(struct i2c_client *client, 86extern s32 i2c_smbus_read_block_data(struct i2c_client *client,
87 u8 command, u8 *values); 87 u8 command, u8 *values);
88extern s32 i2c_smbus_write_block_data(struct i2c_client * client, 88extern s32 i2c_smbus_write_block_data(struct i2c_client *client,
89 u8 command, u8 length, 89 u8 command, u8 length, const u8 *values);
90 const u8 *values);
91/* Returns the number of read bytes */ 90/* Returns the number of read bytes */
92extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client * client, 91extern s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client,
93 u8 command, u8 length, u8 *values); 92 u8 command, u8 length, u8 *values);
94extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client * client, 93extern s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client,
95 u8 command, u8 length, 94 u8 command, u8 length,
96 const u8 *values); 95 const u8 *values);
97 96
@@ -169,7 +168,7 @@ struct i2c_driver {
169 /* a ioctl like command that can be used to perform specific functions 168 /* a ioctl like command that can be used to perform specific functions
170 * with the device. 169 * with the device.
171 */ 170 */
172 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 171 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
173 172
174 struct device_driver driver; 173 struct device_driver driver;
175 const struct i2c_device_id *id_table; 174 const struct i2c_device_id *id_table;
@@ -224,14 +223,14 @@ static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
224 return to_i2c_client(dev); 223 return to_i2c_client(dev);
225} 224}
226 225
227static inline void *i2c_get_clientdata (struct i2c_client *dev) 226static inline void *i2c_get_clientdata(const struct i2c_client *dev)
228{ 227{
229 return dev_get_drvdata (&dev->dev); 228 return dev_get_drvdata(&dev->dev);
230} 229}
231 230
232static inline void i2c_set_clientdata (struct i2c_client *dev, void *data) 231static inline void i2c_set_clientdata(struct i2c_client *dev, void *data)
233{ 232{
234 dev_set_drvdata (&dev->dev, data); 233 dev_set_drvdata(&dev->dev, data);
235} 234}
236 235
237/** 236/**
@@ -240,6 +239,7 @@ static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
240 * @flags: to initialize i2c_client.flags 239 * @flags: to initialize i2c_client.flags
241 * @addr: stored in i2c_client.addr 240 * @addr: stored in i2c_client.addr
242 * @platform_data: stored in i2c_client.dev.platform_data 241 * @platform_data: stored in i2c_client.dev.platform_data
242 * @archdata: copied into i2c_client.dev.archdata
243 * @irq: stored in i2c_client.irq 243 * @irq: stored in i2c_client.irq
244 * 244 *
245 * I2C doesn't actually support hardware probing, although controllers and 245 * I2C doesn't actually support hardware probing, although controllers and
@@ -259,6 +259,7 @@ struct i2c_board_info {
259 unsigned short flags; 259 unsigned short flags;
260 unsigned short addr; 260 unsigned short addr;
261 void *platform_data; 261 void *platform_data;
262 struct dev_archdata *archdata;
262 int irq; 263 int irq;
263}; 264};
264 265
@@ -272,7 +273,7 @@ struct i2c_board_info {
272 * fields (such as associated irq, or device-specific platform_data) 273 * fields (such as associated irq, or device-specific platform_data)
273 * are provided using conventional syntax. 274 * are provided using conventional syntax.
274 */ 275 */
275#define I2C_BOARD_INFO(dev_type,dev_addr) \ 276#define I2C_BOARD_INFO(dev_type, dev_addr) \
276 .type = (dev_type), .addr = (dev_addr) 277 .type = (dev_type), .addr = (dev_addr)
277 278
278 279
@@ -306,10 +307,12 @@ extern void i2c_unregister_device(struct i2c_client *);
306 */ 307 */
307#ifdef CONFIG_I2C_BOARDINFO 308#ifdef CONFIG_I2C_BOARDINFO
308extern int 309extern int
309i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n); 310i2c_register_board_info(int busnum, struct i2c_board_info const *info,
311 unsigned n);
310#else 312#else
311static inline int 313static inline int
312i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned n) 314i2c_register_board_info(int busnum, struct i2c_board_info const *info,
315 unsigned n)
313{ 316{
314 return 0; 317 return 0;
315} 318}
@@ -328,11 +331,11 @@ struct i2c_algorithm {
328 using common I2C messages */ 331 using common I2C messages */
329 /* master_xfer should return the number of messages successfully 332 /* master_xfer should return the number of messages successfully
330 processed, or a negative value on error */ 333 processed, or a negative value on error */
331 int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, 334 int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs,
332 int num); 335 int num);
333 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, 336 int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
334 unsigned short flags, char read_write, 337 unsigned short flags, char read_write,
335 u8 command, int size, union i2c_smbus_data * data); 338 u8 command, int size, union i2c_smbus_data *data);
336 339
337 /* To determine what the adapter supports */ 340 /* To determine what the adapter supports */
338 u32 (*functionality) (struct i2c_adapter *); 341 u32 (*functionality) (struct i2c_adapter *);
@@ -345,7 +348,7 @@ struct i2c_algorithm {
345struct i2c_adapter { 348struct i2c_adapter {
346 struct module *owner; 349 struct module *owner;
347 unsigned int id; 350 unsigned int id;
348 unsigned int class; 351 unsigned int class; /* classes to allow probing for */
349 const struct i2c_algorithm *algo; /* the algorithm to access the bus */ 352 const struct i2c_algorithm *algo; /* the algorithm to access the bus */
350 void *algo_data; 353 void *algo_data;
351 354
@@ -369,14 +372,14 @@ struct i2c_adapter {
369}; 372};
370#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 373#define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
371 374
372static inline void *i2c_get_adapdata (struct i2c_adapter *dev) 375static inline void *i2c_get_adapdata(const struct i2c_adapter *dev)
373{ 376{
374 return dev_get_drvdata (&dev->dev); 377 return dev_get_drvdata(&dev->dev);
375} 378}
376 379
377static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) 380static inline void i2c_set_adapdata(struct i2c_adapter *dev, void *data)
378{ 381{
379 dev_set_drvdata (&dev->dev, data); 382 dev_set_drvdata(&dev->dev, data);
380} 383}
381 384
382/*flags for the client struct: */ 385/*flags for the client struct: */
@@ -449,7 +452,7 @@ extern int i2c_probe(struct i2c_adapter *adapter,
449 const struct i2c_client_address_data *address_data, 452 const struct i2c_client_address_data *address_data,
450 int (*found_proc) (struct i2c_adapter *, int, int)); 453 int (*found_proc) (struct i2c_adapter *, int, int));
451 454
452extern struct i2c_adapter* i2c_get_adapter(int id); 455extern struct i2c_adapter *i2c_get_adapter(int id);
453extern void i2c_put_adapter(struct i2c_adapter *adap); 456extern void i2c_put_adapter(struct i2c_adapter *adap);
454 457
455 458
@@ -465,7 +468,7 @@ static inline int i2c_check_functionality(struct i2c_adapter *adap, u32 func)
465 return (func & i2c_get_functionality(adap)) == func; 468 return (func & i2c_get_functionality(adap)) == func;
466} 469}
467 470
468/* Return id number for a specific adapter */ 471/* Return the adapter number for a specific adapter */
469static inline int i2c_adapter_id(struct i2c_adapter *adap) 472static inline int i2c_adapter_id(struct i2c_adapter *adap)
470{ 473{
471 return adap->nr; 474 return adap->nr;
@@ -526,7 +529,7 @@ struct i2c_msg {
526 529
527#define I2C_FUNC_I2C 0x00000001 530#define I2C_FUNC_I2C 0x00000001
528#define I2C_FUNC_10BIT_ADDR 0x00000002 531#define I2C_FUNC_10BIT_ADDR 0x00000002
529#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ 532#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_NOSTART etc. */
530#define I2C_FUNC_SMBUS_PEC 0x00000008 533#define I2C_FUNC_SMBUS_PEC 0x00000008
531#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ 534#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
532#define I2C_FUNC_SMBUS_QUICK 0x00010000 535#define I2C_FUNC_SMBUS_QUICK 0x00010000
@@ -541,30 +544,26 @@ struct i2c_msg {
541#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 544#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
542#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ 545#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
543#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ 546#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
544#define I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 0x10000000 /* I2C-like block xfer */ 547
545#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2 0x20000000 /* w/ 2-byte reg. addr. */ 548#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
546 549 I2C_FUNC_SMBUS_WRITE_BYTE)
547#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ 550#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
548 I2C_FUNC_SMBUS_WRITE_BYTE) 551 I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
549#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ 552#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
550 I2C_FUNC_SMBUS_WRITE_BYTE_DATA) 553 I2C_FUNC_SMBUS_WRITE_WORD_DATA)
551#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ 554#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
552 I2C_FUNC_SMBUS_WRITE_WORD_DATA) 555 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
553#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ 556#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
554 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) 557 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
555#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ 558
556 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) 559#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \
557#define I2C_FUNC_SMBUS_I2C_BLOCK_2 (I2C_FUNC_SMBUS_READ_I2C_BLOCK_2 | \ 560 I2C_FUNC_SMBUS_BYTE | \
558 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK_2) 561 I2C_FUNC_SMBUS_BYTE_DATA | \
559 562 I2C_FUNC_SMBUS_WORD_DATA | \
560#define I2C_FUNC_SMBUS_EMUL (I2C_FUNC_SMBUS_QUICK | \ 563 I2C_FUNC_SMBUS_PROC_CALL | \
561 I2C_FUNC_SMBUS_BYTE | \ 564 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
562 I2C_FUNC_SMBUS_BYTE_DATA | \ 565 I2C_FUNC_SMBUS_I2C_BLOCK | \
563 I2C_FUNC_SMBUS_WORD_DATA | \ 566 I2C_FUNC_SMBUS_PEC)
564 I2C_FUNC_SMBUS_PROC_CALL | \
565 I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
566 I2C_FUNC_SMBUS_I2C_BLOCK | \
567 I2C_FUNC_SMBUS_PEC)
568 567
569/* 568/*
570 * Data for SMBus Messages 569 * Data for SMBus Messages
@@ -574,7 +573,7 @@ union i2c_smbus_data {
574 __u8 byte; 573 __u8 byte;
575 __u16 word; 574 __u16 word;
576 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ 575 __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
577 /* and one more for user-space compatibility */ 576 /* and one more for user-space compatibility */
578}; 577};
579 578
580/* i2c_smbus_xfer read or write markers */ 579/* i2c_smbus_xfer read or write markers */
@@ -602,21 +601,21 @@ union i2c_smbus_data {
602 601
603/* Default fill of many variables */ 602/* Default fill of many variables */
604#define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 603#define I2C_CLIENT_DEFAULTS {I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
605 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 604 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
606 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 605 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
607 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 606 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
608 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 607 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
609 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 608 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
610 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 609 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
611 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 610 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
612 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 611 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
613 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 612 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
614 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 613 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
615 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 614 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
616 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 615 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
617 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 616 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
618 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \ 617 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END, \
619 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END} 618 I2C_CLIENT_END, I2C_CLIENT_END, I2C_CLIENT_END}
620 619
621/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the 620/* I2C_CLIENT_MODULE_PARM creates a module parameter, and puts it in the
622 module header */ 621 module header */
@@ -625,7 +624,7 @@ union i2c_smbus_data {
625 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \ 624 static unsigned short var[I2C_CLIENT_MAX_OPTS] = I2C_CLIENT_DEFAULTS; \
626 static unsigned int var##_num; \ 625 static unsigned int var##_num; \
627 module_param_array(var, short, &var##_num, 0); \ 626 module_param_array(var, short, &var##_num, 0); \
628 MODULE_PARM_DESC(var,desc) 627 MODULE_PARM_DESC(var, desc)
629 628
630#define I2C_CLIENT_MODULE_PARM_FORCE(name) \ 629#define I2C_CLIENT_MODULE_PARM_FORCE(name) \
631I2C_CLIENT_MODULE_PARM(force_##name, \ 630I2C_CLIENT_MODULE_PARM(force_##name, \