Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5725623imm; Mon, 27 Aug 2018 03:12:30 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZGp9azVBPKvlHJXnAIIQptFBsBfxPBxgol7S36Mjh2yNCSKip6gt9LoZmfc5niE7hU6pZ7 X-Received: by 2002:a17:902:246a:: with SMTP id m39-v6mr12334791plg.57.1535364750449; Mon, 27 Aug 2018 03:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535364750; cv=none; d=google.com; s=arc-20160816; b=kXQG6Wu/OhiNEpScOPzPV7Syfqaaa1dg6gsTeQPw0Nb3hC9Ijd/Qylnw+N3EcuCjQh fhThesOWx00EuH7/em19e3PUjvfU52kzSXcDSIzh8WoNHHIuCjjrJEBKSRJ3kUo0L/iE PK3F34u4HOIKoNsd34Mev01uqnDvvykoCxxhJ8KTKLiuoBO6bhTKwRUhmxgu1yZnEwUQ b7zauEI7Fgh4JOOqhBAhttetjQkx/uZ00y8nIqiHdnbl7QI+nh0YYsGWJsc3lYKcc8Xm L5kTtNJs0sUTuDtENDcAQms0G9wE9X/Ffu5F8oB8IahlKcw2yyMNGdBo2lMT0HRdzta3 iplA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=IXljZmjLlYecteLK8toYmaNwFrnP17l1rqBAyPaI2Lg=; b=ThDJwetp1H7EyYtKNDSgs4sBuZuWQcxC6vvSj0kiycONG6PfWHddtu1eGu83baQVb6 3mRwNbXd/mo8TBWI0d0j/LuRGCTpa01V+98749BK/5cTaGw3nNz9ZbHTD+dQ6eCMnGOc u2aS42KPn51P0OHzo3vhiuknqglY5ib1QWfKYvITOMhnU6nNMxuIKlRFbLNKC6M0ld1+ Nxnuq3XKHWS8JGwtGERga8upmIy5cIPlX8m4MWhpWrLmLvQWhXStKyBZQmrdGG1CkWmf YBWOD7YJAkHhuPQ3Os8eaM89iDymnw5+W+Rmqs/X1SsSVmSbpk4u9au3Cj5V62Qss7bF v1aQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b28-v6si14278668pfe.265.2018.08.27.03.12.15; Mon, 27 Aug 2018 03:12:30 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727346AbeH0N4b (ORCPT + 99 others); Mon, 27 Aug 2018 09:56:31 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:18151 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726960AbeH0N4a (ORCPT ); Mon, 27 Aug 2018 09:56:30 -0400 X-UUID: 94d17ccf5ec9463cb9c4091aeec9f99c-20180827 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 681717074; Mon, 27 Aug 2018 18:10:21 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 27 Aug 2018 18:10:19 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 27 Aug 2018 18:10:20 +0800 From: To: , CC: , , , Sean Wang Subject: [PATCH 15/16] pinctrl: mediatek: adjust error code and message when some register not supported is found Date: Mon, 27 Aug 2018 18:10:14 +0800 Message-ID: <330a14ab323c756b85b3abab254f9b99751a82af.1535363951.git.sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Wang It's usual and not an error for there's some register not supported by a certain SoC or a pin so that in the case we have to adjust the message to print and the error code to get rid of unnecessary false alarm. Signed-off-by: Sean Wang --- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c index 7b7704c..98ef87e 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c @@ -61,12 +61,21 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set) static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc, - const struct mtk_pin_reg_calc *rc, - struct mtk_pin_field *pfd) + int field, struct mtk_pin_field *pfd) { const struct mtk_pin_field_calc *c, *e; + const struct mtk_pin_reg_calc *rc; u32 bits; + if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) { + rc = &hw->soc->reg_cal[field]; + } else { + dev_dbg(hw->dev, + "Not support field %d for pin %d (%s)\n", + field, desc->number, desc->name); + return -ENOTSUPP; + } + c = rc->range; e = c + rc->nranges; @@ -77,14 +86,15 @@ static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw, } if (c >= e) { - dev_err(hw->dev, "Out of range for pin = %d (%s)\n", - desc->number, desc->name); - return -EINVAL; + dev_dbg(hw->dev, "Not support field %d for pin = %d (%s)\n", + field, desc->number, desc->name); + return -ENOTSUPP; } if (c->i_base > hw->nbase - 1) { - dev_err(hw->dev, "Invalid base is found for pin = %d (%s)\n", - desc->number, desc->name); + dev_err(hw->dev, + "Invalid base for field %d for pin = %d (%s)\n", + field, desc->number, desc->name); return -EINVAL; } @@ -116,21 +126,12 @@ static int mtk_hw_pin_field_get(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc, int field, struct mtk_pin_field *pfd) { - const struct mtk_pin_reg_calc *rc; - if (field < 0 || field >= PINCTRL_PIN_REG_MAX) { dev_err(hw->dev, "Invalid Field %d\n", field); return -EINVAL; } - if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) { - rc = &hw->soc->reg_cal[field]; - } else { - dev_err(hw->dev, "Undefined range for field %d\n", field); - return -EINVAL; - } - - return mtk_hw_pin_field_lookup(hw, desc, rc, pfd); + return mtk_hw_pin_field_lookup(hw, desc, field, pfd); } static void mtk_hw_bits_part(struct mtk_pin_field *pf, int *h, int *l) -- 2.7.4