From patchwork Wed Jan 31 23:25:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 768607 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2048.outbound.protection.outlook.com [40.107.8.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4EE613E205; Wed, 31 Jan 2024 23:21:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706743303; cv=fail; b=CQd0I37n/1PDVJirjqKhcv+Uc1Jd4Az9Jq/nh/Xx3LVF9//xYK8dvrN/0W8xZ7maPE5nk2gGUilPcZr0sgzfMXLPs+WwJ6J8bAVOJ1UisHl3bjPjED3AHtxAz0LiYfmz1HUkoEsJWFY8xbCm9YwmjipNZpJ5H07RKJ/8dlXSPeA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706743303; c=relaxed/simple; bh=2zJxqBVqaNuhlGWo42e1QHXlvX1q4/WgIXGzbYmGZIA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=JjvT/pjtCkDsEJ6Jimyda3C//ZLv/N2oqhUnNbVbjKWmhIcqpY1DqjUrgjJm3KKlIwX1tKn7zVjVeL46D60Eif8Jbw4Y3txX0TYU1t63KnbUTOdv2BwQsEv1muEuq3F9hzCtHizKSBnNB6jOQzPSuQx3ZNrsvVUYkSDh/kv8Sbo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=QVuTRRe4; arc=fail smtp.client-ip=40.107.8.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="QVuTRRe4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ytr8ofe3ts12bQiU7ebSXtHASkH9NSNZzGEY5ilCgXsIzQ6Mnpu15xWpr2EgAbxCyaCOEtDwGb9IdLHgIOOSaNPvakG5fb7UVmoNt430J+N+J0HT35oNtVZ9qaSU/JFp4hAgJCFg2qmVmtq7vHrPYY1S++oebt4/CAj3LYeKBl9Dcs4nQqKTjHejIVFYO5foZ0ArBRrQWqzjpXI/pyrdteLn/mbpR2G5OmmCscdzuk44jBPHobRc6kgvkvOj3Wli7H3cGxAPuOISAUMF91t8sRBqsPTyNxUNohaLzsyY9/89XFMsYIEYhLNMjMzCRq5Zjerhy3xcx7s06z685qTLxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yroYNvtM+ftxkBYnpAH09lTiB04eMcTiVCGoXVH7uV4=; b=KnJzDgIsUkS1eqGzn7yXliDTKYM14Q/8lkTPstjCyYAejspJOKdzaW3CVpE2CYW+/OJ2GcneEhqT4iWt6In9fidpquQGfD71XzgEtxZNuTSfTnEHi9BT4w3zWU8iiz6r8V44VQaHlKZ7bkC1f8psamLWdJdGV/xkdioPN0I0+MwdLSmTUncHQ8sXHPfxDbCogku0xwsVW7rd6LcMVcvmtKu/UqL54IYBvaR9kA9DdVxVV4wWKbSNDfK2yVxz019/DFp3vX28c2CS9IXaB2DdZnzl300PL5ZIhbv/Uvlm3P3w/zB+qARnS679dg+Aa47SiYlFdsaIGISPkDUA0a5YbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yroYNvtM+ftxkBYnpAH09lTiB04eMcTiVCGoXVH7uV4=; b=QVuTRRe4NWgUwBdI7ZquVmzmA3GIiUoq0HPftqtp2lzC82/f5uJtwMU+VJmWoJjpU6u4z2/TOpe1iLglVKW77H30tUqeY1BWOafIX+pm5R3rn1LPGD/yYuJlCi5ItLLg2xXSZuGQC33XdniNnE/st0hruCmWYAMNPTtxAsfDlKY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM8PR04MB7396.eurprd04.prod.outlook.com (2603:10a6:20b:1da::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.23; Wed, 31 Jan 2024 23:21:37 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.023; Wed, 31 Jan 2024 23:21:37 +0000 From: "Peng Fan (OSS)" Date: Thu, 01 Feb 2024 07:25:38 +0800 Subject: [PATCH v6 2/4] mailbox: imx: support return value of init Message-Id: <20240201-imx-mailbox-v6-2-76f4f35b403e@nxp.com> References: <20240201-imx-mailbox-v6-0-76f4f35b403e@nxp.com> In-Reply-To: <20240201-imx-mailbox-v6-0-76f4f35b403e@nxp.com> To: Jassi Brar , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Dong Aisheng , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706743555; l=3395; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=S0DKuiQSDcYtu53JqBC1+gV1zoHcWj4DjQyGEWhlcnk=; b=W5a6ZzLKxqmgK4UssaJWiqZtbRVbEUDCD8H7KWbWha1f+NbQ5XEjWrNPiUMtG+qlAKot4FgiU avdfd5odp4cDwUC8V7lCYB6bgabets7kNASm2B93Fs9hzB5Jd+BaD1e X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0049.apcprd02.prod.outlook.com (2603:1096:4:1f5::18) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM8PR04MB7396:EE_ X-MS-Office365-Filtering-Correlation-Id: a483c66f-1bce-488d-3378-08dc22b35f39 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7vDJrZ/G+7VsuhnyRbGzQpIFe9vxOWIzAb2wQksiltLvl6UEOAqbF9lYFGbGAmnlA0/e8hMK5E/FhWcF/UrkullK0leGDmOVnQI3/bFRTcoMOZf96c0UBjczjLCLz/lU3Ccl56gHVeTXknECKo4yndZdsG0i/LNe66PQYjwV4teCADRli7F2VMNVcOr91b+Hkl08/akymob9GmsG36nVy47+csGSHt5H3BxvcId367P2xt/gYHk/mlBiOuJcUvGLBbn1FFHjNSL+tIer/ld6ZN5HCEnzyrImDApViSDXXK4YQsUwNdKLFF2II6gMsoacXyWdK76UldmhATaQDP+IBvr45Ztr6rtNG47CM6cytsKLG89rqYsEyF2Z9OfclbumUfRN2j0JEdznTQDDksE+Vxv9jh7Kl45Avu/dqPk4g4Fl/ZE6AA42eF+uYoUdI6vQwoBz8C8NcGSEQzhQH+NbAUJPUt0GcBDPRnfmQ3mVN3iqLSJS+MpJ857GS1Rq9p2y24VATaJFi5Q9sNyvTanTAcMiX7yKb0rj3GtA6OQB+sAgWSt48I+cSzjYONquHNYYe0qW3mbpWr7CX5rau4q6JGMH03QMIvC7ygrfuz7PJCSnHqj2ExApL9xMdUQq3sCW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(366004)(376002)(39860400002)(136003)(396003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(921011)(26005)(41300700001)(316002)(38350700005)(66556008)(478600001)(36756003)(6512007)(9686003)(6506007)(83380400001)(52116002)(6486002)(66476007)(38100700002)(66946007)(5660300002)(2906002)(8936002)(15650500001)(86362001)(8676002)(110136005)(4326008)(7416002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?S8phy3uJRDNFfpuzLfQ9X4+cYyv5?= =?utf-8?q?+kVBUbH+QPv+CasEGWXvPls2+DXGstwCxIONKxsKuxQD5ss+4LB6Sf2Jmezsi+386?= =?utf-8?q?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?SSuUrjNJCP+2KmmYqBnjwbWpALRc0661JL5vBIKio074OiFWllNZkKHH1pHYR+BKA?= =?utf-8?q?ruf8uZcFd9mnkQpNMfNK+N33qquo8PWd21em/HKKCO7uP8g4W/AeyI4Q0he3l4Nwu?= =?utf-8?q?MaufUwzyH0fuZjs0WlScTeRwvXeTXrtCUDPGVFPy03kwbRQwhM1V457EvScX5uiql?= =?utf-8?q?q/1dY3w9bJo04OTu4HHqAeVdJk4fnsngb76G0xhF68lpdjDdkEp0Gfh4YAcdlGVbH?= =?utf-8?q?AhJMszFMzcYHobh9gpIRX7zuFZXs+sUd/5y4u7FqPVFFxjYEZZWRy6ECLUBvtyjZD?= =?utf-8?q?cNg/nr/A2PLUXCMraWzO0OoNB9WR6mN94cW/BbrVRuHkhHwlZ4FxCHWPCoyGYlEPo?= =?utf-8?q?aXrylTAM49BY48r0XqunIKlmaOn+IOrhU2Wezl28XIf2PR1CEirHJDBQbXjsAMJHc?= =?utf-8?q?HrP4EEEf/ry/+/e1G8dv8GecOOndFVSjUtBuTPydijOc5fkns0bTeZEq2WXLlXtgw?= =?utf-8?q?0gTnoYW8Hu5pQnuENS96CJCeXqTXoaZ34PzEKw3mKiGhg2UHfqyoroUYNZv9jlDkq?= =?utf-8?q?EELjw3DgH4GC?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a483c66f-1bce-488d-3378-08dc22b35f39 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jan 2024 23:21:37.3568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F2fzl64/L6/nebCaXxcNwMfobmB9uQOh5FUxkToluiGlCJdsttgaeiU3D/cOZnnmXtVqqy6g0JE4MjHuQIQq4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7396 From: Peng Fan There will be changes that init may fail, so adding return value for init function. Reviewed-by: Sascha Hauer Signed-off-by: Peng Fan --- drivers/mailbox/imx-mailbox.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c index 656171362fe9..dced4614065f 100644 --- a/drivers/mailbox/imx-mailbox.c +++ b/drivers/mailbox/imx-mailbox.c @@ -110,7 +110,7 @@ struct imx_mu_dcfg { int (*tx)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp, void *data); int (*rx)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp); int (*rxdb)(struct imx_mu_priv *priv, struct imx_mu_con_priv *cp); - void (*init)(struct imx_mu_priv *priv); + int (*init)(struct imx_mu_priv *priv); enum imx_mu_type type; u32 xTR; /* Transmit Register0 */ u32 xRR; /* Receive Register0 */ @@ -737,7 +737,7 @@ static struct mbox_chan *imx_mu_seco_xlate(struct mbox_controller *mbox, return imx_mu_xlate(mbox, sp); } -static void imx_mu_init_generic(struct imx_mu_priv *priv) +static int imx_mu_init_generic(struct imx_mu_priv *priv) { unsigned int i; unsigned int val; @@ -757,7 +757,7 @@ static void imx_mu_init_generic(struct imx_mu_priv *priv) priv->mbox.of_xlate = imx_mu_xlate; if (priv->side_b) - return; + return 0; /* Set default MU configuration */ for (i = 0; i < IMX_MU_xCR_MAX; i++) @@ -770,9 +770,11 @@ static void imx_mu_init_generic(struct imx_mu_priv *priv) /* Clear any pending RSR */ for (i = 0; i < IMX_MU_NUM_RR; i++) imx_mu_read(priv, priv->dcfg->xRR + (i % 4) * 4); + + return 0; } -static void imx_mu_init_specific(struct imx_mu_priv *priv) +static int imx_mu_init_specific(struct imx_mu_priv *priv) { unsigned int i; int num_chans = priv->dcfg->type & IMX_MU_V2_S4 ? IMX_MU_S4_CHANS : IMX_MU_SCU_CHANS; @@ -794,12 +796,20 @@ static void imx_mu_init_specific(struct imx_mu_priv *priv) /* Set default MU configuration */ for (i = 0; i < IMX_MU_xCR_MAX; i++) imx_mu_write(priv, 0, priv->dcfg->xCR[i]); + + return 0; } -static void imx_mu_init_seco(struct imx_mu_priv *priv) +static int imx_mu_init_seco(struct imx_mu_priv *priv) { - imx_mu_init_generic(priv); + int ret; + + ret = imx_mu_init_generic(priv); + if (ret) + return ret; priv->mbox.of_xlate = imx_mu_seco_xlate; + + return 0; } static int imx_mu_probe(struct platform_device *pdev) @@ -866,7 +876,11 @@ static int imx_mu_probe(struct platform_device *pdev) priv->side_b = of_property_read_bool(np, "fsl,mu-side-b"); - priv->dcfg->init(priv); + ret = priv->dcfg->init(priv); + if (ret) { + dev_err(dev, "Failed to init MU\n"); + goto disable_clk; + } spin_lock_init(&priv->xcr_lock); @@ -878,10 +892,8 @@ static int imx_mu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); ret = devm_mbox_controller_register(dev, &priv->mbox); - if (ret) { - clk_disable_unprepare(priv->clk); - return ret; - } + if (ret) + goto disable_clk; pm_runtime_enable(dev); @@ -899,6 +911,7 @@ static int imx_mu_probe(struct platform_device *pdev) disable_runtime_pm: pm_runtime_disable(dev); +disable_clk: clk_disable_unprepare(priv->clk); return ret; }