Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6839048rdb; Fri, 15 Dec 2023 09:32:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMXuf7zdh5k2nUDl9yO9x/Zd8ukn91s1EnaQIvq6mGqaZz9eDuCWGmAjMGiyfJ9XcBBk7P X-Received: by 2002:a0c:d690:0:b0:67c:ae8:add0 with SMTP id k16-20020a0cd690000000b0067c0ae8add0mr11898487qvi.69.1702661554860; Fri, 15 Dec 2023 09:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702661554; cv=none; d=google.com; s=arc-20160816; b=yLMI+2Z+Z/iATPxTXuobJHRbGj3gln9s2naMaiYAP1S8Nzb5CyWf8pQEd3GZOO4naI 2FZWrsWLCU0ERFcb8Vm7v4Y77VawbIUEg22CbpyUI/O3EXnXBHZpIo/vSMPPe7QsSJOO dreKNmP1IzkQKnEqzyJq1hbIqXziUo41E8ulpZKk9Fsmjkzipcu/QMDPhDy//cQNcrol BiQtkEujCvYENP/R7eXo2PTh8N5den8ExAceS0/VcM4pgYP2RAthP1SESt1apxLPKtkH GGqmh60KoAwqfD8fy3MJhfWHH/uOKNNYKGb2AegkDRcWnYrClkNn5FetaisgvSqbOBBS O9sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=13gliIVcQbLU7hKnOSD6BJq01ueaRAAu4jm5L+NVTns=; fh=tSweTT+g76APrhiRJujiRAznB3vKPX8cifTup2J0tG8=; b=XAjPJ9Qap+g4id9x3CyGYYuFSk9vxS5xLTVMO9sOg0dl0JTCu1g+UX10SqeJ6BHYA1 iHH+QNVR/PUEf9vW7GspWrCAMJcH3TSVsbAnQGQbLkoq3P0Wwu4nQFt57jUNsfS5xjgC Y3G/QcFGxlNuP80zxzD1TI1lUS1HF0fXMHpSg5VLM18c+noM08oGyC2DF5pmbgAi7ZHG vUwU1J7kTRpK7A8nv91ytD3I4gBwH5Qu87A5hGXdPM/LGpQF2Rp2Afla1d3deNnd9KQO MVliBivR3yN8xw+807g6ewgPsKy/ifhfdZTd0nsknGciLxJWfNloHp11H9ZUm7XLOzyB DDvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=0b+fpO2r; spf=pass (google.com: domain of linux-kernel+bounces-1424-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1424-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id qd13-20020ad4480d000000b0067eacd2a7a4si7418782qvb.54.2023.12.15.09.32.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:32:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1424-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=0b+fpO2r; spf=pass (google.com: domain of linux-kernel+bounces-1424-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1424-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8BE4D1C2437F for ; Fri, 15 Dec 2023 17:32:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E05D782ED7; Fri, 15 Dec 2023 17:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="0b+fpO2r" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C7453010A for ; Fri, 15 Dec 2023 17:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2c9f85eff28so12660531fa.3 for ; Fri, 15 Dec 2023 09:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1702661517; x=1703266317; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=13gliIVcQbLU7hKnOSD6BJq01ueaRAAu4jm5L+NVTns=; b=0b+fpO2rkETJEdiGFDBfneuXk59LoQQyQ3OsOBqPNdHwU4D67rH7OZWW1DU/EOzYNU ly2Mb3bDAJ+m/zQ37+1iFUpxwodVL9zr5kRXaD0e1D7QNzZEay85FSTYouLFo7bbDjvj AVJBD7pq1XT9twqiF5GsgYy1yhZvEbv0x8TxndhEvSoexLQzNN6okGpO9oRv5FzzjxBQ 3am0bk4jCIQ9Je7tA6o07osbp4ZS6xL2U1LGCO2vQ8ysq3Zf9ysZnjyb2tVMuk+Icn2I kZxtFv8bBEYm7HujV4hXI1/1Gn6SQOjfhKRkquylMSWzBe++G66HVIPM0WXIZBq4NVWg KjyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702661517; x=1703266317; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=13gliIVcQbLU7hKnOSD6BJq01ueaRAAu4jm5L+NVTns=; b=XXJDHObtX3pflhdC93fWuJlH9B3dwTgWnyVRVBrGZAoZIkG0hOJx6/vUjjT17t1pww lIYbkNyDwsSFS0Z88gnp8tHcTpzb0BpR/l49hNnfVRl4cpO/MrpuR2gqDl7/A5pmLc3j 3PnrrKR+LrH2Pr0AAYyw2v3GbQ3kgoHdt5cBdaQdmmp5c0cyZiqUsRdaMAk/Qc9eZwX8 5Zsz44WtVe6beLQomJILT8/RdtwX02O6sQB3V/eTUHDQI6VBny3vXkQJqDzrLNlcKv8j GL/TylWOlzv7TyxCUowLrN+ub9KMFz5uoyCSoJFXSJzbyfHnnAmzcTwQ0nHeVO1wWa1w LYqA== X-Gm-Message-State: AOJu0YxDuWxvw/Wi1+VgdE78vyy7kv/42s0QFD8NLNxYKhXfCLf4rabI a70Usj2CgZVs/trciBxjiHzyiaOltZM9DJoicAI96w== X-Received: by 2002:a05:651c:220b:b0:2cc:1c1f:a895 with SMTP id y11-20020a05651c220b00b002cc1c1fa895mr5329917ljq.22.1702661517493; Fri, 15 Dec 2023 09:31:57 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231215-ad7380-mainline-v3-0-7a11ebf642b9@baylibre.com> <20231215-ad7380-mainline-v3-3-7a11ebf642b9@baylibre.com> <66e9fe7a-927b-465f-aafe-8aea0e5998a4@wanadoo.fr> In-Reply-To: <66e9fe7a-927b-465f-aafe-8aea0e5998a4@wanadoo.fr> From: David Lechner Date: Fri, 15 Dec 2023 18:31:46 +0100 Message-ID: Subject: Re: [PATCH v3 3/3] iio: adc: ad7380: new driver for AD7380 ADCs To: Christophe JAILLET 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 15, 2023 at 5:53=E2=80=AFPM Christophe JAILLET wrote: > > Le 15/12/2023 =C3=A0 11:32, David Lechner a =C3=A9crit : > > 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 =3D devm_iio_device_alloc(&spi->dev, sizeof(*st)); > > + if (!indio_dev) > > + return -ENOMEM; > > + > > + st =3D iio_priv(indio_dev); > > + st->spi =3D spi; > > + st->chip_info =3D spi_get_device_match_data(spi); > > + if (!st->chip_info) > > + return dev_err_probe(&spi->dev, -EINVAL, "missing match d= ata\n"); > > + > > + st->vref =3D devm_regulator_get_optional(&spi->dev, "refio"); > > Hi, > > devm_regulator_get_enable_optional()? > to save some LoC below and ad7380_regulator_disable() It would be nice if we could, but we need the pointer to the regulator to read the voltage of the regulator (it is the reference voltage for an ADC). So we can't use devm_regulator_get_enable_optional() because it only an int and not the pointer to the regulator. > > 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) =3D=3D -ENODEV) > > + st->vref =3D NULL; > > + else > > + return dev_err_probe(&spi->dev, PTR_ERR(st->vref)= , > > + "Failed to get refio regulat= or\n"); > > + } > > + > > + if (st->vref) { > > + ret =3D regulator_enable(st->vref); > > + if (ret) > > + return ret; > > + > > + ret =3D devm_add_action_or_reset(&spi->dev, ad7380_regula= tor_disable, > > + st->vref); > > + if (ret) > > + return ret; > > + } > > + > > + st->regmap =3D devm_regmap_init(&spi->dev, NULL, st, &ad7380_regm= ap_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 =3D st->chip_info->channels; > > + indio_dev->num_channels =3D st->chip_info->num_channels; > > + indio_dev->name =3D st->chip_info->name; > > + indio_dev->info =3D &ad7380_info; > > + indio_dev->modes =3D INDIO_DIRECT_MODE; > > + indio_dev->available_scan_masks =3D ad7380_2_channel_scan_masks; > > + > > + ret =3D devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, > > + iio_pollfunc_store_time, > > + ad7380_trigger_handler, NUL= L); > > + if (ret) > > + return ret; > > + > > + ret =3D ad7380_init(st); > > + if (ret) > > + return ret; > > + > > + return devm_iio_device_register(&spi->dev, indio_dev); > > +} > > ... >