Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp883708lqs; Fri, 14 Jun 2024 08:18:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVp1sOHaL9BPvt8B9qRazz+G5hS9tOdkQ7ICj+z2Lewt4HzsBYQyOlG2uFzRJZ8lqR6mQu22xz8hG1L1HtUz5IjwUdib3BQF3zQFi1AGQ== X-Google-Smtp-Source: AGHT+IFDcNxVVdqjNVNnjpR3UegR50D9MoIxOIPzHHY/cbnmnzpWphnAUjpf2np8aqlsNt2Qt7fc X-Received: by 2002:a05:620a:1a1a:b0:795:4e2c:eac1 with SMTP id af79cd13be357-798d259853cmr336420485a.62.1718378292263; Fri, 14 Jun 2024 08:18:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718378292; cv=pass; d=google.com; s=arc-20160816; b=q5ZAN9NvHxgEfWiebwDm4yHdSqfCZ4Gh3g7y/GT76O80pKspHvDWO5qooBjmITA/4T GZg+itV5hP6W+FNnEB81sFmlW8Bvf/3WjftZ5xIJFaOcLRr5ISxSwGSK9TQM3M8q27Mm 3K+Uxjk0iXxK2VGpk2834ttsb1z0dHxKqwGqx1nweINf0+4HL2a59COqnXtDJ9R38CDe 9rV2+YBo3NlphbJKBNihUy7Ewk1sJqDKdSEPZgKO0RLbrwE9B9eihdnVUAoqcLd/bn1R 2rhq7eJ+TF6G37JRnjDVm7LdWbsH3lUt2BfAwQQSrS+olf2cU9sAXZ9T15CWHqtPF/DQ hHCg== ARC-Message-Signature: i=2; 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=aEXFcMzVkenGJ+BkWNtfk85Td7ZfJA69rDpGmACovwc=; fh=fuRXgY+dsMmsM3vIEdpE9nm9KdOu8ydIjdnAgDFWCrs=; b=usHlZL/Csh+H5L3IAqsh85vRCDBGBF5uYuQPz5Atq+ncK+LicayP67zZB4WWJE2NNh rVM3HX8TjRElgj1nNQcOUq2lJz/SclQgW/nU8huhEMKpHT5ebRz7Bntb9WcsZpUpRTD6 Th5cqRpDfbL45oBuRyhNxbYB0/oEo2FOAU2ztKAa8lXvAhIMOzmu6V1d6eN7YpoG2+BR FNA1vfaenlBdDh/7noLEYwKiP/rVrLsgIMv2UQiV8FBdc9yJPN27ujAfnNm6i0fyFhaN Z4mhuA9roIhyKWuVlkR2cH4RK+Wr6VhiGnJDG3PO18oRutyE4wH7pBsNM7KBxdHdWzTY m9+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ppNIaeTY; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-215132-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215132-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-798abd16c13si387891585a.425.2024.06.14.08.18.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215132-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=ppNIaeTY; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-215132-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215132-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 DE6AB1C25144 for ; Fri, 14 Jun 2024 15:18:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CC9018130C; Fri, 14 Jun 2024 15:16:33 +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="ppNIaeTY" Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 75DF8156F4A for ; Fri, 14 Jun 2024 15:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718378192; cv=none; b=eEm3eD6jZ/1iC9WtHxJQFfGSfvRKBxf6uO/foM1zyrm2oqrYBEKEP+GoG0rmR1odLPQRIDIAeR1GOIR3fOhDlmOAFKu6s6CXB2VUwdNAOXw5ERajkaZIs/hJ586b3mSmXPQ0gMdVHKNsdDVF6WM965iorl78Y2hoYDqzzzRDuuU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718378192; c=relaxed/simple; bh=82BKhcyYzugHO24SccvwRMSP84ffRJcHOxlx5YJViKA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RhRcMQd1rMNfrAxPmzjDPPGyyVEt/mPpLcP22tLXfw9GvyoBVqd6zvZdAXUot/K0jidfUwfeyt067hSgYAIGPeAFGmO3IjU2khIJ02wHVtAc3Xz8PUtXsZj4ikOTBwmfYXr9QVct4qUYdYd1/ym24gjAjba416GEbTPyKZekMEs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=ppNIaeTY; arc=none smtp.client-ip=209.85.160.46 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-oa1-f46.google.com with SMTP id 586e51a60fabf-24c9f892aeaso1092159fac.2 for ; Fri, 14 Jun 2024 08:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1718378187; x=1718982987; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=aEXFcMzVkenGJ+BkWNtfk85Td7ZfJA69rDpGmACovwc=; b=ppNIaeTYeqQChHNTk6cs6u+UKAaveLvQ9zWw1uVt3/+B2ZE2+2I45N87AlbCMa0wTj ocdqmt/qQKPJr+xpBHqk1J3yTxdHzpEjBmW5kiWbyytDr68JG7tFcFcQjbGvTohmqLMt DA4jfhcBfsoZDOWpDuCLa4c9V2O+QjWmiWvz7dCHrrwoM2BFgFbCEPxGazNW0l5xUftO w+9YUFIGsgGrmDrKXWpLRLJyHwK1gClBpY0E5d0sf+1PrpsR1485jmhZn1uyHAhiGGrK +WmWoC+a3UOQktLhnBwY6XizEnpsVVxxgEDAEuyDEeKUWIfoaHhRBveXxrk74OKqyg6z /StA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718378187; x=1718982987; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aEXFcMzVkenGJ+BkWNtfk85Td7ZfJA69rDpGmACovwc=; b=FohXc5uPQMZbFb1AAFcIje1b4qPxvrUhZ+cybI95Op1CQOItqlCey7Ra7uoTt4jDCE 5RYseOT9BHBHCLXQD+/hwPVfDIAGngpT9GGDvlGCxqTS6IpFcX9knoTp1vgNHAjcLiXi BzrImrQNGRmvQiodTEGpHaIDHplsHd4AlBoHdz7xBNygRc0LwZaXwTsJ4VU+biyB6X25 uZLZslB7g441jVfPxUQ0JRVueBYI7wgkZPLfv6VxFgCnAgZkj0E9z34BcEEKSw/fNZCj P7n/yFuGbkG4zXhgIOVX8bm5Teav4/MmjbizZ5RflKZOzbNyF8/T1oxTCNfoO+/ArOtK d58w== X-Forwarded-Encrypted: i=1; AJvYcCXEKNHQFkLTKZQ/OlYt7T5ZpSPAkONoAPq8Oa0r9hUwxmz0j50xXKCDG33m9Lt0TnIT3gdrH/sL2CHxb4Y3spLJ9QCJM8jSan2tARma X-Gm-Message-State: AOJu0Yxha2Pkt/Tq1QLZfQtJ6zoAuC8XDK2ZyhWt7vqFyIKiNsWWCx2R iCcH/9a7AXbE1k8ugVKzwWMRmIjTYnNvVUYiBdlmE+oYRZL5gFO6Afpw+5JhFTE= X-Received: by 2002:a05:6870:4728:b0:254:8c7a:6c97 with SMTP id 586e51a60fabf-2584298504fmr3493907fac.30.1718378187574; Fri, 14 Jun 2024 08:16:27 -0700 (PDT) Received: from [192.168.0.142] (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-2567a9a7fc6sm991687fac.18.2024.06.14.08.16.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jun 2024 08:16:27 -0700 (PDT) Message-ID: Date: Fri, 14 Jun 2024 10:16:26 -0500 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 v2 3/5] iio: adc: ad7292: use devm_regulator_get_enable_read_voltage To: =?UTF-8?Q?Nuno_S=C3=A1?= , Jonathan Cameron Cc: Marcelo Schmitt , =?UTF-8?Q?Nuno_S=C3=A1?= , Michael Hennerich , Mark Brown , Liam Girdwood , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240612-iio-adc-ref-supply-refactor-v2-0-fa622e7354e9@baylibre.com> <20240612-iio-adc-ref-supply-refactor-v2-3-fa622e7354e9@baylibre.com> Content-Language: en-US From: David Lechner In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 6/14/24 10:11 AM, Nuno Sá wrote: > On Wed, 2024-06-12 at 16:03 -0500, David Lechner wrote: >> This makes use of the new devm_regulator_get_enable_read_voltage() >> function to reduce boilerplate code. >> >> Signed-off-by: David Lechner >> --- >> v2 changes: >> * avoid else in return value check >> * use macro instead of comment to document internal reference voltage >> --- >>  drivers/iio/adc/ad7292.c | 36 ++++++------------------------------ >>  1 file changed, 6 insertions(+), 30 deletions(-) >> >> diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c >> index 6aadd14f459d..87ffe66058a1 100644 >> --- a/drivers/iio/adc/ad7292.c >> +++ b/drivers/iio/adc/ad7292.c >> @@ -17,6 +17,8 @@ >>   >>  #define ADI_VENDOR_ID 0x0018 >>   >> +#define AD7292_INTERNAL_REF_MV 1250 >> + >>  /* AD7292 registers definition */ >>  #define AD7292_REG_VENDOR_ID 0x00 >>  #define AD7292_REG_CONF_BANK 0x05 >> @@ -79,7 +81,6 @@ static const struct iio_chan_spec ad7292_channels_diff[] = { >>   >>  struct ad7292_state { >>   struct spi_device *spi; >> - struct regulator *reg; >>   unsigned short vref_mv; >>   >>   __be16 d16 __aligned(IIO_DMA_MINALIGN); >> @@ -250,13 +251,6 @@ static const struct iio_info ad7292_info = { >>   .read_raw = ad7292_read_raw, >>  }; >>   >> -static void ad7292_regulator_disable(void *data) >> -{ >> - struct ad7292_state *st = data; >> - >> - regulator_disable(st->reg); >> -} >> - >>  static int ad7292_probe(struct spi_device *spi) >>  { >>   struct ad7292_state *st; >> @@ -277,29 +271,11 @@ static int ad7292_probe(struct spi_device *spi) >>   return -EINVAL; >>   } >>   >> - st->reg = devm_regulator_get_optional(&spi->dev, "vref"); >> - if (!IS_ERR(st->reg)) { >> - ret = regulator_enable(st->reg); >> - if (ret) { >> - dev_err(&spi->dev, >> - "Failed to enable external vref supply\n"); >> - return ret; >> - } >> - >> - ret = devm_add_action_or_reset(&spi->dev, >> -        ad7292_regulator_disable, st); >> - if (ret) >> - return ret; >> - >> - ret = regulator_get_voltage(st->reg); >> - if (ret < 0) >> - return ret; >> + ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref"); >> + if (ret < 0 && ret == -ENODEV) > > ret != -ENODEV? yup, I messed this one up > > - Nuno Sá >