Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2197490rwb; Sun, 4 Sep 2022 10:17:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR5f0WRT+WjG32OmIPhCP5LzDBS0I33Ne5wdiaZRm8A2neB+Py/SCNxb/LiJPeszRPH5vRUS X-Received: by 2002:a17:907:2cd3:b0:741:550e:17ea with SMTP id hg19-20020a1709072cd300b00741550e17eamr25692275ejc.595.1662311840232; Sun, 04 Sep 2022 10:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662311840; cv=none; d=google.com; s=arc-20160816; b=K7dEfa3zGYmbCD8XzsqnduLNQrh1G89UbiXrHJhFv1+wqu/GgZkX6K+OVTAqHXMmo8 YmDOtVodJrKuoVlUDZCoKELgnA5Ge/O1Y8A36XnDoWLLTWjzbpQmKPqV1dhIJWSUvu42 r6e7SI8MHUJvzTTD0T998MpZ451u5ADj7o+PJR7OSXtVuZxQ+jAwqcIf3V6hyfMjZvZp HYRrngO/vJb0lfIJJOe637Hc7V4BGE7EcYNLBgPXgqPbPjgjXkHCZnfTsR6GbmNQbf/W e4PlaM8aMJJ7aCfXcA9/dH5iP59kWJaq5TQceoQXwZKsZ4FgkpPbPNx53mTATRrlMxCu IQhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=UuF6oVt+O9KhBeBUE54yj9awK8MXemdhw4EFVWZc8dw=; b=v/Z9HH301MPhorBBt3tjxRHYQbkHu7tP5UX4MWtpZVvPNRKU9LqBA7WO0xMM0fr5u2 tRT/qVdQltQeFGwDtz4cCWmeJb3yYxqh4wRkmhwhQgm8KMO0Xj6fuSu/qZy9q9dVYEp7 Ny2cyQEdNcF2ywf4JGRXjAsK2PftEe37EU9ZLV+kkU72+QHwG7NC/Yvj6CnwwTChqEhr jfg8I5Xrjbb5LzC9Ks9Dvpe/e8D44JrSA8WdcPJ7AwS3FRi7xoM+nQAwsMSGU4J33nvT DW/9nPBi2UQzBMLVN4XQ9+WehqWnCb2HK5Qse2Z1vZh4LHotw0oggv4llJG0B5/EFV/s ICzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ETSoUTRj; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kl6-20020a170907994600b0072b3a874867si5441719ejc.874.2022.09.04.10.16.53; Sun, 04 Sep 2022 10:17:20 -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=@kernel.org header.s=k20201202 header.b=ETSoUTRj; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234831AbiIDQYP (ORCPT + 99 others); Sun, 4 Sep 2022 12:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbiIDQYN (ORCPT ); Sun, 4 Sep 2022 12:24:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E2D2B24A; Sun, 4 Sep 2022 09:24:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6047E60FBA; Sun, 4 Sep 2022 16:24:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34B2CC433C1; Sun, 4 Sep 2022 16:24:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662308651; bh=Fgi+BWHxbNWiNdG7x4Mm65WAraxJfue1KVA/T2Rwyes=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ETSoUTRjU1mbLPx/2RKkBt6uUHrHIN0haXltanrHFm+CfADCmheCfxIOEipqTFu+v qPwYX/maVPpCLaR2I1MoOBgoIjWZaLI81wF/guWSToVSLGEI+vmjBTl2Utph28NH18 P7CjhPQljPVtHD3ili1EP5KAiaP+DkxNWI5OhcUdKLGm6LdV5xlM5ZiEFTc3mPUGnU nlX71sGGTG3SPPFJojrAPRbUJMaWvdz1VQAa9e5GlDyd4xkFr+Qy86otEMvf+NcyFA E9D+HngE49dsOX3/gYRxRj2AnSwmN08Ip5zPEQtYgrNyguNeVTpzgRavEnjDcWUpiW JJ2Vtd1s2k/kA== Date: Sun, 4 Sep 2022 16:50:03 +0100 From: Jonathan Cameron To: Ramona Bolboaca Cc: , , , , Subject: Re: [PATCH v2 2/2] iio: adc: add max11205 adc driver Message-ID: <20220904165003.192d5030@jic23-huawei> In-Reply-To: <20220831133021.215625-2-ramona.bolboaca@analog.com> References: <20220831133021.215625-1-ramona.bolboaca@analog.com> <20220831133021.215625-2-ramona.bolboaca@analog.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Wed, 31 Aug 2022 16:30:21 +0300 Ramona Bolboaca wrote: > Adding support for max11205 16-bit single-channel ultra-low power > delta-sigma adc. > The MAX11205 is compatible with the 2-wire interface and uses > SCLK and RDY/DOUT for serial communications. In this mode, all > controls are implemented by timing the high or low phase of the SCLK. > The 2-wire serial interface only allows for data to be read out through > the RDY/DOUT output. > > Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX11205.pdf > Signed-off-by: Ramona Bolboaca Given the requested changes below and those from Andy and Kryzstof are minor, I'll just tweak them whilst applying. Diff for this patch was below. The long line for chip_info is a bit ugly but not too bad... diff --git a/drivers/iio/adc/max11205.c b/drivers/iio/adc/max11205.c index 68e6082e70e5..fc90fed81eb6 100644 --- a/drivers/iio/adc/max11205.c +++ b/drivers/iio/adc/max11205.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * max11205 16-Bit Delta-Sigma ADC + * Maxim MAX11205 16-Bit Delta-Sigma ADC * * Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1240-max11205.pdf * Copyright (C) 2022 Analog Devices, Inc. @@ -19,20 +19,20 @@ #define MAX11205A_OUT_DATA_RATE 116 #define MAX11205B_OUT_DATA_RATE 13 -enum chip_type { +enum max11205_chip_type { TYPE_MAX11205A, TYPE_MAX11205B, }; -struct chip_info { +struct max11205_chip_info { unsigned int out_data_rate; const char *name; }; struct max11205_state { - const struct chip_info *chip_info; - struct regulator *vref; - struct ad_sigma_delta sd; + const struct max11205_chip_info *chip_info; + struct regulator *vref; + struct ad_sigma_delta sd; }; static const struct ad_sigma_delta_info max11205_sigma_delta_info = { @@ -81,12 +81,12 @@ static const struct iio_chan_spec max11205_channels[] = { .endianness = IIO_BE }, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_SAMP_FREQ) | - BIT(IIO_CHAN_INFO_SCALE), + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_SCALE), }, }; -static const struct chip_info max11205_chip_info[] = { +static const struct max11205_chip_info max11205_chip_info[] = { [TYPE_MAX11205A] = { .out_data_rate = MAX11205A_OUT_DATA_RATE, .name = "max11205a", @@ -117,9 +117,9 @@ static int max11205_probe(struct spi_device *spi) ad_sd_init(&st->sd, indio_dev, spi, &max11205_sigma_delta_info); st->chip_info = device_get_match_data(&spi->dev); - if (!st->chip_info) - st->chip_info = (const struct chip_info *)spi_get_device_id(spi)->driver_data; + st->chip_info = + (const struct max11205_chip_info *)spi_get_device_id(spi)->driver_data; indio_dev->name = st->chip_info->name; indio_dev->modes = INDIO_DIRECT_MODE; > --- > changes in v2: > - add chip_info null pointer check > - add support for probing with ACPI table > - remove function for module removal > - remove irq flag from max11205_sigma_delta_info > - add missing commas and missing spaces > - remove redundant blank line > - wrap text to 75-80 chars > - removed typos in commit message > drivers/iio/adc/Kconfig | 14 +++ > drivers/iio/adc/Makefile | 1 + > drivers/iio/adc/max11205.c | 183 +++++++++++++++++++++++++++++++++++++ > 3 files changed, 198 insertions(+) > create mode 100644 drivers/iio/adc/max11205.c > > +enum chip_type { > + TYPE_MAX11205A, > + TYPE_MAX11205B, > +}; > + > +struct chip_info { > + unsigned int out_data_rate; > + const char *name; > +}; Prefix these enums and structures with max11205. They have very generic names, so it's definitely possible that something with the same name might be added to a header included by this driver > + > +struct max11205_state { > + const struct chip_info *chip_info; > + struct regulator *vref; > + struct ad_sigma_delta sd; > +}; > + > +static const struct iio_chan_spec max11205_channels[] = { > + { > + .type = IIO_VOLTAGE, > + .indexed = 1, > + .scan_type = { > + .sign = 's', > + .realbits = 16, > + .storagebits = 16, > + .endianness = IIO_BE > + }, > + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | > + BIT(IIO_CHAN_INFO_SAMP_FREQ) | Code editors always get confused on these, but please add an indent to this line and the next one. Either align it with the BIT() above, or just push it in one tab. > + BIT(IIO_CHAN_INFO_SCALE), > + }, > +};