Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

regulator: qcom_smd: Keep one rpm handle for all vregs

For no apparent reason (as there's just one RPM per SoC), all vregs
currently store a copy of a pointer to smd_rpm. Introduce a single,
global one to save up on space in each definition.

bloat-o-meter reports a slight uptick:

Total: Before=44008, After=44080, chg +0.16%

However the saved n * sizeof(ptr) for every dynamically allocated
regulator quickly makes up for it.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://msgid.link/r/20240109-rpm_vreg_cleanup-v3-1-fa0201029f78@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Konrad Dybcio and committed by
Mark Brown
5df3b41b 6613476e

+10 -9
+10 -9
drivers/regulator/qcom_smd-regulator.c
··· 11 11 #include <linux/regulator/of_regulator.h> 12 12 #include <linux/soc/qcom/smd-rpm.h> 13 13 14 + struct qcom_smd_rpm *smd_vreg_rpm; 15 + 14 16 struct qcom_rpm_reg { 15 17 struct device *dev; 16 - 17 - struct qcom_smd_rpm *rpm; 18 - 19 18 u32 type; 20 19 u32 id; 21 20 ··· 69 70 if (!reqlen) 70 71 return 0; 71 72 72 - ret = qcom_rpm_smd_write(vreg->rpm, QCOM_SMD_RPM_ACTIVE_STATE, 73 + ret = qcom_rpm_smd_write(smd_vreg_rpm, QCOM_SMD_RPM_ACTIVE_STATE, 73 74 vreg->type, vreg->id, 74 75 req, sizeof(req[0]) * reqlen); 75 76 if (!ret) { ··· 1383 1384 * @dev: Pointer to the top level qcom_smd-regulator PMIC device 1384 1385 * @node: Pointer to the individual qcom_smd-regulator resource 1385 1386 * device node 1386 - * @rpm: Pointer to the rpm bus node 1387 1387 * @pmic_rpm_data: Pointer to a null-terminated array of qcom_smd-regulator 1388 1388 * resources defined for the top level PMIC device 1389 1389 * 1390 1390 * Return: 0 on success, errno on failure 1391 1391 */ 1392 1392 static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev, 1393 - struct device_node *node, struct qcom_smd_rpm *rpm, 1393 + struct device_node *node, 1394 1394 const struct rpm_regulator_data *pmic_rpm_data) 1395 1395 { 1396 1396 struct regulator_config config = {}; ··· 1407 1409 } 1408 1410 1409 1411 vreg->dev = dev; 1410 - vreg->rpm = rpm; 1411 1412 vreg->type = rpm_data->type; 1412 1413 vreg->id = rpm_data->id; 1413 1414 ··· 1446 1449 return -ENODEV; 1447 1450 } 1448 1451 1452 + if (smd_vreg_rpm && rpm != smd_vreg_rpm) 1453 + return dev_err_probe(dev, -EINVAL, "RPM mismatch\n"); 1454 + 1455 + smd_vreg_rpm = rpm; 1456 + 1449 1457 vreg_data = of_device_get_match_data(dev); 1450 1458 if (!vreg_data) 1451 1459 return -ENODEV; ··· 1462 1460 return -ENOMEM; 1463 1461 } 1464 1462 1465 - ret = rpm_regulator_init_vreg(vreg, dev, node, rpm, vreg_data); 1466 - 1463 + ret = rpm_regulator_init_vreg(vreg, dev, node, vreg_data); 1467 1464 if (ret < 0) { 1468 1465 of_node_put(node); 1469 1466 return ret;