Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6814762rdb; Fri, 15 Dec 2023 09:01:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbxCVRGFn14yI9LXO4Q7EIycTL21l8cZclfWlGd+u0LVw+9vUho77vN7NQ6eKV0yQhC6K6 X-Received: by 2002:a17:906:10cb:b0:a1f:99e1:8a65 with SMTP id v11-20020a17090610cb00b00a1f99e18a65mr3480055ejv.155.1702659682291; Fri, 15 Dec 2023 09:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702659682; cv=none; d=google.com; s=arc-20160816; b=XvMGC/AHAi1ZmzZhxtTK+E0pOoA/Hx02L6WiV7Yf8guU8m+vHkiOosz9TaBWoWZaXB stIdk+kTk75Gda0ovdQqAynrNAsLdO6fZMwxl8nhXTLz/YQkiRIMTAT7Zq7WXzcexn4T N+Wv/E5XnKeamIp7amyCmCr9AKCCA0RgJj99oes7rMDNiEIgjVIVF4Qh5Bm1YlK+QgwR 9y+nS/CrtFkWcZpO3xlm7p12hQcVr+HfkyCQmg8Hi/aoEfFqU9VCchjl40FS9BglU0rl luSTQRdIJGdGVZoHf5b+y8ZisKUEyz0zWq/x/5I0EuDhbiDXLgBr1rdcca4dh4HPeUN5 ycTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=yYjHwcm5ONKKp2t/E2nQ5jgkSu+ukJ4Ae0Z81VV/l5U=; fh=Rc77zGtzOclKmr4VRKF142VfDYujib7RMbyqYak6svM=; b=GnF6ciJ/E5zP7ukose2KTPqzEDzTRcp2sp0ixoLw2Xrm7iwlH2Vqm0AebCIE01bIFm JrD3ynIhM3yxDzOigmu+PDWDNHdS/sxFXDlt00CA2xDqBc2skerAB5mGs93eUtMmYoWa PxSiRHTx4w6EdAFYiYBVTBASmXgQAzkzfcF+koShRd++A8e5gSBalKpYINfMDqFOUVdy sot1nu1Bhxave4FqR3Y5dr0W5OO/QFGV0rQCZ8ZK1Z1cJU1laG7t+Jsy2Srj+hvVlnyQ +e/KkrS0S0FW7k1nGGKLXiW1mBaDgx1Uasi3+2Vx7DP6hUwH6dsMG2gck8jb8t/tljLs RvPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=UGfEXITT; spf=pass (google.com: domain of linux-kernel+bounces-1344-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1344-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id mm12-20020a170906cc4c00b00a1f8926ae25si5766331ejb.745.2023.12.15.09.01.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:01:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1344-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=UGfEXITT; spf=pass (google.com: domain of linux-kernel+bounces-1344-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1344-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id AA8C61F254BD for ; Fri, 15 Dec 2023 17:01:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B16A93EA90; Fri, 15 Dec 2023 17:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="UGfEXITT" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD2033EA74 for ; Fri, 15 Dec 2023 17:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from [192.168.1.18] ([92.140.202.140]) by smtp.orange.fr with ESMTPA id EBR6rmv31emNIEBR6rInmB; Fri, 15 Dec 2023 17:53:17 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1702659197; bh=yYjHwcm5ONKKp2t/E2nQ5jgkSu+ukJ4Ae0Z81VV/l5U=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=UGfEXITTxE+pPRmAIu4Gbf5iCKKwO9WC9yJDTyvNy1c8Trpi3n/Cod/yWv3CZLx0q AJ9N0QRSrW3JAN8Az4HbSI8H+WFAyOFgjdR0gbuVHiiul17M/98TmXDgIidX+z4zF/ TP2t0gk7J/JKSUsoehFD+MMQsDwCgz/tNH0TzCoAiKzVxGz6ClX4wKa3iRINQEjgK4 OudbrKVOcg58kNynTqM/Wy97jwahCKZapZHCn/LyqYct+orJM8NRM5ew+ndtvD4MRv 8/rf6AuYeDSctx7feQC0fi0/Ob7Y1JyY+nct8hOpX+yitz4oklMvQAHutxVc4E+aZt /KPbT6UKIzqJQ== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 15 Dec 2023 17:53:17 +0100 X-ME-IP: 92.140.202.140 Message-ID: <66e9fe7a-927b-465f-aafe-8aea0e5998a4@wanadoo.fr> Date: Fri, 15 Dec 2023 17:53:16 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] iio: adc: ad7380: new driver for AD7380 ADCs To: dlechner@baylibre.com Cc: broonie@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org, jic23@kernel.org, krzysztof.kozlowski+dt@linaro.org, lgirdwood@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, michael.hennerich@analog.com, nuno.sa@analog.com, robh+dt@kernel.org, stefan.popa@analog.com References: <20231215-ad7380-mainline-v3-0-7a11ebf642b9@baylibre.com> <20231215-ad7380-mainline-v3-3-7a11ebf642b9@baylibre.com> Content-Language: fr From: Christophe JAILLET In-Reply-To: <20231215-ad7380-mainline-v3-3-7a11ebf642b9@baylibre.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 15/12/2023 à 11:32, David Lechner a écrit : > This adds a new driver for the AD7380 family ADCs. > > The driver currently implements basic support for the AD7380, AD7381, > AD7383, and AD7384 2-channel differential ADCs. Support for additional > single-ended and 4-channel chips that use the same register map as well > as additional features of the chip will be added in future patches. > > Co-developed-by: Stefan Popa > Signed-off-by: Stefan Popa > Reviewed-by: Nuno Sa > Signed-off-by: David Lechner > --- ... > +static void ad7380_regulator_disable(void *p) > +{ > + regulator_disable(p); > +} > + > +static int ad7380_probe(struct spi_device *spi) > +{ > + struct iio_dev *indio_dev; > + struct ad7380_state *st; > + int ret; > + > + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); > + if (!indio_dev) > + return -ENOMEM; > + > + st = iio_priv(indio_dev); > + st->spi = spi; > + st->chip_info = spi_get_device_match_data(spi); > + if (!st->chip_info) > + return dev_err_probe(&spi->dev, -EINVAL, "missing match data\n"); > + > + st->vref = devm_regulator_get_optional(&spi->dev, "refio"); Hi, devm_regulator_get_enable_optional()? to save some LoC below and ad7380_regulator_disable() CJ > + if (IS_ERR(st->vref)) { > + /* > + * If there is no REFIO supply, then it means that we are using > + * the internal 2.5V reference. > + */ > + if (PTR_ERR(st->vref) == -ENODEV) > + st->vref = NULL; > + else > + return dev_err_probe(&spi->dev, PTR_ERR(st->vref), > + "Failed to get refio regulator\n"); > + } > + > + if (st->vref) { > + ret = regulator_enable(st->vref); > + if (ret) > + return ret; > + > + ret = devm_add_action_or_reset(&spi->dev, ad7380_regulator_disable, > + st->vref); > + if (ret) > + return ret; > + } > + > + st->regmap = devm_regmap_init(&spi->dev, NULL, st, &ad7380_regmap_config); > + if (IS_ERR(st->regmap)) > + return dev_err_probe(&spi->dev, PTR_ERR(st->regmap), > + "failed to allocate register map\n"); > + > + indio_dev->channels = st->chip_info->channels; > + indio_dev->num_channels = st->chip_info->num_channels; > + indio_dev->name = st->chip_info->name; > + indio_dev->info = &ad7380_info; > + indio_dev->modes = INDIO_DIRECT_MODE; > + indio_dev->available_scan_masks = ad7380_2_channel_scan_masks; > + > + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, > + iio_pollfunc_store_time, > + ad7380_trigger_handler, NULL); > + if (ret) > + return ret; > + > + ret = ad7380_init(st); > + if (ret) > + return ret; > + > + return devm_iio_device_register(&spi->dev, indio_dev); > +} ...