Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5177458ybl; Wed, 22 Jan 2020 11:45:48 -0800 (PST) X-Google-Smtp-Source: APXvYqycFw1Csf+eDsN2sJsoY072Ba7HEOMWz52CL1spZAIPJ9TqTiYkhCXOoPE8oZkIXlOwo2BL X-Received: by 2002:aca:534f:: with SMTP id h76mr8200804oib.23.1579722348507; Wed, 22 Jan 2020 11:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579722348; cv=none; d=google.com; s=arc-20160816; b=jo9wQ3jxh2WHaluT8PR5poldUHTzKZeqDR/fM1J72GSJOffV70e0hXjUIGIMoRI4lW XtrlsGOzTnxs/tx6ECCKsDBplAwylgVLEEv3luw8LCEcK/PgkpeUDN+zB9naGLeNYGNk IPyK9j1Ugz+twJmIfoPTYhuanmZ5LEwl4uu1/yooR6I2jVnAp+l88yuBmU9kaLC1r4KM 39maXgUQQ6y05JOMthQ8Lr3niHef03ky1LDdoPh72gI2i/UsS7GI6SyRb+TKMAlrf5QZ tr784aalnwUB3tOwDNiSMx0oUsnDLo60uUheRF24tV2BfMKSOrpYMZEgIpxFfKli7fen R80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=U26j/qpGJ0Is5QmyAlW9piOf/MeSuRs9+Px9AX0L7UM=; b=FmjmvYZ+vrWh2lUvzNOj5mrRAyyuPKznn8m/X0aXm2GbPL8RYGvIam8gC41meZVSYt XoYST8n+FcGGbcCitRHDU06oupxY38RpPh4ouL6On3+J8PckQdna2yZXPoNSjq5uYn60 7ra08NWzU4SsPM+X2xwrKQI8GRFFKXiMmSAD5ZAsSGmXeMMHNWtYg8+I1JFEqjSjENHV dUIfrb+oLmMZjOxzG/9MI7cmgdWnvK2w3lSumeYIWyOF/0P17yFqyCYXJ3TGREXGC8Uo 3vqsYqewb2SsB0zECkZWDagHlT0yOxKX7LRktaEcl5RZgpQc9juuMznNb5ZnuKLTVpBo fseQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OIts7Fe5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18si14915681otp.61.2020.01.22.11.45.11; Wed, 22 Jan 2020 11:45:48 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=OIts7Fe5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbgAVTnM (ORCPT + 99 others); Wed, 22 Jan 2020 14:43:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:40520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725827AbgAVTnL (ORCPT ); Wed, 22 Jan 2020 14:43:11 -0500 Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F1F6C24656; Wed, 22 Jan 2020 19:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579722191; bh=A90BQl2RN2zbfyWz1gVKm18acKQthqJdIb4G83Hj8zw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=OIts7Fe5sKuVNBOHwDMDngnIZ5ZZUdqywiV0gklD8cZ89LANd1gvTpVdvz7C/w572 qPQw9nlzvENXfN2U6IpN2w6h3+eu8DGep0/3Je9DyKp1igtSJj4VFR/a02y4jEP+Pt wo4gGrYC6OzXA9ZNI/DQMn2+zq1irtB6/hHOMgO0= Received: by mail-io1-f46.google.com with SMTP id d15so506068iog.3; Wed, 22 Jan 2020 11:43:10 -0800 (PST) X-Gm-Message-State: APjAAAUCM7yCkyUW8QwosjnTs2fdYWBhOILA4oALqfzOrPfxp7IMEnIw AYozwZCb4EsrcGwg1gA1CxE8x2n4A01odaI0V3I= X-Received: by 2002:a6b:f206:: with SMTP id q6mr8435332ioh.264.1579722190438; Wed, 22 Jan 2020 11:43:10 -0800 (PST) MIME-Version: 1.0 References: <1579675994-7001-1-git-send-email-light.hsieh@mediatek.com> <1579675994-7001-4-git-send-email-light.hsieh@mediatek.com> In-Reply-To: <1579675994-7001-4-git-send-email-light.hsieh@mediatek.com> From: Sean Wang Date: Wed, 22 Jan 2020 11:42:59 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 4/6] pinctrl: mediatek: Refine mtk_pinconf_get() To: Light Hsieh Cc: Linus Walleij , "moderated list:ARM/Mediatek SoC support" , "open list:GPIO SUBSYSTEM" , lkml , kuohong.wang@mediatek.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 21, 2020 at 10:53 PM wrote: > > From: Light Hsieh > > Correct cases for PIN_CONFIG_SLEW_RATE, PIN_CONFIG_INPUT_SCHMITT_ENABLE, > and PIN_CONFIG_OUTPUT_ENABLE - > Use variable ret to receive value in mtk_hw_get_value() (instead of > variable val) since pinconf_to_config_packed() at end of this function > use variable ret to pack config value. > > Signed-off-by: Light Hsieh Acked-by: Sean Wang > --- > drivers/pinctrl/mediatek/pinctrl-paris.c | 40 ++++++++++++-------------------- > 1 file changed, 15 insertions(+), 25 deletions(-) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c > index 2f07500..d09a726 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -78,7 +78,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > { > struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev); > u32 param = pinconf_to_config_param(*config); > - int val, val2, err, reg, ret = 1; > + int err, reg, ret = 1; > const struct mtk_pin_desc *desc; > > if (pin >= hw->soc->npins) { > @@ -107,17 +107,11 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > err = -ENOTSUPP; > break; > case PIN_CONFIG_SLEW_RATE: > - err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &val); > - if (err) > - return err; > - > - if (!val) > - return -EINVAL; > - > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SR, &ret); > break; > case PIN_CONFIG_INPUT_ENABLE: > case PIN_CONFIG_OUTPUT_ENABLE: > - err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val); > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret); > if (err) > goto out; > /* CONFIG Current direction return value > @@ -128,20 +122,22 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > * input 1 (= reverse HW value) > */ > if (param == PIN_CONFIG_INPUT_ENABLE) > - val = !val; > + ret = !ret; > > break; > case PIN_CONFIG_INPUT_SCHMITT_ENABLE: > - err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &val); > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &ret); > if (err) > - return err; > - > - err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SMT, &val2); > - if (err) > - return err; > + goto out; > + /* return error when in output mode > + * because schmitt trigger only work in input mode > + */ > + if (ret) { > + err = -EINVAL; > + goto out; > + } > > - if (val || !val2) > - return -EINVAL; > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_SMT, &ret); > > break; > case PIN_CONFIG_DRIVE_STRENGTH: > @@ -154,13 +150,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, > case MTK_PIN_CONFIG_RDSEL: > reg = (param == MTK_PIN_CONFIG_TDSEL) ? > PINCTRL_PIN_REG_TDSEL : PINCTRL_PIN_REG_RDSEL; > - > - err = mtk_hw_get_value(hw, desc, reg, &val); > - if (err) > - return err; > - > - ret = val; > - > + err = mtk_hw_get_value(hw, desc, reg, &ret); > break; > case MTK_PIN_CONFIG_PU_ADV: > case MTK_PIN_CONFIG_PD_ADV: > -- > 1.8.1.1.dirty