aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/driver.c')
-rw-r--r--drivers/pnp/driver.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index d3ccce706ab4..7cafacdd12b0 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -146,10 +146,59 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv)
146 return 1; 146 return 1;
147} 147}
148 148
149static int pnp_bus_suspend(struct device *dev, pm_message_t state)
150{
151 struct pnp_dev * pnp_dev = to_pnp_dev(dev);
152 struct pnp_driver * pnp_drv = pnp_dev->driver;
153 int error;
154
155 if (!pnp_drv)
156 return 0;
157
158 if (pnp_drv->suspend) {
159 error = pnp_drv->suspend(pnp_dev, state);
160 if (error)
161 return error;
162 }
163
164 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) &&
165 pnp_can_disable(pnp_dev)) {
166 error = pnp_stop_dev(pnp_dev);
167 if (error)
168 return error;
169 }
170
171 return 0;
172}
173
174static int pnp_bus_resume(struct device *dev)
175{
176 struct pnp_dev * pnp_dev = to_pnp_dev(dev);
177 struct pnp_driver * pnp_drv = pnp_dev->driver;
178 int error;
179
180 if (!pnp_drv)
181 return 0;
182
183 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) {
184 error = pnp_start_dev(pnp_dev);
185 if (error)
186 return error;
187 }
188
189 if (pnp_drv->resume)
190 return pnp_drv->resume(pnp_dev);
191
192 return 0;
193}
149 194
150struct bus_type pnp_bus_type = { 195struct bus_type pnp_bus_type = {
151 .name = "pnp", 196 .name = "pnp",
152 .match = pnp_bus_match, 197 .match = pnp_bus_match,
198 .probe = pnp_device_probe,
199 .remove = pnp_device_remove,
200 .suspend = pnp_bus_suspend,
201 .resume = pnp_bus_resume,
153}; 202};
154 203
155 204
@@ -168,8 +217,6 @@ int pnp_register_driver(struct pnp_driver *drv)
168 217
169 drv->driver.name = drv->name; 218 drv->driver.name = drv->name;
170 drv->driver.bus = &pnp_bus_type; 219 drv->driver.bus = &pnp_bus_type;
171 drv->driver.probe = pnp_device_probe;
172 drv->driver.remove = pnp_device_remove;
173 220
174 count = driver_register(&drv->driver); 221 count = driver_register(&drv->driver);
175 222