From patchwork Wed Apr 2 06:10:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14035556 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 BC446230BE3; Wed, 2 Apr 2025 06:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743574235; cv=none; b=IvLcVhi/a9U+Zo/xlzaSTtYqTLrJs1dV58tmo3IMl+LjcjlAQ7ihpm2jh7J/UUuuGOfBOX85BUHo7haoL/9uaCXcbjPNRYdFoLR2t0NfqxlMgtvx/OD/FNHXcdBzp4NuUnheU7/LlPwAjtsUhhsRcT9Vs/38gDzPfLBzyhTU59E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743574235; c=relaxed/simple; bh=qcJYs/4Hq/T5cxfjGUwALW1qfxveSrmKWWWjVClELts=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JuQe4zyozJtMB8THCzcwxaHufBw4lB1ZXXs4a5TdQI3GPWKWABE9v68sLfy1PAenzDixgaeykHAktTvrhzNAphBWT6xbKXrVTlqYungeeeHmh6upCVdKntq9cana0D9s5SvYwZnmbRbCVdOYaeMMErrOcgg94437QxUvnrXhj1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jgBiqayY; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jgBiqayY" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-30bfc8faef9so61566551fa.1; Tue, 01 Apr 2025 23:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743574232; x=1744179032; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1fUyGCDgTIMq1vHv/uBEeZiyDV2WeO50QuM/4Ssw5Y0=; b=jgBiqayY2CJIfscZTkAYvQj1HwmHS2jeNFvI6t8bWxd0ZkxsXpoVbX7cCqbvxfmt3/ LuIr2SDdjth8HS0viRb70gpgaL484VI5L3qo38TRwVs0VoQJbl5lE/EpnmrcHht57+WW h7YW4nxdZgKFR9jl83dcveVg24jSusVp+WREbr1GTfeslUmdpJNbxWFeBnxLa1CQ5OOT acKxH7qyjr3e74Vdnxh8EZoYwKS/wv932A7k7wpgnarognrhwIooItDXgINqunuQLS8m hOTid+JzTYuGjoA3YiSMRrGVkbd2gf7u9cTeRiuU9AuVrklGbIudv1+/S34uK6renHVI QCIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743574232; x=1744179032; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1fUyGCDgTIMq1vHv/uBEeZiyDV2WeO50QuM/4Ssw5Y0=; b=e7aG3Xsiz3Xslt8pRKKoSxIWL3YlJRtfTBfAMfQ6zmeFEbqoZcbRyirxIFSIsipo/B Sou1hPnYi0qafZ598d7rq0FI/nlsijSCpFD12zeQ54qjKxo3lISFflm2ts5UC2nesEtn w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R55tLnHzLH7o7Q== X-Received: by 2002:a05:651c:212a:b0:30b:f42b:72f6 with SMTP id 38308e7fff4ca-30de034a374mr55127891fa.32.1743574231622; Tue, 01 Apr 2025 23:10:31 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-30dd2ad3cdfsm19169761fa.54.2025.04.01.23.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 23:10:30 -0700 (PDT) Date: Wed, 2 Apr 2025 09:10:26 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , Nuno Sa , David Lechner , Javier Carrasco , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC v2 7/7] iio: ti-adc128s052: Drop variable vref Message-ID: References: Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: According to Jonathan, variable reference voltages are very rare. It is unlikely it is needed, and supporting it makes the code a bit more complex. Simplify the driver and drop the variable vref support. Suggested-by: Jonathan Cameron Signed-off-by: Matti Vaittinen --- Revision History: v2: - New patch --- drivers/iio/adc/ti-adc128s052.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 0f93c6266527..0bfe4e558c69 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -29,13 +29,12 @@ struct adc128_configuration { struct adc128 { struct spi_device *spi; - struct regulator *reg; /* * Serialize the SPI 'write-channel + read data' accesses and protect * the shared buffer. */ struct mutex lock; - + int vref; union { __be16 rx_buffer; u8 tx_buffer[2]; @@ -82,11 +81,7 @@ static int adc128_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: - ret = regulator_get_voltage(adc->reg); - if (ret < 0) - return ret; - - *val = ret / 1000; + *val = adc->vref / 1000; *val2 = 12; return IIO_VAL_FRACTIONAL_LOG2; @@ -156,11 +151,6 @@ static const struct iio_info adc128_info = { .read_raw = adc128_read_raw, }; -static void adc128_disable_regulator(void *reg) -{ - regulator_disable(reg); -} - static int adc128_probe(struct spi_device *spi) { const struct adc128_configuration *config; @@ -184,17 +174,10 @@ static int adc128_probe(struct spi_device *spi) indio_dev->channels = config->channels; indio_dev->num_channels = config->num_channels; - adc->reg = devm_regulator_get(&spi->dev, config->refname); - if (IS_ERR(adc->reg)) - return PTR_ERR(adc->reg); - - ret = regulator_enable(adc->reg); - if (ret < 0) - return ret; - ret = devm_add_action_or_reset(&spi->dev, adc128_disable_regulator, - adc->reg); - if (ret) - return ret; + adc->vref = devm_regulator_get_enable_read_voltage(&spi->dev, + config->refname); + if (adc->vref < 0) + return adc->vref; if (config->num_other_regulators) { ret = devm_regulator_bulk_get_enable(&spi->dev,