Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1973095iog; Sun, 19 Jun 2022 04:01:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1umUlEbxcHZPrM1MHX4FU4BF4atmN0kjyB4ARpBu05kc5b/+vw1Fs/vul8GisaGzI367noO X-Received: by 2002:a17:907:1310:b0:709:bfa:4f3e with SMTP id vj16-20020a170907131000b007090bfa4f3emr16634858ejb.589.1655636500665; Sun, 19 Jun 2022 04:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655636500; cv=none; d=google.com; s=arc-20160816; b=TXRa9EOaaZYLbYkd2d5kGEhUFEd1/ql7D98QoZa3PFkzMiy1gF3oWpixJyBuleut6X TNaYSnebc6VspI/Wutgt4jV1MN5Zn0qtXellxipopad+KFHcsyDRdFd5Zgr+Oh5vmdQq wJRhoG9zGme1yy7onSVenUrTBIwBgQtQNzSLGdYhxOc8O1Xkv+MJRYX1KFaPC8adTu9U ZNdIUVb8V/M6QLTEZoE/OGHXIwP7Llizp/UuBgftZHz5wKTDWMX90vzYyNdwLf0G8QUR E6q2mZ6D124iYHarD/WgwW35nRa4g/wyg/pOB94zLVYL4urtOiPRcLL5iAKqajxkoIjD 1Ifw== 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=m0ywi20rvMwf+A69ukm4ilfE8YyNyi5FpOBHrhUncaw=; b=BwEnWRAyk436vkwV41hoAWU8CDcmw/NON9ghm9AgMBHpxSTvsbiInJYk3PKx7LpE52 57sFElmcKBaAo+iKKC0K1ZLj5x5EmfxL/Kd2LYPuqc0YdwY5eNZM5eUJGGnp5XtdrhdW TSV7LuUqxZAoxImmEwvW+/6doMt+dFDXiqSCCYXLSPt7s53/t3hG2KB0JVv3Q1a4yIyA rYp0cgeQF5WzKZLSHHi9zfXMtGcnRohKOfsr8CigWnBs7d/bvlchPx0atFuaIBVKQXLo fVnGmgMJsdFNm+ds10VMVvkqi/TjEAj/5II0ZLumhxZ7+dOL8qTNVu4ZEg+U1A23p3CL IQTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GgDe22l8; 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 ds16-20020a170907725000b006fed9a4632csi10461554ejc.66.2022.06.19.04.01.13; Sun, 19 Jun 2022 04:01:40 -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=GgDe22l8; 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 S235421AbiFSK4X (ORCPT + 99 others); Sun, 19 Jun 2022 06:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231238AbiFSK4V (ORCPT ); Sun, 19 Jun 2022 06:56:21 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 527A69594; Sun, 19 Jun 2022 03:56:19 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id fd6so8724204edb.5; Sun, 19 Jun 2022 03:56:19 -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=m0ywi20rvMwf+A69ukm4ilfE8YyNyi5FpOBHrhUncaw=; b=GgDe22l8dWchMEZivxKCfNnrK3RMHQzpIOUH/cLZX99uGyOuj9FedzgCkDKtnzCAgL PPIpPLnjvAjJjF5tXNw70id9LeCLdDuJgovbQ9c8/FhEdFgda4ca+CjuqXFgaMlQLVEc t8zW3pdf8llLHbVepVISWOJrgYY8/LWQa69pyu3Z0ja78Khz7AtV4te8thHdld7xfa9U DOxG0WyksvGVrqDWi7LP55yTbAXi0oTEuc79yCfT9Nmnu2EZe3cdXMWN/DcbGplCWmWS LVpmYK6NJdiM27S23BwdzKpMrwNmgCBWSUaCxaOxFKwIJztxgw6kSBuyZCmHE3/C4JOu oaLw== 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=m0ywi20rvMwf+A69ukm4ilfE8YyNyi5FpOBHrhUncaw=; b=JcnavkxbAHHFac7EMECKvcDAWIwdL2ImbzlOQgpFanBezI7vMKaazhK3aEBNk5QllS vgebwnGFHkL/ErteJ8IwrZIYY3BCNxRb5bvc49v7JsiENIiIRNjk8sQPEhRwOjDa3qCP n4CkXCQLpBDXBq6zoa2wnW6PScZCUVPNlQ7In9q61Zy8FfS8xokoRknn0EZTYugdu0iw QwhAsH0jG/g+h5yoYV2b1+fTzpoohwy3LGfKl5HzkwI0sM5o0TdboD/bpcRB1hw0zy5I l1R1PullBafkBhQvrWcActxoy6KaImdb3//hgOieqx1i/NJ5gkBo4+IS2iFnQBa0broy /QWw== X-Gm-Message-State: AJIora8IveTRoxvlAPgRznP52Y922Svzx+rvndMOXXRVpveYg+CHD1da RjQyMQkk250ZPr7boH4i8ATsln1Yrtt69hrDFRY= X-Received: by 2002:a05:6402:11d2:b0:42d:e68a:eae0 with SMTP id j18-20020a05640211d200b0042de68aeae0mr23095268edw.111.1655636177910; Sun, 19 Jun 2022 03:56:17 -0700 (PDT) MIME-Version: 1.0 References: <20220618214009.2178567-1-aidanmacdonald.0x0@gmail.com> <20220618214009.2178567-12-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220618214009.2178567-12-aidanmacdonald.0x0@gmail.com> From: Andy Shevchenko Date: Sun, 19 Jun 2022 12:55:41 +0200 Message-ID: Subject: Re: [PATCH v3 11/16] iio: adc: axp20x_adc: Add support for AXP192 To: Aidan MacDonald Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Chen-Yu Tsai , Jonathan Cameron , Lee Jones , Sebastian Reichel , Mark Brown , Greg Kroah-Hartman , Liam Girdwood , Lars-Peter Clausen , "Rafael J. Wysocki" , quic_gurus@quicinc.com, Sebastian Reichel , Michael Walle , "open list:GPIO SUBSYSTEM" , devicetree , Linux Kernel Mailing List , linux-iio , Linux PM 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 Sat, Jun 18, 2022 at 11:40 PM Aidan MacDonald wrote: > > The AXP192 is identical to the AXP20x, except for the addition of > two more GPIO ADC channels. ... > +static int axp192_write_raw(struct iio_dev *indio_dev, > + struct iio_chan_spec const *chan, int val, int val2, > + long mask) > +{ > + struct axp20x_adc_iio *info = iio_priv(indio_dev); > + unsigned int regmask, regval; > + > + /* > + * The AXP192 PMIC allows the user to choose between 0V and 0.7V offsets > + * for (independently) GPIO0-3 when in ADC mode. > + */ > + if (mask != IIO_CHAN_INFO_OFFSET) > + return -EINVAL; > + > + if (val != 0 && val != 700000) > + return -EINVAL; > + regval = val ? 1 : 0; > + As per comment against the previous patch use !!val directly? > + switch (chan->channel) { > + case AXP192_GPIO0_V: > + regmask = AXP192_GPIO30_IN_RANGE_GPIO0; > + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO0, regval); > + break; > + > + case AXP192_GPIO1_V: > + regmask = AXP192_GPIO30_IN_RANGE_GPIO1; > + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO1, regval); > + break; > + > + case AXP192_GPIO2_V: > + regmask = AXP192_GPIO30_IN_RANGE_GPIO2; > + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO2, regval); > + break; > + > + case AXP192_GPIO3_V: > + regmask = AXP192_GPIO30_IN_RANGE_GPIO3; > + regval = FIELD_PREP(AXP192_GPIO30_IN_RANGE_GPIO3, regval); > + break; > + > + default: > + return -EINVAL; > + } > + > + return regmap_update_bits(info->regmap, AXP192_GPIO30_IN_RANGE, regmask, regval); > +} -- With Best Regards, Andy Shevchenko