From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90D1EC61DB3 for ; Tue, 10 Jan 2023 18:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235074AbjAJSxp (ORCPT ); Tue, 10 Jan 2023 13:53:45 -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 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; > +};