lkml.org 
[lkml]   [2022]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v3 1/7] mfd: qcom-spmi-pmic: expose the PMIC revid information to clients
On Mon, 10 Jan 2022 11:46:39 +0000
Caleb Connolly <caleb.connolly@linaro.org> wrote:

> On 09/01/2022 16:57, Jonathan Cameron wrote:
> > On Thu, 6 Jan 2022 17:31:25 +0000
> > Caleb Connolly <caleb.connolly@linaro.org> wrote:
> >
> >> Some PMIC functions such as the RRADC need to be aware of the PMIC
> >> chip revision information to implement errata or otherwise adjust
> >> behaviour, export the PMIC information to enable this.
> >>
> >> This is specifically required to enable the RRADC to adjust
> >> coefficients based on which chip fab the PMIC was produced in,
> >> this can vary per unique device and therefore has to be read at
> >> runtime.
> >>
> >> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> > Hi Caleb,
> >
> > Some comments inline.
> Hi Jonathan,
>
> Thanks for the feedback, I had a question about one of your points below.

Miss read on my part.


> >>
> >> static const struct regmap_config spmi_regmap_config = {
> >> @@ -144,22 +122,38 @@ static const struct regmap_config spmi_regmap_config = {
> >> static int pmic_spmi_probe(struct spmi_device *sdev)
> >> {
> >> struct regmap *regmap;
> >> + struct qcom_spmi_pmic *pmic;
> >>
> >> regmap = devm_regmap_init_spmi_ext(sdev, &spmi_regmap_config);
> >> if (IS_ERR(regmap))
> >> return PTR_ERR(regmap);
> >>
> >> + pmic = devm_kzalloc(&sdev->dev, sizeof(*pmic), GFP_KERNEL);
> >> + if (!pmic)
> >> + return -ENOMEM;
> >
> > Within the code visible here, why can't this just be on the stack?
> I allocated on the heap beacuse the data has to be read by other drivers
> (it's handed over in spmi_device_set_drvdata() below). I don't have a
> whole lot of C experience so please forgive the potentially ignorant
> questions - is it ok to allocate on the stack if the object needs to
> have a lifetime longer than the function?

You are of course correct. I just missed the set_drvdata call when reading this
and thought it was just being used for the print! Oops.

\
 
 \ /
  Last update: 2022-01-15 14:02    [W:0.156 / U:0.800 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site