Skip to content

Commit 5df3b41

Browse files
konradybciobroonie
authored andcommitted
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 <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 6613476 commit 5df3b41

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

drivers/regulator/qcom_smd-regulator.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
#include <linux/regulator/of_regulator.h>
1212
#include <linux/soc/qcom/smd-rpm.h>
1313

14+
struct qcom_smd_rpm *smd_vreg_rpm;
15+
1416
struct qcom_rpm_reg {
1517
struct device *dev;
16-
17-
struct qcom_smd_rpm *rpm;
18-
1918
u32 type;
2019
u32 id;
2120

@@ -70,7 +69,7 @@ static int rpm_reg_write_active(struct qcom_rpm_reg *vreg)
7069
if (!reqlen)
7170
return 0;
7271

73-
ret = qcom_rpm_smd_write(vreg->rpm, QCOM_SMD_RPM_ACTIVE_STATE,
72+
ret = qcom_rpm_smd_write(smd_vreg_rpm, QCOM_SMD_RPM_ACTIVE_STATE,
7473
vreg->type, vreg->id,
7574
req, sizeof(req[0]) * reqlen);
7675
if (!ret) {
@@ -1384,14 +1383,13 @@ MODULE_DEVICE_TABLE(of, rpm_of_match);
13841383
* @dev: Pointer to the top level qcom_smd-regulator PMIC device
13851384
* @node: Pointer to the individual qcom_smd-regulator resource
13861385
* device node
1387-
* @rpm: Pointer to the rpm bus node
13881386
* @pmic_rpm_data: Pointer to a null-terminated array of qcom_smd-regulator
13891387
* resources defined for the top level PMIC device
13901388
*
13911389
* Return: 0 on success, errno on failure
13921390
*/
13931391
static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev,
1394-
struct device_node *node, struct qcom_smd_rpm *rpm,
1392+
struct device_node *node,
13951393
const struct rpm_regulator_data *pmic_rpm_data)
13961394
{
13971395
struct regulator_config config = {};
@@ -1409,7 +1407,6 @@ static int rpm_regulator_init_vreg(struct qcom_rpm_reg *vreg, struct device *dev
14091407
}
14101408

14111409
vreg->dev = dev;
1412-
vreg->rpm = rpm;
14131410
vreg->type = rpm_data->type;
14141411
vreg->id = rpm_data->id;
14151412

@@ -1449,6 +1446,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
14491446
return -ENODEV;
14501447
}
14511448

1449+
if (smd_vreg_rpm && rpm != smd_vreg_rpm)
1450+
return dev_err_probe(dev, -EINVAL, "RPM mismatch\n");
1451+
1452+
smd_vreg_rpm = rpm;
1453+
14521454
vreg_data = of_device_get_match_data(dev);
14531455
if (!vreg_data)
14541456
return -ENODEV;
@@ -1460,8 +1462,7 @@ static int rpm_reg_probe(struct platform_device *pdev)
14601462
return -ENOMEM;
14611463
}
14621464

1463-
ret = rpm_regulator_init_vreg(vreg, dev, node, rpm, vreg_data);
1464-
1465+
ret = rpm_regulator_init_vreg(vreg, dev, node, vreg_data);
14651466
if (ret < 0) {
14661467
of_node_put(node);
14671468
return ret;

0 commit comments

Comments
 (0)