16 #include <linux/device.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
24 #include <linux/slab.h>
49 static int gpio_charger_get_property(
struct power_supply *psy,
74 struct gpio_charger *gpio_charger;
84 if (!gpio_is_valid(pdata->
gpio)) {
89 gpio_charger = kzalloc(
sizeof(*gpio_charger),
GFP_KERNEL);
91 dev_err(&pdev->
dev,
"Failed to alloc driver structure\n");
95 charger = &gpio_charger->
charger;
97 charger->
name = pdata->
name ? pdata->
name :
"gpio-charger";
107 dev_err(&pdev->
dev,
"Failed to request gpio pin: %d\n", ret);
112 dev_err(&pdev->
dev,
"Failed to set gpio to input: %d\n", ret);
120 dev_err(&pdev->
dev,
"Failed to register power supply: %d\n",
129 dev_name(&pdev->
dev), charger);
131 dev_warn(&pdev->
dev,
"Failed to request irq: %d\n", ret);
133 gpio_charger->
irq = irq;
136 platform_set_drvdata(pdev, gpio_charger);
149 struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
151 if (gpio_charger->
irq)
158 platform_set_drvdata(pdev,
NULL);
164 #ifdef CONFIG_PM_SLEEP
165 static int gpio_charger_resume(
struct device *
dev)
168 struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);
179 .probe = gpio_charger_probe,
182 .name =
"gpio-charger",
184 .pm = &gpio_charger_pm_ops,
191 MODULE_DESCRIPTION(
"Driver for chargers which report their online status through a GPIO");