From patchwork Thu Jul 22 03:39:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhen Lei X-Patchwork-Id: 483859 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp6791096jao; Wed, 21 Jul 2021 20:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8Frr1gWAg0y+4Dd0UjA6xTrqem2su+1iKTHwfGF4uRDl/ThTtTeevY1C6UXahkaYPPbmr X-Received: by 2002:aa7:d543:: with SMTP id u3mr41031439edr.37.1626925254218; Wed, 21 Jul 2021 20:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626925254; cv=none; d=google.com; s=arc-20160816; b=q+wf9K4K3XTTGcQptx6SggA/jeBRCTmt6xxUoxB8ltPHxqmCre9909CzrKMyFc7p8u xNJSr0eQxFbpe1UJlrphpvQRnqpaO2rxrXxKmWj6EmNdl1UbPf8t0WwDwjBUDHDGuS4z KJvDOXN+GOgvMprngI9oEo3WYGFHkm9eBMr7ds/xfHacjF4P6s9BHa9Rayh+oD+cV77L u+WAN8gT74Cz1s7u0bJxfmrEL4VpYlWawyvRGzzjMX84TkEh1asMapQo3B3/Az+J2Rmz /GP6Ujg2Ddm1WqncUql4+SzQpCz5DLqP0NyRhLIsWs0Q7JCIK5dJl0bBDBSndDxtx7ZQ c6tQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=N7GmQ5PGLRb4K5E7TAllrZqYvXaEUW++kzqgbBsMRfk=; b=tdDM2xrRbrn7a4YCCUCw79rI5bmWj6ExVSHTJcJc8VRV8FsZ0x9SVdrgJzEjGZHzg9 oRKAC/csZh6eL8MkQ7R4RjSkGBMW0mBLVnoPefcPal1jBhmqCwm6NCGCB4hmH0c8XPVt ynQdZP/ftaPoIpR5mhxkPaz8k6TSVayNG60gwh/qj28R4hrMSvngCJVcuCsZRD5R5++m 3rZP8vFXS+h6Kt2cX7y3GkMZ6A89b0ysS62QoGHWp5NVt6i8q777745+6QaTQBleirgX HK3crNdKmcmrn4Xt94edjxJVXOwWLIFgLXNvStYM04v+O+T/OXJzNaRWaIzCfO7AT5Ry gw+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w12si30733328edu.48.2021.07.21.20.40.54; Wed, 21 Jul 2021 20:40:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbhGVDAF (ORCPT + 3 others); Wed, 21 Jul 2021 23:00:05 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:12234 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230026AbhGVDAD (ORCPT ); Wed, 21 Jul 2021 23:00:03 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4GVdP555Kpz1CMXP; Thu, 22 Jul 2021 11:34:49 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 11:40:37 +0800 Received: from thunder-town.china.huawei.com (10.174.179.0) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 22 Jul 2021 11:40:36 +0800 From: Zhen Lei To: Tony Lindgren , Haojian Zhuang , Linus Walleij , linux-arm-kernel , linux-omap , linux-gpio , linux-kernel CC: Zhen Lei Subject: [PATCH v2 2/2] pinctrl: single: Move test PCS_HAS_PINCONF in pcs_parse_bits_in_pinctrl_entry() to the beginning Date: Thu, 22 Jul 2021 11:39:30 +0800 Message-ID: <20210722033930.4034-3-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20210722033930.4034-1-thunder.leizhen@huawei.com> References: <20210722033930.4034-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.179.0] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org The value of pcs->flags is not overwritten in function pcs_parse_bits_in_pinctrl_entry() and its subfunctions, so moving this check to the beginning of the function eliminates unnecessary rollback operations. Signed-off-by: Zhen Lei --- drivers/pinctrl/pinctrl-single.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) -- 2.25.1 Reviewed-by: Tony Lindgren diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 4fcae8458359..d8b4dc40f3c6 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -1115,7 +1115,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, { const char *name = "pinctrl-single,bits"; struct pcs_func_vals *vals; - int rows, *pins, found = 0, res = -ENOMEM, i, fsel, gsel; + int rows, *pins, found = 0, res = -ENOMEM, i, fsel; int npins_in_row; struct pcs_function *function = NULL; @@ -1125,6 +1125,11 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, return -EINVAL; } + if (PCS_HAS_PINCONF) { + dev_err(pcs->dev, "pinconf not supported\n"); + return -ENOTSUPP; + } + npins_in_row = pcs->width / pcs->bits_per_pin; vals = devm_kzalloc(pcs->dev, @@ -1212,30 +1217,19 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, goto free_pins; } - gsel = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs); - if (gsel < 0) { - res = gsel; + res = pinctrl_generic_add_group(pcs->pctl, np->name, pins, found, pcs); + if (res < 0) goto free_function; - } (*map)->type = PIN_MAP_TYPE_MUX_GROUP; (*map)->data.mux.group = np->name; (*map)->data.mux.function = np->name; - if (PCS_HAS_PINCONF) { - dev_err(pcs->dev, "pinconf not supported\n"); - res = -ENOTSUPP; - goto free_pingroups; - } - *num_maps = 1; mutex_unlock(&pcs->mutex); return 0; -free_pingroups: - pinctrl_generic_remove_group(pcs->pctl, gsel); - *num_maps = 1; free_function: pinmux_generic_remove_function(pcs->pctl, fsel); free_pins: