diff options
| -rw-r--r-- | drivers/base/power/wakeirq.c | 12 | ||||
| -rw-r--r-- | drivers/base/power/wakeup.c | 31 |
2 files changed, 15 insertions, 28 deletions
diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c index 7470004ca810..eb6e67451dec 100644 --- a/drivers/base/power/wakeirq.c +++ b/drivers/base/power/wakeirq.c | |||
| @@ -45,14 +45,12 @@ static int dev_pm_attach_wake_irq(struct device *dev, int irq, | |||
| 45 | return -EEXIST; | 45 | return -EEXIST; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | dev->power.wakeirq = wirq; | ||
| 49 | spin_unlock_irqrestore(&dev->power.lock, flags); | ||
| 50 | |||
| 51 | err = device_wakeup_attach_irq(dev, wirq); | 48 | err = device_wakeup_attach_irq(dev, wirq); |
| 52 | if (err) | 49 | if (!err) |
| 53 | return err; | 50 | dev->power.wakeirq = wirq; |
| 54 | 51 | ||
| 55 | return 0; | 52 | spin_unlock_irqrestore(&dev->power.lock, flags); |
| 53 | return err; | ||
| 56 | } | 54 | } |
| 57 | 55 | ||
| 58 | /** | 56 | /** |
| @@ -105,10 +103,10 @@ void dev_pm_clear_wake_irq(struct device *dev) | |||
| 105 | return; | 103 | return; |
| 106 | 104 | ||
| 107 | spin_lock_irqsave(&dev->power.lock, flags); | 105 | spin_lock_irqsave(&dev->power.lock, flags); |
| 106 | device_wakeup_detach_irq(dev); | ||
| 108 | dev->power.wakeirq = NULL; | 107 | dev->power.wakeirq = NULL; |
| 109 | spin_unlock_irqrestore(&dev->power.lock, flags); | 108 | spin_unlock_irqrestore(&dev->power.lock, flags); |
| 110 | 109 | ||
| 111 | device_wakeup_detach_irq(dev); | ||
| 112 | if (wirq->dedicated_irq) | 110 | if (wirq->dedicated_irq) |
| 113 | free_irq(wirq->irq, wirq); | 111 | free_irq(wirq->irq, wirq); |
| 114 | kfree(wirq); | 112 | kfree(wirq); |
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 40f71603378c..51f15bc15774 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c | |||
| @@ -281,32 +281,25 @@ EXPORT_SYMBOL_GPL(device_wakeup_enable); | |||
| 281 | * Attach a device wakeirq to the wakeup source so the device | 281 | * Attach a device wakeirq to the wakeup source so the device |
| 282 | * wake IRQ can be configured automatically for suspend and | 282 | * wake IRQ can be configured automatically for suspend and |
| 283 | * resume. | 283 | * resume. |
| 284 | * | ||
| 285 | * Call under the device's power.lock lock. | ||
| 284 | */ | 286 | */ |
| 285 | int device_wakeup_attach_irq(struct device *dev, | 287 | int device_wakeup_attach_irq(struct device *dev, |
| 286 | struct wake_irq *wakeirq) | 288 | struct wake_irq *wakeirq) |
| 287 | { | 289 | { |
| 288 | struct wakeup_source *ws; | 290 | struct wakeup_source *ws; |
| 289 | int ret = 0; | ||
| 290 | 291 | ||
| 291 | spin_lock_irq(&dev->power.lock); | ||
| 292 | ws = dev->power.wakeup; | 292 | ws = dev->power.wakeup; |
| 293 | if (!ws) { | 293 | if (!ws) { |
| 294 | dev_err(dev, "forgot to call call device_init_wakeup?\n"); | 294 | dev_err(dev, "forgot to call call device_init_wakeup?\n"); |
| 295 | ret = -EINVAL; | 295 | return -EINVAL; |
| 296 | goto unlock; | ||
| 297 | } | 296 | } |
| 298 | 297 | ||
| 299 | if (ws->wakeirq) { | 298 | if (ws->wakeirq) |
| 300 | ret = -EEXIST; | 299 | return -EEXIST; |
| 301 | goto unlock; | ||
| 302 | } | ||
| 303 | 300 | ||
| 304 | ws->wakeirq = wakeirq; | 301 | ws->wakeirq = wakeirq; |
| 305 | 302 | return 0; | |
| 306 | unlock: | ||
| 307 | spin_unlock_irq(&dev->power.lock); | ||
| 308 | |||
| 309 | return ret; | ||
| 310 | } | 303 | } |
| 311 | 304 | ||
| 312 | /** | 305 | /** |
| @@ -314,20 +307,16 @@ unlock: | |||
| 314 | * @dev: Device to handle | 307 | * @dev: Device to handle |
| 315 | * | 308 | * |
| 316 | * Removes a device wakeirq from the wakeup source. | 309 | * Removes a device wakeirq from the wakeup source. |
| 310 | * | ||
| 311 | * Call under the device's power.lock lock. | ||
| 317 | */ | 312 | */ |
| 318 | void device_wakeup_detach_irq(struct device *dev) | 313 | void device_wakeup_detach_irq(struct device *dev) |
| 319 | { | 314 | { |
| 320 | struct wakeup_source *ws; | 315 | struct wakeup_source *ws; |
| 321 | 316 | ||
| 322 | spin_lock_irq(&dev->power.lock); | ||
| 323 | ws = dev->power.wakeup; | 317 | ws = dev->power.wakeup; |
| 324 | if (!ws) | 318 | if (ws) |
| 325 | goto unlock; | 319 | ws->wakeirq = NULL; |
| 326 | |||
| 327 | ws->wakeirq = NULL; | ||
| 328 | |||
| 329 | unlock: | ||
| 330 | spin_unlock_irq(&dev->power.lock); | ||
| 331 | } | 320 | } |
| 332 | 321 | ||
| 333 | /** | 322 | /** |
