Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1139207ybh; Sat, 14 Mar 2020 19:07:28 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtDwDHlX7/iqlePkpJdOXOLcRMeVDQbc7zIKP6KhPbFXQ0P43zRgcTK91lmWKN5rY6nBjK0 X-Received: by 2002:aca:4f57:: with SMTP id d84mr12252568oib.161.1584238048513; Sat, 14 Mar 2020 19:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584238048; cv=none; d=google.com; s=arc-20160816; b=U3ESdrBI5U0HUpziXxfVfDRvI+QUj1wB1PNiEjfDxcVGMofKEpKomgWKN8agZUaV9E NFVdRzajKtZ9iv8cX+M7XXNU5I26W5eu1BrMSopaqcZJKoIs7UutFyWO4OIMSBbT9kXw amLjyifXtzMphozkVOk6qRKer8TBQ3ZXgUUi16vjwXPf4lkgOzqNb2YI0WacPigYUtqS yLJC4GZGIF2/cGrjazZOapZmvrr/R8+bq998whGVW4KVXJLdHRq92148Coaf5mwa+NOI nQJTtC4w91wYEucf62qMqsR3dCx+LPXtRdEGN53pZAggirZ8mc/IoZm7L0M7tNZq7jfT l5nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=IdM993W7spB78Iu0KdGLCLj+Uwp/Ch/pd+8wytClVWw=; b=XpyQv4KEDkv+L70hhk/0hBvZSWFYSr7jRyQsA2X6MlX3WQ3CxnUWslHKTWfbD+IGyP oLZi55xYZXzM9g44XrKUVc1fCud/Xd8eqzptxi6YId6SPhcjLyYtZ2PhtJ2ePciOggsC Zf3HPVXaRnfgGi52tLcYSWRlgYEbMBTzUQkw71a9alW/+JMAK2sDIsA9dzSnY0IzKFNT 2hfEUJM98oxjzoWuzBq0HqP+igwg5hXYW6fqsKHlM/1hbaiiR40PZiUqsV7r2E5mzfmV 7gTlOyccCmVt+eXlkdqJIB5QmR4iqxvFgKWBfMFJhTEI+TaKqSa7FWn4ePtzEmKY0mQW gtcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t64si227830oig.68.2020.03.14.19.07.16; Sat, 14 Mar 2020 19:07:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727448AbgCOCEo (ORCPT + 99 others); Sat, 14 Mar 2020 22:04:44 -0400 Received: from inva021.nxp.com ([92.121.34.21]:60384 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgCOCEo (ORCPT ); Sat, 14 Mar 2020 22:04:44 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6951520155F; Sat, 14 Mar 2020 08:17:49 +0100 (CET) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 12B13201561; Sat, 14 Mar 2020 08:17:45 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 8931D402A5; Sat, 14 Mar 2020 15:17:39 +0800 (SGT) From: Anson Huang To: srinivas.kandagatla@linaro.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] nvmem: mxs-ocotp: Use devm_add_action_or_reset() for cleanup Date: Sat, 14 Mar 2020 15:11:11 +0800 Message-Id: <1584169871-418-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_add_action_or_reset() for cleanup to call clk_unprepare(), which can simplify the error handling in .probe, and .remove callback can be dropped. Signed-off-by: Anson Huang --- drivers/nvmem/mxs-ocotp.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/nvmem/mxs-ocotp.c b/drivers/nvmem/mxs-ocotp.c index 8e4898d..588ab56 100644 --- a/drivers/nvmem/mxs-ocotp.c +++ b/drivers/nvmem/mxs-ocotp.c @@ -130,6 +130,11 @@ static const struct of_device_id mxs_ocotp_match[] = { }; MODULE_DEVICE_TABLE(of, mxs_ocotp_match); +static void mxs_ocotp_action(void *data) +{ + clk_unprepare(data); +} + static int mxs_ocotp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -160,39 +165,26 @@ static int mxs_ocotp_probe(struct platform_device *pdev) return ret; } + ret = devm_add_action_or_reset(&pdev->dev, mxs_ocotp_action, otp->clk); + if (ret) + return ret; + data = match->data; ocotp_config.size = data->size; ocotp_config.priv = otp; ocotp_config.dev = dev; otp->nvmem = devm_nvmem_register(dev, &ocotp_config); - if (IS_ERR(otp->nvmem)) { - ret = PTR_ERR(otp->nvmem); - goto err_clk; - } + if (IS_ERR(otp->nvmem)) + return PTR_ERR(otp->nvmem); platform_set_drvdata(pdev, otp); return 0; - -err_clk: - clk_unprepare(otp->clk); - - return ret; -} - -static int mxs_ocotp_remove(struct platform_device *pdev) -{ - struct mxs_ocotp *otp = platform_get_drvdata(pdev); - - clk_unprepare(otp->clk); - - return 0; } static struct platform_driver mxs_ocotp_driver = { .probe = mxs_ocotp_probe, - .remove = mxs_ocotp_remove, .driver = { .name = "mxs-ocotp", .of_match_table = mxs_ocotp_match, -- 2.7.4