Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8286801rwl; Tue, 10 Jan 2023 11:20:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXtipjVlghohi1fq52/B9UEqWpxi+7Hv4u5DtZ8AjhvOoh80xfyErkQ9MOj+c1dWQgtJ3NWG X-Received: by 2002:a17:902:ab1e:b0:193:17b7:7909 with SMTP id ik30-20020a170902ab1e00b0019317b77909mr12651640plb.5.1673378404351; Tue, 10 Jan 2023 11:20:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673378404; cv=none; d=google.com; s=arc-20160816; b=BAeezsIyEs69WcfPYOSCCvfBjgfkklJBE6Xq+oO6eeGX/rREjNaf9inRU0Y/db0o5K JsngKtjg1qM45Ej0v9N82xmVq5xOakYOMwRpjkfFx6mzxPXgvqcfe+w7tHcFhdHTcSD7 879/Az0XiKSrj0tZ23F43AbO1Lj+tzZxz+vIv1vbBK0Z6NX55EojWHPW6maKlJC4lqS3 z2wElLIbPiZrly/6968SKJASCy57+cJL40kLmn0Rnn2bGpAuCGl6ihkMkbJP5ueH/20P rNgMXl6UM49Fq1RUaJnlYd3c9s5rQ7igXVbtVOPqUtlU6l9qkJc6rSfiJkJXcMtgg6Iy K1bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=J/tcOBXj+UqI4MR38Fcmx27Tq0y9qwgrxOaolAB5az0=; b=vpJ/nc2PBiZTyTLuY89U0vXiatGuaJkssh5WFXptfU8pDYg2B5FhIJsnQCJVGNGPdr nOjfGfW3FSNIznxCkF4mQXQQvnmQw6SJwbacudDjFIsiV67/oF/tXrgractc07N8eJDx SOgznoPmH3X7s5+LKqCRoR69wtJx0tjtFlnCTJmjwyBg8P6YS6ShJ4mHmIfAHIMsFuwX ByV5yDi2bfL2M8tgss1B4nJ1WSWLoWHvLy7jlXWFQsnk/SBG4u7Os/7fZFZgJxtBpM5g j2h6w9ydLXlhgqIjowK61DO/pEldkwWcau4hyIIVwXvHvRqPN0U2yMeD5DiQU6GV1Qb6 gDLA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a170902e74400b001897e34ac5dsi12663915plf.289.2023.01.10.11.19.57; Tue, 10 Jan 2023 11:20:04 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235066AbjAJSxo (ORCPT + 53 others); Tue, 10 Jan 2023 13:53:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239763AbjAJSxL (ORCPT ); Tue, 10 Jan 2023 13:53:11 -0500 Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0125326CF for ; Tue, 10 Jan 2023 10:50:47 -0800 (PST) Received: from [192.168.1.18] ([86.243.100.34]) by smtp.orange.fr with ESMTPA id FJhqp8DrgidowFJhqp2KIp; Tue, 10 Jan 2023 19:50:45 +0100 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 10 Jan 2023 19:50:45 +0100 X-ME-IP: 86.243.100.34 Message-ID: Date: Tue, 10 Jan 2023 19:50:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 1/2] iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver Content-Language: fr To: Hugo Villeneuve , hvilleneuve@dimonoff.com, jic23@kernel.org, lars@metafoo.de, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230110160124.3853593-1-hugo@hugovil.com> <20230110160124.3853593-2-hugo@hugovil.com> From: Christophe JAILLET In-Reply-To: <20230110160124.3853593-2-hugo@hugovil.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS 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 Le 10/01/2023 à 17:01, Hugo Villeneuve a écrit : > From: Hugo Villeneuve > > The Texas Instruments ADS7924 is a 4 channels, 12-bit analog to > digital converter (ADC) with an I2C interface. > > Datasheet: https://www.ti.com/lit/gpn/ads7924 > > Signed-off-by: Hugo Villeneuve > --- Hi, should there be a v3, a few nits below. CJ > MAINTAINERS | 7 + > drivers/iio/adc/Kconfig | 11 + > drivers/iio/adc/Makefile | 1 + > drivers/iio/adc/ti-ads7924.c | 492 +++++++++++++++++++++++++++++++++++ > 4 files changed, 511 insertions(+) > create mode 100644 drivers/iio/adc/ti-ads7924.c > [...] > +static int ads7924_get_channels_config(struct i2c_client *client, > + struct iio_dev *indio_dev) > +{ > + struct ads7924_data *priv = iio_priv(indio_dev); > + struct device *dev = priv->dev; > + struct fwnode_handle *node; > + int num_channels = 0; > + > + device_for_each_child_node(dev, node) { > + u32 pval; > + unsigned int channel; > + > + if (fwnode_property_read_u32(node, "reg", &pval)) { > + dev_err(dev, "invalid reg on %pfw\n", node); > + continue; > + } > + > + channel = pval; > + if (channel >= ADS7924_CHANNELS) { > + dev_err(dev, "invalid channel index %d on %pfw\n", > + channel, node); > + continue; > + } > + > + num_channels++; > + } > + > + if (num_channels > 0) { > + dev_dbg(dev, "found %d ADC channels\n", num_channels); > + return 0; > + } else { > + return -EINVAL; > + } if (num_channels <= 0) return -EINVAL; dev_dbg(dev, "found %d ADC channels\n", num_channels); return 0; is much more usual. > +} > + [...] > +static int ads7924_reset(struct iio_dev *indio_dev) > +{ > + struct ads7924_data *data = iio_priv(indio_dev); > + > + if (data->reset_gpio) { > + gpiod_set_value(data->reset_gpio, 1); /* Assert. */ > + /* Educated guess: assert time not specified in datasheet... */ > + mdelay(100); > + gpiod_set_value(data->reset_gpio, 0); /* Deassert. */ > + } else { > + int ret; having 'ret' near 'struct ads7924_data *data' is more usual and saves 1 LoC. > + > + /* > + * A write of 10101010 to this register will generate a > + * software reset of the ADS7924. > + */ > + ret = regmap_write(data->regmap, ADS7924_RESET_REG, 0b10101010); > + if (ret) > + return ret; > + } > + > + return 0; > +};