Commit a21c1ea6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v4.1' of git://git.infradead.org/battery-2.6

Pull power supply and reset changes from Sebastian Reichel:

 - new API for safe access of power supply function attrs

 - devres support for power supply (un)registration

 - new drivers / chips:
     - generic syscon based poweroff driver
     - iio & charger driver for da9150
     - fuel gauge driver for axp288
     - bq27x00: add support for bq27510
     - bq2415x: add support for bq24157s

 - twl4030-madc-battery: convert to iio consumer

 - misc fixes

* tag 'for-v4.1' of git://git.infradead.org/battery-2.6: (66 commits)
  power: twl4030_madc_battery: Add missing MODULE_ALIAS
  power: twl4030-madc-battery: Convert to iio consumer.
  dt: power: Add docs for generic SYSCON poweroff driver.
  power: reset: Add generic SYSCON register mapped poweroff.
  power: max17042_battery: add missed blank
  power: max17042_battery: Use reg type instead of chip type
  power/reset: at91: big endian fixes for atsama5d3x
  power_supply: charger-manager: Fix dereferencing of ERR_PTR
  HID: input: Fix NULL pointer dereference when power_supply_register fails
  power: constify of_device_id array
  power/reset/rmobile-reset.c: Fix !HAS_IOMEM build
  power_supply: 88pm860x_charger: Fix possible NULL pointer dereference and use of initialized variable
  arm: mach-pxa: Decrement the power supply's device reference counter
  mfd: ab8500: Decrement the power supply's device reference counter
  power_supply: bq2415x_charger: Decrement the power supply's device reference counter
  power_supply: 88pm860x_charger: Decrement the power supply's device reference counter
  x86/olpc/xo15/sci: Use newly added power_supply_put API
  x86/olpc/xo1/sci: Use newly added power_supply_put API
  power_supply: charger-manager: Decrement the power supply's device reference counter
  power_supply: Increment power supply use counter when obtaining references
  ...
parents d700b056 5939d9df
Dialog Semiconductor DA9150 IIO GPADC bindings
Required properties:
- compatible: "dlg,da9150-gpadc" for DA9150 IIO GPADC
- #io-channel-cells: Should be set to <1>
(See Documentation/devicetree/bindings/iio/iio-bindings.txt for further info)
For further information on GPADC channels, see device datasheet.
Example:
gpadc: da9150-gpadc {
compatible = "dlg,da9150-gpadc";
#io-channel-cells = <1>;
};
Dialog Semiconductor DA9150 Charger Power Supply bindings
Required properties:
- compatible: "dlg,da9150-charger" for DA9150 Charger Power Supply
Optional properties:
- io-channels: List of phandle and IIO specifier pairs
- io-channel-names: List of channel names used by charger
["CHAN_IBUS", "CHAN_VBUS", "CHAN_TJUNC", "CHAN_VBAT"]
(See Documentation/devicetree/bindings/iio/iio-bindings.txt for further info)
Example:
da9150-charger {
compatible = "dlg,da9150-charger";
io-channels = <&gpadc 0>,
<&gpadc 2>,
<&gpadc 8>,
<&gpadc 5>;
io-channel-names = "CHAN_IBUS",
"CHAN_VBUS",
"CHAN_TJUNC",
"CHAN_VBAT";
};
Generic SYSCON mapped register poweroff driver
This is a generic poweroff driver using syscon to map the poweroff register.
The poweroff is generally performed with a write to the poweroff register
defined by the register map pointed by syscon reference plus the offset
with the mask defined in the poweroff node.
Required properties:
- compatible: should contain "syscon-poweroff"
- regmap: this is phandle to the register map node
- offset: offset in the register map for the poweroff register (in bytes)
- mask: the poweroff value written to the poweroff register (32 bit access)
Default will be little endian mode, 32 bit access only.
Examples:
poweroff {
compatible = "syscon-poweroff";
regmap = <&regmapnode>;
offset = <0x0>;
mask = <0x7a>;
};
...@@ -3137,12 +3137,15 @@ S: Supported ...@@ -3137,12 +3137,15 @@ S: Supported
F: Documentation/hwmon/da90?? F: Documentation/hwmon/da90??
F: drivers/gpio/gpio-da90??.c F: drivers/gpio/gpio-da90??.c
F: drivers/hwmon/da90??-hwmon.c F: drivers/hwmon/da90??-hwmon.c
F: drivers/iio/adc/da91??-*.c
F: drivers/input/misc/da90??_onkey.c F: drivers/input/misc/da90??_onkey.c
F: drivers/input/touchscreen/da9052_tsi.c F: drivers/input/touchscreen/da9052_tsi.c
F: drivers/leds/leds-da90??.c F: drivers/leds/leds-da90??.c
F: drivers/mfd/da903x.c F: drivers/mfd/da903x.c
F: drivers/mfd/da90??-*.c F: drivers/mfd/da90??-*.c
F: drivers/mfd/da91??-*.c
F: drivers/power/da9052-battery.c F: drivers/power/da9052-battery.c
F: drivers/power/da91??-*.c
F: drivers/regulator/da903x.c F: drivers/regulator/da903x.c
F: drivers/regulator/da9???-regulator.[ch] F: drivers/regulator/da9???-regulator.[ch]
F: drivers/rtc/rtc-da90??.c F: drivers/rtc/rtc-da90??.c
...@@ -3152,6 +3155,7 @@ F: include/linux/mfd/da903x.h ...@@ -3152,6 +3155,7 @@ F: include/linux/mfd/da903x.h
F: include/linux/mfd/da9052/ F: include/linux/mfd/da9052/
F: include/linux/mfd/da9055/ F: include/linux/mfd/da9055/
F: include/linux/mfd/da9063/ F: include/linux/mfd/da9063/
F: include/linux/mfd/da9150/
F: include/sound/da[79]*.h F: include/sound/da[79]*.h
F: sound/soc/codecs/da[79]*.[ch] F: sound/soc/codecs/da[79]*.[ch]
......
...@@ -758,8 +758,10 @@ static void raumfeld_power_signal_charged(void) ...@@ -758,8 +758,10 @@ static void raumfeld_power_signal_charged(void)
struct power_supply *psy = struct power_supply *psy =
power_supply_get_by_name(raumfeld_power_supplicants[0]); power_supply_get_by_name(raumfeld_power_supplicants[0]);
if (psy) if (psy) {
power_supply_set_battery_charged(psy); power_supply_set_battery_charged(psy);
power_supply_put(psy);
}
} }
static int raumfeld_power_resume(void) static int raumfeld_power_resume(void)
......
...@@ -61,7 +61,7 @@ static void battery_status_changed(void) ...@@ -61,7 +61,7 @@ static void battery_status_changed(void)
if (psy) { if (psy) {
power_supply_changed(psy); power_supply_changed(psy);
put_device(psy->dev); power_supply_put(psy);
} }
} }
...@@ -71,7 +71,7 @@ static void ac_status_changed(void) ...@@ -71,7 +71,7 @@ static void ac_status_changed(void)
if (psy) { if (psy) {
power_supply_changed(psy); power_supply_changed(psy);
put_device(psy->dev); power_supply_put(psy);
} }
} }
......
...@@ -83,7 +83,7 @@ static void battery_status_changed(void) ...@@ -83,7 +83,7 @@ static void battery_status_changed(void)
if (psy) { if (psy) {
power_supply_changed(psy); power_supply_changed(psy);
put_device(psy->dev); power_supply_put(psy);
} }
} }
...@@ -93,7 +93,7 @@ static void ac_status_changed(void) ...@@ -93,7 +93,7 @@ static void ac_status_changed(void)
if (psy) { if (psy) {
power_supply_changed(psy); power_supply_changed(psy);
put_device(psy->dev); power_supply_put(psy);
} }
} }
......
...@@ -95,13 +95,14 @@ static struct acpi_driver acpi_ac_driver = { ...@@ -95,13 +95,14 @@ static struct acpi_driver acpi_ac_driver = {
}; };
struct acpi_ac { struct acpi_ac {
struct power_supply charger; struct power_supply *charger;
struct power_supply_desc charger_desc;
struct acpi_device * device; struct acpi_device * device;
unsigned long long state; unsigned long long state;
struct notifier_block battery_nb; struct notifier_block battery_nb;
}; };
#define to_acpi_ac(x) container_of(x, struct acpi_ac, charger) #define to_acpi_ac(x) power_supply_get_drvdata(x)
#ifdef CONFIG_ACPI_PROCFS_POWER #ifdef CONFIG_ACPI_PROCFS_POWER
static const struct file_operations acpi_ac_fops = { static const struct file_operations acpi_ac_fops = {
...@@ -275,7 +276,7 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event) ...@@ -275,7 +276,7 @@ static void acpi_ac_notify(struct acpi_device *device, u32 event)
dev_name(&device->dev), event, dev_name(&device->dev), event,
(u32) ac->state); (u32) ac->state);
acpi_notifier_call_chain(device, event, (u32) ac->state); acpi_notifier_call_chain(device, event, (u32) ac->state);
kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
} }
return; return;
...@@ -321,6 +322,7 @@ static struct dmi_system_id ac_dmi_table[] = { ...@@ -321,6 +322,7 @@ static struct dmi_system_id ac_dmi_table[] = {
static int acpi_ac_add(struct acpi_device *device) static int acpi_ac_add(struct acpi_device *device)
{ {
struct power_supply_config psy_cfg = {};
int result = 0; int result = 0;
struct acpi_ac *ac = NULL; struct acpi_ac *ac = NULL;
...@@ -341,19 +343,24 @@ static int acpi_ac_add(struct acpi_device *device) ...@@ -341,19 +343,24 @@ static int acpi_ac_add(struct acpi_device *device)
if (result) if (result)
goto end; goto end;
ac->charger.name = acpi_device_bid(device); psy_cfg.drv_data = ac;
ac->charger_desc.name = acpi_device_bid(device);
#ifdef CONFIG_ACPI_PROCFS_POWER #ifdef CONFIG_ACPI_PROCFS_POWER
result = acpi_ac_add_fs(ac); result = acpi_ac_add_fs(ac);
if (result) if (result)
goto end; goto end;
#endif #endif
ac->charger.type = POWER_SUPPLY_TYPE_MAINS; ac->charger_desc.type = POWER_SUPPLY_TYPE_MAINS;
ac->charger.properties = ac_props; ac->charger_desc.properties = ac_props;
ac->charger.num_properties = ARRAY_SIZE(ac_props); ac->charger_desc.num_properties = ARRAY_SIZE(ac_props);
ac->charger.get_property = get_ac_property; ac->charger_desc.get_property = get_ac_property;
result = power_supply_register(&ac->device->dev, &ac->charger); ac->charger = power_supply_register(&ac->device->dev,
if (result) &ac->charger_desc, &psy_cfg);
if (IS_ERR(ac->charger)) {
result = PTR_ERR(ac->charger);
goto end; goto end;
}
printk(KERN_INFO PREFIX "%s [%s] (%s)\n", printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
acpi_device_name(device), acpi_device_bid(device), acpi_device_name(device), acpi_device_bid(device),
...@@ -390,7 +397,7 @@ static int acpi_ac_resume(struct device *dev) ...@@ -390,7 +397,7 @@ static int acpi_ac_resume(struct device *dev)
if (acpi_ac_get_state(ac)) if (acpi_ac_get_state(ac))
return 0; return 0;
if (old_state != ac->state) if (old_state != ac->state)
kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE); kobject_uevent(&ac->charger->dev.kobj, KOBJ_CHANGE);
return 0; return 0;
} }
#else #else
...@@ -407,8 +414,7 @@ static int acpi_ac_remove(struct acpi_device *device) ...@@ -407,8 +414,7 @@ static int acpi_ac_remove(struct acpi_device *device)
ac = acpi_driver_data(device); ac = acpi_driver_data(device);
if (ac->charger.dev) power_supply_unregister(ac->charger);
power_supply_unregister(&ac->charger);
unregister_acpi_notifier(&ac->battery_nb); unregister_acpi_notifier(&ac->battery_nb);
#ifdef CONFIG_ACPI_PROCFS_POWER #ifdef CONFIG_ACPI_PROCFS_POWER
......
...@@ -117,7 +117,8 @@ enum { ...@@ -117,7 +117,8 @@ enum {
struct acpi_battery { struct acpi_battery {
struct mutex lock; struct mutex lock;
struct mutex sysfs_lock; struct mutex sysfs_lock;
struct power_supply bat; struct power_supply *bat;
struct power_supply_desc bat_desc;
struct acpi_device *device; struct acpi_device *device;
struct notifier_block pm_nb; struct notifier_block pm_nb;
unsigned long update_time; unsigned long update_time;
...@@ -149,7 +150,7 @@ struct acpi_battery { ...@@ -149,7 +150,7 @@ struct acpi_battery {
unsigned long flags; unsigned long flags;
}; };
#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat) #define to_acpi_battery(x) power_supply_get_drvdata(x)
static inline int acpi_battery_present(struct acpi_battery *battery) static inline int acpi_battery_present(struct acpi_battery *battery)
{ {
...@@ -608,40 +609,45 @@ static struct device_attribute alarm_attr = { ...@@ -608,40 +609,45 @@ static struct device_attribute alarm_attr = {
static int sysfs_add_battery(struct acpi_battery *battery) static int sysfs_add_battery(struct acpi_battery *battery)
{ {
int result; struct power_supply_config psy_cfg = { .drv_data = battery, };
if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) { if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA) {
battery->bat.properties = charge_battery_props; battery->bat_desc.properties = charge_battery_props;
battery->bat.num_properties = battery->bat_desc.num_properties =
ARRAY_SIZE(charge_battery_props); ARRAY_SIZE(charge_battery_props);
} else { } else {
battery->bat.properties = energy_battery_props; battery->bat_desc.properties = energy_battery_props;
battery->bat.num_properties = battery->bat_desc.num_properties =
ARRAY_SIZE(energy_battery_props); ARRAY_SIZE(energy_battery_props);
} }
battery->bat.name = acpi_device_bid(battery->device); battery->bat_desc.name = acpi_device_bid(battery->device);
battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; battery->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY;
battery->bat.get_property = acpi_battery_get_property; battery->bat_desc.get_property = acpi_battery_get_property;
result = power_supply_register_no_ws(&battery->device->dev, &battery->bat); battery->bat = power_supply_register_no_ws(&battery->device->dev,
&battery->bat_desc, &psy_cfg);
if (result) if (IS_ERR(battery->bat)) {
int result = PTR_ERR(battery->bat);
battery->bat = NULL;
return result; return result;
return device_create_file(battery->bat.dev, &alarm_attr); }
return device_create_file(&battery->bat->dev, &alarm_attr);
} }
static void sysfs_remove_battery(struct acpi_battery *battery) static void sysfs_remove_battery(struct acpi_battery *battery)
{ {
mutex_lock(&battery->sysfs_lock); mutex_lock(&battery->sysfs_lock);
if (!battery->bat.dev) { if (!battery->bat) {
mutex_unlock(&battery->sysfs_lock); mutex_unlock(&battery->sysfs_lock);
return; return;
} }
device_remove_file(battery->bat.dev, &alarm_attr); device_remove_file(&battery->bat->dev, &alarm_attr);
power_supply_unregister(&battery->bat); power_supply_unregister(battery->bat);
battery->bat.dev = NULL; battery->bat = NULL;
mutex_unlock(&battery->sysfs_lock); mutex_unlock(&battery->sysfs_lock);
} }
...@@ -738,7 +744,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume) ...@@ -738,7 +744,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume)
return result; return result;
acpi_battery_init_alarm(battery); acpi_battery_init_alarm(battery);
} }
if (!battery->bat.dev) { if (!battery->bat) {
result = sysfs_add_battery(battery); result = sysfs_add_battery(battery);
if (result) if (result)
return result; return result;
...@@ -764,7 +770,7 @@ static void acpi_battery_refresh(struct acpi_battery *battery) ...@@ -764,7 +770,7 @@ static void acpi_battery_refresh(struct acpi_battery *battery)
{ {
int power_unit; int power_unit;
if (!battery->bat.dev) if (!battery->bat)
return; return;
power_unit = battery->power_unit; power_unit = battery->power_unit;
...@@ -1062,11 +1068,11 @@ static void acpi_battery_remove_fs(struct acpi_device *device) ...@@ -1062,11 +1068,11 @@ static void acpi_battery_remove_fs(struct acpi_device *device)
static void acpi_battery_notify(struct acpi_device *device, u32 event) static void acpi_battery_notify(struct acpi_device *device, u32 event)
{ {
struct acpi_battery *battery = acpi_driver_data(device); struct acpi_battery *battery = acpi_driver_data(device);
struct device *old; struct power_supply *old;
if (!battery) if (!battery)
return; return;
old = battery->bat.dev; old = battery->bat;
/* /*
* On Acer Aspire V5-573G notifications are sometimes triggered too * On Acer Aspire V5-573G notifications are sometimes triggered too
* early. For example, when AC is unplugged and notification is * early. For example, when AC is unplugged and notification is
...@@ -1083,8 +1089,8 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event) ...@@ -1083,8 +1089,8 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
acpi_battery_present(battery)); acpi_battery_present(battery));
acpi_notifier_call_chain(device, event, acpi_battery_present(battery)); acpi_notifier_call_chain(device, event, acpi_battery_present(battery));
/* acpi_battery_update could remove power_supply object */ /* acpi_battery_update could remove power_supply object */
if (old && battery->bat.dev) if (old && battery->bat)
power_supply_changed(&battery->bat); power_supply_changed(battery->bat);
} }
static int battery_notify(struct notifier_block *nb, static int battery_notify(struct notifier_block *nb,
...@@ -1100,7 +1106,7 @@ static int battery_notify(struct notifier_block *nb, ...@@ -1100,7 +1106,7 @@ static int battery_notify(struct notifier_block *nb,
if (!acpi_battery_present(battery)) if (!acpi_battery_present(battery))
return 0; return 0;
if (!battery->bat.dev) { if (battery->bat) {
result = acpi_battery_get_info(battery); result = acpi_battery_get_info(battery);
if (result) if (result)
return result; return result;
......
...@@ -74,7 +74,8 @@ static const struct acpi_device_id sbs_device_ids[] = { ...@@ -74,7 +74,8 @@ static const struct acpi_device_id sbs_device_ids[] = {
MODULE_DEVICE_TABLE(acpi, sbs_device_ids); MODULE_DEVICE_TABLE(acpi, sbs_device_ids);
struct acpi_battery { struct acpi_battery {
struct power_supply bat; struct power_supply *bat;
struct power_supply_desc bat_desc;
struct acpi_sbs *sbs; struct acpi_sbs *sbs;
unsigned long update_time; unsigned long update_time;
char name[8]; char name[8];
...@@ -101,10 +102,10 @@ struct acpi_battery { ...@@ -101,10 +102,10 @@ struct acpi_battery {
u8 have_sysfs_alarm:1; u8 have_sysfs_alarm:1;
}; };
#define to_acpi_battery(x) container_of(x, struct acpi_battery, bat) #define to_acpi_battery(x) power_supply_get_drvdata(x)
struct acpi_sbs { struct acpi_sbs {
struct power_supply charger; struct power_supply *charger;
struct acpi_device *device; struct acpi_device *device;
struct acpi_smb_hc *hc; struct acpi_smb_hc *hc;
struct mutex lock; struct mutex lock;
...@@ -115,7 +116,7 @@ struct acpi_sbs { ...@@ -115,7 +116,7 @@ struct acpi_sbs {
u8 charger_exists:1; u8 charger_exists:1;
}; };
#define to_acpi_sbs(x) container_of(x, struct acpi_sbs, charger) #define to_acpi_sbs(x) power_supply_get_drvdata(x)
static int acpi_sbs_remove(struct acpi_device *device); static int acpi_sbs_remove(struct acpi_device *device);
static int acpi_battery_get_state(struct acpi_battery *battery); static int acpi_battery_get_state(struct acpi_battery *battery);
...@@ -303,6 +304,13 @@ static enum power_supply_property sbs_energy_battery_props[] = { ...@@ -303,6 +304,13 @@ static enum power_supply_property sbs_energy_battery_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_MANUFACTURER,
}; };
static const struct power_supply_desc acpi_sbs_charger_desc = {
.name = "sbs-charger",
.type = POWER_SUPPLY_TYPE_MAINS,
.properties = sbs_ac_props,
.num_properties = ARRAY_SIZE(sbs_ac_props),
.get_property = sbs_get_ac_property,
};
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
Smart Battery System Management Smart Battery System Management
...@@ -519,6 +527,7 @@ static int acpi_battery_read(struct acpi_battery *battery) ...@@ -519,6 +527,7 @@ static int acpi_battery_read(struct acpi_battery *battery)
static int acpi_battery_add(struct acpi_sbs *sbs, int id) static int acpi_battery_add(struct acpi_sbs *sbs, int id)
{ {
struct acpi_battery *battery = &sbs->battery[id]; struct acpi_battery *battery = &sbs->battery[id];
struct power_supply_config psy_cfg = { .drv_data = battery, };
int result; int result;
battery->id = id; battery->id = id;
...@@ -528,23 +537,27 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id) ...@@ -528,23 +537,27 @@ static int acpi_battery_add(struct acpi_sbs *sbs, int id)
return result; return result;
sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id); sprintf(battery->name, ACPI_BATTERY_DIR_NAME, id);
battery->bat.name = battery->name; battery->bat_desc.name = battery->name;
battery->bat.type = POWER_SUPPLY_TYPE_BATTERY; battery->bat_desc.type = POWER_SUPPLY_TYPE_BATTERY;
if (!acpi_battery_mode(battery)) { if (!acpi_battery_mode(battery)) {
battery->bat.properties = sbs_charge_battery_props; battery->bat_desc.properties = sbs_charge_battery_props;
battery->bat.num_properties = battery->bat_desc.num_properties =
ARRAY_SIZE(sbs_charge_battery_props); ARRAY_SIZE(sbs_charge_battery_props);
} else { } else {
battery->bat.properties = sbs_energy_battery_props; battery->bat_desc.properties = sbs_energy_battery_props;
battery->bat.num_properties = battery->bat_desc.num_properties =
ARRAY_SIZE(sbs_energy_battery_props); ARRAY_SIZE(sbs_energy_battery_props);
} }
battery->bat.get_property = acpi_sbs_battery_get_property; battery->bat_desc.get_property = acpi_sbs_battery_get_property;
result = power_supply_register(&sbs->device->dev, &battery->bat); battery->bat = power_supply_register(&sbs->device->dev,
if (result) &battery->bat_desc, &psy_cfg);
if (IS_ERR(battery->bat)) {
result = PTR_ERR(battery->bat);
battery->bat = NULL;
goto end; goto end;
}
result = device_create_file(battery->bat.dev, &alarm_attr); result = device_create_file(&battery->bat->dev, &alarm_attr);
if (result) if (result)
goto end; goto end;
battery->have_sysfs_alarm = 1; battery->have_sysfs_alarm = 1;
...@@ -559,28 +572,29 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id) ...@@ -559,28 +572,29 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
{ {
struct acpi_battery *battery = &sbs->battery[id]; struct acpi_battery *battery = &sbs->battery[id];
if (battery->bat.dev) { if (battery->bat) {
if (battery->have_sysfs_alarm) if (battery->have_sysfs_alarm)
device_remove_file(battery->bat.dev, &alarm_attr); device_remove_file(&battery->bat->dev, &alarm_attr);
power_supply_unregister(&battery->bat); power_supply_unregister(battery->bat);
} }
} }
static int acpi_charger_add(struct acpi_sbs *sbs) static int acpi_charger_add(struct acpi_sbs *sbs)
{ {
int result; int result;
struct power_supply_config psy_cfg = { .drv_data = sbs, };
result = acpi_ac_get_present(sbs); result = acpi_ac_get_present(sbs);
if (result) if (result)
goto end; goto end;
sbs->charger_exists = 1; sbs->charger_exists = 1;
sbs->charger.name = "sbs-charger"; sbs->charger = power_supply_register(&sbs->device->dev,
sbs->charger.type = POWER_SUPPLY_TYPE_MAINS; &acpi_sbs_charger_desc, &psy_cfg);
sbs->charger.properties = sbs_ac_props; if (IS_ERR(sbs->charger)) {
sbs->charger.num_properties = ARRAY_SIZE(sbs_ac_props); result = PTR_ERR(sbs->charger);
sbs->charger.get_property = sbs_get_ac_property; sbs->charger = NULL;
power_supply_register(&sbs->device->dev, &sbs->charger); }
printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n", printk(KERN_INFO PREFIX "%s [%s]: AC Adapter [%s] (%s)\n",
ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device), ACPI_SBS_DEVICE_NAME, acpi_device_bid(sbs->device),
ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line"); ACPI_AC_DIR_NAME, sbs->charger_present ? "on-line" : "off-line");
...@@ -590,8 +604,8 @@ static int acpi_charger_add(struct acpi_sbs *sbs) ...@@ -590,8 +604,8 @@ static int acpi_charger_add(struct acpi_sbs *sbs)
static void acpi_charger_remove(struct acpi_sbs *sbs) static void acpi_charger_remove(struct acpi_sbs *sbs)
{ {
if (sbs->charger.dev) if (sbs->charger)
power_supply_unregister(&sbs->charger); power_supply_unregister(sbs->charger);
} }
static void acpi_sbs_callback(void *context) static void acpi_sbs_callback(void *context)
...@@ -605,7 +619,7 @@ static void acpi_sbs_callback(void *context) ...@@ -605,7 +619,7 @@ static void acpi_sbs_callback(void *context)
if (sbs->charger_exists) { if (sbs->charger_exists) {
acpi_ac_get_present(sbs); acpi_ac_get_present(sbs);
if (sbs->charger_present != saved_charger_state) if (sbs->charger_present != saved_charger_state)
kobject_uevent(&sbs->charger.dev->kobj, KOBJ_CHANGE); kobject_uevent(&sbs->charger->dev.kobj, KOBJ_CHANGE);
} }
if (sbs->manager_present) { if (sbs->manager_present) {
...@@ -617,7 +631,7 @@ static void acpi_sbs_callback(void *context) ...@@ -617,7 +631,7 @@ static void acpi_sbs_callback(void *context)
acpi_battery_read(bat); acpi_battery_read(bat);
if (saved_battery_state == bat->present) if (saved_battery_state == bat->present)
continue; continue;
kobject_uevent(&bat->bat.dev->kobj, KOBJ_CHANGE); kobject_uevent(&bat->bat->dev.kobj, KOBJ_CHANGE);
} }
} }
} }
......
...@@ -339,7 +339,7 @@ static int hidinput_get_battery_property(struct power_supply *psy, ...@@ -339,7 +339,7 @@ static int hidinput_get_battery_property(struct power_supply *psy,
enum power_supply_property prop, enum power_supply_property prop,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct hid_device *dev = container_of(psy, struct hid_device, battery); struct hid_device *dev = power_supply_get_drvdata(psy);
int ret = 0; int ret = 0;
__u8 *buf; __u8 *buf;
...@@ -397,26 +397,32 @@ static int hidinput_get_battery_property(struct power_supply *psy, ...@@ -397,26 +397,32 @@ static int hidinput_get_battery_property(struct power_supply *psy,
static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, struct hid_field *field) static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, struct hid_field *field)
{ {
struct power_supply *battery = &dev->battery; struct power_supply_desc *psy_desc = NULL;
int ret; struct power_supply_config psy_cfg = { .drv_data = dev, };
unsigned quirks; unsigned quirks;
s32 min, max; s32 min, max;
if (field->usage->hid != HID_DC_BATTERYSTRENGTH) if (field->usage->hid != HID_DC_BATTERYSTRENGTH)
return false; /* no match */ return false; /* no match */
if (battery->name != NULL) if (dev->battery != NULL)
goto out; /* already initialized? */ goto out; /* already initialized? */
battery->name = kasprintf(GFP_KERNEL, "hid-%s-battery", dev->uniq); psy_desc = kzalloc(sizeof(*psy_desc), GFP_KERNEL);
if (battery->name == NULL) if (psy_desc == NULL)
goto out; goto out;
battery->type = POWER_SUPPLY_TYPE_BATTERY; psy_desc->name = kasprintf(GFP_KERNEL, "hid-%s-battery", dev->uniq);
battery->properties = hidinput_battery_props; if (psy_desc->name == NULL) {
battery->num_properties = ARRAY_SIZE(hidinput_battery_props); kfree(psy_desc);
battery->use_for_apm = 0; goto out;
battery->get_property = hidinput_get_battery_property; }
psy_desc->type = POWER_SUPPLY_TYPE_BATTERY;
psy_desc->properties = hidinput_battery_props;
psy_desc->num_properties = ARRAY_SIZE(hidinput_battery_props);
psy_desc->use_for_apm = 0;
psy_desc->get_property = hidinput_get_battery_property;
quirks = find_battery_quirk(dev); quirks = find_battery_quirk(dev);
...@@ -439,27 +445,30 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, ...@@ -439,27 +445,30 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
dev->battery_report_type = report_type; dev->battery_report_type = report_type;
dev->battery_report_id = field->report->id; dev->battery_report_id = field->report->id;
ret = power_supply_register(&dev->dev, battery); dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg);
if (ret != 0) { if (IS_ERR(dev->battery)) {
hid_warn(dev, "can't register power supply: %d\n", ret); hid_warn(dev, "can't register power supply: %ld\n",
kfree(battery->name); PTR_ERR(dev->battery));
battery->name = NULL; kfree(psy_desc->name);
kfree(psy_desc);
dev->battery = NULL;
} else {
power_supply_powers(dev->battery, &dev->dev);
} }
power_supply_powers(battery, &dev->dev);
out: out:
return true; return true;
} }
static void hidinput_cleanup_battery(struct hid_device *dev) static void hidinput_cleanup_battery(struct hid_device *dev)
{ {
if (!dev->battery.name) if (!dev->battery)
return; return;
power_supply_unregister(&dev->battery); power_supply_unregister(dev->battery);
kfree(dev->battery.name); kfree(dev->battery->desc->name);
dev->battery.name = NULL; kfree(dev->battery->desc);
dev->battery = NULL;
} }
#else /* !CONFIG_HID_BATTERY_STRENGTH */ #else /* !CONFIG_HID_BATTERY_STRENGTH */
static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type, static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
......
...@@ -815,7 +815,8 @@ struct sony_sc { ...@@ -815,7 +815,8 @@ struct sony_sc {
struct led_classdev *leds[MAX_LEDS]; struct led_classdev *leds[MAX_LEDS];
unsigned long quirks; unsigned long quirks;
struct work_struct state_worker; struct work_struct state_worker;
struct power_supply battery; struct power_supply *battery;
struct power_supply_desc battery_desc;
int device_id; int device_id;
__u8 *output_report_dmabuf; __u8 *output_report_dmabuf;
...@@ -1660,7 +1661,7 @@ static int sony_battery_get_property(struct power_supply *psy, ...@@ -1660,7 +1661,7 @@ static int sony_battery_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct sony_sc *sc = container_of(psy, struct sony_sc, battery); struct sony_sc *sc = power_supply_get_drvdata(psy);
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
u8 battery_charging, battery_capacity, cable_state; u8 battery_charging, battery_capacity, cable_state;
...@@ -1699,6 +1700,7 @@ static int sony_battery_get_property(struct power_supply *psy, ...@@ -1699,6 +1700,7 @@ static int sony_battery_get_property(struct power_supply *psy,
static int sony_battery_probe(struct sony_sc *sc) static int sony_battery_probe(struct sony_sc *sc)
{ {
struct power_supply_config psy_cfg = { .drv_data = sc, };
struct hid_device *hdev = sc->hdev; struct hid_device *hdev = sc->hdev;
int ret; int ret;
...@@ -1708,39 +1710,42 @@ static int sony_battery_probe(struct sony_sc *sc) ...@@ -1708,39 +1710,42 @@ static int sony_battery_probe(struct sony_sc *sc)
*/ */
sc->battery_capacity = 100; sc->battery_capacity = 100;
sc->battery.properties = sony_battery_props; sc->battery_desc.properties = sony_battery_props;
sc->battery.num_properties = ARRAY_SIZE(sony_battery_props); sc->battery_desc.num_properties = ARRAY_SIZE(sony_battery_props);
sc->battery.get_property = sony_battery_get_property; sc->battery_desc.get_property = sony_battery_get_property;
sc->battery.type = POWER_SUPPLY_TYPE_BATTERY; sc->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY;
sc->battery.use_for_apm = 0; sc->battery_desc.use_for_apm = 0;
sc->battery.name = kasprintf(GFP_KERNEL, "sony_controller_battery_%pMR", sc->battery_desc.name = kasprintf(GFP_KERNEL,
sc->mac_address); "sony_controller_battery_%pMR",
if (!sc->battery.name) sc->mac_address);
if (!sc->battery_desc.name)
return -ENOMEM; return -ENOMEM;
ret = power_supply_register(&hdev->dev, &sc->battery); sc->battery = power_supply_register(&hdev->dev, &sc->battery_desc,
if (ret) { &psy_cfg);
if (IS_ERR(sc->battery)) {
ret = PTR_ERR(sc->battery);
hid_err(hdev, "Unable to register battery device\n"); hid_err(hdev, "Unable to register battery device\n");
goto err_free; goto err_free;
} }
power_supply_powers(&sc->battery, &hdev->dev); power_supply_powers(sc->battery, &hdev->dev);
return 0; return 0;
err_free: err_free:
kfree(sc->battery.name); kfree(sc->battery_desc.name);
sc->battery.name = NULL; sc->battery_desc.name = NULL;
return ret; return ret;
} }
static void sony_battery_remove(struct sony_sc *sc) static void sony_battery_remove(struct sony_sc *sc)
{ {
if (!sc->battery.name) if (!sc->battery_desc.name)
return; return;
power_supply_unregister(&sc->battery); power_supply_unregister(sc->battery);
kfree(sc->battery.name); kfree(sc->battery_desc.name);
sc->battery.name = NULL; sc->battery_desc.name = NULL;
} }
/* /*
......
...@@ -203,8 +203,7 @@ static int wiimod_battery_get_property(struct power_supply *psy, ...@@ -203,8 +203,7 @@ static int wiimod_battery_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct wiimote_data *wdata = container_of(psy, struct wiimote_data, struct wiimote_data *wdata = power_supply_get_drvdata(psy);
battery);
int ret = 0, state; int ret = 0, state;
unsigned long flags; unsigned long flags;
...@@ -238,42 +237,46 @@ static int wiimod_battery_get_property(struct power_supply *psy, ...@@ -238,42 +237,46 @@ static int wiimod_battery_get_property(struct power_supply *psy,
static int wiimod_battery_probe(const struct wiimod_ops *ops, static int wiimod_battery_probe(const struct wiimod_ops *ops,
struct wiimote_data *wdata) struct wiimote_data *wdata)
{ {
struct power_supply_config psy_cfg = { .drv_data = wdata, };
int ret; int ret;
wdata->battery.properties = wiimod_battery_props; wdata->battery_desc.properties = wiimod_battery_props;
wdata->battery.num_properties = ARRAY_SIZE(wiimod_battery_props); wdata->battery_desc.num_properties = ARRAY_SIZE(wiimod_battery_props);
wdata->battery.get_property = wiimod_battery_get_property; wdata->battery_desc.get_property = wiimod_battery_get_property;
wdata->battery.type = POWER_SUPPLY_TYPE_BATTERY; wdata->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY;
wdata->battery.use_for_apm = 0; wdata->battery_desc.use_for_apm = 0;
wdata->battery.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s", wdata->battery_desc.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s",
wdata->hdev->uniq); wdata->hdev->uniq);
if (!wdata->battery.name) if (!wdata->battery_desc.name)
return -ENOMEM; return -ENOMEM;
ret = power_supply_register(&wdata->hdev->dev, &wdata->battery); wdata->battery = power_supply_register(&wdata->hdev->dev,
if (ret) { &wdata->battery_desc,
&psy_cfg);
if (IS_ERR(wdata->battery)) {
hid_err(wdata->hdev, "cannot register battery device\n"); hid_err(wdata->hdev, "cannot register battery device\n");
ret = PTR_ERR(wdata->battery);
goto err_free; goto err_free;
} }
power_supply_powers(&wdata->battery, &wdata->hdev->dev); power_supply_powers(wdata->battery, &wdata->hdev->dev);
return 0; return 0;
err_free: err_free:
kfree(wdata->battery.name); kfree(wdata->battery_desc.name);
wdata->battery.name = NULL; wdata->battery_desc.name = NULL;
return ret; return ret;
} }
static void wiimod_battery_remove(const struct wiimod_ops *ops, static void wiimod_battery_remove(const struct wiimod_ops *ops,
struct wiimote_data *wdata) struct wiimote_data *wdata)
{ {
if (!wdata->battery.name) if (!wdata->battery_desc.name)
return; return;
power_supply_unregister(&wdata->battery); power_supply_unregister(wdata->battery);
kfree(wdata->battery.name); kfree(wdata->battery_desc.name);
wdata->battery.name = NULL; wdata->battery_desc.name = NULL;
} }
static const struct wiimod_ops wiimod_battery = { static const struct wiimod_ops wiimod_battery = {
......
...@@ -147,7 +147,8 @@ struct wiimote_data { ...@@ -147,7 +147,8 @@ struct wiimote_data {
struct led_classdev *leds[4]; struct led_classdev *leds[4];
struct input_dev *accel; struct input_dev *accel;
struct input_dev *ir; struct input_dev *ir;
struct power_supply battery; struct power_supply *battery;
struct power_supply_desc battery_desc;
struct input_dev *mp; struct input_dev *mp;
struct timer_list timer; struct timer_list timer;
struct wiimote_debug *debug; struct wiimote_debug *debug;
......
...@@ -119,8 +119,10 @@ struct wacom { ...@@ -119,8 +119,10 @@ struct wacom {
u8 img_lum; /* OLED matrix display brightness */ u8 img_lum; /* OLED matrix display brightness */
} led; } led;
bool led_initialized; bool led_initialized;
struct power_supply battery; struct power_supply *battery;
struct power_supply ac; struct power_supply *ac;
struct power_supply_desc battery_desc;
struct power_supply_desc ac_desc;
}; };
static inline void wacom_schedule_work(struct wacom_wac *wacom_wac) static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
...@@ -133,7 +135,7 @@ static inline void wacom_notify_battery(struct wacom_wac *wacom_wac) ...@@ -133,7 +135,7 @@ static inline void wacom_notify_battery(struct wacom_wac *wacom_wac)
{ {
struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac); struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
power_supply_changed(&wacom->battery); power_supply_changed(wacom->battery);
} }
extern const struct hid_device_id wacom_ids[]; extern const struct hid_device_id wacom_ids[];
......
...@@ -944,7 +944,7 @@ static int wacom_battery_get_property(struct power_supply *psy, ...@@ -944,7 +944,7 @@ static int wacom_battery_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct wacom *wacom = container_of(psy, struct wacom, battery); struct wacom *wacom = power_supply_get_drvdata(psy);
int ret = 0; int ret = 0;
switch (psp) { switch (psp) {
...@@ -976,7 +976,7 @@ static int wacom_ac_get_property(struct power_supply *psy, ...@@ -976,7 +976,7 @@ static int wacom_ac_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct wacom *wacom = container_of(psy, struct wacom, ac); struct wacom *wacom = power_supply_get_drvdata(psy);
int ret = 0; int ret = 0;
switch (psp) { switch (psp) {
...@@ -998,42 +998,46 @@ static int wacom_ac_get_property(struct power_supply *psy, ...@@ -998,42 +998,46 @@ static int wacom_ac_get_property(struct power_supply *psy,
static int wacom_initialize_battery(struct wacom *wacom) static int wacom_initialize_battery(struct wacom *wacom)
{ {
static atomic_t battery_no = ATOMIC_INIT(0); static atomic_t battery_no = ATOMIC_INIT(0);
int error; struct power_supply_config psy_cfg = { .drv_data = wacom, };
unsigned long n; unsigned long n;
if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) { if (wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) {
struct power_supply_desc *bat_desc = &wacom->battery_desc;
struct power_supply_desc *ac_desc = &wacom->ac_desc;
n = atomic_inc_return(&battery_no) - 1; n = atomic_inc_return(&battery_no) - 1;
wacom->battery.properties = wacom_battery_props; bat_desc->properties = wacom_battery_props;
wacom->battery.num_properties = ARRAY_SIZE(wacom_battery_props); bat_desc->num_properties = ARRAY_SIZE(wacom_battery_props);
wacom->battery.get_property = wacom_battery_get_property; bat_desc->get_property = wacom_battery_get_property;
sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n); sprintf(wacom->wacom_wac.bat_name, "wacom_battery_%ld", n);
wacom->battery.name = wacom->wacom_wac.bat_name; bat_desc->name = wacom->wacom_wac.bat_name;
wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY; bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
wacom->battery.use_for_apm = 0; bat_desc->use_for_apm = 0;
wacom->ac.properties = wacom_ac_props; ac_desc->properties = wacom_ac_props;
wacom->ac.num_properties = ARRAY_SIZE(wacom_ac_props); ac_desc->num_properties = ARRAY_SIZE(wacom_ac_props);
wacom->ac.get_property = wacom_ac_get_property; ac_desc->get_property = wacom_ac_get_property;
sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n); sprintf(wacom->wacom_wac.ac_name, "wacom_ac_%ld", n);
wacom->ac.name = wacom->wacom_wac.ac_name; ac_desc->name = wacom->wacom_wac.ac_name;
wacom->ac.type = POWER_SUPPLY_TYPE_MAINS; ac_desc->type = POWER_SUPPLY_TYPE_MAINS;
wacom->ac.use_for_apm = 0; ac_desc->use_for_apm = 0;
error = power_supply_register(&wacom->hdev->dev, wacom->battery = power_supply_register(&wacom->hdev->dev,
&wacom->battery); &wacom->battery_desc, &psy_cfg);
if (error) if (IS_ERR(wacom->battery))
return error; return PTR_ERR(wacom->battery);
power_supply_powers(&wacom->battery, &wacom->hdev->dev); power_supply_powers(wacom->battery, &wacom->hdev->dev);
error = power_supply_register(&wacom->hdev->dev, &wacom->ac); wacom->ac = power_supply_register(&wacom->hdev->dev,
if (error) { &wacom->ac_desc,
power_supply_unregister(&wacom->battery); &psy_cfg);
return error; if (IS_ERR(wacom->ac)) {
power_supply_unregister(wacom->battery);
return PTR_ERR(wacom->ac);
} }
power_supply_powers(&wacom->ac, &wacom->hdev->dev); power_supply_powers(wacom->ac, &wacom->hdev->dev);
} }
return 0; return 0;
...@@ -1042,11 +1046,11 @@ static int wacom_initialize_battery(struct wacom *wacom) ...@@ -1042,11 +1046,11 @@ static int wacom_initialize_battery(struct wacom *wacom)
static void wacom_destroy_battery(struct wacom *wacom) static void wacom_destroy_battery(struct wacom *wacom)
{ {
if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) && if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
wacom->battery.dev) { wacom->battery) {
power_supply_unregister(&wacom->battery); power_supply_unregister(wacom->battery);
wacom->battery.dev = NULL; wacom->battery = NULL;
power_supply_unregister(&wacom->ac); power_supply_unregister(wacom->ac);
wacom->ac.dev = NULL; wacom->ac = NULL;
} }
} }
......
...@@ -135,6 +135,15 @@ config AXP288_ADC ...@@ -135,6 +135,15 @@ config AXP288_ADC
device. Depending on platform configuration, this general purpose ADC can device. Depending on platform configuration, this general purpose ADC can
be used for sampling sensors such as thermal resistors. be used for sampling sensors such as thermal resistors.
config DA9150_GPADC
tristate "Dialog DA9150 GPADC driver support"
depends on MFD_DA9150
help
Say yes here to build support for Dialog DA9150 GPADC.
This driver can also be built as a module. If chosen, the module name
will be da9150-gpadc.
config CC10001_ADC config CC10001_ADC
tristate "Cosmic Circuits 10001 ADC driver" tristate "Cosmic Circuits 10001 ADC driver"
depends on HAVE_CLK || REGULATOR depends on HAVE_CLK || REGULATOR
......
...@@ -15,6 +15,7 @@ obj-$(CONFIG_AD7887) += ad7887.o ...@@ -15,6 +15,7 @@ obj-$(CONFIG_AD7887) += ad7887.o
obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AD799X) += ad799x.o
obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_AT91_ADC) += at91_adc.o
obj-$(CONFIG_AXP288_ADC) += axp288_adc.o obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
......
This diff is collapsed.
...@@ -49,7 +49,9 @@ static void ab8500_power_off(void) ...@@ -49,7 +49,9 @@ static void ab8500_power_off(void)
if (!psy) if (!psy)
continue; continue;
ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,
&val);
power_supply_put(psy);
if (!ret && val.intval) { if (!ret && val.intval) {
charger_present = true; charger_present = true;
...@@ -63,8 +65,8 @@ static void ab8500_power_off(void) ...@@ -63,8 +65,8 @@ static void ab8500_power_off(void)
/* Check if battery is known */ /* Check if battery is known */
psy = power_supply_get_by_name("ab8500_btemp"); psy = power_supply_get_by_name("ab8500_btemp");
if (psy) { if (psy) {
ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY, ret = power_supply_get_property(psy,
&val); POWER_SUPPLY_PROP_TECHNOLOGY, &val);
if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) { if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) {
printk(KERN_INFO printk(KERN_INFO
"Charger \"%s\" is connected with known battery." "Charger \"%s\" is connected with known battery."
...@@ -72,6 +74,7 @@ static void ab8500_power_off(void) ...@@ -72,6 +74,7 @@ static void ab8500_power_off(void)
pss[i]); pss[i]);
machine_restart("charging"); machine_restart("charging");
} }
power_supply_put(psy);
} }
shutdown: shutdown:
......
...@@ -87,7 +87,7 @@ static struct resource axp20x_pek_resources[] = { ...@@ -87,7 +87,7 @@ static struct resource axp20x_pek_resources[] = {
}, },
}; };
static struct resource axp288_battery_resources[] = { static struct resource axp288_fuel_gauge_resources[] = {
{ {
.start = AXP288_IRQ_QWBTU, .start = AXP288_IRQ_QWBTU,
.end = AXP288_IRQ_QWBTU, .end = AXP288_IRQ_QWBTU,
...@@ -350,9 +350,9 @@ static struct mfd_cell axp288_cells[] = { ...@@ -350,9 +350,9 @@ static struct mfd_cell axp288_cells[] = {
.resources = axp288_charger_resources, .resources = axp288_charger_resources,
}, },
{ {
.name = "axp288_battery", .name = "axp288_fuel_gauge",
.num_resources = ARRAY_SIZE(axp288_battery_resources), .num_resources = ARRAY_SIZE(axp288_fuel_gauge_resources),
.resources = axp288_battery_resources, .resources = axp288_fuel_gauge_resources,
}, },
{ {
.name = "axp288_pmic_acpi", .name = "axp288_pmic_acpi",
......
...@@ -177,7 +177,7 @@ struct compal_data{ ...@@ -177,7 +177,7 @@ struct compal_data{
unsigned char curr_pwm; unsigned char curr_pwm;
/* Power supply */ /* Power supply */
struct power_supply psy; struct power_supply *psy;
struct power_supply_info psy_info; struct power_supply_info psy_info;
char bat_model_name[BAT_MODEL_NAME_LEN + 1]; char bat_model_name[BAT_MODEL_NAME_LEN + 1];
char bat_manufacturer_name[BAT_MANUFACTURER_NAME_LEN + 1]; char bat_manufacturer_name[BAT_MANUFACTURER_NAME_LEN + 1];
...@@ -565,8 +565,7 @@ static int bat_get_property(struct power_supply *psy, ...@@ -565,8 +565,7 @@ static int bat_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct compal_data *data; struct compal_data *data = power_supply_get_drvdata(psy);
data = container_of(psy, struct compal_data, psy);
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_STATUS: case POWER_SUPPLY_PROP_STATUS:
...@@ -875,13 +874,16 @@ static struct dmi_system_id __initdata compal_dmi_table[] = { ...@@ -875,13 +874,16 @@ static struct dmi_system_id __initdata compal_dmi_table[] = {
}; };
MODULE_DEVICE_TABLE(dmi, compal_dmi_table); MODULE_DEVICE_TABLE(dmi, compal_dmi_table);
static const struct power_supply_desc psy_bat_desc = {
.name = DRIVER_NAME,
.type = POWER_SUPPLY_TYPE_BATTERY,
.properties = compal_bat_properties,
.num_properties = ARRAY_SIZE(compal_bat_properties),
.get_property = bat_get_property,
};
static void initialize_power_supply_data(struct compal_data *data) static void initialize_power_supply_data(struct compal_data *data)
{ {
data->psy.name = DRIVER_NAME;
data->psy.type = POWER_SUPPLY_TYPE_BATTERY;
data->psy.properties = compal_bat_properties;
data->psy.num_properties = ARRAY_SIZE(compal_bat_properties);
data->psy.get_property = bat_get_property;
ec_read_sequence(BAT_MANUFACTURER_NAME_ADDR, ec_read_sequence(BAT_MANUFACTURER_NAME_ADDR,
data->bat_manufacturer_name, data->bat_manufacturer_name,
...@@ -1011,6 +1013,7 @@ static int compal_probe(struct platform_device *pdev) ...@@ -1011,6 +1013,7 @@ static int compal_probe(struct platform_device *pdev)
int err; int err;
struct compal_data *data; struct compal_data *data;
struct device *hwmon_dev; struct device *hwmon_dev;
struct power_supply_config psy_cfg = {};
if (!extra_features) if (!extra_features)
return 0; return 0;
...@@ -1026,9 +1029,9 @@ static int compal_probe(struct platform_device *pdev) ...@@ -1026,9 +1029,9 @@ static int compal_probe(struct platform_device *pdev)
if (err) if (err)
return err; return err;
hwmon_dev = hwmon_device_register_with_groups(&pdev->dev, hwmon_dev = devm_hwmon_device_register_with_groups(&pdev->dev,
"compal", data, "compal", data,
compal_hwmon_groups); compal_hwmon_groups);
if (IS_ERR(hwmon_dev)) { if (IS_ERR(hwmon_dev)) {
err = PTR_ERR(hwmon_dev); err = PTR_ERR(hwmon_dev);
goto remove; goto remove;
...@@ -1036,7 +1039,13 @@ static int compal_probe(struct platform_device *pdev) ...@@ -1036,7 +1039,13 @@ static int compal_probe(struct platform_device *pdev)
/* Power supply */ /* Power supply */
initialize_power_supply_data(data); initialize_power_supply_data(data);
power_supply_register(&compal_device->dev, &data->psy); psy_cfg.drv_data = data;
data->psy = power_supply_register(&compal_device->dev, &psy_bat_desc,
&psy_cfg);
if (IS_ERR(data->psy)) {
err = PTR_ERR(data->psy);
goto remove;
}
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
...@@ -1071,7 +1080,7 @@ static int compal_remove(struct platform_device *pdev) ...@@ -1071,7 +1080,7 @@ static int compal_remove(struct platform_device *pdev)
pwm_disable_control(); pwm_disable_control();
data = platform_get_drvdata(pdev); data = platform_get_drvdata(pdev);
power_supply_unregister(&data->psy); power_supply_unregister(data->psy);
sysfs_remove_group(&pdev->dev.kobj, &compal_platform_attr_group); sysfs_remove_group(&pdev->dev.kobj, &compal_platform_attr_group);
......
...@@ -98,7 +98,7 @@ struct pm860x_battery_info { ...@@ -98,7 +98,7 @@ struct pm860x_battery_info {
struct i2c_client *i2c; struct i2c_client *i2c;
struct device *dev; struct device *dev;
struct power_supply battery; struct power_supply *battery;
struct mutex lock; struct mutex lock;
int status; int status;
int irq_cc; int irq_cc;
...@@ -798,9 +798,8 @@ static int calc_capacity(struct pm860x_battery_info *info, int *cap) ...@@ -798,9 +798,8 @@ static int calc_capacity(struct pm860x_battery_info *info, int *cap)
static void pm860x_external_power_changed(struct power_supply *psy) static void pm860x_external_power_changed(struct power_supply *psy)
{ {
struct pm860x_battery_info *info; struct pm860x_battery_info *info = dev_get_drvdata(psy->dev.parent);
info = container_of(psy, struct pm860x_battery_info, battery);
calc_resistor(info); calc_resistor(info);
} }
...@@ -808,7 +807,7 @@ static int pm860x_batt_get_prop(struct power_supply *psy, ...@@ -808,7 +807,7 @@ static int pm860x_batt_get_prop(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct pm860x_battery_info *info = dev_get_drvdata(psy->dev->parent); struct pm860x_battery_info *info = dev_get_drvdata(psy->dev.parent);
int data; int data;
int ret; int ret;
...@@ -874,7 +873,7 @@ static int pm860x_batt_set_prop(struct power_supply *psy, ...@@ -874,7 +873,7 @@ static int pm860x_batt_set_prop(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
const union power_supply_propval *val) const union power_supply_propval *val)
{ {
struct pm860x_battery_info *info = dev_get_drvdata(psy->dev->parent); struct pm860x_battery_info *info = dev_get_drvdata(psy->dev.parent);
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_FULL: case POWER_SUPPLY_PROP_CHARGE_FULL:
...@@ -901,6 +900,16 @@ static enum power_supply_property pm860x_batt_props[] = { ...@@ -901,6 +900,16 @@ static enum power_supply_property pm860x_batt_props[] = {
POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP,
}; };
static const struct power_supply_desc pm860x_battery_desc = {
.name = "battery-monitor",
.type = POWER_SUPPLY_TYPE_BATTERY,
.properties = pm860x_batt_props,
.num_properties = ARRAY_SIZE(pm860x_batt_props),
.get_property = pm860x_batt_get_prop,
.set_property = pm860x_batt_set_prop,
.external_power_changed = pm860x_external_power_changed,
};
static int pm860x_battery_probe(struct platform_device *pdev) static int pm860x_battery_probe(struct platform_device *pdev)
{ {
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
...@@ -936,14 +945,6 @@ static int pm860x_battery_probe(struct platform_device *pdev) ...@@ -936,14 +945,6 @@ static int pm860x_battery_probe(struct platform_device *pdev)
pm860x_init_battery(info); pm860x_init_battery(info);
info->battery.name = "battery-monitor";
info->battery.type = POWER_SUPPLY_TYPE_BATTERY;
info->battery.properties = pm860x_batt_props;
info->battery.num_properties = ARRAY_SIZE(pm860x_batt_props);
info->battery.get_property = pm860x_batt_get_prop;
info->battery.set_property = pm860x_batt_set_prop;
info->battery.external_power_changed = pm860x_external_power_changed;
if (pdata && pdata->max_capacity) if (pdata && pdata->max_capacity)
info->max_capacity = pdata->max_capacity; info->max_capacity = pdata->max_capacity;
else else
...@@ -953,10 +954,11 @@ static int pm860x_battery_probe(struct platform_device *pdev) ...@@ -953,10 +954,11 @@ static int pm860x_battery_probe(struct platform_device *pdev)
else else
info->resistor = 300; /* set default internal resistor */ info->resistor = 300; /* set default internal resistor */
ret = power_supply_register(&pdev->dev, &info->battery); info->battery = power_supply_register(&pdev->dev, &pm860x_battery_desc,
if (ret) NULL);
return ret; if (IS_ERR(info->battery))
info->battery.dev->parent = &pdev->dev; return PTR_ERR(info->battery);
info->battery->dev.parent = &pdev->dev;
ret = request_threaded_irq(info->irq_cc, NULL, ret = request_threaded_irq(info->irq_cc, NULL,
pm860x_coulomb_handler, IRQF_ONESHOT, pm860x_coulomb_handler, IRQF_ONESHOT,
...@@ -981,7 +983,7 @@ static int pm860x_battery_probe(struct platform_device *pdev) ...@@ -981,7 +983,7 @@ static int pm860x_battery_probe(struct platform_device *pdev)
out_coulomb: out_coulomb:
free_irq(info->irq_cc, info); free_irq(info->irq_cc, info);
out_reg: out_reg:
power_supply_unregister(&info->battery); power_supply_unregister(info->battery);
return ret; return ret;
} }
...@@ -991,7 +993,7 @@ static int pm860x_battery_remove(struct platform_device *pdev) ...@@ -991,7 +993,7 @@ static int pm860x_battery_remove(struct platform_device *pdev)
free_irq(info->irq_batt, info); free_irq(info->irq_batt, info);
free_irq(info->irq_cc, info); free_irq(info->irq_cc, info);
power_supply_unregister(&info->battery); power_supply_unregister(info->battery);
return 0; return 0;
} }
......
...@@ -102,7 +102,7 @@ struct pm860x_charger_info { ...@@ -102,7 +102,7 @@ struct pm860x_charger_info {
struct i2c_client *i2c_8606; struct i2c_client *i2c_8606;
struct device *dev; struct device *dev;
struct power_supply usb; struct power_supply *usb;
struct mutex lock; struct mutex lock;
int irq_nums; int irq_nums;
int irq[7]; int irq[7];
...@@ -296,14 +296,20 @@ static int set_charging_fsm(struct pm860x_charger_info *info) ...@@ -296,14 +296,20 @@ static int set_charging_fsm(struct pm860x_charger_info *info)
psy = power_supply_get_by_name(pm860x_supplied_to[0]); psy = power_supply_get_by_name(pm860x_supplied_to[0]);
if (!psy) if (!psy)
return -EINVAL; return -EINVAL;
ret = psy->get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &data); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW,
if (ret) &data);
if (ret) {
power_supply_put(psy);
return ret; return ret;
}
vbatt = data.intval / 1000; vbatt = data.intval / 1000;
ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT, &data);
if (ret) if (ret) {
power_supply_put(psy);
return ret; return ret;
}
power_supply_put(psy);
mutex_lock(&info->lock); mutex_lock(&info->lock);
info->present = data.intval; info->present = data.intval;
...@@ -414,7 +420,7 @@ static irqreturn_t pm860x_charger_handler(int irq, void *data) ...@@ -414,7 +420,7 @@ static irqreturn_t pm860x_charger_handler(int irq, void *data)
set_charging_fsm(info); set_charging_fsm(info);
power_supply_changed(&info->usb); power_supply_changed(info->usb);
out: out:
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -430,7 +436,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data) ...@@ -430,7 +436,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data)
psy = power_supply_get_by_name(pm860x_supplied_to[0]); psy = power_supply_get_by_name(pm860x_supplied_to[0]);
if (!psy) if (!psy)
goto out; goto out;
ret = psy->get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_TEMP, &temp);
if (ret) if (ret)
goto out; goto out;
value = temp.intval / 10; value = temp.intval / 10;
...@@ -446,6 +452,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data) ...@@ -446,6 +452,7 @@ static irqreturn_t pm860x_temp_handler(int irq, void *data)
set_charging_fsm(info); set_charging_fsm(info);
out: out:
power_supply_put(psy);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -485,9 +492,10 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) ...@@ -485,9 +492,10 @@ static irqreturn_t pm860x_done_handler(int irq, void *data)
psy = power_supply_get_by_name(pm860x_supplied_to[0]); psy = power_supply_get_by_name(pm860x_supplied_to[0]);
if (!psy) if (!psy)
goto out; goto out;
ret = psy->get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_VOLTAGE_NOW,
&val);
if (ret) if (ret)
goto out; goto out_psy_put;
vbatt = val.intval / 1000; vbatt = val.intval / 1000;
/* /*
* CHG_DONE interrupt is faster than CHG_DET interrupt when * CHG_DONE interrupt is faster than CHG_DET interrupt when
...@@ -498,10 +506,13 @@ static irqreturn_t pm860x_done_handler(int irq, void *data) ...@@ -498,10 +506,13 @@ static irqreturn_t pm860x_done_handler(int irq, void *data)
*/ */
ret = pm860x_reg_read(info->i2c, PM8607_STATUS_2); ret = pm860x_reg_read(info->i2c, PM8607_STATUS_2);
if (ret < 0) if (ret < 0)
goto out; goto out_psy_put;
if (vbatt > CHARGE_THRESHOLD && ret & STATUS2_CHG) if (vbatt > CHARGE_THRESHOLD && ret & STATUS2_CHG)
psy->set_property(psy, POWER_SUPPLY_PROP_CHARGE_FULL, &val); power_supply_set_property(psy, POWER_SUPPLY_PROP_CHARGE_FULL,
&val);
out_psy_put:
power_supply_put(psy);
out: out:
mutex_unlock(&info->lock); mutex_unlock(&info->lock);
dev_dbg(info->dev, "%s, Allowed: %d\n", __func__, info->allowed); dev_dbg(info->dev, "%s, Allowed: %d\n", __func__, info->allowed);
...@@ -584,8 +595,7 @@ static int pm860x_usb_get_prop(struct power_supply *psy, ...@@ -584,8 +595,7 @@ static int pm860x_usb_get_prop(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct pm860x_charger_info *info = struct pm860x_charger_info *info = power_supply_get_drvdata(psy);
dev_get_drvdata(psy->dev->parent);
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_STATUS: case POWER_SUPPLY_PROP_STATUS:
...@@ -645,9 +655,18 @@ static struct pm860x_irq_desc { ...@@ -645,9 +655,18 @@ static struct pm860x_irq_desc {
{ "vchg", pm860x_vchg_handler }, { "vchg", pm860x_vchg_handler },
}; };
static const struct power_supply_desc pm860x_charger_desc = {
.name = "usb",
.type = POWER_SUPPLY_TYPE_USB,
.properties = pm860x_usb_props,
.num_properties = ARRAY_SIZE(pm860x_usb_props),
.get_property = pm860x_usb_get_prop,
};
static int pm860x_charger_probe(struct platform_device *pdev) static int pm860x_charger_probe(struct platform_device *pdev)
{ {
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config psy_cfg = {};
struct pm860x_charger_info *info; struct pm860x_charger_info *info;
int ret; int ret;
int count; int count;
...@@ -685,16 +704,15 @@ static int pm860x_charger_probe(struct platform_device *pdev) ...@@ -685,16 +704,15 @@ static int pm860x_charger_probe(struct platform_device *pdev)
mutex_init(&info->lock); mutex_init(&info->lock);
platform_set_drvdata(pdev, info); platform_set_drvdata(pdev, info);
info->usb.name = "usb"; psy_cfg.drv_data = info;
info->usb.type = POWER_SUPPLY_TYPE_USB; psy_cfg.supplied_to = pm860x_supplied_to;
info->usb.supplied_to = pm860x_supplied_to; psy_cfg.num_supplicants = ARRAY_SIZE(pm860x_supplied_to);
info->usb.num_supplicants = ARRAY_SIZE(pm860x_supplied_to); info->usb = power_supply_register(&pdev->dev, &pm860x_charger_desc,
info->usb.properties = pm860x_usb_props; &psy_cfg);
info->usb.num_properties = ARRAY_SIZE(pm860x_usb_props); if (IS_ERR(info->usb)) {
info->usb.get_property = pm860x_usb_get_prop; ret = PTR_ERR(info->usb);
ret = power_supply_register(&pdev->dev, &info->usb);
if (ret)
goto out; goto out;
}
pm860x_init_charger(info); pm860x_init_charger(info);
...@@ -711,7 +729,7 @@ static int pm860x_charger_probe(struct platform_device *pdev) ...@@ -711,7 +729,7 @@ static int pm860x_charger_probe(struct platform_device *pdev)
return 0; return 0;
out_irq: out_irq:
power_supply_unregister(&info->usb); power_supply_unregister(info->usb);
while (--i >= 0) while (--i >= 0)
free_irq(info->irq[i], info); free_irq(info->irq[i], info);
out: out:
...@@ -723,7 +741,7 @@ static int pm860x_charger_remove(struct platform_device *pdev) ...@@ -723,7 +741,7 @@ static int pm860x_charger_remove(struct platform_device *pdev)
struct pm860x_charger_info *info = platform_get_drvdata(pdev); struct pm860x_charger_info *info = platform_get_drvdata(pdev);
int i; int i;
power_supply_unregister(&info->usb); power_supply_unregister(info->usb);
free_irq(info->irq[0], info); free_irq(info->irq[0], info);
for (i = 0; i < info->irq_nums; i++) for (i = 0; i < info->irq_nums; i++)
free_irq(info->irq[i], info); free_irq(info->irq[i], info);
......
...@@ -192,6 +192,27 @@ config BATTERY_DA9052 ...@@ -192,6 +192,27 @@ config BATTERY_DA9052
Say Y here to enable support for batteries charger integrated into Say Y here to enable support for batteries charger integrated into
DA9052 PMIC. DA9052 PMIC.
config CHARGER_DA9150
tristate "Dialog Semiconductor DA9150 Charger support"
depends on MFD_DA9150
depends on DA9150_GPADC
depends on IIO
help
Say Y here to enable support for charger unit of the DA9150
Integrated Charger & Fuel-Gauge IC.
This driver can also be built as a module. If so, the module will be
called da9150-charger.
config AXP288_FUEL_GAUGE
tristate "X-Powers AXP288 Fuel Gauge"
depends on MFD_AXP20X && IIO
help
Say yes here to have support for X-Power power management IC (PMIC)
Fuel Gauge. The device provides battery statistics and status
monitoring as well as alerts for battery over/under voltage and
over/under temperature.
config BATTERY_MAX17040 config BATTERY_MAX17040
tristate "Maxim MAX17040 Fuel Gauge" tristate "Maxim MAX17040 Fuel Gauge"
depends on I2C depends on I2C
......
ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG subdir-ccflags-$(CONFIG_POWER_SUPPLY_DEBUG) := -DDEBUG
power_supply-y := power_supply_core.o power_supply-y := power_supply_core.o
power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o power_supply-$(CONFIG_SYSFS) += power_supply_sysfs.o
...@@ -32,6 +32,7 @@ obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o ...@@ -32,6 +32,7 @@ obj-$(CONFIG_BATTERY_SBS) += sbs-battery.o
obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o obj-$(CONFIG_BATTERY_DA9052) += da9052-battery.o
obj-$(CONFIG_CHARGER_DA9150) += da9150-charger.o
obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
obj-$(CONFIG_BATTERY_Z2) += z2_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
...@@ -62,3 +63,4 @@ obj-$(CONFIG_POWER_AVS) += avs/ ...@@ -62,3 +63,4 @@ obj-$(CONFIG_POWER_AVS) += avs/
obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o
obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
obj-$(CONFIG_POWER_RESET) += reset/ obj-$(CONFIG_POWER_RESET) += reset/
obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o
...@@ -45,9 +45,6 @@ ...@@ -45,9 +45,6 @@
#define BTEMP_BATCTRL_CURR_SRC_60UA 60 #define BTEMP_BATCTRL_CURR_SRC_60UA 60
#define BTEMP_BATCTRL_CURR_SRC_120UA 120 #define BTEMP_BATCTRL_CURR_SRC_120UA 120
#define to_ab8500_btemp_device_info(x) container_of((x), \
struct ab8500_btemp, btemp_psy);
/** /**
* struct ab8500_btemp_interrupts - ab8500 interrupts * struct ab8500_btemp_interrupts - ab8500 interrupts
* @name: name of the interrupt * @name: name of the interrupt
...@@ -102,7 +99,7 @@ struct ab8500_btemp { ...@@ -102,7 +99,7 @@ struct ab8500_btemp {
struct ab8500_gpadc *gpadc; struct ab8500_gpadc *gpadc;
struct ab8500_fg *fg; struct ab8500_fg *fg;
struct abx500_bm_data *bm; struct abx500_bm_data *bm;
struct power_supply btemp_psy; struct power_supply *btemp_psy;
struct ab8500_btemp_events events; struct ab8500_btemp_events events;
struct ab8500_btemp_ranges btemp_ranges; struct ab8500_btemp_ranges btemp_ranges;
struct workqueue_struct *btemp_wq; struct workqueue_struct *btemp_wq;
...@@ -654,14 +651,14 @@ static void ab8500_btemp_periodic_work(struct work_struct *work) ...@@ -654,14 +651,14 @@ static void ab8500_btemp_periodic_work(struct work_struct *work)
if ((di->bat_temp != di->prev_bat_temp) || !di->initialized) { if ((di->bat_temp != di->prev_bat_temp) || !di->initialized) {
di->initialized = true; di->initialized = true;
di->bat_temp = bat_temp; di->bat_temp = bat_temp;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
} }
} else if (bat_temp < di->prev_bat_temp) { } else if (bat_temp < di->prev_bat_temp) {
di->bat_temp--; di->bat_temp--;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
} else if (bat_temp > di->prev_bat_temp) { } else if (bat_temp > di->prev_bat_temp) {
di->bat_temp++; di->bat_temp++;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
} }
di->prev_bat_temp = bat_temp; di->prev_bat_temp = bat_temp;
...@@ -689,7 +686,7 @@ static irqreturn_t ab8500_btemp_batctrlindb_handler(int irq, void *_di) ...@@ -689,7 +686,7 @@ static irqreturn_t ab8500_btemp_batctrlindb_handler(int irq, void *_di)
dev_err(di->dev, "Battery removal detected!\n"); dev_err(di->dev, "Battery removal detected!\n");
di->events.batt_rem = true; di->events.batt_rem = true;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -715,7 +712,7 @@ static irqreturn_t ab8500_btemp_templow_handler(int irq, void *_di) ...@@ -715,7 +712,7 @@ static irqreturn_t ab8500_btemp_templow_handler(int irq, void *_di)
di->events.btemp_high = false; di->events.btemp_high = false;
di->events.btemp_medhigh = false; di->events.btemp_medhigh = false;
di->events.btemp_lowmed = false; di->events.btemp_lowmed = false;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
} }
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -738,7 +735,7 @@ static irqreturn_t ab8500_btemp_temphigh_handler(int irq, void *_di) ...@@ -738,7 +735,7 @@ static irqreturn_t ab8500_btemp_temphigh_handler(int irq, void *_di)
di->events.btemp_medhigh = false; di->events.btemp_medhigh = false;
di->events.btemp_lowmed = false; di->events.btemp_lowmed = false;
di->events.btemp_low = false; di->events.btemp_low = false;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -760,7 +757,7 @@ static irqreturn_t ab8500_btemp_lowmed_handler(int irq, void *_di) ...@@ -760,7 +757,7 @@ static irqreturn_t ab8500_btemp_lowmed_handler(int irq, void *_di)
di->events.btemp_medhigh = false; di->events.btemp_medhigh = false;
di->events.btemp_high = false; di->events.btemp_high = false;
di->events.btemp_low = false; di->events.btemp_low = false;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -782,7 +779,7 @@ static irqreturn_t ab8500_btemp_medhigh_handler(int irq, void *_di) ...@@ -782,7 +779,7 @@ static irqreturn_t ab8500_btemp_medhigh_handler(int irq, void *_di)
di->events.btemp_lowmed = false; di->events.btemp_lowmed = false;
di->events.btemp_high = false; di->events.btemp_high = false;
di->events.btemp_low = false; di->events.btemp_low = false;
power_supply_changed(&di->btemp_psy); power_supply_changed(di->btemp_psy);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -884,9 +881,7 @@ static int ab8500_btemp_get_property(struct power_supply *psy, ...@@ -884,9 +881,7 @@ static int ab8500_btemp_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct ab8500_btemp *di; struct ab8500_btemp *di = power_supply_get_drvdata(psy);
di = to_ab8500_btemp_device_info(psy);
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_PRESENT:
...@@ -919,14 +914,14 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) ...@@ -919,14 +914,14 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
psy = (struct power_supply *)data; psy = (struct power_supply *)data;
ext = dev_get_drvdata(dev); ext = dev_get_drvdata(dev);
di = to_ab8500_btemp_device_info(psy); di = power_supply_get_drvdata(psy);
/* /*
* For all psy where the name of your driver * For all psy where the name of your driver
* appears in any supplied_to * appears in any supplied_to
*/ */
for (i = 0; i < ext->num_supplicants; i++) { for (i = 0; i < ext->num_supplicants; i++) {
if (!strcmp(ext->supplied_to[i], psy->name)) if (!strcmp(ext->supplied_to[i], psy->desc->name))
psy_found = true; psy_found = true;
} }
...@@ -934,16 +929,16 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) ...@@ -934,16 +929,16 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
return 0; return 0;
/* Go through all properties for the psy */ /* Go through all properties for the psy */
for (j = 0; j < ext->num_properties; j++) { for (j = 0; j < ext->desc->num_properties; j++) {
enum power_supply_property prop; enum power_supply_property prop;
prop = ext->properties[j]; prop = ext->desc->properties[j];
if (ext->get_property(ext, prop, &ret)) if (power_supply_get_property(ext, prop, &ret))
continue; continue;
switch (prop) { switch (prop) {
case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_PRESENT:
switch (ext->type) { switch (ext->desc->type) {
case POWER_SUPPLY_TYPE_MAINS: case POWER_SUPPLY_TYPE_MAINS:
/* AC disconnected */ /* AC disconnected */
if (!ret.intval && di->events.ac_conn) { if (!ret.intval && di->events.ac_conn) {
...@@ -990,10 +985,10 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) ...@@ -990,10 +985,10 @@ static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data)
*/ */
static void ab8500_btemp_external_power_changed(struct power_supply *psy) static void ab8500_btemp_external_power_changed(struct power_supply *psy)
{ {
struct ab8500_btemp *di = to_ab8500_btemp_device_info(psy); struct ab8500_btemp *di = power_supply_get_drvdata(psy);
class_for_each_device(power_supply_class, NULL, class_for_each_device(power_supply_class, NULL,
&di->btemp_psy, ab8500_btemp_get_ext_psy_data); di->btemp_psy, ab8500_btemp_get_ext_psy_data);
} }
/* ab8500 btemp driver interrupts and their respective isr */ /* ab8500 btemp driver interrupts and their respective isr */
...@@ -1044,7 +1039,7 @@ static int ab8500_btemp_remove(struct platform_device *pdev) ...@@ -1044,7 +1039,7 @@ static int ab8500_btemp_remove(struct platform_device *pdev)
destroy_workqueue(di->btemp_wq); destroy_workqueue(di->btemp_wq);
flush_scheduled_work(); flush_scheduled_work();
power_supply_unregister(&di->btemp_psy); power_supply_unregister(di->btemp_psy);
return 0; return 0;
} }
...@@ -1054,10 +1049,20 @@ static char *supply_interface[] = { ...@@ -1054,10 +1049,20 @@ static char *supply_interface[] = {
"ab8500_fg", "ab8500_fg",
}; };
static const struct power_supply_desc ab8500_btemp_desc = {
.name = "ab8500_btemp",
.type = POWER_SUPPLY_TYPE_BATTERY,
.properties = ab8500_btemp_props,
.num_properties = ARRAY_SIZE(ab8500_btemp_props),
.get_property = ab8500_btemp_get_property,
.external_power_changed = ab8500_btemp_external_power_changed,
};
static int ab8500_btemp_probe(struct platform_device *pdev) static int ab8500_btemp_probe(struct platform_device *pdev)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct abx500_bm_data *plat = pdev->dev.platform_data; struct abx500_bm_data *plat = pdev->dev.platform_data;
struct power_supply_config psy_cfg = {};
struct ab8500_btemp *di; struct ab8500_btemp *di;
int irq, i, ret = 0; int irq, i, ret = 0;
u8 val; u8 val;
...@@ -1089,17 +1094,9 @@ static int ab8500_btemp_probe(struct platform_device *pdev) ...@@ -1089,17 +1094,9 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
di->initialized = false; di->initialized = false;
/* BTEMP supply */ psy_cfg.supplied_to = supply_interface;
di->btemp_psy.name = "ab8500_btemp"; psy_cfg.num_supplicants = ARRAY_SIZE(supply_interface);
di->btemp_psy.type = POWER_SUPPLY_TYPE_BATTERY; psy_cfg.drv_data = di;
di->btemp_psy.properties = ab8500_btemp_props;
di->btemp_psy.num_properties = ARRAY_SIZE(ab8500_btemp_props);
di->btemp_psy.get_property = ab8500_btemp_get_property;
di->btemp_psy.supplied_to = supply_interface;
di->btemp_psy.num_supplicants = ARRAY_SIZE(supply_interface);
di->btemp_psy.external_power_changed =
ab8500_btemp_external_power_changed;
/* Create a work queue for the btemp */ /* Create a work queue for the btemp */
di->btemp_wq = di->btemp_wq =
...@@ -1140,9 +1137,11 @@ static int ab8500_btemp_probe(struct platform_device *pdev) ...@@ -1140,9 +1137,11 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
} }
/* Register BTEMP power supply class */ /* Register BTEMP power supply class */
ret = power_supply_register(di->dev, &di->btemp_psy); di->btemp_psy = power_supply_register(di->dev, &ab8500_btemp_desc,
if (ret) { &psy_cfg);
if (IS_ERR(di->btemp_psy)) {
dev_err(di->dev, "failed to register BTEMP psy\n"); dev_err(di->dev, "failed to register BTEMP psy\n");
ret = PTR_ERR(di->btemp_psy);
goto free_btemp_wq; goto free_btemp_wq;
} }
...@@ -1171,7 +1170,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) ...@@ -1171,7 +1170,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)
return ret; return ret;
free_irq: free_irq:
power_supply_unregister(&di->btemp_psy); power_supply_unregister(di->btemp_psy);
/* We also have to free all successfully registered irqs */ /* We also have to free all successfully registered irqs */
for (i = i - 1; i >= 0; i--) { for (i = i - 1; i >= 0; i--) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#include <linux/apm-emulation.h> #include <linux/apm-emulation.h>
#define PSY_PROP(psy, prop, val) (psy->get_property(psy, \ #define PSY_PROP(psy, prop, val) (power_supply_get_property(psy, \
POWER_SUPPLY_PROP_##prop, val)) POWER_SUPPLY_PROP_##prop, val))
#define _MPSY_PROP(prop, val) (main_battery->get_property(main_battery, \ #define _MPSY_PROP(prop, val) (power_supply_get_property(main_battery, \
prop, val)) prop, val))
#define MPSY_PROP(prop, val) _MPSY_PROP(POWER_SUPPLY_PROP_##prop, val) #define MPSY_PROP(prop, val) _MPSY_PROP(POWER_SUPPLY_PROP_##prop, val)
...@@ -48,7 +48,7 @@ static int __find_main_battery(struct device *dev, void *data) ...@@ -48,7 +48,7 @@ static int __find_main_battery(struct device *dev, void *data)
bp->bat = dev_get_drvdata(dev); bp->bat = dev_get_drvdata(dev);
if (bp->bat->use_for_apm) { if (bp->bat->desc->use_for_apm) {
/* nice, we explicitly asked to report this battery. */ /* nice, we explicitly asked to report this battery. */
bp->main = bp->bat; bp->main = bp->bat;
return 1; return 1;
......
This diff is collapsed.
This diff is collapsed.
...@@ -152,8 +152,8 @@ ...@@ -152,8 +152,8 @@
struct bq24190_dev_info { struct bq24190_dev_info {
struct i2c_client *client; struct i2c_client *client;
struct device *dev; struct device *dev;
struct power_supply charger; struct power_supply *charger;
struct power_supply battery; struct power_supply *battery;
char model_name[I2C_NAME_SIZE]; char model_name[I2C_NAME_SIZE];
kernel_ulong_t model; kernel_ulong_t model;
unsigned int gpio_int; unsigned int gpio_int;
...@@ -423,8 +423,7 @@ static ssize_t bq24190_sysfs_show(struct device *dev, ...@@ -423,8 +423,7 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct power_supply *psy = dev_get_drvdata(dev); struct power_supply *psy = dev_get_drvdata(dev);
struct bq24190_dev_info *bdi = struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
container_of(psy, struct bq24190_dev_info, charger);
struct bq24190_sysfs_field_info *info; struct bq24190_sysfs_field_info *info;
int ret; int ret;
u8 v; u8 v;
...@@ -444,8 +443,7 @@ static ssize_t bq24190_sysfs_store(struct device *dev, ...@@ -444,8 +443,7 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct power_supply *psy = dev_get_drvdata(dev); struct power_supply *psy = dev_get_drvdata(dev);
struct bq24190_dev_info *bdi = struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
container_of(psy, struct bq24190_dev_info, charger);
struct bq24190_sysfs_field_info *info; struct bq24190_sysfs_field_info *info;
int ret; int ret;
u8 v; u8 v;
...@@ -469,13 +467,13 @@ static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi) ...@@ -469,13 +467,13 @@ static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi)
{ {
bq24190_sysfs_init_attrs(); bq24190_sysfs_init_attrs();
return sysfs_create_group(&bdi->charger.dev->kobj, return sysfs_create_group(&bdi->charger->dev.kobj,
&bq24190_sysfs_attr_group); &bq24190_sysfs_attr_group);
} }
static void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) static void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi)
{ {
sysfs_remove_group(&bdi->charger.dev->kobj, &bq24190_sysfs_attr_group); sysfs_remove_group(&bdi->charger->dev.kobj, &bq24190_sysfs_attr_group);
} }
#else #else
static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi) static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi)
...@@ -807,8 +805,7 @@ static int bq24190_charger_set_voltage(struct bq24190_dev_info *bdi, ...@@ -807,8 +805,7 @@ static int bq24190_charger_set_voltage(struct bq24190_dev_info *bdi,
static int bq24190_charger_get_property(struct power_supply *psy, static int bq24190_charger_get_property(struct power_supply *psy,
enum power_supply_property psp, union power_supply_propval *val) enum power_supply_property psp, union power_supply_propval *val)
{ {
struct bq24190_dev_info *bdi = struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
container_of(psy, struct bq24190_dev_info, charger);
int ret; int ret;
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
...@@ -861,8 +858,7 @@ static int bq24190_charger_set_property(struct power_supply *psy, ...@@ -861,8 +858,7 @@ static int bq24190_charger_set_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
const union power_supply_propval *val) const union power_supply_propval *val)
{ {
struct bq24190_dev_info *bdi = struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
container_of(psy, struct bq24190_dev_info, charger);
int ret; int ret;
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
...@@ -922,18 +918,15 @@ static char *bq24190_charger_supplied_to[] = { ...@@ -922,18 +918,15 @@ static char *bq24190_charger_supplied_to[] = {
"main-battery", "main-battery",
}; };
static void bq24190_charger_init(struct power_supply *charger) static const struct power_supply_desc bq24190_charger_desc = {
{ .name = "bq24190-charger",
charger->name = "bq24190-charger"; .type = POWER_SUPPLY_TYPE_USB,
charger->type = POWER_SUPPLY_TYPE_USB; .properties = bq24190_charger_properties,
charger->properties = bq24190_charger_properties; .num_properties = ARRAY_SIZE(bq24190_charger_properties),
charger->num_properties = ARRAY_SIZE(bq24190_charger_properties); .get_property = bq24190_charger_get_property,
charger->supplied_to = bq24190_charger_supplied_to; .set_property = bq24190_charger_set_property,
charger->num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to); .property_is_writeable = bq24190_charger_property_is_writeable,
charger->get_property = bq24190_charger_get_property; };
charger->set_property = bq24190_charger_set_property;
charger->property_is_writeable = bq24190_charger_property_is_writeable;
}
/* Battery power supply property routines */ /* Battery power supply property routines */
...@@ -1102,8 +1095,7 @@ static int bq24190_battery_set_temp_alert_max(struct bq24190_dev_info *bdi, ...@@ -1102,8 +1095,7 @@ static int bq24190_battery_set_temp_alert_max(struct bq24190_dev_info *bdi,
static int bq24190_battery_get_property(struct power_supply *psy, static int bq24190_battery_get_property(struct power_supply *psy,
enum power_supply_property psp, union power_supply_propval *val) enum power_supply_property psp, union power_supply_propval *val)
{ {
struct bq24190_dev_info *bdi = struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
container_of(psy, struct bq24190_dev_info, battery);
int ret; int ret;
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
...@@ -1144,8 +1136,7 @@ static int bq24190_battery_set_property(struct power_supply *psy, ...@@ -1144,8 +1136,7 @@ static int bq24190_battery_set_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
const union power_supply_propval *val) const union power_supply_propval *val)
{ {
struct bq24190_dev_info *bdi = struct bq24190_dev_info *bdi = power_supply_get_drvdata(psy);
container_of(psy, struct bq24190_dev_info, battery);
int ret; int ret;
dev_dbg(bdi->dev, "prop: %d\n", psp); dev_dbg(bdi->dev, "prop: %d\n", psp);
...@@ -1193,16 +1184,15 @@ static enum power_supply_property bq24190_battery_properties[] = { ...@@ -1193,16 +1184,15 @@ static enum power_supply_property bq24190_battery_properties[] = {
POWER_SUPPLY_PROP_SCOPE, POWER_SUPPLY_PROP_SCOPE,
}; };
static void bq24190_battery_init(struct power_supply *battery) static const struct power_supply_desc bq24190_battery_desc = {
{ .name = "bq24190-battery",
battery->name = "bq24190-battery"; .type = POWER_SUPPLY_TYPE_BATTERY,
battery->type = POWER_SUPPLY_TYPE_BATTERY; .properties = bq24190_battery_properties,
battery->properties = bq24190_battery_properties; .num_properties = ARRAY_SIZE(bq24190_battery_properties),
battery->num_properties = ARRAY_SIZE(bq24190_battery_properties); .get_property = bq24190_battery_get_property,
battery->get_property = bq24190_battery_get_property; .set_property = bq24190_battery_set_property,
battery->set_property = bq24190_battery_set_property; .property_is_writeable = bq24190_battery_property_is_writeable,
battery->property_is_writeable = bq24190_battery_property_is_writeable; };
}
static irqreturn_t bq24190_irq_handler_thread(int irq, void *data) static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
{ {
...@@ -1269,8 +1259,8 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data) ...@@ -1269,8 +1259,8 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
* interrupt received). * interrupt received).
*/ */
if (alert_userspace && !bdi->first_time) { if (alert_userspace && !bdi->first_time) {
power_supply_changed(&bdi->charger); power_supply_changed(bdi->charger);
power_supply_changed(&bdi->battery); power_supply_changed(bdi->battery);
bdi->first_time = false; bdi->first_time = false;
} }
...@@ -1362,6 +1352,7 @@ static int bq24190_probe(struct i2c_client *client, ...@@ -1362,6 +1352,7 @@ static int bq24190_probe(struct i2c_client *client,
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct bq24190_platform_data *pdata = client->dev.platform_data; struct bq24190_platform_data *pdata = client->dev.platform_data;
struct power_supply_config charger_cfg = {}, battery_cfg = {};
struct bq24190_dev_info *bdi; struct bq24190_dev_info *bdi;
int ret; int ret;
...@@ -1416,19 +1407,23 @@ static int bq24190_probe(struct i2c_client *client, ...@@ -1416,19 +1407,23 @@ static int bq24190_probe(struct i2c_client *client,
goto out2; goto out2;
} }
bq24190_charger_init(&bdi->charger); charger_cfg.drv_data = bdi;
charger_cfg.supplied_to = bq24190_charger_supplied_to;
ret = power_supply_register(dev, &bdi->charger); charger_cfg.num_supplicants = ARRAY_SIZE(bq24190_charger_supplied_to),
if (ret) { bdi->charger = power_supply_register(dev, &bq24190_charger_desc,
&charger_cfg);
if (IS_ERR(bdi->charger)) {
dev_err(dev, "Can't register charger\n"); dev_err(dev, "Can't register charger\n");
ret = PTR_ERR(bdi->charger);
goto out2; goto out2;
} }
bq24190_battery_init(&bdi->battery); battery_cfg.drv_data = bdi;
bdi->battery = power_supply_register(dev, &bq24190_battery_desc,
ret = power_supply_register(dev, &bdi->battery); &battery_cfg);
if (ret) { if (IS_ERR(bdi->battery)) {
dev_err(dev, "Can't register battery\n"); dev_err(dev, "Can't register battery\n");
ret = PTR_ERR(bdi->battery);
goto out3; goto out3;
} }
...@@ -1441,9 +1436,9 @@ static int bq24190_probe(struct i2c_client *client, ...@@ -1441,9 +1436,9 @@ static int bq24190_probe(struct i2c_client *client,
return 0; return 0;
out4: out4:
power_supply_unregister(&bdi->battery); power_supply_unregister(bdi->battery);
out3: out3:
power_supply_unregister(&bdi->charger); power_supply_unregister(bdi->charger);
out2: out2:
pm_runtime_disable(dev); pm_runtime_disable(dev);
out1: out1:
...@@ -1462,8 +1457,8 @@ static int bq24190_remove(struct i2c_client *client) ...@@ -1462,8 +1457,8 @@ static int bq24190_remove(struct i2c_client *client)
pm_runtime_put_sync(bdi->dev); pm_runtime_put_sync(bdi->dev);
bq24190_sysfs_remove_group(bdi); bq24190_sysfs_remove_group(bdi);
power_supply_unregister(&bdi->battery); power_supply_unregister(bdi->battery);
power_supply_unregister(&bdi->charger); power_supply_unregister(bdi->charger);
pm_runtime_disable(bdi->dev); pm_runtime_disable(bdi->dev);
if (bdi->gpio_int) if (bdi->gpio_int)
...@@ -1499,8 +1494,8 @@ static int bq24190_pm_resume(struct device *dev) ...@@ -1499,8 +1494,8 @@ static int bq24190_pm_resume(struct device *dev)
pm_runtime_put_sync(bdi->dev); pm_runtime_put_sync(bdi->dev);
/* Things may have changed while suspended so alert upper layer */ /* Things may have changed while suspended so alert upper layer */
power_supply_changed(&bdi->charger); power_supply_changed(bdi->charger);
power_supply_changed(&bdi->battery); power_supply_changed(bdi->battery);
return 0; return 0;
} }
......
...@@ -44,14 +44,15 @@ ...@@ -44,14 +44,15 @@
#define BQ24735_DEVICE_ID 0xff #define BQ24735_DEVICE_ID 0xff
struct bq24735 { struct bq24735 {
struct power_supply charger; struct power_supply *charger;
struct i2c_client *client; struct power_supply_desc charger_desc;
struct bq24735_platform *pdata; struct i2c_client *client;
struct bq24735_platform *pdata;
}; };
static inline struct bq24735 *to_bq24735(struct power_supply *psy) static inline struct bq24735 *to_bq24735(struct power_supply *psy)
{ {
return container_of(psy, struct bq24735, charger); return power_supply_get_drvdata(psy);
} }
static enum power_supply_property bq24735_charger_properties[] = { static enum power_supply_property bq24735_charger_properties[] = {
...@@ -192,9 +193,7 @@ static int bq24735_charger_get_property(struct power_supply *psy, ...@@ -192,9 +193,7 @@ static int bq24735_charger_get_property(struct power_supply *psy,
enum power_supply_property psp, enum power_supply_property psp,
union power_supply_propval *val) union power_supply_propval *val)
{ {
struct bq24735 *charger; struct bq24735 *charger = to_bq24735(psy);
charger = container_of(psy, struct bq24735, charger);
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_ONLINE: case POWER_SUPPLY_PROP_ONLINE:
...@@ -248,7 +247,8 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -248,7 +247,8 @@ static int bq24735_charger_probe(struct i2c_client *client,
{ {
int ret; int ret;
struct bq24735 *charger; struct bq24735 *charger;
struct power_supply *supply; struct power_supply_desc *supply_desc;
struct power_supply_config psy_cfg = {};
char *name; char *name;
charger = devm_kzalloc(&client->dev, sizeof(*charger), GFP_KERNEL); charger = devm_kzalloc(&client->dev, sizeof(*charger), GFP_KERNEL);
...@@ -277,16 +277,18 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -277,16 +277,18 @@ static int bq24735_charger_probe(struct i2c_client *client,
charger->client = client; charger->client = client;
supply = &charger->charger; supply_desc = &charger->charger_desc;
supply->name = name; supply_desc->name = name;
supply->type = POWER_SUPPLY_TYPE_MAINS; supply_desc->type = POWER_SUPPLY_TYPE_MAINS;
supply->properties = bq24735_charger_properties; supply_desc->properties = bq24735_charger_properties;
supply->num_properties = ARRAY_SIZE(bq24735_charger_properties); supply_desc->num_properties = ARRAY_SIZE(bq24735_charger_properties);
supply->get_property = bq24735_charger_get_property; supply_desc->get_property = bq24735_charger_get_property;
supply->supplied_to = charger->pdata->supplied_to;
supply->num_supplicants = charger->pdata->num_supplicants; psy_cfg.supplied_to = charger->pdata->supplied_to;
supply->of_node = client->dev.of_node; psy_cfg.num_supplicants = charger->pdata->num_supplicants;
psy_cfg.of_node = client->dev.of_node;
psy_cfg.drv_data = charger;
i2c_set_clientdata(client, charger); i2c_set_clientdata(client, charger);
...@@ -341,8 +343,10 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -341,8 +343,10 @@ static int bq24735_charger_probe(struct i2c_client *client,
} }
} }
ret = power_supply_register(&client->dev, supply); charger->charger = power_supply_register(&client->dev, supply_desc,
if (ret < 0) { &psy_cfg);
if (IS_ERR(charger->charger)) {
ret = PTR_ERR(charger->charger);
dev_err(&client->dev, "Failed to register power supply: %d\n", dev_err(&client->dev, "Failed to register power supply: %d\n",
ret); ret);
goto err_free_name; goto err_free_name;
...@@ -354,7 +358,8 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -354,7 +358,8 @@ static int bq24735_charger_probe(struct i2c_client *client,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING | IRQF_TRIGGER_FALLING |
IRQF_ONESHOT, IRQF_ONESHOT,
supply->name, supply); supply_desc->name,
charger->charger);
if (ret) { if (ret) {
dev_err(&client->dev, dev_err(&client->dev,
"Unable to register IRQ %d err %d\n", "Unable to register IRQ %d err %d\n",
...@@ -365,7 +370,7 @@ static int bq24735_charger_probe(struct i2c_client *client, ...@@ -365,7 +370,7 @@ static int bq24735_charger_probe(struct i2c_client *client,
return 0; return 0;
err_unregister_supply: err_unregister_supply:
power_supply_unregister(supply); power_supply_unregister(charger->charger);
err_free_name: err_free_name:
if (name != charger->pdata->name) if (name != charger->pdata->name)
kfree(name); kfree(name);
...@@ -381,10 +386,10 @@ static int bq24735_charger_remove(struct i2c_client *client) ...@@ -381,10 +386,10 @@ static int bq24735_charger_remove(struct i2c_client *client)
devm_free_irq(&charger->client->dev, charger->client->irq, devm_free_irq(&charger->client->dev, charger->client->irq,
&charger->charger); &charger->charger);
power_supply_unregister(&charger->charger); power_supply_unregister(charger->charger);
if (charger->charger.name != charger->pdata->name) if (charger->charger_desc.name != charger->pdata->name)
kfree(charger->charger.name); kfree(charger->charger_desc.name);
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -486,6 +486,7 @@ struct pm2xxx_charger { ...@@ -486,6 +486,7 @@ struct pm2xxx_charger {
struct work_struct check_main_thermal_prot_work; struct work_struct check_main_thermal_prot_work;
struct delayed_work check_hw_failure_work; struct delayed_work check_hw_failure_work;
struct ux500_charger ac_chg; struct ux500_charger ac_chg;
struct power_supply_desc ac_chg_desc;
struct pm2xxx_charger_event_flags flags; struct pm2xxx_charger_event_flags flags;
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -151,9 +151,17 @@ config POWER_RESET_SYSCON ...@@ -151,9 +151,17 @@ config POWER_RESET_SYSCON
help help
Reboot support for generic SYSCON mapped register reset. Reboot support for generic SYSCON mapped register reset.
config POWER_RESET_SYSCON_POWEROFF
bool "Generic SYSCON regmap poweroff driver"
depends on OF
select MFD_SYSCON
help
Poweroff support for generic SYSCON mapped register poweroff.
config POWER_RESET_RMOBILE config POWER_RESET_RMOBILE
tristate "Renesas R-Mobile reset driver" tristate "Renesas R-Mobile reset driver"
depends on ARCH_RMOBILE || COMPILE_TEST depends on ARCH_RMOBILE || COMPILE_TEST
depends on HAS_IOMEM
help help
Reboot support for Renesas R-Mobile and SH-Mobile SoCs. Reboot support for Renesas R-Mobile and SH-Mobile SoCs.
......
...@@ -17,4 +17,5 @@ obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o ...@@ -17,4 +17,5 @@ obj-$(CONFIG_POWER_RESET_VEXPRESS) += vexpress-poweroff.o
obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o obj-$(CONFIG_POWER_RESET_XGENE) += xgene-reboot.o
obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o obj-$(CONFIG_POWER_RESET_KEYSTONE) += keystone-reset.o
obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o
obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o
obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o obj-$(CONFIG_POWER_RESET_RMOBILE) += rmobile-reset.o
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment