All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alex Tran" <alex.tran@oss.qualcomm.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 5/5] pinctrl: pinctrl-scmi: Log number of pins, groups, functions
Date: Thu, 14 May 2026 10:22:55 +0000	[thread overview]
Message-ID: <20260514102255.86C36C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260513-scmi-client-probe-log-v2-5-36607e9dd540@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Low] Unnecessary structure bloat by adding `nr_groups` to persistent driver state.
- [Low] Missing error handling for firmware query result before assignment to an unsigned integer.
- [Low] Format specifier type mismatch in `dev_dbg`.
--

commit 1afe1feb7c661d03b99df0a5046eac6639ef2fe6
Author: Alex Tran <alex.tran@oss.qualcomm.com>

pinctrl: pinctrl-scmi: Log number of pins, groups, functions

The SCMI pinctrl driver does not currently log the number of pins, groups,
and functions discovered from firmware. This commit adds a debug log statement
to print these counts after a successful probe.

> diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
> index f22be6b7b82a4..999c2061ddc38 100644
> --- a/drivers/pinctrl/pinctrl-scmi.c
> +++ b/drivers/pinctrl/pinctrl-scmi.c
> @@ -40,6 +40,7 @@ struct scmi_pinctrl {
>  	struct pinctrl_desc pctl_desc;
>  	struct pinfunction *functions;
>  	unsigned int nr_functions;
> +	unsigned int nr_groups;

Is it necessary to add nr_groups to struct scmi_pinctrl?

Unlike nr_functions which is used later, nr_groups is only written and read
sequentially within scmi_pinctrl_probe() to populate the dev_dbg message.
Could this simply be a local variable in the probe function to avoid bloating
the persistent device data structure?

>  };
>  
>  static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev)

[ ... ]

> @@ -578,7 +579,15 @@ static int scmi_pinctrl_probe(struct scmi_device *sdev)
>  	if (!pmx->functions)
>  		return -ENOMEM;
>  
> -	return pinctrl_enable(pmx->pctldev);
> +	pmx->nr_groups = pinctrl_scmi_get_groups_count(pmx->pctldev);

What happens if pinctrl_scmi_get_groups_count() returns a negative error code
due to an SCMI firmware query failure?

Since nr_groups is an unsigned int, assigning a negative error code will
result in a silent integer underflow. While this isn't used for memory
allocation or bounds checking, it will result in incorrect values being
logged.

> +
> +	ret = pinctrl_enable(pmx->pctldev);
> +	if (ret)
> +		return ret;
> +
> +	dev_dbg(dev, "Initialized %d pins, %d groups, %d functions\n",
> +		 pmx->pctl_desc.npins, pmx->nr_groups, pmx->nr_functions);

Should we use %u instead of %d for these format specifiers?

pmx->pctl_desc.npins, nr_groups, and nr_functions are all unsigned integers.
Using %d causes any underflowed error codes to print deceptively as negative
numbers in the logs rather than revealing the implicit cast.

> +	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513-scmi-client-probe-log-v2-0-36607e9dd540@oss.qualcomm.com?part=5

  parent reply	other threads:[~2026-05-14 10:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 17:16 [PATCH v2 0/5] scmi: Log client subsystem entity counts Alex Tran
2026-05-13 17:16 ` [PATCH v2 1/5] powercap: arm_scmi_powercap: Log number of powercap domains Alex Tran
2026-05-14  8:00   ` sashiko-bot
2026-05-13 17:16 ` [PATCH v2 2/5] cpufreq: scmi-cpufreq: Log number of perf domains Alex Tran
2026-05-14  8:42   ` sashiko-bot
2026-05-13 17:16 ` [PATCH v2 3/5] hwmon: scmi-hwmon: Log number of sensors Alex Tran
2026-05-14  9:29   ` sashiko-bot
2026-05-13 17:16 ` [PATCH v2 4/5] reset: reset-scmi: Log number of reset domains Alex Tran
2026-05-14  9:43   ` sashiko-bot
2026-05-13 17:16 ` [PATCH v2 5/5] pinctrl: pinctrl-scmi: Log number of pins, groups, functions Alex Tran
2026-05-13 18:06   ` Andy Shevchenko
2026-05-14 10:22   ` sashiko-bot [this message]
2026-05-13 18:04 ` [PATCH v2 0/5] scmi: Log client subsystem entity counts Andy Shevchenko
2026-05-14 15:44 ` Jonathan Cameron
2026-05-14 18:42   ` Sudeep Holla
2026-05-14 21:23   ` Alex Tran
2026-05-15  8:29     ` Sudeep Holla

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=20260514102255.86C36C2BCB3@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alex.tran@oss.qualcomm.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.