Commit 6feba6a6 authored by Douglas Anderson's avatar Douglas Anderson Committed by Bjorn Andersson

PM: AVS: qcom-cpr: Use nvmem_cell_read_variable_le_u32()

Let's delete the private function cpr_read_efuse() since it does the
basically the same thing as the new API call
nvmem_cell_read_variable_le_u32().

Differences between the new API call and the old private function:
* less error printing (I assume this is OK).
* will give an error if the value doesn't fit in 32-bits (the old code
  would have truncated silently).
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: default avatarNiklas Cassel <nks@flawful.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20210521134437.v2.1.Id1c70158722750aec0673d60c12e46a9c66bbfed@changeidSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 18785c94
...@@ -801,38 +801,6 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain, ...@@ -801,38 +801,6 @@ static int cpr_set_performance_state(struct generic_pm_domain *domain,
return ret; return ret;
} }
static int cpr_read_efuse(struct device *dev, const char *cname, u32 *data)
{
struct nvmem_cell *cell;
ssize_t len;
char *ret;
int i;
*data = 0;
cell = nvmem_cell_get(dev, cname);
if (IS_ERR(cell)) {
if (PTR_ERR(cell) != -EPROBE_DEFER)
dev_err(dev, "undefined cell %s\n", cname);
return PTR_ERR(cell);
}
ret = nvmem_cell_read(cell, &len);
nvmem_cell_put(cell);
if (IS_ERR(ret)) {
dev_err(dev, "can't read cell %s\n", cname);
return PTR_ERR(ret);
}
for (i = 0; i < len; i++)
*data |= ret[i] << (8 * i);
kfree(ret);
dev_dbg(dev, "efuse read(%s) = %x, bytes %zd\n", cname, *data, len);
return 0;
}
static int static int
cpr_populate_ring_osc_idx(struct cpr_drv *drv) cpr_populate_ring_osc_idx(struct cpr_drv *drv)
{ {
...@@ -843,8 +811,7 @@ cpr_populate_ring_osc_idx(struct cpr_drv *drv) ...@@ -843,8 +811,7 @@ cpr_populate_ring_osc_idx(struct cpr_drv *drv)
int ret; int ret;
for (; fuse < end; fuse++, fuses++) { for (; fuse < end; fuse++, fuses++) {
ret = cpr_read_efuse(drv->dev, fuses->ring_osc, ret = nvmem_cell_read_variable_le_u32(drv->dev, fuses->ring_osc, &data);
&data);
if (ret) if (ret)
return ret; return ret;
fuse->ring_osc_idx = data; fuse->ring_osc_idx = data;
...@@ -863,7 +830,7 @@ static int cpr_read_fuse_uV(const struct cpr_desc *desc, ...@@ -863,7 +830,7 @@ static int cpr_read_fuse_uV(const struct cpr_desc *desc,
u32 bits = 0; u32 bits = 0;
int ret; int ret;
ret = cpr_read_efuse(drv->dev, init_v_efuse, &bits); ret = nvmem_cell_read_variable_le_u32(drv->dev, init_v_efuse, &bits);
if (ret) if (ret)
return ret; return ret;
...@@ -932,7 +899,7 @@ static int cpr_fuse_corner_init(struct cpr_drv *drv) ...@@ -932,7 +899,7 @@ static int cpr_fuse_corner_init(struct cpr_drv *drv)
} }
/* Populate target quotient by scaling */ /* Populate target quotient by scaling */
ret = cpr_read_efuse(drv->dev, fuses->quotient, &fuse->quot); ret = nvmem_cell_read_variable_le_u32(drv->dev, fuses->quotient, &fuse->quot);
if (ret) if (ret)
return ret; return ret;
...@@ -1001,7 +968,7 @@ static int cpr_calculate_scaling(const char *quot_offset, ...@@ -1001,7 +968,7 @@ static int cpr_calculate_scaling(const char *quot_offset,
prev_fuse = fuse - 1; prev_fuse = fuse - 1;
if (quot_offset) { if (quot_offset) {
ret = cpr_read_efuse(drv->dev, quot_offset, &quot_diff); ret = nvmem_cell_read_variable_le_u32(drv->dev, quot_offset, &quot_diff);
if (ret) if (ret)
return ret; return ret;
...@@ -1701,7 +1668,7 @@ static int cpr_probe(struct platform_device *pdev) ...@@ -1701,7 +1668,7 @@ static int cpr_probe(struct platform_device *pdev)
* initialized after attaching to the power domain, * initialized after attaching to the power domain,
* since it depends on the CPU's OPP table. * since it depends on the CPU's OPP table.
*/ */
ret = cpr_read_efuse(dev, "cpr_fuse_revision", &cpr_rev); ret = nvmem_cell_read_variable_le_u32(dev, "cpr_fuse_revision", &cpr_rev);
if (ret) if (ret)
return ret; return ret;
......
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