Commit 619e17cf authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
 "Core:
   - Ensure HWMON devices are registered with valid names
   - Fix device wakeup code

  Drivers:
   - bq25890_charger: Add BQ25895 support
   - axp288_fuel_gauge: Add Minix Neo Z83-4 to blacklist
   - sc27xx: improve battery calibration
   - misc small fixes all over drivers"

* tag 'for-v5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (24 commits)
  power: supply: cpcap-charger: Enable vbus boost voltage
  power: supply: sc27xx: Add POWER_SUPPLY_PROP_CALIBRATE attribute
  power: supply: sc27xx: Optimize the battery capacity calibration
  power: supply: sc27xx: Make sure the alarm capacity is larger than 0
  power: supply: sc27xx: Fix the the accuracy issue of coulomb calculation
  power: supply: sc27xx: Fix conditon to enable the FGU interrupt
  power: supply: sc27xx: Add POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN attribute
  power: supply: max77650: add MODULE_ALIAS()
  power: supply: isp1704: remove redundant assignment to variable ret
  power: supply: bq25890_charger: Add the BQ25895 part
  power: supply: sc27xx: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
  power: supply: sc27xx: Introduce local variable 'struct device *dev'
  power: reset: reboot-mode: Fix author email format
  power: supply: ab8500: remove set but not used variables 'vbup33_vrtcn' and 'bup_vch_range'
  power: supply: max17042_battery: Fix a typo in function names
  power: reset: gpio-restart: Fix typo when gpio reset is not found
  power: supply: Init device wakeup after device_add()
  power: supply: ab8500_charger: Mark expected switch fall-through
  power: supply: sbs-battery: only return health when battery present
  MAINTAINERS: N900: Remove isp1704_charger.h record
  ...
parents 57f1c3ca 7f737861
...@@ -11511,7 +11511,6 @@ NOKIA N900 POWER SUPPLY DRIVERS ...@@ -11511,7 +11511,6 @@ NOKIA N900 POWER SUPPLY DRIVERS
R: Pali Rohár <pali.rohar@gmail.com> R: Pali Rohár <pali.rohar@gmail.com>
F: include/linux/power/bq2415x_charger.h F: include/linux/power/bq2415x_charger.h
F: include/linux/power/bq27xxx_battery.h F: include/linux/power/bq27xxx_battery.h
F: include/linux/power/isp1704_charger.h
F: drivers/power/supply/bq2415x_charger.c F: drivers/power/supply/bq2415x_charger.c
F: drivers/power/supply/bq27xxx_battery.c F: drivers/power/supply/bq27xxx_battery.c
F: drivers/power/supply/bq27xxx_battery_i2c.c F: drivers/power/supply/bq27xxx_battery_i2c.c
......
...@@ -231,8 +231,9 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -231,8 +231,9 @@ static void cpcap_usb_detect(struct work_struct *work)
goto out_err; goto out_err;
error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3, error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3,
CPCAP_BIT_VBUSSTBY_EN, CPCAP_BIT_VBUSSTBY_EN |
CPCAP_BIT_VBUSSTBY_EN); CPCAP_BIT_VBUSEN_SPI,
CPCAP_BIT_VBUSEN_SPI);
if (error) if (error)
goto out_err; goto out_err;
...@@ -240,7 +241,8 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -240,7 +241,8 @@ static void cpcap_usb_detect(struct work_struct *work)
} }
error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3, error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3,
CPCAP_BIT_VBUSSTBY_EN, 0); CPCAP_BIT_VBUSSTBY_EN |
CPCAP_BIT_VBUSEN_SPI, 0);
if (error) if (error)
goto out_err; goto out_err;
......
...@@ -65,7 +65,7 @@ static int gpio_restart_probe(struct platform_device *pdev) ...@@ -65,7 +65,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
gpio_restart->reset_gpio = devm_gpiod_get(&pdev->dev, NULL, gpio_restart->reset_gpio = devm_gpiod_get(&pdev->dev, NULL,
open_source ? GPIOD_IN : GPIOD_OUT_LOW); open_source ? GPIOD_IN : GPIOD_OUT_LOW);
if (IS_ERR(gpio_restart->reset_gpio)) { if (IS_ERR(gpio_restart->reset_gpio)) {
dev_err(&pdev->dev, "Could net get reset GPIO\n"); dev_err(&pdev->dev, "Could not get reset GPIO\n");
return PTR_ERR(gpio_restart->reset_gpio); return PTR_ERR(gpio_restart->reset_gpio);
} }
......
...@@ -190,6 +190,6 @@ void devm_reboot_mode_unregister(struct device *dev, ...@@ -190,6 +190,6 @@ void devm_reboot_mode_unregister(struct device *dev,
} }
EXPORT_SYMBOL_GPL(devm_reboot_mode_unregister); EXPORT_SYMBOL_GPL(devm_reboot_mode_unregister);
MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com"); MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com>");
MODULE_DESCRIPTION("System reboot mode core library"); MODULE_DESCRIPTION("System reboot mode core library");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -742,7 +742,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di, ...@@ -742,7 +742,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,
USB_CH_IP_CUR_LVL_1P5; USB_CH_IP_CUR_LVL_1P5;
break; break;
} }
/* Else, fall through */ /* else, fall through */
case USB_STAT_HM_IDGND: case USB_STAT_HM_IDGND:
dev_err(di->dev, "USB Type - Charging not allowed\n"); dev_err(di->dev, "USB Type - Charging not allowed\n");
di->max_usb_in_curr.usb_type_max = USB_CH_IP_CUR_LVL_0P05; di->max_usb_in_curr.usb_type_max = USB_CH_IP_CUR_LVL_0P05;
...@@ -3011,7 +3011,6 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, ...@@ -3011,7 +3011,6 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy,
static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) static int ab8500_charger_init_hw_registers(struct ab8500_charger *di)
{ {
int ret = 0; int ret = 0;
u8 bup_vch_range = 0, vbup33_vrtcn = 0;
/* Setup maximum charger current and voltage for ABB cut2.0 */ /* Setup maximum charger current and voltage for ABB cut2.0 */
if (!is_ab8500_1p1_or_earlier(di->parent)) { if (!is_ab8500_1p1_or_earlier(di->parent)) {
...@@ -3112,12 +3111,6 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) ...@@ -3112,12 +3111,6 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di)
goto out; goto out;
} }
/* Backup battery voltage and current */
if (di->bm->bkup_bat_v > BUP_VCH_SEL_3P1V)
bup_vch_range = BUP_VCH_RANGE;
if (di->bm->bkup_bat_v == BUP_VCH_SEL_3P3V)
vbup33_vrtcn = VBUP33_VRTCN;
ret = abx500_set_register_interruptible(di->dev, ret = abx500_set_register_interruptible(di->dev,
AB8500_RTC, AB8500_RTC,
AB8500_RTC_BACKUP_CHG_REG, AB8500_RTC_BACKUP_CHG_REG,
......
...@@ -674,6 +674,7 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info) ...@@ -674,6 +674,7 @@ static void fuel_gauge_init_irq(struct axp288_fg_info *info)
/* /*
* Some devices have no battery (HDMI sticks) and the axp288 battery's * Some devices have no battery (HDMI sticks) and the axp288 battery's
* detection reports one despite it not being there. * detection reports one despite it not being there.
* Please keep this listed sorted alphabetically.
*/ */
static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = { static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = {
{ {
...@@ -696,6 +697,12 @@ static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = { ...@@ -696,6 +697,12 @@ static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = {
DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"), DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
}, },
}, },
{
/* ECS EF20EA */
.matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
},
},
{ {
/* Intel Cherry Trail Compute Stick, Windows version */ /* Intel Cherry Trail Compute Stick, Windows version */
.matches = { .matches = {
...@@ -720,10 +727,11 @@ static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = { ...@@ -720,10 +727,11 @@ static const struct dmi_system_id axp288_fuel_gauge_blacklist[] = {
}, },
}, },
{ {
/* ECS EF20EA */ /* Minix Neo Z83-4 mini PC */
.matches = { .matches = {
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"), DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
}, DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
}
}, },
{} {}
}; };
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define BQ25890_IRQ_PIN "bq25890_irq" #define BQ25890_IRQ_PIN "bq25890_irq"
#define BQ25890_ID 3 #define BQ25890_ID 3
#define BQ25895_ID 7
#define BQ25896_ID 0 #define BQ25896_ID 0
enum bq25890_fields { enum bq25890_fields {
...@@ -171,7 +172,7 @@ static const struct reg_field bq25890_reg_fields[] = { ...@@ -171,7 +172,7 @@ static const struct reg_field bq25890_reg_fields[] = {
[F_WD] = REG_FIELD(0x07, 4, 5), [F_WD] = REG_FIELD(0x07, 4, 5),
[F_TMR_EN] = REG_FIELD(0x07, 3, 3), [F_TMR_EN] = REG_FIELD(0x07, 3, 3),
[F_CHG_TMR] = REG_FIELD(0x07, 1, 2), [F_CHG_TMR] = REG_FIELD(0x07, 1, 2),
[F_JEITA_ISET] = REG_FIELD(0x07, 0, 0), [F_JEITA_ISET] = REG_FIELD(0x07, 0, 0), // reserved on BQ25895
/* REG08 */ /* REG08 */
[F_BATCMP] = REG_FIELD(0x08, 5, 7), [F_BATCMP] = REG_FIELD(0x08, 5, 7),
[F_VCLAMP] = REG_FIELD(0x08, 2, 4), [F_VCLAMP] = REG_FIELD(0x08, 2, 4),
...@@ -180,7 +181,7 @@ static const struct reg_field bq25890_reg_fields[] = { ...@@ -180,7 +181,7 @@ static const struct reg_field bq25890_reg_fields[] = {
[F_FORCE_ICO] = REG_FIELD(0x09, 7, 7), [F_FORCE_ICO] = REG_FIELD(0x09, 7, 7),
[F_TMR2X_EN] = REG_FIELD(0x09, 6, 6), [F_TMR2X_EN] = REG_FIELD(0x09, 6, 6),
[F_BATFET_DIS] = REG_FIELD(0x09, 5, 5), [F_BATFET_DIS] = REG_FIELD(0x09, 5, 5),
[F_JEITA_VSET] = REG_FIELD(0x09, 4, 4), [F_JEITA_VSET] = REG_FIELD(0x09, 4, 4), // reserved on BQ25895
[F_BATFET_DLY] = REG_FIELD(0x09, 3, 3), [F_BATFET_DLY] = REG_FIELD(0x09, 3, 3),
[F_BATFET_RST_EN] = REG_FIELD(0x09, 2, 2), [F_BATFET_RST_EN] = REG_FIELD(0x09, 2, 2),
[F_PUMPX_UP] = REG_FIELD(0x09, 1, 1), [F_PUMPX_UP] = REG_FIELD(0x09, 1, 1),
...@@ -188,7 +189,7 @@ static const struct reg_field bq25890_reg_fields[] = { ...@@ -188,7 +189,7 @@ static const struct reg_field bq25890_reg_fields[] = {
/* REG0A */ /* REG0A */
[F_BOOSTV] = REG_FIELD(0x0A, 4, 7), [F_BOOSTV] = REG_FIELD(0x0A, 4, 7),
/* PFM_OTG_DIS 3 on BQ25896 */ /* PFM_OTG_DIS 3 on BQ25896 */
[F_BOOSTI] = REG_FIELD(0x0A, 0, 2), [F_BOOSTI] = REG_FIELD(0x0A, 0, 2), // reserved on BQ25895
/* REG0B */ /* REG0B */
[F_VBUS_STAT] = REG_FIELD(0x0B, 5, 7), [F_VBUS_STAT] = REG_FIELD(0x0B, 5, 7),
[F_CHG_STAT] = REG_FIELD(0x0B, 3, 4), [F_CHG_STAT] = REG_FIELD(0x0B, 3, 4),
...@@ -392,6 +393,8 @@ static int bq25890_power_supply_get_property(struct power_supply *psy, ...@@ -392,6 +393,8 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_MODEL_NAME: case POWER_SUPPLY_PROP_MODEL_NAME:
if (bq->chip_id == BQ25890_ID) if (bq->chip_id == BQ25890_ID)
val->strval = "BQ25890"; val->strval = "BQ25890";
else if (bq->chip_id == BQ25895_ID)
val->strval = "BQ25895";
else if (bq->chip_id == BQ25896_ID) else if (bq->chip_id == BQ25896_ID)
val->strval = "BQ25896"; val->strval = "BQ25896";
else else
...@@ -862,7 +865,8 @@ static int bq25890_probe(struct i2c_client *client, ...@@ -862,7 +865,8 @@ static int bq25890_probe(struct i2c_client *client,
return bq->chip_id; return bq->chip_id;
} }
if ((bq->chip_id != BQ25890_ID) && (bq->chip_id != BQ25896_ID)) { if ((bq->chip_id != BQ25890_ID) && (bq->chip_id != BQ25895_ID)
&& (bq->chip_id != BQ25896_ID)) {
dev_err(dev, "Chip with ID=%d, not supported!\n", bq->chip_id); dev_err(dev, "Chip with ID=%d, not supported!\n", bq->chip_id);
return -ENODEV; return -ENODEV;
} }
......
...@@ -108,6 +108,9 @@ ...@@ -108,6 +108,9 @@
#define CPCAP_REG_CRM_ICHRG_1A596 CPCAP_REG_CRM_ICHRG(0xe) #define CPCAP_REG_CRM_ICHRG_1A596 CPCAP_REG_CRM_ICHRG(0xe)
#define CPCAP_REG_CRM_ICHRG_NO_LIMIT CPCAP_REG_CRM_ICHRG(0xf) #define CPCAP_REG_CRM_ICHRG_NO_LIMIT CPCAP_REG_CRM_ICHRG(0xf)
/* CPCAP_REG_VUSBC register bits needed for VBUS */
#define CPCAP_BIT_VBUS_SWITCH BIT(0) /* VBUS boost to 5V */
enum { enum {
CPCAP_CHARGER_IIO_BATTDET, CPCAP_CHARGER_IIO_BATTDET,
CPCAP_CHARGER_IIO_VOLTAGE, CPCAP_CHARGER_IIO_VOLTAGE,
...@@ -130,7 +133,8 @@ struct cpcap_charger_ddata { ...@@ -130,7 +133,8 @@ struct cpcap_charger_ddata {
struct power_supply *usb; struct power_supply *usb;
struct phy_companion comparator; /* For USB VBUS */ struct phy_companion comparator; /* For USB VBUS */
bool vbus_enabled; unsigned int vbus_enabled:1;
unsigned int feeding_vbus:1;
atomic_t active; atomic_t active;
int status; int status;
...@@ -325,7 +329,6 @@ static bool cpcap_charger_vbus_valid(struct cpcap_charger_ddata *ddata) ...@@ -325,7 +329,6 @@ static bool cpcap_charger_vbus_valid(struct cpcap_charger_ddata *ddata)
} }
/* VBUS control functions for the USB PHY companion */ /* VBUS control functions for the USB PHY companion */
static void cpcap_charger_vbus_work(struct work_struct *work) static void cpcap_charger_vbus_work(struct work_struct *work)
{ {
struct cpcap_charger_ddata *ddata; struct cpcap_charger_ddata *ddata;
...@@ -343,6 +346,7 @@ static void cpcap_charger_vbus_work(struct work_struct *work) ...@@ -343,6 +346,7 @@ static void cpcap_charger_vbus_work(struct work_struct *work)
return; return;
} }
ddata->feeding_vbus = true;
cpcap_charger_set_cable_path(ddata, false); cpcap_charger_set_cable_path(ddata, false);
cpcap_charger_set_inductive_path(ddata, false); cpcap_charger_set_inductive_path(ddata, false);
...@@ -350,12 +354,23 @@ static void cpcap_charger_vbus_work(struct work_struct *work) ...@@ -350,12 +354,23 @@ static void cpcap_charger_vbus_work(struct work_struct *work)
if (error) if (error)
goto out_err; goto out_err;
error = regmap_update_bits(ddata->reg, CPCAP_REG_VUSBC,
CPCAP_BIT_VBUS_SWITCH,
CPCAP_BIT_VBUS_SWITCH);
if (error)
goto out_err;
error = regmap_update_bits(ddata->reg, CPCAP_REG_CRM, error = regmap_update_bits(ddata->reg, CPCAP_REG_CRM,
CPCAP_REG_CRM_RVRSMODE, CPCAP_REG_CRM_RVRSMODE,
CPCAP_REG_CRM_RVRSMODE); CPCAP_REG_CRM_RVRSMODE);
if (error) if (error)
goto out_err; goto out_err;
} else { } else {
error = regmap_update_bits(ddata->reg, CPCAP_REG_VUSBC,
CPCAP_BIT_VBUS_SWITCH, 0);
if (error)
goto out_err;
error = regmap_update_bits(ddata->reg, CPCAP_REG_CRM, error = regmap_update_bits(ddata->reg, CPCAP_REG_CRM,
CPCAP_REG_CRM_RVRSMODE, 0); CPCAP_REG_CRM_RVRSMODE, 0);
if (error) if (error)
...@@ -363,6 +378,7 @@ static void cpcap_charger_vbus_work(struct work_struct *work) ...@@ -363,6 +378,7 @@ static void cpcap_charger_vbus_work(struct work_struct *work)
cpcap_charger_set_cable_path(ddata, true); cpcap_charger_set_cable_path(ddata, true);
cpcap_charger_set_inductive_path(ddata, true); cpcap_charger_set_inductive_path(ddata, true);
ddata->feeding_vbus = false;
} }
return; return;
...@@ -431,7 +447,8 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -431,7 +447,8 @@ static void cpcap_usb_detect(struct work_struct *work)
if (error) if (error)
return; return;
if (cpcap_charger_vbus_valid(ddata) && s.chrgcurr1) { if (!ddata->feeding_vbus && cpcap_charger_vbus_valid(ddata) &&
s.chrgcurr1) {
int max_current; int max_current;
if (cpcap_charger_battery_found(ddata)) if (cpcap_charger_battery_found(ddata))
......
...@@ -342,7 +342,7 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) ...@@ -342,7 +342,7 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp)
int vendor; int vendor;
int product; int product;
int i; int i;
int ret = -ENODEV; int ret;
/* Test ULPI interface */ /* Test ULPI interface */
ret = isp1704_write(isp, ULPI_SCRATCH, 0xaa); ret = isp1704_write(isp, ULPI_SCRATCH, 0xaa);
......
...@@ -511,7 +511,7 @@ static inline void max17042_override_por(struct regmap *map, ...@@ -511,7 +511,7 @@ static inline void max17042_override_por(struct regmap *map,
regmap_write(map, reg, value); regmap_write(map, reg, value);
} }
static inline void max10742_unlock_model(struct max17042_chip *chip) static inline void max17042_unlock_model(struct max17042_chip *chip)
{ {
struct regmap *map = chip->regmap; struct regmap *map = chip->regmap;
...@@ -519,7 +519,7 @@ static inline void max10742_unlock_model(struct max17042_chip *chip) ...@@ -519,7 +519,7 @@ static inline void max10742_unlock_model(struct max17042_chip *chip)
regmap_write(map, MAX17042_MLOCKReg2, MODEL_UNLOCK2); regmap_write(map, MAX17042_MLOCKReg2, MODEL_UNLOCK2);
} }
static inline void max10742_lock_model(struct max17042_chip *chip) static inline void max17042_lock_model(struct max17042_chip *chip)
{ {
struct regmap *map = chip->regmap; struct regmap *map = chip->regmap;
...@@ -577,7 +577,7 @@ static int max17042_init_model(struct max17042_chip *chip) ...@@ -577,7 +577,7 @@ static int max17042_init_model(struct max17042_chip *chip)
if (!temp_data) if (!temp_data)
return -ENOMEM; return -ENOMEM;
max10742_unlock_model(chip); max17042_unlock_model(chip);
max17042_write_model_data(chip, MAX17042_MODELChrTbl, max17042_write_model_data(chip, MAX17042_MODELChrTbl,
table_size); table_size);
max17042_read_model_data(chip, MAX17042_MODELChrTbl, temp_data, max17042_read_model_data(chip, MAX17042_MODELChrTbl, temp_data,
...@@ -589,7 +589,7 @@ static int max17042_init_model(struct max17042_chip *chip) ...@@ -589,7 +589,7 @@ static int max17042_init_model(struct max17042_chip *chip)
temp_data, temp_data,
table_size); table_size);
max10742_lock_model(chip); max17042_lock_model(chip);
kfree(temp_data); kfree(temp_data);
return ret; return ret;
......
...@@ -366,3 +366,4 @@ module_platform_driver(max77650_charger_driver); ...@@ -366,3 +366,4 @@ module_platform_driver(max77650_charger_driver);
MODULE_DESCRIPTION("MAXIM 77650/77651 charger driver"); MODULE_DESCRIPTION("MAXIM 77650/77651 charger driver");
MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@baylibre.com>"); MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@baylibre.com>");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:max77650-charger");
...@@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent, ...@@ -1051,14 +1051,14 @@ __power_supply_register(struct device *parent,
} }
spin_lock_init(&psy->changed_lock); spin_lock_init(&psy->changed_lock);
rc = device_init_wakeup(dev, ws);
if (rc)
goto wakeup_init_failed;
rc = device_add(dev); rc = device_add(dev);
if (rc) if (rc)
goto device_add_failed; goto device_add_failed;
rc = device_init_wakeup(dev, ws);
if (rc)
goto wakeup_init_failed;
rc = psy_register_thermal(psy); rc = psy_register_thermal(psy);
if (rc) if (rc)
goto register_thermal_failed; goto register_thermal_failed;
...@@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent, ...@@ -1101,8 +1101,8 @@ __power_supply_register(struct device *parent,
psy_unregister_thermal(psy); psy_unregister_thermal(psy);
register_thermal_failed: register_thermal_failed:
device_del(dev); device_del(dev);
device_add_failed:
wakeup_init_failed: wakeup_init_failed:
device_add_failed:
check_supplies_failed: check_supplies_failed:
dev_set_name_failed: dev_set_name_failed:
put_device(dev); put_device(dev);
......
...@@ -284,6 +284,7 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy) ...@@ -284,6 +284,7 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
struct device *dev = &psy->dev; struct device *dev = &psy->dev;
struct device *hwmon; struct device *hwmon;
int ret, i; int ret, i;
const char *name;
if (!devres_open_group(dev, power_supply_add_hwmon_sysfs, if (!devres_open_group(dev, power_supply_add_hwmon_sysfs,
GFP_KERNEL)) GFP_KERNEL))
...@@ -334,7 +335,19 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy) ...@@ -334,7 +335,19 @@ int power_supply_add_hwmon_sysfs(struct power_supply *psy)
} }
} }
hwmon = devm_hwmon_device_register_with_info(dev, psy->desc->name, name = psy->desc->name;
if (strchr(name, '-')) {
char *new_name;
new_name = devm_kstrdup(dev, name, GFP_KERNEL);
if (!new_name) {
ret = -ENOMEM;
goto error;
}
strreplace(new_name, '-', '_');
name = new_name;
}
hwmon = devm_hwmon_device_register_with_info(dev, name,
psyhw, psyhw,
&power_supply_hwmon_chip_info, &power_supply_hwmon_chip_info,
NULL); NULL);
......
...@@ -314,17 +314,22 @@ static int sbs_get_battery_presence_and_health( ...@@ -314,17 +314,22 @@ static int sbs_get_battery_presence_and_health(
{ {
int ret; int ret;
if (psp == POWER_SUPPLY_PROP_PRESENT) { /* Dummy command; if it succeeds, battery is present. */
/* Dummy command; if it succeeds, battery is present. */ ret = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
ret = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
if (ret < 0) if (ret < 0) { /* battery not present*/
val->intval = 0; /* battery disconnected */ if (psp == POWER_SUPPLY_PROP_PRESENT) {
else val->intval = 0;
val->intval = 1; /* battery present */ return 0;
} else { /* POWER_SUPPLY_PROP_HEALTH */ }
return ret;
}
if (psp == POWER_SUPPLY_PROP_PRESENT)
val->intval = 1; /* battery present */
else /* POWER_SUPPLY_PROP_HEALTH */
/* SBS spec doesn't have a general health command. */ /* SBS spec doesn't have a general health command. */
val->intval = POWER_SUPPLY_HEALTH_UNKNOWN; val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
}
return 0; return 0;
} }
...@@ -620,12 +625,14 @@ static int sbs_get_property(struct power_supply *psy, ...@@ -620,12 +625,14 @@ static int sbs_get_property(struct power_supply *psy,
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_PRESENT: case POWER_SUPPLY_PROP_PRESENT:
case POWER_SUPPLY_PROP_HEALTH: case POWER_SUPPLY_PROP_HEALTH:
if (client->flags & SBS_FLAGS_TI_BQ20Z75) if (chip->flags & SBS_FLAGS_TI_BQ20Z75)
ret = sbs_get_ti_battery_presence_and_health(client, ret = sbs_get_ti_battery_presence_and_health(client,
psp, val); psp, val);
else else
ret = sbs_get_battery_presence_and_health(client, psp, ret = sbs_get_battery_presence_and_health(client, psp,
val); val);
/* this can only be true if no gpio is used */
if (psp == POWER_SUPPLY_PROP_PRESENT) if (psp == POWER_SUPPLY_PROP_PRESENT)
return 0; return 0;
break; break;
......
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