Received: by 10.192.165.148 with SMTP id m20csp243821imm; Thu, 19 Apr 2018 20:44:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+a/jpF3l1r2TH9WmEHZIZ/vpnhLFvOFvFFClB9tb8HQVnXivJlt8CvW0PoAf4zqYLcfG/B X-Received: by 10.99.117.22 with SMTP id q22mr7184707pgc.68.1524195869945; Thu, 19 Apr 2018 20:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524195869; cv=none; d=google.com; s=arc-20160816; b=oZ/mJjowchoR8raIMWRKloS4Hhqww1PYuaulM9D9v76guF1vbOxo4M0V8JjcB7SPWN HtRQLAuBYeei3UgWNExKjyH2tXxAl1Xro3MvDYUXCjgiDkB0/RsLJnb9mJiYvjoQASuD EmUaFkuISR0mEnd3GSre+aDN0b5trR7SotjK6GrXaPIToET7n1rRL20ISTiI+JjRCCjS rxR/6WoKjr+si6T/AXfv2ypXgK5K6IHmI0iYt6flrc67YQfOCK1HkQVvyhrYwt8wJxy/ IQQYFq1KI2uTpRAj2SZHLfXMWIOOJflp6BJNYAr9NRCh1KsWQ5L5gj65h9Eo/ZOQcpFU hrHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=j+XdTlTywrje0b6MrEErvNFW+Pibh/0of70XrzE7aLY=; b=j4e4ekz8EZyywJ8dBgR1HlynAqdpeB+VDkz40F0C9iLC/tbAry2wL06ZrINk7NYizz GXXsCWxOr1eeXaMRZxStpxVPVDPsPfCgTjJXJefDPpQDIKor6hrAQTsNe9MWNNlG/L3n jkUQoTd8x6VWT6DWSp096dzASGuqqOv59CyMLQ+eG1eA4z/TplhD3/vo3fKNH4WtEccD 3XSHLZd2vcMkbxfHwNeGAMcosHRnYCY5oAWzT9RG57wocKwZdFiE9SqCqnQf2Z1+B6Fd TiA4eboyL+PC3ntMR8DE9+NdYE5CkiJ8LEgMhTTDBac89WsicCV665boD2HwTDuquPJS JEHw== 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 n3-v6si4893673pld.172.2018.04.19.20.44.15; Thu, 19 Apr 2018 20:44:29 -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 S1754253AbeDTDnD (ORCPT + 99 others); Thu, 19 Apr 2018 23:43:03 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:20815 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754126AbeDTDnC (ORCPT ); Thu, 19 Apr 2018 23:43:02 -0400 X-UUID: 1db965937d504fe59e61249bca3ef203-20180420 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1813843975; Fri, 20 Apr 2018 11:42:56 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 20 Apr 2018 11:42:54 +0800 Received: from [172.21.77.33] (172.21.77.33) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Fri, 20 Apr 2018 11:42:54 +0800 Message-ID: <1524195774.26454.1.camel@mtkswgap22> Subject: Re: [PATCH v1 4/7] soc: mediatek: reuse regmap_read_poll_timeout helpers From: Sean Wang To: Matthias Brugger CC: , , , , , , , , , "Ulf Hansson" , Weiyi Lu Date: Fri, 20 Apr 2018 11:42:54 +0800 In-Reply-To: <6fd85b96-f076-36c7-8ff4-8e8ed252edb2@gmail.com> References: <2f84f7695ea3223b8626a8369aa4ae5e0d03fdce.1522736996.git.sean.wang@mediatek.com> <6fd85b96-f076-36c7-8ff4-8e8ed252edb2@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2018-04-19 at 12:23 +0200, Matthias Brugger wrote: > > On 04/03/2018 09:15 AM, sean.wang@mediatek.com wrote: > > From: Sean Wang > > > > Reuse the common helpers regmap_read_poll_timeout provided by Linux core > > instead of an open-coded handling. > > > > Signed-off-by: Sean Wang > > Cc: Matthias Brugger > > Cc: Ulf Hansson > > Cc: Weiyi Lu > > --- > > drivers/soc/mediatek/mtk-infracfg.c | 45 +++++++++---------------------------- > > 1 file changed, 10 insertions(+), 35 deletions(-) > > > > diff --git a/drivers/soc/mediatek/mtk-infracfg.c b/drivers/soc/mediatek/mtk-infracfg.c > > index 8c310de..b849aa5 100644 > > --- a/drivers/soc/mediatek/mtk-infracfg.c > > +++ b/drivers/soc/mediatek/mtk-infracfg.c > > @@ -12,6 +12,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > #include > > @@ -37,7 +38,6 @@ > > int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, > > bool reg_update) > > { > > - unsigned long expired; > > u32 val; > > int ret; > > > > @@ -47,22 +47,11 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, > > else > > regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask); > > > > - expired = jiffies + HZ; > > + ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1, > > + val, (val & mask) == mask, 10, > > + jiffies_to_usecs(HZ)); > > To align with the changes in scpsys, please define MTK_POLL_DELAY_US and > MTK_POLL_TIMEOUT. I'm not really fan of passing macros as function arguments. > Agreed on. will have an improve on it thanks! > Other then that, the patch looks good. > > Thanks a lot, > Matthias > > > > > - while (1) { > > - ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val); > > - if (ret) > > - return ret; > > - > > - if ((val & mask) == mask) > > - break; > > - > > - cpu_relax(); > > - if (time_after(jiffies, expired)) > > - return -EIO; > > - } > > - > > - return 0; > > + return ret; > > } > > > > /** > > @@ -80,30 +69,16 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask, > > int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask, > > bool reg_update) > > { > > - unsigned long expired; > > int ret; > > + u32 val; > > > > if (reg_update) > > regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0); > > else > > regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask); > > > > - expired = jiffies + HZ; > > - > > - while (1) { > > - u32 val; > > - > > - ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val); > > - if (ret) > > - return ret; > > - > > - if (!(val & mask)) > > - break; > > - > > - cpu_relax(); > > - if (time_after(jiffies, expired)) > > - return -EIO; > > - } > > - > > - return 0; > > + ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1, > > + val, !(val & mask), 10, > > + jiffies_to_usecs(HZ)); > > + return ret; > > } > >