diff options
Diffstat (limited to 'drivers/pnp/driver.c')
-rw-r--r-- | drivers/pnp/driver.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index d3ccce706ab4..15fb758a9e52 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -146,10 +146,57 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv) | |||
146 | return 1; | 146 | return 1; |
147 | } | 147 | } |
148 | 148 | ||
149 | static 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 | |||
174 | static 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 | ||
150 | struct bus_type pnp_bus_type = { | 195 | struct bus_type pnp_bus_type = { |
151 | .name = "pnp", | 196 | .name = "pnp", |
152 | .match = pnp_bus_match, | 197 | .match = pnp_bus_match, |
198 | .suspend = pnp_bus_suspend, | ||
199 | .resume = pnp_bus_resume, | ||
153 | }; | 200 | }; |
154 | 201 | ||
155 | 202 | ||