From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Peng Fan <peng.fan@nxp.com>
Cc: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Cristian Marussi <cristian.marussi@arm.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Subject: Re: [PATCH v7 3/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support
Date: Tue, 2 Apr 2024 17:05:19 +0300 [thread overview]
Message-ID: <ZgwQn7DzrBh-aUVX@smile.fi.intel.com> (raw)
In-Reply-To: <DU0PR04MB941780B4C28DB353C64966F8883E2@DU0PR04MB9417.eurprd04.prod.outlook.com>
On Tue, Apr 02, 2024 at 01:27:19PM +0000, Peng Fan wrote:
> > On Tue, Apr 02, 2024 at 10:22:23AM +0800, Peng Fan (OSS) wrote:
...
> > > +#include <linux/module.h>
> > > +#include <linux/scmi_protocol.h>
> > > +#include <linux/slab.h>
> >
> > Please, follow IWYU principle, a lot of headers are missed.
>
> ok. I will try to figure out. BTW, is there an easy way to filter
> out what is missed?
For you is much easier than to me as I'm not familiar with the code.
Basically you should know what you wrote :-)
But if you are asking about tooling, we would appreciate when somebody comes
with a such.
> > > +#include "common.h"
> > > +#include "protocols.h"
...
> > > + ret = scmi_pinctrl_get_pin_info(ph, selector,
> > > + &pi->pins[selector]);
> >
> > It's netter as a single line.
>
> I try to follow 80 max chars per SCMI coding style. If Sudeep and Cristian
> is ok, I could use a single line.
It's minor, but even before relaxation of 80 limit it was and is mentioned
in the documentation that you may go over if it increases readability.
> > > + if (ret)
> > > + return ret;
> > > + }
...
> > > +static int scmi_pinctrl_protocol_init(const struct
> > > +scmi_protocol_handle *ph) {
> > > + int ret;
> > > + u32 version;
> > > + struct scmi_pinctrl_info *pinfo;
> > > +
> > > + ret = ph->xops->version_get(ph, &version);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + dev_dbg(ph->dev, "Pinctrl Version %d.%d\n",
> > > + PROTOCOL_REV_MAJOR(version),
> > PROTOCOL_REV_MINOR(version));
> > > +
> > > + pinfo = devm_kzalloc(ph->dev, sizeof(*pinfo), GFP_KERNEL);
> > > + if (!pinfo)
> > > + return -ENOMEM;
> > > +
> > > + ret = scmi_pinctrl_attributes_get(ph, pinfo);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + pinfo->pins = devm_kcalloc(ph->dev, pinfo->nr_pins,
> > > + sizeof(*pinfo->pins), GFP_KERNEL);
> > > + if (!pinfo->pins)
> > > + return -ENOMEM;
> > > +
> > > + pinfo->groups = devm_kcalloc(ph->dev, pinfo->nr_groups,
> > > + sizeof(*pinfo->groups), GFP_KERNEL);
> > > + if (!pinfo->groups)
> > > + return -ENOMEM;
> > > +
> > > + pinfo->functions = devm_kcalloc(ph->dev, pinfo->nr_functions,
> > > + sizeof(*pinfo->functions),
> > GFP_KERNEL);
> > > + if (!pinfo->functions)
> > > + return -ENOMEM;
> > > +
> > > + pinfo->version = version;
> > > +
> > > + return ph->set_priv(ph, pinfo, version);
> >
> > Same comments as per previous version. devm_ here is simply wrong.
> > It breaks the order of freeing resources.
> >
> > I.o.w. I see *no guarantee* that these init-deinit functions will be properly
> > called from the respective probe-remove. Moreover the latter one may also
> > have its own devm allocations (which are rightfully placed) and you get
> > completely out of control the resource management.
>
> I see an old thread.
> https://lore.kernel.org/linux-arm-kernel/ZJ78hBcjAhiU+ZBO@e120937-lin/#t
>
> The free in deinit is not to free the ones alloced in init, it is to free the ones
> alloced such as in scmi_pinctrl_get_function_info
Even messier than I thought. For bare minimum these two should be documented
and renamed accordingly that no-one will think that deinit is a counter part
of init.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-04-02 14:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 2:22 [PATCH v7 0/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Peng Fan (OSS)
2024-04-02 2:22 ` [PATCH v7 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Peng Fan (OSS)
2024-04-02 2:22 ` [PATCH v7 2/4] dt-bindings: firmware: arm,scmi: support pinctrl protocol Peng Fan (OSS)
2024-04-02 2:22 ` [PATCH v7 3/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Peng Fan (OSS)
2024-04-02 10:29 ` Cristian Marussi
2024-04-02 14:04 ` Peng Fan
2024-04-02 13:14 ` Andy Shevchenko
2024-04-02 13:27 ` Peng Fan
2024-04-02 14:05 ` Andy Shevchenko [this message]
2024-04-02 2:22 ` [PATCH v7 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Peng Fan (OSS)
2024-04-02 13:22 ` Andy Shevchenko
2024-04-02 13:59 ` Peng Fan
2024-04-02 14:09 ` Andy Shevchenko
2024-04-02 14:09 ` Dan Carpenter
2024-04-02 16:40 ` Cristian Marussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZgwQn7DzrBh-aUVX@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=conor+dt@kernel.org \
--cc=cristian.marussi@arm.com \
--cc=dan.carpenter@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleksii_moisieiev@epam.com \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=robh@kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox