mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
power: supply: bq25630: Initialize hardware before exposing the power supply
bq25630_setup() resets the device, disables the watchdog and programs the charge limits from the battery information. It runs at the end of bq25630_probe(), that is after the power supply has been registered, so the device is already exposed to the system while the hardware still holds its power-on defaults. power_supply_desc::init runs during registration, after the driver data and the fwnode are available and before the device is added. Use it for bq25630_setup() and drop the explicit call from bq25630_probe(). The callback is passed the power supply, so take the driver data from it and use it for the battery information as well: data->psy is only assigned once devm_power_supply_register() returns, which is after the callback has run. Signed-off-by: Linmao Li <lilinmao@kylinos.cn> Reviewed-by: Waqar Hameed <waqar.hameed@axis.com> Link: https://patch.msgid.link/20260730011713.3332913-3-lilinmao@kylinos.cn Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
9092828e18
commit
fdece8642e
|
|
@ -665,8 +665,9 @@ static int bq25630_reset(struct bq25630_data *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int bq25630_setup(struct bq25630_data *data)
|
||||
static int bq25630_setup(struct power_supply *psy)
|
||||
{
|
||||
struct bq25630_data *data = power_supply_get_drvdata(psy);
|
||||
struct power_supply_battery_info *batinfo;
|
||||
int ret;
|
||||
|
||||
|
|
@ -684,7 +685,7 @@ static int bq25630_setup(struct bq25630_data *data)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = power_supply_get_battery_info(data->psy, &batinfo);
|
||||
ret = power_supply_get_battery_info(psy, &batinfo);
|
||||
if (ret) {
|
||||
dev_err(data->dev, "Could not get battery info (%d)\n", ret);
|
||||
return ret;
|
||||
|
|
@ -753,7 +754,7 @@ static int bq25630_setup(struct bq25630_data *data)
|
|||
}
|
||||
|
||||
out_put_batinfo:
|
||||
power_supply_put_battery_info(data->psy, batinfo);
|
||||
power_supply_put_battery_info(psy, batinfo);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -976,6 +977,7 @@ static const struct power_supply_desc bq25630_charger_psy_desc = {
|
|||
.get_property = bq25630_charger_get_property,
|
||||
.set_property = bq25630_charger_set_property,
|
||||
.property_is_writeable = bq25630_charger_property_is_writeable,
|
||||
.init = bq25630_setup,
|
||||
};
|
||||
|
||||
static int bq25630_probe(struct i2c_client *client)
|
||||
|
|
@ -1048,10 +1050,6 @@ static int bq25630_probe(struct i2c_client *client)
|
|||
if (ret)
|
||||
return dev_err_probe(data->dev, ret, "Could not request IRQ\n");
|
||||
|
||||
ret = bq25630_setup(data);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user