From patchwork Thu Jul 15 06:42:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 477397 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1401170jao; Wed, 14 Jul 2021 23:42:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytaC1QzsAwXZMZTVZN9NQ9tv1TuUm0dY7zxru7wAz0GrZEu9QhSAkXJCi7PxtlVk6iKb/m X-Received: by 2002:a92:d912:: with SMTP id s18mr1672183iln.172.1626331375889; Wed, 14 Jul 2021 23:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626331375; cv=none; d=google.com; s=arc-20160816; b=XwZih+97uiGScNcFyHU5rIv9T26DjOELFhqhHk0y7Ow32j2CBMbkAusp4OUMGVXzAF tPtlaVhcIbiunwRyfWqyXkqpxtGTFC4N0JvNzKABlrSuWAJUbWDa2CDuiBABZKtEvO1+ qUml6AWgTnBoxvDLpaydXuW962+tvNehhXh9AzGbqjJb9cfsDEpv/PEmum0w5w6NltNU tXvcnQ6CCYjdBuVEuqv7mclh2r3wq4wVUkaQksoYZVozD425NpGUnD7YtTudtShr90Rt eF5dLIDSXWrwJe91XEv5pjjg+PUNCLUSUdXNOtlbYnfNI6AiA7qPVCfKqMqMriyGTbrF SQ4w== 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=d4mdkZCRWPQ78hGAfXSguLQgxI88wdoUrZVNXlAHiDs=; b=q1W/Lv3eBjLri5N7h16uGTWZMQMMGGhgdLvVcE/6VAnpIu7PTf96bnPilU5yooCdKu +HPb97So3ZwHjDx8BkwJ/QtHuJFx32oaHT5XYxMxMJhk9krrJXT3yE309A19OnQOCSr2 w59u0+plTC0ty2DM4JO71Sj5IUCq7SyWumJB7K7oTG3HCrqfjS1ZSIai5IIR0YDZeSXg W+s6JqdlfHWU2CKs7sds4tky8BRO8M5vVaKXuWKEAtT4VLP5uiDQRI2b1IgpmxSUh0eR HKe7zA/qyiXPaiZxC2NLc0bvp5/Eheg8DLMNX88MI16ISsXeq+sK0tDxkb1lat4aejnJ uwbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-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 k5si5515888ioq.67.2021.07.14.23.42.55; Wed, 14 Jul 2021 23:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-gpio-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-gpio-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-gpio-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 S231809AbhGOGpr (ORCPT + 3 others); Thu, 15 Jul 2021 02:45:47 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:6933 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231579AbhGOGpq (ORCPT ); Thu, 15 Jul 2021 02:45:46 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GQPq92KGLz7v0p; Thu, 15 Jul 2021 14:39:17 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 15 Jul 2021 14:42: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, 15 Jul 2021 14:42:37 +0800 From: Zhen Lei To: Tony Lindgren , Haojian Zhuang , Linus Walleij , Manjunathappa Prakash , linux-arm-kernel , linux-omap , linux-gpio , linux-kernel CC: Zhen Lei Subject: [PATCH] pinctrl: single: Fix error return code in pcs_parse_bits_in_pinctrl_entry() Date: Thu, 15 Jul 2021 14:42:06 +0800 Message-ID: <20210715064206.3193-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 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-gpio@vger.kernel.org Fix to return -ENOTSUPP instead of 0 when PCS_HAS_PINCONF is true, which is the same as that returned in pcs_parse_pinconf(). In addition, I found the value of pcs->flags is not overwritten in pcs_parse_bits_in_pinctrl_entry() and its subfunctions, so moving this check to the beginning of the function eliminates unnecessary rollback operations. Fixes: 4e7e8017a80e ("pinctrl: pinctrl-single: enhance to configure multiple pins of different modules") Reported-by: Hulk Robot Signed-off-by: Zhen Lei --- drivers/pinctrl/pinctrl-single.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) -- 2.25.1 diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index e3aa64798f7d..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,29 +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"); - 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: