Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'pm-wakeirq'

* pm-wakeirq:
PM / wakeirq: Avoid setting power.wakeirq too hastily

+15 -28
+5 -7
drivers/base/power/wakeirq.c
··· 45 45 return -EEXIST; 46 46 } 47 47 48 - dev->power.wakeirq = wirq; 49 - spin_unlock_irqrestore(&dev->power.lock, flags); 50 - 51 48 err = device_wakeup_attach_irq(dev, wirq); 52 - if (err) 53 - return err; 49 + if (!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 /** ··· 103 105 return; 104 106 105 107 spin_lock_irqsave(&dev->power.lock, flags); 108 + device_wakeup_detach_irq(dev); 106 109 dev->power.wakeirq = NULL; 107 110 spin_unlock_irqrestore(&dev->power.lock, flags); 108 111 109 - device_wakeup_detach_irq(dev); 110 112 if (wirq->dedicated_irq) 111 113 free_irq(wirq->irq, wirq); 112 114 kfree(wirq);
+10 -21
drivers/base/power/wakeup.c
··· 281 281 * Attach a device wakeirq to the wakeup source so the device 282 282 * wake IRQ can be configured automatically for suspend and 283 283 * resume. 284 + * 285 + * Call under the device's power.lock lock. 284 286 */ 285 287 int device_wakeup_attach_irq(struct device *dev, 286 288 struct wake_irq *wakeirq) 287 289 { 288 290 struct wakeup_source *ws; 289 - int ret = 0; 290 291 291 - spin_lock_irq(&dev->power.lock); 292 292 ws = dev->power.wakeup; 293 293 if (!ws) { 294 294 dev_err(dev, "forgot to call call device_init_wakeup?\n"); 295 - ret = -EINVAL; 296 - goto unlock; 295 + return -EINVAL; 297 296 } 298 297 299 - if (ws->wakeirq) { 300 - ret = -EEXIST; 301 - goto unlock; 302 - } 298 + if (ws->wakeirq) 299 + return -EEXIST; 303 300 304 301 ws->wakeirq = wakeirq; 305 - 306 - unlock: 307 - spin_unlock_irq(&dev->power.lock); 308 - 309 - return ret; 302 + return 0; 310 303 } 311 304 312 305 /** ··· 307 314 * @dev: Device to handle 308 315 * 309 316 * Removes a device wakeirq from the wakeup source. 317 + * 318 + * Call under the device's power.lock lock. 310 319 */ 311 320 void device_wakeup_detach_irq(struct device *dev) 312 321 { 313 322 struct wakeup_source *ws; 314 323 315 - spin_lock_irq(&dev->power.lock); 316 324 ws = dev->power.wakeup; 317 - if (!ws) 318 - goto unlock; 319 - 320 - ws->wakeirq = NULL; 321 - 322 - unlock: 323 - spin_unlock_irq(&dev->power.lock); 325 + if (ws) 326 + ws->wakeirq = NULL; 324 327 } 325 328 326 329 /**