* [PATCH] soc: fsl: cpm1: qmc: Do not use IS_ERR_VALUE() on error pointers
@ 2024-09-30 15:08 Geert Uytterhoeven
2024-09-30 16:24 ` Herve Codina
0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2024-09-30 15:08 UTC (permalink / raw)
To: Herve Codina, Qiang Zhao, Christophe Leroy
Cc: linuxppc-dev, linux-arm-kernel, linux-kernel, Geert Uytterhoeven
ppc64_book3e_allmodconfig:
drivers/soc/fsl/qe/qmc.c: In function ‘qmc_qe_init_resources’:
include/linux/err.h:28:49: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
28 | #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
| ^
include/linux/compiler.h:77:45: note: in definition of macro ‘unlikely’
77 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
drivers/soc/fsl/qe/qmc.c:1764:13: note: in expansion of macro ‘IS_ERR_VALUE’
1764 | if (IS_ERR_VALUE(info)) {
| ^~~~~~~~~~~~
IS_ERR_VALUE() is only meant for pointers. Fix this by checking for a
negative error value instead, which matches the documented behavior of
devm_qe_muram_alloc() aka devm_cpm_muram_alloc().
While at it, remove the unneeded print in case of a memory allocation
failure, and propagate the returned error code.
Fixes: eb680d563089e55b ("soc: fsl: cpm1: qmc: Add support for QUICC Engine (QE) implementation")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
---
drivers/soc/fsl/qe/qmc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c
index 3dffebb48b0daced..659c579d751d7240 100644
--- a/drivers/soc/fsl/qe/qmc.c
+++ b/drivers/soc/fsl/qe/qmc.c
@@ -1761,10 +1761,9 @@ static int qmc_qe_init_resources(struct qmc *qmc, struct platform_device *pdev)
*/
info = devm_qe_muram_alloc(qmc->dev, UCC_SLOW_PRAM_SIZE + 2 * 64,
ALIGNMENT_OF_UCC_SLOW_PRAM);
- if (IS_ERR_VALUE(info)) {
- dev_err(qmc->dev, "cannot allocate MURAM for PRAM");
- return -ENOMEM;
- }
+ if (info < 0)
+ return info;
+
if (!qe_issue_cmd(QE_ASSIGN_PAGE_TO_DEVICE, qmc->qe_subblock,
QE_CR_PROTOCOL_UNSPECIFIED, info)) {
dev_err(qmc->dev, "QE_ASSIGN_PAGE_TO_DEVICE cmd failed");
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] soc: fsl: cpm1: qmc: Do not use IS_ERR_VALUE() on error pointers
2024-09-30 15:08 [PATCH] soc: fsl: cpm1: qmc: Do not use IS_ERR_VALUE() on error pointers Geert Uytterhoeven
@ 2024-09-30 16:24 ` Herve Codina
0 siblings, 0 replies; 2+ messages in thread
From: Herve Codina @ 2024-09-30 16:24 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Qiang Zhao, Christophe Leroy, linuxppc-dev, linux-arm-kernel,
linux-kernel
Hi Geert,
On Mon, 30 Sep 2024 17:08:31 +0200
Geert Uytterhoeven <geert+renesas@glider.be> wrote:
> ppc64_book3e_allmodconfig:
>
> drivers/soc/fsl/qe/qmc.c: In function ‘qmc_qe_init_resources’:
> include/linux/err.h:28:49: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
> 28 | #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
> | ^
> include/linux/compiler.h:77:45: note: in definition of macro ‘unlikely’
> 77 | # define unlikely(x) __builtin_expect(!!(x), 0)
> | ^
> drivers/soc/fsl/qe/qmc.c:1764:13: note: in expansion of macro ‘IS_ERR_VALUE’
> 1764 | if (IS_ERR_VALUE(info)) {
> | ^~~~~~~~~~~~
>
> IS_ERR_VALUE() is only meant for pointers. Fix this by checking for a
> negative error value instead, which matches the documented behavior of
> devm_qe_muram_alloc() aka devm_cpm_muram_alloc().
> While at it, remove the unneeded print in case of a memory allocation
> failure, and propagate the returned error code.
>
> Fixes: eb680d563089e55b ("soc: fsl: cpm1: qmc: Add support for QUICC Engine (QE) implementation")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Compile-tested only.
> ---
> drivers/soc/fsl/qe/qmc.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
Thanks for the patch.
Works on my side, no regressions found on my MPC8321 system.
Tested-by: Herve Codina <herve.codina@bootlin.com>
And of course:
Acked-by: Herve Codina <herve.codina@bootlin.com>
Sorry for this mistake.
Best regards,
Hervé
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-30 16:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 15:08 [PATCH] soc: fsl: cpm1: qmc: Do not use IS_ERR_VALUE() on error pointers Geert Uytterhoeven
2024-09-30 16:24 ` Herve Codina
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).