Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1822468rwb; Fri, 7 Oct 2022 20:01:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5XaHbeX3KUdWkh18q0FOBmLyUfjcpGU2MnxU/KFcdbn8s/5x3Uove83EPlSmSxASGETqYk X-Received: by 2002:aa7:838a:0:b0:550:5e4a:ab55 with SMTP id u10-20020aa7838a000000b005505e4aab55mr8485754pfm.10.1665198101664; Fri, 07 Oct 2022 20:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665198101; cv=none; d=google.com; s=arc-20160816; b=EFTQ3fsNEpK+AJvvogSXGXMQHcjfSDgVFpDmA1T1iySNl//SR4OsPyQnZ9rzT+Xih3 skOab8/orjbVG5v5HyoCcaHM815nXAZoj8+j7sh43FS1m7qBspYVyzARGrUX3ihwysp8 1XGMb/rzu/zBspHnkMYhMrKWGENw+i/gb+Z3hyzKaCqtVn+lo46z0zQph/P/63UKnItP bWDjERUvGZ8+dcXzeW4ODd2P8v2hSglfp7cus48A+v/Yuy6GuWs3t6PUCnmRgOR1W7d2 u6rfNg2qrQ1sg9lN6Hzi6/CvqLAnrgSDq4CEWJrG30xVaWg33sSUPLLpn3XUkdNcpXpU b1+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FKELfeLOHpCQgpPyJR1Eu1U6KS3BdWMLaP7v/rpcCys=; b=GpUSbmF9fVVk50FI9uRn7+HZUvR/RBcKpf/UjXqyisRuT2HFeeZmoKyTwNFC3iD+Hl vQY1szERpEw/ibiHqoDDME8udLZyITS0FG5faWYPo8jQ9TqfguPvYi7wjsxlmISMXdcN 0K4TOmYAcPaBPjPP9rJtW9ByTgQC4xD+H5eh7wbMZTByoCHp0vf720/zlviIjVRWyyhA Jidv/5pQfnqA6an/hytj5VLxuCPrmpUMhmZXU14Eb8v0Vw48lXDotHEOCIOOkq3RPqT+ Y7y4b4XtZWRqwcJVGOoqzufEfOC3nSJjRQV0o1QnIhziDHAmvFzGEL4uiKu33j9tMzQU oaGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a654d01000000b0045c19daa33esi4701346pgt.355.2022.10.07.20.01.26; Fri, 07 Oct 2022 20:01:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229548AbiJHCic (ORCPT + 99 others); Fri, 7 Oct 2022 22:38:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbiJHCia (ORCPT ); Fri, 7 Oct 2022 22:38:30 -0400 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA776127BED for ; Fri, 7 Oct 2022 19:38:28 -0700 (PDT) Received: from localhost.localdomain (unknown [124.16.138.125]) by APP-03 (Coremail) with SMTP id rQCowABHTbWc4kBjvPCNAw--.12816S2; Sat, 08 Oct 2022 10:38:20 +0800 (CST) From: Jiasheng Jiang To: qiang.zhao@nxp.com, leoyang.li@nxp.com Cc: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] soc: fsl: qe: Add check for ioremap Date: Sat, 8 Oct 2022 10:38:18 +0800 Message-Id: <20221008023819.47679-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowABHTbWc4kBjvPCNAw--.12816S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CFW5KFWDuF1UJr48Zr17Awb_yoW8trW3p3 yDJFy5Ary5KFZ7W397Jw1kXF15uayIkas3GrWvg3s3uwnxJ34DCwsaqFyYvFsxKrWFkryr tF47J3W5uF1UtF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkq14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Cr 1j6rxdM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj 6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr 0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxkIecxEwVAFwVW8 JwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF 0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUbYhF7UUUUU== X-Originating-IP: [124.16.138.125] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As ioremap can return NULL pointer, it should be better to check the return value return error if fails. Moreover, the return value of qe_reset should be checked by cascade. Fixes: 68f047e3d62e ("fsl/qe: add rx_sync and tx_sync for TDM mode") Signed-off-by: Jiasheng Jiang --- drivers/soc/fsl/qe/qe.c | 23 ++++++++++++++++++----- include/soc/fsl/qe/qe.h | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c index b3c226eb5292..88e335e8eef7 100644 --- a/drivers/soc/fsl/qe/qe.c +++ b/drivers/soc/fsl/qe/qe.c @@ -83,10 +83,13 @@ static phys_addr_t get_qe_base(void) return qebase; } -void qe_reset(void) +int qe_reset(void) { - if (qe_immr == NULL) + if (qe_immr == NULL) { qe_immr = ioremap(get_qe_base(), QE_IMMAP_SIZE); + if (qe_immr == NULL) + return -ENOMEM; + } qe_snums_init(); @@ -98,6 +101,8 @@ void qe_reset(void) if (qe_sdma_init()) panic("sdma init failed!"); + + return 0; } int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input) @@ -640,11 +645,14 @@ EXPORT_SYMBOL(qe_get_num_of_snums); static int __init qe_init(void) { struct device_node *np; + int ret; np = of_find_compatible_node(NULL, NULL, "fsl,qe"); if (!np) return -ENODEV; - qe_reset(); + ret = qe_reset(); + if (ret) + return ret; of_node_put(np); return 0; } @@ -653,8 +661,13 @@ subsys_initcall(qe_init); #if defined(CONFIG_SUSPEND) && defined(CONFIG_PPC_85xx) static int qe_resume(struct platform_device *ofdev) { - if (!qe_alive_during_sleep()) - qe_reset(); + int ret; + + if (!qe_alive_during_sleep()) { + ret = qe_reset(); + if (ret) + return ret; + } return 0; } diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h index b02e9fe69146..71129b8a5807 100644 --- a/include/soc/fsl/qe/qe.h +++ b/include/soc/fsl/qe/qe.h @@ -84,9 +84,9 @@ extern spinlock_t cmxgcr_lock; /* Export QE common operations */ #ifdef CONFIG_QUICC_ENGINE -extern void qe_reset(void); +extern int qe_reset(void); #else -static inline void qe_reset(void) {} +static inline int qe_reset(void) {} #endif int cpm_muram_init(void); -- 2.25.1