aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c71
1 files changed, 47 insertions, 24 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index b05378a3d673..21fe1406c8b4 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -32,6 +32,7 @@
32#include <linux/seq_file.h> 32#include <linux/seq_file.h>
33#include <linux/platform_device.h> 33#include <linux/platform_device.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/completion.h>
35#include <asm/uaccess.h> 36#include <asm/uaccess.h>
36 37
37 38
@@ -40,49 +41,72 @@ static LIST_HEAD(drivers);
40static DEFINE_MUTEX(core_lists); 41static DEFINE_MUTEX(core_lists);
41static DEFINE_IDR(i2c_adapter_idr); 42static DEFINE_IDR(i2c_adapter_idr);
42 43
44
45/* ------------------------------------------------------------------------- */
46
43/* 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 */
44static int i2c_device_match(struct device *dev, struct device_driver *drv) 48static int i2c_device_match(struct device *dev, struct device_driver *drv)
45{ 49{
46 return 1; 50 return 1;
47} 51}
48 52
49static int i2c_bus_suspend(struct device * dev, pm_message_t state) 53static int i2c_device_probe(struct device *dev)
50{ 54{
51 int rc = 0; 55 return -ENODEV;
56}
52 57
53 if (dev->driver && dev->driver->suspend) 58static int i2c_device_remove(struct device *dev)
54 rc = dev->driver->suspend(dev, state); 59{
55 return rc; 60 return 0;
56} 61}
57 62
58static int i2c_bus_resume(struct device * dev) 63static void i2c_device_shutdown(struct device *dev)
59{ 64{
60 int rc = 0; 65 struct i2c_driver *driver;
61 66
62 if (dev->driver && dev->driver->resume) 67 if (!dev->driver)
63 rc = dev->driver->resume(dev); 68 return;
64 return rc; 69 driver = to_i2c_driver(dev->driver);
70 if (driver->shutdown)
71 driver->shutdown(to_i2c_client(dev));
65} 72}
66 73
67static int i2c_device_probe(struct device *dev) 74static int i2c_device_suspend(struct device * dev, pm_message_t mesg)
68{ 75{
69 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);
70} 84}
71 85
72static int i2c_device_remove(struct device *dev) 86static int i2c_device_resume(struct device * dev)
73{ 87{
74 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));
75} 96}
76 97
77struct bus_type i2c_bus_type = { 98struct bus_type i2c_bus_type = {
78 .name = "i2c", 99 .name = "i2c",
79 .match = i2c_device_match, 100 .match = i2c_device_match,
80 .probe = i2c_device_probe, 101 .probe = i2c_device_probe,
81 .remove = i2c_device_remove, 102 .remove = i2c_device_remove,
82 .suspend = i2c_bus_suspend, 103 .shutdown = i2c_device_shutdown,
83 .resume = i2c_bus_resume, 104 .suspend = i2c_device_suspend,
105 .resume = i2c_device_resume,
84}; 106};
85 107
108/* ------------------------------------------------------------------------- */
109
86void i2c_adapter_dev_release(struct device *dev) 110void i2c_adapter_dev_release(struct device *dev)
87{ 111{
88 struct i2c_adapter *adap = dev_to_i2c_adapter(dev); 112 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
@@ -193,9 +217,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
193 */ 217 */
194 if (adap->dev.parent == NULL) { 218 if (adap->dev.parent == NULL) {
195 adap->dev.parent = &platform_bus; 219 adap->dev.parent = &platform_bus;
196 printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] " 220 pr_debug("I2C adapter driver [%s] forgot to specify "
197 "forgot to specify physical device; fix it!\n", 221 "physical device\n", adap->name);
198 adap->name);
199 } 222 }
200 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 223 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
201 adap->dev.driver = &i2c_adapter_driver; 224 adap->dev.driver = &i2c_adapter_driver;