]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
soc: fsl: cpm1: qmc: Do not use IS_ERR_VALUE() on error pointers
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 30 Sep 2024 15:08:31 +0000 (17:08 +0200)
committerChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 2 Oct 2024 21:28:46 +0000 (23:28 +0200)
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>
Tested-by: Herve Codina <herve.codina@bootlin.com>
Acked-by: Herve Codina <herve.codina@bootlin.com>
Link: https://lore.kernel.org/r/8b113596b2c8cdda6655346232cc603efdeb935a.1727708905.git.geert+renesas@glider.be
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
drivers/soc/fsl/qe/qmc.c

index 3dffebb48b0daced840746c1a77503b9f94540de..659c579d751d72401270b029f0f0980ce42a3f0d 100644 (file)
@@ -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");