Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp369403ybg; Thu, 19 Mar 2020 01:05:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu4BSzMbFKaAKzoXAbeQ0OGlgtHsNctcOcY/7zVSBDxf9zMqtyYW+5zn429JoUUGwnSg8Qw X-Received: by 2002:aca:ea0a:: with SMTP id i10mr1453014oih.12.1584605105278; Thu, 19 Mar 2020 01:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584605105; cv=none; d=google.com; s=arc-20160816; b=S32msuWpfV/4P2jQ5BY5UEagUGyqq5Y7XNt9soEzhOSbYRobfra9OEpurcE/SZ+9cL /JhuzZ6ytUKPUl9C0tJfTX6r5rY7Dajw+7ZW4iXSNBdfiqvKpfawFCLc1xusLgrXiVFA ZI/Z7ORUld38DAQuI0HIL79+yJkwdnhUQrn3WfMg0RcD+oddJtFb0bN3cEISmFSANE3Y ScNAbVkwL/1h9Wqf+dtor/kR45FVPAwFB7fub6VpC77icVMAXZ6L1yKsP6bEEqVtAE5t aTqclE27w7o+/seKPqK+SvDXYJQGh+t0WXerFbi8bGmwYbG6sRK9ahHw5lKaZhMzuqbH j2aw== 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=frPURc9xVURJFro5g+DcCb3ZwR2jeKnIwAv2+0t9q/4=; b=uOWL2UXW8u7202r1as1UfIim5ngnjtQ+PBhqc0ozXKl5rTkHN/dASd+08cI8nM7cyS JxQfj211/P4nnqhFlrex9pruFCxPJzT22TLiwJxFEW9/7j9OJpQ4J4mkac7kA+kvtiU6 LLC9/Purwwq459l8yM0VkExcPDH+0Dl5PuTrvZKdeJ4pJ+7pH8MuYXKFgFLi7x2mrteW toOAPrfmkuds4hIAR4w2UX1hoM8A1tcyV6sOW63do57pbK5fRMEHq2w1cNKXj9ePnEyg I+IlPNbbCq1KjKDj2tD+qxWa1/UsE2JiZrdjZ4/VhHrUXZ9qBZUmqdrlE5pzXnzYqa6V uIOw== 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 y16si662756oie.225.2020.03.19.01.04.52; Thu, 19 Mar 2020 01:05:05 -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 S1726877AbgCSICd (ORCPT + 99 others); Thu, 19 Mar 2020 04:02:33 -0400 Received: from inva021.nxp.com ([92.121.34.21]:52570 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbgCSICd (ORCPT ); Thu, 19 Mar 2020 04:02:33 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A80D220150E; Thu, 19 Mar 2020 09:02:31 +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 752E920151B; Thu, 19 Mar 2020 09:02:27 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 80B4340246; Thu, 19 Mar 2020 16:02:22 +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: imx-ocotp: Improve logic to save many code lines Date: Thu, 19 Mar 2020 15:55:40 +0800 Message-Id: <1584604540-10097-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 Several logic improvements to save many code lines: - no need to use goto; - no need to assign return value; - combine different conditions of return value into one line. Signed-off-by: Anson Huang --- drivers/nvmem/imx-ocotp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 50bea2a..7a1ebd6 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -196,7 +196,6 @@ static int imx_ocotp_read(void *context, unsigned int offset, if (*(buf - 1) == IMX_OCOTP_READ_LOCKED_VAL) imx_ocotp_clr_err_if_set(priv); } - ret = 0; read_end: clk_disable_unprepare(priv->clk); @@ -435,17 +434,13 @@ static int imx_ocotp_write(void *context, unsigned int offset, void *val, priv->base + IMX_OCOTP_ADDR_CTRL_SET); ret = imx_ocotp_wait_for_busy(priv, priv->params->ctrl.bm_rel_shadows); - if (ret < 0) { + if (ret < 0) dev_err(priv->dev, "timeout during shadow register reload\n"); - goto write_end; - } write_end: clk_disable_unprepare(priv->clk); mutex_unlock(&ocotp_mutex); - if (ret < 0) - return ret; - return bytes; + return ret < 0 ? ret : bytes; } static struct nvmem_config imx_ocotp_nvmem_config = { -- 2.7.4