Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6150603iog; Thu, 23 Jun 2022 12:23:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcdNJhnY9RCD7dm0/2hY1MvAq8iTbBFpd2djFvUZ8i7bbzjTd39d42v9+jlBZ7lASNE1TV X-Received: by 2002:aa7:9470:0:b0:525:4214:bd9e with SMTP id t16-20020aa79470000000b005254214bd9emr11997081pfq.11.1656012211051; Thu, 23 Jun 2022 12:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656012211; cv=none; d=google.com; s=arc-20160816; b=DXslQvIw/Nwt21ClNNJvNoZzmiRlITUc48YER4fWwZR0xAqjWT2e22hgIZ5MT0jD06 mT/W9NXJJBu0D6rVeUde8WwIueQ2+C2PKKBASfrtsrQHLp3Ta0/wcXsOn3lKunNhVdEG GbX8wHInvUSZba2DFwJU8FxQI2aCldVPJmpvNE8Rudo07jebPxOSW6FTAy+TRFfyjVnz B2fzT8APDdSdiwwthBSGR9fppPeGZK5IiWLy451KNggLAw8A4TiH5NcSgO8CVj7zS0Tu ZSAXEAJJaXnKiLRUnQqMyYOTj7XqmLatCqPw4DTp+5jgrF6/X2zK+NXvIBRde96CmarN 04MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=WFXpnCRvpVBhsuNFE1ahfBGJsqNDQt8dQxVvfN6MrL0=; b=WQVA6gX14QdfemoKvc5u3bt1v4tn+OqKhuhm9iI4Xa47j3ZbzD08k7DHFGGyMw+oDL +INjhgxo4EAO2VD9K6Tx9Mku32JhZ4OjRifH7UIu8aO3iIBTt/ApEoro5NVPEch+zwRI TFdvPxmL/9u2qhYRTfwM7oWvzcZvj4J/sU2cYbm7ezIvhjx0BAK7tacO5N+yC8dZKqCE HxkmXMSjhUHsxXfazXtm1MIzB+Tu/gJRZY9GhaPoE2uQI6MHjmiYy1PskguIE56+WFBo LqZfM6xtbylwu12zVn/Ohjro3i29cICUMjMo3rCS6ziVDNaUx5p1UuKFkNeskTBBuuXM 39hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DalKGI6l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a056a001a8900b0052559f96fcfsi30235pfv.121.2022.06.23.12.23.18; Thu, 23 Jun 2022 12:23:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DalKGI6l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229689AbiFWTWB (ORCPT + 99 others); Thu, 23 Jun 2022 15:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbiFWTVr (ORCPT ); Thu, 23 Jun 2022 15:21:47 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B258B6F7AA; Thu, 23 Jun 2022 11:26:26 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id y32so411183lfa.6; Thu, 23 Jun 2022 11:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WFXpnCRvpVBhsuNFE1ahfBGJsqNDQt8dQxVvfN6MrL0=; b=DalKGI6li9osCh4k7iO37g3v5OUCWoMlA9lcg8wxp3/qi5HIMenhTTdp7lkfmkxaFO 5i56DaW7feuRINiq2kOC05AY8brpkmge87NEOdDGkcHQCABHBrM/lR06xLa/uYNXD2JN HByhcVabc+qx2jAze76QRQrmHqJQ43fznNb6YOxVQdupQu3sbTr5FFXwdhK74fJl0jvb eciLddbEjTkpfnvpSmNtkeUy899xl8kuFlza0mCjMLlY6mqMYFafWfL0HXdzY9mmrBbl tiYMDiQrKJpSB3DVDSB21zZOwwu+OGmacE6r0lbpRpEmfZUo1aV2LD7kFZYuIORe47QB 7iCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WFXpnCRvpVBhsuNFE1ahfBGJsqNDQt8dQxVvfN6MrL0=; b=Pk4aFqbqHFxJM4s7fjWgDh/2A56Pbgd7uqPafsCkYc+YREYX+rofmacP899CZnHNpw tCavvCU03cURBjJ7shDSXIzbfVsY0L15A2kLBR8okQd141s8/Xyja+x3KgT2YAhOXC38 q+6gjpJxRPL0DLxrBvwYufDhbGHapX/zcZ2lX9SCtFK1LvGxizGNaIGQ7N/Rvn52wCha 417ZlrOfUKgDzsr7ZDOdh1eILtCGAevLaOyIK5t20z7k4lh0w4d44TcCJRbR8yXIno8R KUsfJCpd5ldiB13AGH1e/krhZcsmAIdjg9KDlr3DDTzke+djVtLIlXQSdDDs1ZxlZ39M a2Lg== X-Gm-Message-State: AJIora+diopr+Nkvc+HhJFbovcYlqqVGen9hytmQZGqtbGeRdC8IqGpF yTIORdhemwgh7T2aCDG83IoaonO45W0rjyx5I4I= X-Received: by 2002:a05:6512:348f:b0:47f:8b25:e9f9 with SMTP id v15-20020a056512348f00b0047f8b25e9f9mr6543451lfr.512.1656008785046; Thu, 23 Jun 2022 11:26:25 -0700 (PDT) MIME-Version: 1.0 References: <20220623115631.22209-1-peterwu.pub@gmail.com> <20220623115631.22209-11-peterwu.pub@gmail.com> In-Reply-To: <20220623115631.22209-11-peterwu.pub@gmail.com> From: Andy Shevchenko Date: Thu, 23 Jun 2022 20:25:48 +0200 Message-ID: Subject: Re: [PATCH v3 10/14] iio: adc: mt6370: Add Mediatek MT6370 support To: ChiaEn Wu Cc: Lee Jones , Daniel Thompson , Jingoo Han , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Matthias Brugger , Sebastian Reichel , Chunfeng Yun , Greg Kroah-Hartman , Jonathan Cameron , Lars-Peter Clausen , Liam Girdwood , Mark Brown , Guenter Roeck , "Krogerus, Heikki" , Helge Deller , chiaen_wu@richtek.com, alice_chen@richtek.com, cy_huang , dri-devel , Linux LED Subsystem , devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Linux PM , USB , linux-iio , "open list:FRAMEBUFFER LAYER" , szuni chen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 23, 2022 at 2:00 PM ChiaEn Wu wrote: > > From: ChiaEn Wu > > Add Mediatek MT6370 ADC support. ... > +config MEDIATEK_MT6370_ADC > + tristate "Mediatek MT6370 ADC driver" > + depends on MFD_MT6370 > + help > + Say yes here to enable Mediatek MT6370 ADC support. > + > + This ADC driver provides 9 channels for system monitoring (charger > + current, voltage, and temperature). What will be the module name? ... > +#include Usually this goes after linux/* asm/* as it's not so generic. > +#include > +#include > +#include > +#include > +#include > +#include I believe the order should be otherwise, this is first followed by module.h. > +#include > +#include > +#include ... > +#define ADC_CONV_POLLING_TIME 1000 If it's time, add a unit suffix, if it's a counter, make it clear. ... > + msleep(ADC_CONV_TIME_US / 1000); Why define microseconds if milliseconds are in use? ... > + ret = regmap_read_poll_timeout(priv->regmap, > + MT6370_REG_CHG_ADC, reg_val, > + !(reg_val & MT6370_ADC_START_MASK), > + ADC_CONV_POLLING_TIME, > + ADC_CONV_TIME_US * 3); > + if (ret) { > + if (ret == -ETIMEDOUT) > + dev_err(priv->dev, "Failed to wait ADC conversion\n"); wait for > + else > + dev_err(priv->dev, > + "Failed to read ADC register (%d)\n", ret); Do you really need to differentiate the errors here? I believe the latter one covers all cases. > + goto adc_unlock; > + } ... > +#define MT6370_ADC_CHAN(_idx, _type, _addr, _extra_info) { \ > + .type = _type, \ > + .channel = MT6370_CHAN_##_idx, \ > + .address = _addr, \ > + .scan_index = MT6370_CHAN_##_idx, \ > + .indexed = 1, \ > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ > + BIT(IIO_CHAN_INFO_SCALE) | \ > + _extra_info \ Leave a comma after the last member as well. > +} ... > + regmap = dev_get_regmap(pdev->dev.parent, NULL); > + if (!regmap) { > + dev_err(&pdev->dev, "Failed to get regmap\n"); > + return -ENODEV; return dev_err_probe(...); > + } ... > + ret = regmap_write(priv->regmap, MT6370_REG_CHG_ADC, 0); > + if (ret) { > + dev_err(&pdev->dev, "Failed to reset ADC\n"); > + return ret; > + } Ditto. -- With Best Regards, Andy Shevchenko