Re: [PATCH] regulator: qcom_smd: Keep one rpm handle for all vregs

From: Dmitry Baryshkov
Date: Wed Jan 03 2024 - 13:31:58 EST


On Wed, 3 Jan 2024 at 12:03, Konrad Dybcio <konrad.dybcio@xxxxxxxxxx> wrote:
>
> On 27.12.2023 12:48, Dmitry Baryshkov wrote:
> > On 27/12/2023 03:29, Konrad Dybcio wrote:
> >> 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:
> >>
> >> Total: Before=43944, After=43924, chg -0.05%
> >>
> >> plus sizeof(ptr) on every dynamically allocated regulator :)
> >>
> >> Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxx>
> >> ---
>
> [...]
>
> >> @@ -1440,11 +1438,10 @@ static int rpm_reg_probe(struct platform_device *pdev)
> >> const struct rpm_regulator_data *vreg_data;
> >> struct device_node *node;
> >> struct qcom_rpm_reg *vreg;
> >> - struct qcom_smd_rpm *rpm;
> >> int ret;
> >> - rpm = dev_get_drvdata(pdev->dev.parent);
> >> - if (!rpm) {
> >> + smd_vreg_rpm = dev_get_drvdata(pdev->dev.parent);
> >> + if (!smd_vreg_rpm) {
> >
> > I thought about having a mutex around (I don't remember if secondary PMICs and/or chargers can be routed through RPM or not).
>
> A mutex for assigning this?

Yep.

>
> Konrad
> >
> > Then I went on checking other RPM and SMD-RPM drivers.
> >
> > clk-rpm: global variable, field
> > clk-smd-rpm: struct field
> > regulator_qcom-smd-rpm: struct field
> >
> > Probably it's worth using the same approach in all four drivers?
>
>


--
With best wishes
Dmitry