These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / power / wm831x_power.c
index 0161bda..7082301 100644 (file)
@@ -499,7 +499,8 @@ static int wm831x_power_probe(struct platform_device *pdev)
        struct wm831x_power *power;
        int ret, irq, i;
 
-       power = kzalloc(sizeof(struct wm831x_power), GFP_KERNEL);
+       power = devm_kzalloc(&pdev->dev, sizeof(struct wm831x_power),
+                            GFP_KERNEL);
        if (power == NULL)
                return -ENOMEM;
 
@@ -536,7 +537,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
                                            NULL);
        if (IS_ERR(power->wall)) {
                ret = PTR_ERR(power->wall);
-               goto err_kmalloc;
+               goto err;
        }
 
        power->usb_desc.name = power->usb_name,
@@ -572,7 +573,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
 
        irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "SYSLO"));
        ret = request_threaded_irq(irq, NULL, wm831x_syslo_irq,
-                                  IRQF_TRIGGER_RISING, "System power low",
+                                  IRQF_TRIGGER_RISING | IRQF_ONESHOT, "System power low",
                                   power);
        if (ret != 0) {
                dev_err(&pdev->dev, "Failed to request SYSLO IRQ %d: %d\n",
@@ -582,7 +583,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
 
        irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "PWR SRC"));
        ret = request_threaded_irq(irq, NULL, wm831x_pwr_src_irq,
-                                  IRQF_TRIGGER_RISING, "Power source",
+                                  IRQF_TRIGGER_RISING | IRQF_ONESHOT, "Power source",
                                   power);
        if (ret != 0) {
                dev_err(&pdev->dev, "Failed to request PWR SRC IRQ %d: %d\n",
@@ -595,7 +596,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
                                 platform_get_irq_byname(pdev,
                                                         wm831x_bat_irqs[i]));
                ret = request_threaded_irq(irq, NULL, wm831x_bat_irq,
-                                          IRQF_TRIGGER_RISING,
+                                          IRQF_TRIGGER_RISING | IRQF_ONESHOT,
                                           wm831x_bat_irqs[i],
                                           power);
                if (ret != 0) {
@@ -609,6 +610,7 @@ static int wm831x_power_probe(struct platform_device *pdev)
        return ret;
 
 err_bat_irq:
+       --i;
        for (; i >= 0; i--) {
                irq = platform_get_irq_byname(pdev, wm831x_bat_irqs[i]);
                free_irq(irq, power);
@@ -625,8 +627,7 @@ err_usb:
        power_supply_unregister(power->usb);
 err_wall:
        power_supply_unregister(power->wall);
-err_kmalloc:
-       kfree(power);
+err:
        return ret;
 }
 
@@ -653,7 +654,6 @@ static int wm831x_power_remove(struct platform_device *pdev)
                power_supply_unregister(wm831x_power->battery);
        power_supply_unregister(wm831x_power->wall);
        power_supply_unregister(wm831x_power->usb);
-       kfree(wm831x_power);
        return 0;
 }