pwm: qti-lpg: Fix erroneous clearing of LUT
The memory allocated for the lookup table (LUT) is getting cleared even
when a valid nvmem and PBS configuration is detected. Fix this by
ensuring that this happens only when neither a LUT peripheral's address
nor a valid nvmem configuration is detected.
Fixes: 218908e848
("pwm: pwm-qti-lpg: Refactor qpnp_lpg_parse_dt() for
readability").
Change-Id: I59467d46779e0a01bf0843863680ec2a8f85f2ce
Signed-off-by: Guru Das Srinagesh <gurus@codeaurora.org>
This commit is contained in:
parent
875a76755f
commit
9f5b5d0105
@ -1477,11 +1477,12 @@ static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip)
|
||||
}
|
||||
}
|
||||
|
||||
chip->lut = devm_kmalloc(chip->dev, sizeof(*chip->lut), GFP_KERNEL);
|
||||
if (!chip->lut)
|
||||
return -ENOMEM;
|
||||
|
||||
if (of_find_property(chip->dev->of_node, "nvmem", NULL)) {
|
||||
chip->lut = devm_kmalloc(chip->dev, sizeof(*chip->lut),
|
||||
GFP_KERNEL);
|
||||
if (!chip->lut)
|
||||
return -ENOMEM;
|
||||
|
||||
chip->sdam_nvmem = devm_nvmem_device_get(chip->dev, "ppg_sdam");
|
||||
if (IS_ERR_OR_NULL(chip->sdam_nvmem)) {
|
||||
rc = PTR_ERR(chip->sdam_nvmem);
|
||||
@ -1514,13 +1515,19 @@ static int qpnp_lpg_parse_dt(struct qpnp_lpg_chip *chip)
|
||||
return rc;
|
||||
}
|
||||
} else if (lut_is_defined(chip, &addr)) {
|
||||
chip->lut->reg_base = be32_to_cpu(*addr);
|
||||
return qpnp_lpg_parse_pattern_dt(chip, LPG_LUT_COUNT_MAX);
|
||||
}
|
||||
chip->lut = devm_kmalloc(chip->dev, sizeof(*chip->lut),
|
||||
GFP_KERNEL);
|
||||
if (!chip->lut)
|
||||
return -ENOMEM;
|
||||
|
||||
pr_debug("Neither SDAM nor LUT specified\n");
|
||||
devm_kfree(chip->dev, chip->lut);
|
||||
chip->lut = NULL;
|
||||
chip->lut->reg_base = be32_to_cpu(*addr);
|
||||
|
||||
rc = qpnp_lpg_parse_pattern_dt(chip, LPG_LUT_COUNT_MAX);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
} else {
|
||||
pr_debug("Neither SDAM nor LUT specified\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user