On Mon, 10 Jan 2022 11:46:39 +0000 Caleb Connolly <caleb.connolly@xxxxxxxxxx> wrote: > On 09/01/2022 16:57, Jonathan Cameron wrote: > > On Thu, 6 Jan 2022 17:31:25 +0000 > > Caleb Connolly <caleb.connolly@xxxxxxxxxx> 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@xxxxxxxxxx> > > 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.