Merge branch 'slabh' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc
[sfrench/cifs-2.6.git] / drivers / power / wm97xx_battery.c
index fa39e759a275a2a49ef7a0ceb306c4eee9c5abbf..94c70650aafc90275fd24d74b798d6d66f91263c 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/gpio.h>
 #include <linux/irq.h>
+#include <linux/slab.h>
 
 static DEFINE_MUTEX(bat_lock);
 static struct work_struct bat_work;
-struct mutex work_lock;
+static struct mutex work_lock;
 static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
 static struct wm97xx_batt_info *gpdata;
 static enum power_supply_property *prop;
@@ -175,8 +176,14 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
                dev_err(&dev->dev, "Do not pass platform_data through "
                        "wm97xx_bat_set_pdata!\n");
                return -EINVAL;
-       } else
-               pdata = wmdata->batt_pdata;
+       }
+
+       if (!wmdata) {
+               dev_err(&dev->dev, "No platform data supplied\n");
+               return -EINVAL;
+       }
+
+       pdata = wmdata->batt_pdata;
 
        if (dev->id != -1)
                return -EINVAL;
@@ -197,7 +204,7 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
                        goto err2;
                ret = request_irq(gpio_to_irq(pdata->charge_gpio),
                                wm97xx_chrg_irq, IRQF_DISABLED,
-                               "AC Detect", 0);
+                               "AC Detect", dev);
                if (ret)
                        goto err2;
                props++;        /* POWER_SUPPLY_PROP_STATUS */