[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABTCjFB9ybKmNh-xuF0qaWQc_j4zNXW36vimdrEPh2hzP1VsBw@mail.gmail.com>
Date: Sat, 30 Nov 2024 14:38:21 +0300
From: Dzmitry Sankouski <dsankouski@...il.com>
To: Amit Singh Tomar <amitsinght@...vell.com>
Cc: Hans de Goede <hdegoede@...hat.com>, Krzysztof Kozlowski <krzk@...nel.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Sebastian Krzyszkowiak <sebastian.krzyszkowiak@...i.sm>, Purism Kernel Team <kernel@...i.sm>,
Sebastian Reichel <sre@...nel.org>, Rob Herring <robh@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
Alim Akhtar <alim.akhtar@...sung.com>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>, linux-pm@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-samsung-soc@...r.kernel.org,
imx@...ts.linux.dev, linux-arm-msm@...r.kernel.org
Subject: Re: [PATCH v4 2/2] power: supply: max17042: add platform driver variant
пт, 29 нояб. 2024 г. в 17:03, Amit Singh Tomar <amitsinght@...vell.com>:
>
> Hi,
>
> >
> > The solution here add and option to use max17042 driver as a MFD
> > sub device, thus allowing any additional functionality be implemented as
> > another sub device. This will help to reduce code duplication in MFD
> > fuel gauge drivers.
> >
> > Signed-off-by: Dzmitry Sankouski <dsankouski@...il.com>
> > ---
> > Changes in v4:
> > - rename module_init and module_exit fuctions
> > - rework max17042_init
> > - assign chip_type in probe function
> > - pass i2c_client as pointer on pointer, to use same pointer created in
> > MFD. This allows devm_regmap_init_i2c to cleanup gracefully.
> >
> > Changes in v3:
> > - pass dev pointer in max17042_probe
> > - remove prints
> > ---
> > drivers/power/supply/max17042_battery.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
> > 1 file changed, 92 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
(...)
> > +static int max17042_platform_probe(struct platform_device *pdev)
> > +{
> > + struct device *dev = &pdev->dev;
> > + struct i2c_client **i2c = dev_get_platdata(dev);
> This seems a bit unusual; can't we just use:
> struct i2c_client *i2c = dev_get_platdata(&pdev->dev); instead?
> > + const struct platform_device_id *id = platform_get_device_id(pdev);
> > +
> > + if (!i2c)
> > + return -EINVAL;
> > +
> > + return max17042_probe(*i2c, dev, id->driver_data);
> and then just pass "i2c" here ?
This leads to hang on freeing devm resources, when unloading modules.
Platform driver version intended to be used as MFD sub device, where mfd
creates a dummy i2c client, and passes it to max17042 via platform data.
Sequence is: insmod MFD; insmod max17042; rmmod max17042; rmmod MFD; hang here.
My guess is that it is caused by a new pointer to the i2c-client. New pointer
created at `platform_device_add_data` function call in `mfd_add_device`.
Since C is pass by value, new pointer is assigned to platform device data.
--
Best regards,
Dzmitry
Powered by blists - more mailing lists