diff options
author | David Brownell <david-b@pacbell.net> | 2007-02-13 16:09:00 -0500 |
---|---|---|
committer | Jean Delvare <khali@arrakis.delvare> | 2007-02-13 16:09:00 -0500 |
commit | f37dd80ac2a67e4e4e921f99d34a1ceeb2488abb (patch) | |
tree | c845e39b24feac331a9a67d49e0b8061f52131b3 /drivers/i2c/i2c-core.c | |
parent | b8d6f45b32f6fe72bf7304183275e99332544ce1 (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 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 60f6eb194046..9653f7f81561 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -41,49 +41,72 @@ static LIST_HEAD(drivers); | |||
41 | static DEFINE_MUTEX(core_lists); | 41 | static DEFINE_MUTEX(core_lists); |
42 | static DEFINE_IDR(i2c_adapter_idr); | 42 | static DEFINE_IDR(i2c_adapter_idr); |
43 | 43 | ||
44 | |||
45 | /* ------------------------------------------------------------------------- */ | ||
46 | |||
44 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ | 47 | /* match always succeeds, as we want the probe() to tell if we really accept this match */ |
45 | static int i2c_device_match(struct device *dev, struct device_driver *drv) | 48 | static int i2c_device_match(struct device *dev, struct device_driver *drv) |
46 | { | 49 | { |
47 | return 1; | 50 | return 1; |
48 | } | 51 | } |
49 | 52 | ||
50 | static int i2c_bus_suspend(struct device * dev, pm_message_t state) | 53 | static int i2c_device_probe(struct device *dev) |
51 | { | 54 | { |
52 | int rc = 0; | 55 | return -ENODEV; |
56 | } | ||
53 | 57 | ||
54 | if (dev->driver && dev->driver->suspend) | 58 | static int i2c_device_remove(struct device *dev) |
55 | rc = dev->driver->suspend(dev, state); | 59 | { |
56 | return rc; | 60 | return 0; |
57 | } | 61 | } |
58 | 62 | ||
59 | static int i2c_bus_resume(struct device * dev) | 63 | static void i2c_device_shutdown(struct device *dev) |
60 | { | 64 | { |
61 | int rc = 0; | 65 | struct i2c_driver *driver; |
62 | 66 | ||
63 | if (dev->driver && dev->driver->resume) | 67 | if (!dev->driver) |
64 | rc = dev->driver->resume(dev); | 68 | return; |
65 | return rc; | 69 | driver = to_i2c_driver(dev->driver); |
70 | if (driver->shutdown) | ||
71 | driver->shutdown(to_i2c_client(dev)); | ||
66 | } | 72 | } |
67 | 73 | ||
68 | static int i2c_device_probe(struct device *dev) | 74 | static int i2c_device_suspend(struct device * dev, pm_message_t mesg) |
69 | { | 75 | { |
70 | return -ENODEV; | 76 | struct i2c_driver *driver; |
77 | |||
78 | if (!dev->driver) | ||
79 | return 0; | ||
80 | driver = to_i2c_driver(dev->driver); | ||
81 | if (!driver->suspend) | ||
82 | return 0; | ||
83 | return driver->suspend(to_i2c_client(dev), mesg); | ||
71 | } | 84 | } |
72 | 85 | ||
73 | static int i2c_device_remove(struct device *dev) | 86 | static int i2c_device_resume(struct device * dev) |
74 | { | 87 | { |
75 | return 0; | 88 | struct i2c_driver *driver; |
89 | |||
90 | if (!dev->driver) | ||
91 | return 0; | ||
92 | driver = to_i2c_driver(dev->driver); | ||
93 | if (!driver->resume) | ||
94 | return 0; | ||
95 | return driver->resume(to_i2c_client(dev)); | ||
76 | } | 96 | } |
77 | 97 | ||
78 | struct bus_type i2c_bus_type = { | 98 | struct bus_type i2c_bus_type = { |
79 | .name = "i2c", | 99 | .name = "i2c", |
80 | .match = i2c_device_match, | 100 | .match = i2c_device_match, |
81 | .probe = i2c_device_probe, | 101 | .probe = i2c_device_probe, |
82 | .remove = i2c_device_remove, | 102 | .remove = i2c_device_remove, |
83 | .suspend = i2c_bus_suspend, | 103 | .shutdown = i2c_device_shutdown, |
84 | .resume = i2c_bus_resume, | 104 | .suspend = i2c_device_suspend, |
105 | .resume = i2c_device_resume, | ||
85 | }; | 106 | }; |
86 | 107 | ||
108 | /* ------------------------------------------------------------------------- */ | ||
109 | |||
87 | void i2c_adapter_dev_release(struct device *dev) | 110 | void i2c_adapter_dev_release(struct device *dev) |
88 | { | 111 | { |
89 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); | 112 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); |