aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/i2c/writing-clients
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-02-13 16:09:00 -0500
committerJean Delvare <khali@arrakis.delvare>2007-02-13 16:09:00 -0500
commitf37dd80ac2a67e4e4e921f99d34a1ceeb2488abb (patch)
treec845e39b24feac331a9a67d49e0b8061f52131b3 /Documentation/i2c/writing-clients
parentb8d6f45b32f6fe72bf7304183275e99332544ce1 (diff)
i2c: Add driver suspend/resume/shutdown support
Driver model updates for the I2C core: - Add new suspend(), resume(), and shutdown() methods. Use them in the standard driver model style; document them. - Minor doc updates to highlight zero-initialized fields in drivers, and the driver model accessors for "clientdata". If any i2c drivers were previously using the old suspend/resume calls in "struct driver", they were getting warning messages ... and will now no longer work. Other than that, this patch changes no behaviors; and it lets I2C drivers use conventional PM and shutdown support. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'Documentation/i2c/writing-clients')
-rw-r--r--Documentation/i2c/writing-clients58
1 files changed, 49 insertions, 9 deletions
diff --git a/Documentation/i2c/writing-clients b/Documentation/i2c/writing-clients
index 3a057c8e5507..fbcff96f4ca1 100644
--- a/Documentation/i2c/writing-clients
+++ b/Documentation/i2c/writing-clients
@@ -21,20 +21,26 @@ The driver structure
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, a client structure specific information like the actual I2C 24routines, and should be zero-initialized except for fields with data you
25address. 25provide. A client structure holds device-specific information like the
26driver model device node, and its I2C address.
26 27
27static struct i2c_driver foo_driver = { 28static struct i2c_driver foo_driver = {
28 .driver = { 29 .driver = {
29 .name = "foo", 30 .name = "foo",
30 }, 31 },
31 .attach_adapter = &foo_attach_adapter, 32 .attach_adapter = foo_attach_adapter,
32 .detach_client = &foo_detach_client, 33 .detach_client = foo_detach_client,
33 .command = &foo_command /* may be NULL */ 34 .shutdown = foo_shutdown, /* optional */
35 .suspend = foo_suspend, /* optional */
36 .resume = foo_resume, /* optional */
37 .command = foo_command, /* optional */
34} 38}
35 39
36The name field must match the driver name, including the case. It must not 40The name field is the driver name, and must not contain spaces. It
37contain spaces, and may be up to 31 characters long. 41should match the module name (if the driver can be compiled as a module),
42although you can use MODULE_ALIAS (passing "foo" in this example) to add
43another name for the module.
38 44
39All other fields are for call-back functions which will be explained 45All other fields are for call-back functions which will be explained
40below. 46below.
@@ -43,11 +49,18 @@ below.
43Extra client data 49Extra client data
44================= 50=================
45 51
46The client structure has a special `data' field that can point to any 52Each client structure has a special `data' field that can point to any
47structure at all. You can use this to keep client-specific data. You 53structure at all. You should use this to keep device-specific data,
54especially in drivers that handle multiple I2C or SMBUS devices. You
48do not always need this, but especially for `sensors' drivers, it can 55do not always need this, but especially for `sensors' drivers, it can
49be very useful. 56be very useful.
50 57
58 /* store the value */
59 void i2c_set_clientdata(struct i2c_client *client, void *data);
60
61 /* retrieve the value */
62 void *i2c_get_clientdata(struct i2c_client *client);
63
51An example structure is below. 64An example structure is below.
52 65
53 struct foo_data { 66 struct foo_data {
@@ -493,6 +506,33 @@ by `__init_data'. Hose functions and structures can be removed after
493kernel booting (or module loading) is completed. 506kernel booting (or module loading) is completed.
494 507
495 508
509Power Management
510================
511
512If your I2C device needs special handling when entering a system low
513power state -- like putting a transceiver into a low power mode, or
514activating a system wakeup mechanism -- do that in the suspend() method.
515The resume() method should reverse what the suspend() method does.
516
517These are standard driver model calls, and they work just like they
518would for any other driver stack. The calls can sleep, and can use
519I2C messaging to the device being suspended or resumed (since their
520parent I2C adapter is active when these calls are issued, and IRQs
521are still enabled).
522
523
524System Shutdown
525===============
526
527If your I2C device needs special handling when the system shuts down
528or reboots (including kexec) -- like turning something off -- use a
529shutdown() method.
530
531Again, this is a standard driver model call, working just like it
532would for any other driver stack: the calls can sleep, and can use
533I2C messaging.
534
535
496Command function 536Command function
497================ 537================
498 538