drivers: regulator: move I2C reg reads to regulator_read_register
Move I2C register reads to regulator_read_register in regulator driver, to enable better abstraction of regulator I2C reads Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
This commit is contained in:
parent
f367897bce
commit
30d71d5457
1 changed files with 13 additions and 3 deletions
|
@ -58,6 +58,16 @@ struct regulator_config {
|
||||||
uint32_t *current_array;
|
uint32_t *current_array;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a register from the PMIC
|
||||||
|
* Returns 0 on success, or errno on error
|
||||||
|
*/
|
||||||
|
static int regulator_read_register(const struct regulator_config *conf,
|
||||||
|
uint8_t reg, uint8_t *out)
|
||||||
|
{
|
||||||
|
return i2c_reg_read_byte_dt(&conf->i2c, reg, out);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies a register within the PMIC
|
* Modifies a register within the PMIC
|
||||||
* Returns 0 on success, or errno on error
|
* Returns 0 on success, or errno on error
|
||||||
|
@ -68,7 +78,7 @@ static int regulator_modify_register(const struct regulator_config *conf,
|
||||||
uint8_t reg_current;
|
uint8_t reg_current;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = i2c_reg_read_byte_dt(&conf->i2c, reg, ®_current);
|
rc = regulator_read_register(conf, reg, ®_current);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +172,7 @@ int regulator_get_voltage(const struct device *dev)
|
||||||
int rc, i = 0;
|
int rc, i = 0;
|
||||||
uint8_t raw_reg;
|
uint8_t raw_reg;
|
||||||
|
|
||||||
rc = i2c_reg_read_byte_dt(&config->i2c, config->vsel_reg, &raw_reg);
|
rc = regulator_read_register(config, config->vsel_reg, &raw_reg);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +231,7 @@ int regulator_get_current_limit(const struct device *dev)
|
||||||
if (config->num_current_levels == 0) {
|
if (config->num_current_levels == 0) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
rc = i2c_reg_read_byte_dt(&config->i2c, config->ilim_reg, &raw_reg);
|
rc = regulator_read_register(config, config->ilim_reg, &raw_reg);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue