From: Dan Carpenter <dan.carpenter@oracle.com>
To: cristian.marussi@arm.com
Cc: linux-pm@vger.kernel.org
Subject: [bug report] powercap: arm_scmi: Add SCMI powercap based driver
Date: Wed, 6 Jul 2022 17:09:13 +0300 [thread overview]
Message-ID: <YsWXievahG19PODw@kili> (raw)
Hello Cristian Marussi,
The patch 31afdd34f2b9: "powercap: arm_scmi: Add SCMI powercap based
driver" from Jul 4, 2022, leads to the following Smatch static
checker warning:
drivers/powercap/arm_scmi_powercap.c:214 scmi_powercap_get_max_power_uw()
warn: cast after binop
drivers/powercap/arm_scmi_powercap.c
203 static int scmi_powercap_get_max_power_uw(struct powercap_zone *pz, int cid,
204 u64 *max_power_uw)
205 {
206 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz);
207
208 if (!spz->info)
209 return -ENODEV;
210
211 if (spz->info->powercap_scale_uw)
212 *max_power_uw = (u64)spz->info->max_power_cap;
213 else
214 *max_power_uw = (u64)(spz->info->max_power_cap * 1000);
What's the deal with this cast? It would make more sense to do the cast
before the * 1000 so that it doesn't overflow the 32 bits. Is the cast
even required though? The cast on the line before is decorative so
maybe it's not required.
215
216 return 0;
217 }
218
219 static int scmi_powercap_get_min_power_uw(struct powercap_zone *pz, int cid,
220 u64 *min_power_uw)
221 {
222 struct scmi_powercap_zone *spz = to_scmi_powercap_zone(pz);
223
224 if (!spz->info)
225 return -ENODEV;
226
227 if (spz->info->powercap_scale_uw)
228 *min_power_uw = (u64)spz->info->min_power_cap;
229 else
230 *min_power_uw = (u64)(spz->info->min_power_cap * 1000);
Same cast here.
231
232 return 0;
233 }
regards,
dan carpenter
next reply other threads:[~2022-07-06 14:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 14:09 Dan Carpenter [this message]
2022-07-06 14:49 ` [bug report] powercap: arm_scmi: Add SCMI powercap based driver 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=YsWXievahG19PODw@kili \
--to=dan.carpenter@oracle.com \
--cc=cristian.marussi@arm.com \
--cc=linux-pm@vger.kernel.org \
/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