From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: 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-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
Oleksii Moisieiev <oleksii_moisieiev@epam.com>
Subject: Re: [PATCH v6 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver
Date: Fri, 29 Mar 2024 21:10:25 +0200 [thread overview]
Message-ID: <ZgcSIb4BVcbVmPyW@surfacebook.localdomain> (raw)
In-Reply-To: <20240323-pinctrl-scmi-v6-4-a895243257c0@nxp.com>
Sat, Mar 23, 2024 at 08:15:17PM +0800, Peng Fan (OSS) kirjoitti:
> From: Peng Fan <peng.fan@nxp.com>
>
> scmi-pinctrl driver implements pinctrl driver interface and using
> SCMI protocol to redirect messages from pinctrl subsystem SDK to
> SCMI platform firmware, which does the changes in HW.
...
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/seq_file.h>
> +#include <linux/scmi_protocol.h>
> +#include <linux/slab.h>
Use IWYU principle. There are missing header inclusions and/or forward
declarations.
...
> +struct scmi_pinctrl_funcs {
> + unsigned int num_groups;
> + const char **groups;
> +};
This is repeating struct pinfunction. Why can't the latter be used?
...
> +err_free:
> + devm_kfree(pmx->dev, groups);
Why?!
This is 99.9% that the initial allocation must not be devm.
...
> + *p_config_value = kcalloc(num_configs, sizeof(u32), GFP_KERNEL);
sizeof(**p_config_value)?
> + *p_config_type = kcalloc(num_configs,
> + sizeof(enum scmi_pinctrl_conf_type),
sizeof(**p_config_type)?
> + GFP_KERNEL);
> +
> + if (!*p_config_value || !*p_config_type) {
> + kfree(*p_config_value);
> + kfree(*p_config_type);
> + return -ENOMEM;
Why to allocate / free memory in the case when you know that the first one
failed?
> + }
...
> +static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx,
> + struct pinctrl_desc *desc)
> +{
> + struct pinctrl_pin_desc *pins;
> + unsigned int npins;
> + int ret, i;
> +
> + npins = pinctrl_ops->count_get(pmx->ph, PIN_TYPE);
> + pins = devm_kmalloc_array(pmx->dev, npins, sizeof(*pins), GFP_KERNEL);
> + if (!pins)
> + return -ENOMEM;
> +
> + for (i = 0; i < npins; i++) {
> + pins[i].number = i;
> + ret = pinctrl_ops->name_get(pmx->ph, i, PIN_TYPE, &pins[i].name);
> + if (ret)
> + return dev_err_probe(pmx->dev, ret,
> + "Can't get name for pin %d", i);
> + }
> +
> + desc->npins = npins;
> + desc->pins = pins;
> + dev_dbg(pmx->dev, "got pins %d", npins);
%u
> + return 0;
> +}
...
> + pinctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_PINCTRL,
> + &ph);
One line.
> + if (IS_ERR(pinctrl_ops))
> + return PTR_ERR(pinctrl_ops);
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-03-29 19:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-23 12:15 [PATCH v6 0/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Peng Fan (OSS)
2024-03-23 12:15 ` [PATCH v6 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Peng Fan (OSS)
2024-03-23 12:15 ` [PATCH v6 2/4] dt-bindings: firmware: arm,scmi: support pinctrl protocol Peng Fan (OSS)
2024-03-23 12:15 ` [PATCH v6 3/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support Peng Fan (OSS)
2024-03-27 10:46 ` Dan Carpenter
2024-03-27 12:20 ` Cristian Marussi
2024-03-31 12:47 ` Peng Fan
2024-03-28 15:47 ` Cristian Marussi
2024-03-31 13:28 ` Peng Fan
2024-03-29 19:00 ` Andy Shevchenko
2024-03-31 13:44 ` Peng Fan
2024-04-02 7:48 ` Cristian Marussi
2024-04-02 13:06 ` Andy Shevchenko
2024-04-02 14:01 ` Peng Fan
2024-04-02 14:35 ` Peng Fan
2024-04-02 15:58 ` Cristian Marussi
2024-04-02 16:39 ` Andy Shevchenko
2024-04-03 8:06 ` Cristian Marussi
2024-04-03 8:44 ` Andy Shevchenko
2024-03-23 12:15 ` [PATCH v6 4/4] pinctrl: Implementation of the generic scmi-pinctrl driver Peng Fan (OSS)
2024-03-27 11:20 ` Dan Carpenter
2024-03-28 16:46 ` Cristian Marussi
2024-03-29 19:10 ` Andy Shevchenko [this message]
2024-03-28 16:48 ` [PATCH v6 0/4] firmware: arm_scmi: Add SCMI v3.2 pincontrol protocol basic support 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=ZgcSIb4BVcbVmPyW@surfacebook.localdomain \
--to=andy.shevchenko@gmail.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;
as well as URLs for NNTP newsgroup(s).