From patchwork Mon Apr 7 10:45:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040202 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 67548199E9A; Mon, 7 Apr 2025 10:45:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744022714; cv=none; b=jlT8hGT9CQ78VlgtYz156PYG5+SoDpUa4FMFKpSMvqf4ggrNTKnVrbCbQ3iXJx5dbMhevSvgC6vUxiv2muBInGylbxWt6rcH4wulMdj6JxyGsqrrBMKOWEPu65LTvMpt5CAb/p53rvM8ozhi8FCfpbya9+9CIm1WHRrx/B74ONc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744022714; c=relaxed/simple; bh=NXPOzpeCwPDnycPH2c7OfmWVhNM7SK2Xf7Bt8/1zCaY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ajjU6jvGIDVq6Z0M0kjf3eb9XlE1+V+bRS2+PY54UOVkx60d04bswzLp87gyYrzCtIhWGPjj3xeUWrKMNNlitL30E2fCuZSv75dp3QWJdowYfKXVCmkdcA1xWWlQvc5kgTTGL1c/3EF8x5Heb8yq3/dFDTeMHqDL3u8ZuzH72IQ= 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=ezp+d0l3; arc=none smtp.client-ip=209.85.167.47 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="ezp+d0l3" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-54b10594812so4740306e87.1; Mon, 07 Apr 2025 03:45:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744022710; x=1744627510; 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=f5OIXlm56gKmh/A9Z+P9Y2yDvHss8pWd/2p6nBUoAZc=; b=ezp+d0l3YTqaiQYTfYk9t9XcabWjtBphWwSo2NBwAgjq4OuHad5V9ebpO1xJ6buept fwiZjoiH/m2anCCD55ATeHqD8ZolK+vpMwgiiCEYKOeDr3FherLQzBQkgP6gv2Vo7uMq O6uwfdfRxrPyvLCwU9nk1d09AL06Qt95I2RLUfwdL8dzJQsOMq4Usswn3XH4UmjXRyDt 6CWmLc3uhu1lSg05Oy2CwzYV8gdy2pE7R5qIDP2Tq58dman0sqp0pzOldBHbG5vqN52j 4E89DOiAlqDpzF/VZ/DJVBFPOmAoPllgzrsyzPh5YKwc2NlqKoX+EtHbNuFGY4utc7Jc xMAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744022710; x=1744627510; 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=f5OIXlm56gKmh/A9Z+P9Y2yDvHss8pWd/2p6nBUoAZc=; b=t7ewdFIboW61xFtd4BCENqlqFw3o0nvwO3EOrqog5dDiBU04h3Mxp2TG6/gHBeCFXL Ryla8mAmx1x5qGayXqb+VsTYIfoBAuATDCTJY5wVNFx7Ua5gGCh4T9QlCm4/FvFU0j7k pDl4i6tRNO/wtI4vt2uGce9Mh/PplxtuD60i8WW39Dtf3Rxos828sHGiji3RkRXy8CBu FbGaNf4ORoarZgIrVLdUPE53zmU3FeqYnaiL3KPJmy/+f+g4pwF6qha3lgk0mD5lGiAZ oqauOaJXHpCJt2LYZapkpA0GZElKPgkWFiz0c8Uy53QgTCAiFW7flOH5OSM9F1W0apje Ml/g== X-Forwarded-Encrypted: i=1; AJvYcCVM0WXMMDb4JmxCAXfDQP9PEU3BzL72Y/5Ir4tTLjoDI0rLdiqSYhuPqV/Q4OgZX6y3tyu5BsUs8Jtf@vger.kernel.org, AJvYcCX7lG7x3DFKMr/vFkB1D3AMTZv6MKdYqCiycIkJF8V3bmpoNE5HzWMQA5xhXprHlAUqyd7xhFxY1z1vVDlb@vger.kernel.org, AJvYcCXqiAHj8RFzwe/zQ7YV8SopUlIrMT12LaA4/XY11NQ4RPwXfToqKfUMtaQl9OOsB7KCyQjWXluKc2uh@vger.kernel.org X-Gm-Message-State: AOJu0YxNmiZ0w8V0RZPQ9AkM/Phcs8iPBL+DRK5FZyo5+SbzWBMNeIH0 OyGpCdVa9IFIg1zjgMgkhN4i1PFCvFCCgrFK8sh3T8TR68CkT0dc X-Gm-Gg: ASbGncvlUCfwWSrDBNvC7fCCrYHqzntyKhB7RGnszCTm9NsmHCvNNSTbV5Yhs7YmWjb Ow/7O4U51J/S1ORa/ie3rVYFfNAn7NBHXPyw/KiUsq9iaAIcKPyxJVt5+GQAud8XWxvaHQV3b5y RBtmKK5QJ6StpiqVEdluO70VPUfQhWjTwkL3ruat7bMI9U4kT/swMDeJPTfE6Yu5KzkgX/AKtMw fyjrZV+vOJqSO0zAuRLtNc033QQNflXkdcVlpbb+79KR0Xjs0mLKXOAIlFZPj9P2MWz0LWozzvr KK1dv9IEGd9XZDgiI/4tWJZoh4XUrD1i926M5mBCOopA32taGCMc3KvXnOkaUA== X-Google-Smtp-Source: AGHT+IHQ1k7gyWSF8meHnKZO7bwz77/mvDW2LY7CtZ8hMaWsRkVM1bYe3hg+yQFgQX8Y/JpvqT8STw== X-Received: by 2002:a05:6512:23a9:b0:545:cc2:accd with SMTP id 2adb3069b0e04-54c232dd30dmr3059697e87.20.1744022710277; Mon, 07 Apr 2025 03:45:10 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e5ab7besm1196646e87.41.2025.04.07.03.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 03:45:09 -0700 (PDT) Date: Mon, 7 Apr 2025 13:45:06 +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 v3 1/8] dt-bindings: ROHM BD79104 ADC Message-ID: <2a4c65ee35cb79c6b29dbc59cfd9bc7d615a08ac.1744022065.git.mazziesaccount@gmail.com> 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: The ROHM BD79104 is a 12-bit, 8-channel ADC with two power supply pins, connected to SPI. It's worth noting the IC requires SPI MODE 3, (CPHA = 1, CPOL = 1). I used an evaluation board "BD79104FV-EVK-001" from ROHM. With this board I had problems to have things working correctly with higher SPI clock frequencies. I didn't do thorough testing for maximum frequency though. First attempt was 40M, then 20M and finally 4M. With 20M it seemed as if the read values were shifted by 1 bit. With 4M it worked fine. The component data-sheet is not exact what comes to the maximum SPI frequency. It says SPI frequency is 20M - "unless othervice specified". Additionally, it says that maximum sampling rate is 1Mhz, and since reading a sample requires writing the channel (16 bits) and reading data (16 bits) - we get some upper limit from this. From the "frequency is 20M, unless othervice specified" I picked the maximum frequency 20M - and did assumption that my problems with 20M weren't related to the BD79104 - but to the evaluation board "BD79104FV-EVK-001". Add bindings for the ROHM BD79104 ADC. Signed-off-by: Matti Vaittinen Reviewed-by: Conor Dooley --- Revision history: v1 => - No changes --- .../bindings/iio/adc/rohm,bd79104.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/rohm,bd79104.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/rohm,bd79104.yaml b/Documentation/devicetree/bindings/iio/adc/rohm,bd79104.yaml new file mode 100644 index 000000000000..2a8ad4fdfc6b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/rohm,bd79104.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/rohm,bd79104.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM Semiconductor BD79104 ADC + +maintainers: + - Matti Vaittinen + +description: | + 12 bit SPI ADC with 8 channels. + +properties: + compatible: + const: rohm,bd79104 + + reg: + maxItems: 1 + + vdd-supply: true + iovdd-supply: true + +# The component data-sheet says the frequency is 20M. I, however, found +# that the ROHM evaluation board BD79104FV-EVK-001 had problems with 20M. +# I have successfully used it with 4M. My _assumption_ is that this is not +# the limitation of the component itself, but a limitation of the EVK. + spi-max-frequency: + maximum: 20000000 + + "#io-channel-cells": + const: 1 + + spi-cpha: true + spi-cpol: true + +required: + - compatible + - reg + - vdd-supply + - iovdd-supply + - spi-cpha + - spi-cpol + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "rohm,bd79104"; + reg = <0>; + vdd-supply = <&vdd_supply>; + iovdd-supply = <&iovdd_supply>; + spi-max-frequency = <4000000>; + spi-cpha; + spi-cpol; + #io-channel-cells = <1>; + }; + }; +... From patchwork Mon Apr 7 11:35:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040275 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 5BBED51C5A; Mon, 7 Apr 2025 11:36:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025767; cv=none; b=hD0sn2yy4Zt8K5WB+HHXzMiWS5gLXXkUYr7kO2pINJNOokpf51bxQWbPbZcX9T+5J3DmICVdIQDCP0SePA6TFhyBIOepj5Mf9KGwwMebJ+YillCiNNtRvpQQw1+IIgpv5LuC5B0wyaM8Glm4ADuJn7pdWDwZTKVBauG3onU1fEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025767; c=relaxed/simple; bh=8r6O3wJgxWSEfWdnMU0SsVa39yr41Y9p9k1tGUpTvzo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YYd8zub70obaZeggaZJTBlOGUFvvSKVxnEX6E9nS1u3e92G4i2e+rBrqpN+NV3qjWLiTkCg3tXOXK2xC/ZEGIOMs49r9JWPYOzCnCjxBY6a7KFmV0RshWWXqJ993gHJcpYRHU9fUfA+REN3gGzous0kzQ6az9CbP3LMg4KBp52o= 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=cxoq8CtN; arc=none smtp.client-ip=209.85.167.41 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="cxoq8CtN" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-549946c5346so5033347e87.2; Mon, 07 Apr 2025 04:36:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025763; x=1744630563; 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=3pnTHuBGqWlRiXoCFZ8cMc3CEM7rT1/Z8f5jWlLiSzc=; b=cxoq8CtNLRdK3Nk5/q1NWkUgUODxrk4Iy5vp6l1hcPhOTAx3xtsi6eodqbWZ02M4b4 Atrm+eGBzT2rCBWz4kOwfwsaXXly8aOwvblGSe4MFc0IoKXYziqF2m1WpsSiOAvJdnXP XDHyImkpAArgD7p1r9HI0MCdbJPYBjrPlRh8+tJBxlYxmujaTQAAEJ10zwkC6gBnbpim l4/TB1MTIsoujYDS5MGGOw39ryYvt/db3xGuc8H/FwFl96Xh9RG8G7jhXD78SI92mJSp ueOkxOyoHpG+1hl3RB8/a7kZCdVQg5SWDs7/YbChaodWoISkJzlqB3R71accXNI7IZm8 1umQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025763; x=1744630563; 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=3pnTHuBGqWlRiXoCFZ8cMc3CEM7rT1/Z8f5jWlLiSzc=; b=JJpKfIaKOraxB7NE28ZvYoAUdvpqMx5gYQNxGyqmMEYMJN8Hlc5iTqtqIlSyc6/ibQ QlElBZS8eWUNsicEIHsaEzIGoAA4SQKKvgal0Z4DmSwS3BSmPzXqJADQjMB+KH0SowbA /IyTLWI9Q/trok8jA3jSFRnrv4BdDlpixInMDqp9KRRWw2a/UTeqjVCDf70QA3FKLGLB 2WITdLXAh23iRJB820H0bAjmcM/TSS1UufGna3aZCnGLb+JoPw2UXWqnPYJtcHSj9YPK tV91xMY+YtqOKK3oo3fOroBlID1UgQERyMnOkD7u2FsBDPt8b4DJLcD+TjzwfdYqJjxS VF7Q== X-Forwarded-Encrypted: i=1; AJvYcCVE5ESMz2elGkON7NKLE4ACWoO2qxgf+IvkgGtV9Wc+JvNycEZrynAuYuqm13FlwC7ValT8jtrV1sJl@vger.kernel.org, AJvYcCVdAqpN7bS1449ku5cWggZoAuMeJTICFdaTv1P/p1+SZk48L9EaZid7wSU2JTcCO7kvivPXUzTItmmB@vger.kernel.org, AJvYcCXHtexnD3OISF+YB8EV1HL33XEZo7OTKSroc3W4uDrcFE2C8XmfxPCn5VJpKfMZkL3r138RPw3vdokPw6QN@vger.kernel.org X-Gm-Message-State: AOJu0YynI0FkB3LxG7w+wXPKAoJWrd7IKcgLto5h9yQ5G/H1+jjr6zt6 RwQvRCPYcPu6BSE4ufgfI3mDSKgWU4dMMujqs6WDW4fXqkfVhaCB X-Gm-Gg: ASbGncu5wSw0dK2C4z7xXpv4qC1g4hDKvI60tmSyK3Yek3b4lTY7PsrGnfk1cQNLtdF jonpUTdF+pxSk/fjBnSEwLDHTB4gEluN3dGuN6ydqbj0CvAOo3bq9BW9vomwSqxiz1hutlgYWXK KkRGAmXQxfDEIJftJ6Z++bHjIVsMpD0guVIWwbkjWSnevAcDwQd95ethr+x6ESiwgtDEPQRQmYN jaatCaAnk2l3xRUPPK/PIMyretSoVbSlgt+opruAfURTBZ/gnHKuajomcMrvQ+jAD6tKZB8rB8Q LuE60kIA8w1QtDTujLoefZRa4iCDA6hfMPcoHOg5w5k1tL9L/Wo= X-Google-Smtp-Source: AGHT+IFqWPFnPbY5HdI9w1QEqNzTwmRtdAEuWycHKDFUQonp9aiaZtKA9lTeq6IWThW//jG+7LpAZg== X-Received: by 2002:a05:6512:1089:b0:545:109b:a9c7 with SMTP id 2adb3069b0e04-54c227dc83fmr3619290e87.35.1744025763278; Mon, 07 Apr 2025 04:36:03 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e5ab889sm1215684e87.11.2025.04.07.04.36.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:36:02 -0700 (PDT) Date: Mon, 7 Apr 2025 14:35:56 +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 v3 2/8] iio: adc: ti-adc128s052: Simplify using be16_to_cpu() Message-ID: <8202060d90221beb9b8cf467606641349ad47fe9.1744022065.git.mazziesaccount@gmail.com> 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: The register data is 12-bit big-endian data. Use be16_to_cpu() to do the conversion, and simple bitwise AND for masking to make it more obvious. Signed-off-by: Matti Vaittinen --- Revision history: v2 => v3: - Decrease amount of changed lines by keeping the old buffer name. v1 => v2: - Fix commit msg to reflect the fact there was no bug - Drop Fixes tag - Use union for rx / tx buffer to avoid casting - Keep the shared message protected by the mutex --- drivers/iio/adc/ti-adc128s052.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index a456ea78462f..c5b2374322e4 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -28,7 +28,10 @@ struct adc128 { struct regulator *reg; struct mutex lock; - u8 buffer[2] __aligned(IIO_DMA_MINALIGN); + union { + __be16 buffer16; + u8 buffer[2]; + } __aligned(IIO_DMA_MINALIGN); }; static int adc128_adc_conversion(struct adc128 *adc, u8 channel) @@ -40,20 +43,18 @@ static int adc128_adc_conversion(struct adc128 *adc, u8 channel) adc->buffer[0] = channel << 3; adc->buffer[1] = 0; - ret = spi_write(adc->spi, &adc->buffer, 2); + ret = spi_write(adc->spi, &adc->buffer, sizeof(adc->buffer)); if (ret < 0) { mutex_unlock(&adc->lock); return ret; } - ret = spi_read(adc->spi, &adc->buffer, 2); - + ret = spi_read(adc->spi, &adc->buffer16, sizeof(adc->buffer16)); mutex_unlock(&adc->lock); - if (ret < 0) return ret; - return ((adc->buffer[0] << 8 | adc->buffer[1]) & 0xFFF); + return be16_to_cpu(adc->buffer16) & 0xFFF; } static int adc128_read_raw(struct iio_dev *indio_dev, From patchwork Mon Apr 7 11:36:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040276 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 2879F51C5A; Mon, 7 Apr 2025 11:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025780; cv=none; b=AhjtC23Pnqetfv1fjstTANDvLpAT0+W8hdi+8Kjx6i2trHGLjM/17l+mtV/MP02JRkCoca3cL9idXA24uKOgWsw3mlFocKLgmh+L3/J1rN4kaIcIKgn9w03u8ytRaIYB+E3bE8Mb3m87Zt9/8tIxCNempkBX2gczqz+GZrtIKJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025780; c=relaxed/simple; bh=MxYirPcg7T1+nJvqAKo/63KukNj0KJ4u8JdzTJzEO+s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lRAxshx31USC77iyb0yw5m0lATfo9Fb6pvi8AtpwKqm5pVcTv2CzJaNqYQ3zs7QPohf1zsdwD+YIdzb2vGrV1Ado9Ly/7l1TA71nkvIxZkLhmL1oKWbLnn76DJBQylSH/Soj54scEer8o/jL5nlPDIOif8ZQ3i7vl9oODtNKMiU= 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=GQTWw3xw; arc=none smtp.client-ip=209.85.167.43 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="GQTWw3xw" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-54acc04516cso4869531e87.1; Mon, 07 Apr 2025 04:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025776; x=1744630576; 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=J6BeKUOweUvfpGj1ohccp8brekbwVQ7DsDFM2oFUjBw=; b=GQTWw3xwAbC6xCqWwEs/8EZriN2TOmS4MRIxnTrQti87IzqcHL/N9QA+8iD2W7lHQ6 EEM73Yel6JxnnhSTLUsn+UeFCnjaEn5ATeTzXsIY1SN5OtNYonwF2G9EGP60sWvjKDRp 2jGWw7HWOiEu4KNL7+I8mz/E21Wei2Xai2yrMApPB5Sxj3w1IS98qqRmsBn6p3RUwUci Z6IYKYyFkHvHa/7iqx9xlvCMWWJRY1nR45K6eHs1a5xTNVJ2aGrzC/rf21Jwq/jNxiSH hshcooiMLNMJh20ch9VzC9s3IuwQcfiCMZEJUOD+C7ROJN3EcA5qQ9V6Os3qmTzdWEaA j5jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025776; x=1744630576; 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=J6BeKUOweUvfpGj1ohccp8brekbwVQ7DsDFM2oFUjBw=; b=T50/SPuPQ0SAf51Um7i7gwQop1EKDlfkP5AC83Wm6cON8oywkTWFYKsucwMgNQSDc2 +0KU8o6/Zl8gi/SH68PWyJMCYo9aLciVIY2T/0LNK4FiMOWh7SMLYxW6ubiOIlPowOdz JtZ8MnZRxD7PYPB6yKXAdgh3ZJqbCHFZS95kLuZaE7nlJYt6uoRE9bpphH0zcGyZ7+Zk JCtYOXYC16PzQjj1VkM4ox2SVkcbM4in4xhKFh6bFKn0ARu+Jwd0ffNMMdWE71UO04zc gAL9J85Tp/39QINaoBz6iOJgozwBMg96nQUtOmH/P048t+GiWvsNoI1R08J7JBuOJ/nC wBtw== X-Forwarded-Encrypted: i=1; AJvYcCUAF26nxx1S8Zgie3d8QRxmchEF4TolTjlnuLsqfP/CT1EKetbEd96NtS6SNnNvDPMbIjQbnVnB8rOW@vger.kernel.org, AJvYcCUHnKbtZS63p8TdkB0hoKQdTEjwD8SOfjfwBmPYOiPa5QcBRV3B1EtOTwrBz+icGpC+5FqUNg8IsdbDVY1D@vger.kernel.org, AJvYcCW3KD0NHkpY40AfSdWc+lC9p02520gMV8DSiIUU+Lv5CIANMEtJWsELd5CI2rjKZ39JChi1hfypF+yv@vger.kernel.org X-Gm-Message-State: AOJu0YzvmhEz2ZQ6OImRF4aM608KCXipFHuT2q6iwbyhYow3p6xJYlpK l9bRZ5gcQC4VsKkIkvmcdrM2G53He14DvI5mPrHiPCPoK4y6tXtj X-Gm-Gg: ASbGnctQsB9D7L7+BhzkMVtTlzrRh3X23aJ009ybrCxLjDhh1ybLmWdW7y9ZZseqQe1 SFD4pxykltmCLWHuInw/+Zhp6l2vbjGdd8ArC3LpcryfJKRJWYZrlqzk2mnuaSu3ads1hYNXQPl AwOUT619/sDU3KeiBnbavAsbZJAMCa/Y1uPna/WALC3j4eF2tyla+ctaAk8Rzv8CWlH3pLDS7VR 9tNd+tP/a9SgmFcAS7lk6qnL2RkYnmLelDqTMsKyk4E45a1+YPE1VjcuSRllh1kHfn3CJQKQmBo RFHGi8Jmtw2jrCY07ZvejNgcUje2nfs1DtS4C1C0z2dyyN5oD6k= X-Google-Smtp-Source: AGHT+IGj31lRuBREjFo3rRZxA4ScwO5XxI8BkCbuvTyHaUbHVOvi9He1bWiKVn8f8CwfuRWSMSx2FQ== X-Received: by 2002:a05:6512:b10:b0:549:8ebe:b3c8 with SMTP id 2adb3069b0e04-54c297b796cmr2130691e87.11.1744025775960; Mon, 07 Apr 2025 04:36:15 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e6370ebsm1198490e87.130.2025.04.07.04.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:36:15 -0700 (PDT) Date: Mon, 7 Apr 2025 14:36:11 +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 v3 3/8] iio: adc: ti-adc128s052: Be consistent with arrays 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: The ti-adc128s052 driver has NULL terminated ID arrays for the of_device_id, spi_device_id and acpi_device_id. All of these are terminated by having an empty string as the last member of an array. Only the of_device_id array uses the /* sentinel */ comment. It's better to be consistent. This /* sentinel */ comment serves no real purpose these days as people are used to seeing these ID lists terminated with an empty array element. Drop the /* sentinel */ from the of_device_id. Signed-off-by: Matti Vaittinen --- Revision history: v2 => - No changes v1 => v2: - Drop the comma from the end of the of_device_id list. --- drivers/iio/adc/ti-adc128s052.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index c5b2374322e4..d0702d403fbe 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -185,7 +185,7 @@ static const struct of_device_id adc128_of_match[] = { { .compatible = "ti,adc124s021", .data = &adc128_config[2] }, { .compatible = "ti,adc124s051", .data = &adc128_config[2] }, { .compatible = "ti,adc124s101", .data = &adc128_config[2] }, - { /* sentinel */ }, + { } }; MODULE_DEVICE_TABLE(of, adc128_of_match); From patchwork Mon Apr 7 11:36:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040277 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 2899D238D27; Mon, 7 Apr 2025 11:36:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025791; cv=none; b=BcEJXYHejL9pDhVwUkjJh+oATQdb8Jnzp3GECpm/bkJPS783V5wZSQTSPm4OG2abdUPG8pwCMxXMAsXzoKAD8waaWZrkOYGSLSk573iiG3Vr7JB/9caipviabNdtBYNxCB13mjcKKYhTgPSq1ikbW1VO477mNnMfyQVhXaL31kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025791; c=relaxed/simple; bh=GG0FbHW98GA8nLlASB1APu+LSyoziWqFH993IrgInAA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QAV5VAkIocEZwa94i9Y40E52Jp2S2qVqi6ZOtTGhmYZV6ULErasn64XwBZ1jI1hcGSzLfjtsYJb6nTwh2cy4OIwdjODuRMXOCpospE0WpnU8/UpbnDfw975pq6TGe/+989ZEftoymvBpGc+hN9iceaKfek9gPIDNAJqxJi0Ng/U= 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=YROihR9L; arc=none smtp.client-ip=209.85.167.48 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="YROihR9L" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-549946c5346so5033848e87.2; Mon, 07 Apr 2025 04:36:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025788; x=1744630588; 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=MIvoKoc5sivfRuz4kaXhGJp5sspXW/jKkyEKwtPzqrg=; b=YROihR9LReRXQeMIlmbTc5elcgG+cLeKaEK1buwTerZ89pTkr30P+Roycj0rnrQvkT m1VIOHICyq2gHo/6fINhTEwBlFE9gs418BwnZlh/jnSJhZk4ICHd/DjlZpcIoKCeAFFZ dXXg9Zt41PSki+rVob8+3w3z4zvWy6qu8X+IHwoQf0aSmXxgdXy+D0nSmbdY859rt/Ck xQ6fbA13nQcTVmpBg7/wDZHKirM/Bhj6MlLtWI04Vfp7sL5hCytlE3aKSYGD3FMLtwQu CJEvQmbU4RsOnNZMpUHmXGW+hDrHfoRz9KHffA499WQpk6b9BNTmRoD3pUNNA21b5RTd 0taw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025788; x=1744630588; 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=MIvoKoc5sivfRuz4kaXhGJp5sspXW/jKkyEKwtPzqrg=; b=BWlEnY+s+gCq2kPQ++tKtSGAkdWja6I3YGh/TFEGj8SZjS0pXDiK0hDK9XXWHWFTXi 2rEaBLhIeQUiA5eQagWqhv4ZUGqaki5kL+K4BMNVMJBSMMC/moC4IojKPB3huIkHL6oK 1WoB+CCrbhNNMYNL+hB1nTBgTJHTOVuD/KAi3X8M5gP/H3miBcrs7lFQRtbr88ZmwTGk GC9ufyrohCPAxVPYkjVCBv3Inve/ndwfEEOD3mqVJRcZn5ZOHxC/fV/CGpx1cIKW2vs8 jRBqKdZvfUEbTLh8391KiO/iyqLaPpLiEY7qYVThz+s1CPs5Rg+uXPt/AHRQtNuXtZVg 6BRA== X-Forwarded-Encrypted: i=1; AJvYcCUxUVy6qSrAu3/lw3QIZoCzOdzw1tlqEuFRiDcu6pqMpMg6J2XKP/appdI/EjvZz/34xuakNuZa/zsX@vger.kernel.org, AJvYcCWRlKuarJKEU2UdOfug4bcIaCanvcR/l9xA49mEVD6gcp+UNdG7+P58YXnpDkpmXOnmnILDpleepd5v3Uqo@vger.kernel.org, AJvYcCWSXClEaU5zs1MDbr6WbA1XCiZd++TpOLPFg1RX6qlwVaThUlPF7ldCHyd6ad8GrSritKHrcw3iOhHt@vger.kernel.org X-Gm-Message-State: AOJu0YwzbCqf2a09nXrkNnWjDC4oVLjH1iWCH8NTrW8Gvb5gzQLeq/US GYD+9a5DIgDfz2L5riGnimCA+fiuvQRYuHNhgxcOY0CmmA4vjExD X-Gm-Gg: ASbGncvuBE+7eWVBoMg2syQAAi6uIOLyMwevTb9L9J84o5+Un3Hx4SZULMph8phM4Al PJsUmcJZPNQ4RAp+X4UmbJrE/jxwETfZC7Jj/IJrOKCFxtj5ptXzoJIuM/jw+TWVTnrVSjsyjAm YvFie7v73dSY8JJ+K8p0oEWXkb92Y6Om44USoEdH2EIFWqnlFniLlZ/IOwJjPGkulAPGOVBp1lL QB+JGVLtPMBrfYPbiL7OZpvMMMjOxEb2C8yLUuAPBHGLQKi+9myK3hRU516r10f2s6uDulIRH/u kb6qO7o7ljKNxsln2wgdwBRuld1ALAlValzDiMZXndkJlmHFCv83ZlB+PzyclQ== X-Google-Smtp-Source: AGHT+IGnEUXtNUmpditN4kH/NEFSAsG1PRIf8trdr/dXmWV0/EQ93agz6fKxchHyh2Zkq7tTKh6FdA== X-Received: by 2002:a05:6512:2316:b0:545:1082:918d with SMTP id 2adb3069b0e04-54c227dc802mr3814153e87.41.1744025787997; Mon, 07 Apr 2025 04:36:27 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d5d5sm1212186e87.195.2025.04.07.04.36.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:36:26 -0700 (PDT) Date: Mon, 7 Apr 2025 14:36:23 +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 v3 4/8] iio: adc: ti-adc128s052: Use devm_mutex_init() 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: Quoting Jonathan: "Whilst it doesn't bring huge advantage, now we have devm_mutex_init() it seems reasonable to use it and maybe catch a use after free for the lock" Switch to use devm_mutex_init() while working on this file. Signed-off-by: Matti Vaittinen --- v2 => - No changes v1 => v2: - Check the return value for the devm_mutex_init() --- drivers/iio/adc/ti-adc128s052.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index d0702d403fbe..d90a5caa028f 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -172,7 +172,9 @@ static int adc128_probe(struct spi_device *spi) if (ret) return ret; - mutex_init(&adc->lock); + ret = devm_mutex_init(&spi->dev, &adc->lock); + if (ret) + return ret; return devm_iio_device_register(&spi->dev, indio_dev); } From patchwork Mon Apr 7 11:36:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040278 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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 9B3BE238D27; Mon, 7 Apr 2025 11:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025804; cv=none; b=rEunulxiQXgB9dJE4IPJ8c4vTqSvxBDdbx7icNDVD6OBw/TCAm23w8Io631N4cq9omGT1xx40SNK3PoWCSKe704UW+22ublp6eZcTFe/ytJtoNwzaDcVHVr7fhqQmZuK4Y2wZ+49Q7Ev5Y2XLYFRP+XaWuT9dxfzSP2Xs9KupsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025804; c=relaxed/simple; bh=OBb6yPw+qEBGKPSi4wctAZVMTzOzBeM49h5g17UI5OU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SzpHEQwyHvCLUkdVdOO4ADuQUKbfRgJsICpdf9HX4rL2aQWrq6/lZXMnY4x5ecWTqxUHKFCLXGw1LZ/DPSw1zdv/uuoIc6cqz0gi0sNRyXz1uLydTCu8EGxUA2RrMVsmroyIdfSHZfM40E8fAUE35NmTX3e1So+Q16Lg9r24MOk= 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=BktBQZc3; arc=none smtp.client-ip=209.85.167.51 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="BktBQZc3" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5499c5d9691so4807412e87.2; Mon, 07 Apr 2025 04:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025801; x=1744630601; 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=c5WYMF9sR/AEB+gocgzCJwNMf68a65+bR/TxFPCym6o=; b=BktBQZc3C+sdQNFGygUuRZ9GP9IoTUKNj4mRbXko4J6GUiU7+V7H/SRUzwnPjHsF+R nl/X54pOGbBHpY5nmj6HKfLttuvSc2Pq0lbM+YxZBOY+BCixy1zj5G6Jkg3wrva7aANp d+wZmpFC9FcpQYWPHw03YJpeTWoBZQXq+AvaCBZuWbqFvTZQunym45uCrOnoSjnOFfOE VZB36KYEnxMsCaXh+5FVXyctgYO8f35BlOTCJ/3ur5VK50K8LPnpePQGoFlr/UnKUZkg wlPHf0ENgfvkoc768aJ8MhNKhIud7QT8JXAKLp4Kxp+rv/AckzrG0POXevVt+r50smuT f3Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025801; x=1744630601; 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=c5WYMF9sR/AEB+gocgzCJwNMf68a65+bR/TxFPCym6o=; b=r5OvAqW+/Gn6TAcdcnNTBtoBj5ZA7N0t3qN95DykW0tw2nOJ6J1zUuhP7s8xFPnz/T /xs8z3y3BViGt/wLel6aQu71Pp8b86hdrgciTNWe3LTNKqDryRmFQEDZfuBOEL+i/AgQ W5W1vnga8LD5nbcCpApuWww7aW3xwo/kRKMTiVKeVXvGLkOmWH+6dd5AwaQFUGNYPTGH qYxCgFIGSSLrI7PndQm3sYynJPS53fFImm+sla/n996Lfft8CKi1HxuK43i7TtG91+db k3hW7FjdGhNLPf5Six6v5sx858+8ES1sQXLDObZvKSFVSouPF9eKUxBn4WIZ8tQCarrp s4Wg== X-Forwarded-Encrypted: i=1; AJvYcCVdgYd2R1nRlZWXjQ7YEjw0SctQAI5AuwRnfNg5XsWzekQJ9YrneuQiPstAf5YNjYjklGAiGSyBQARP@vger.kernel.org, AJvYcCWct9jYMVCTAntklOZcHF5wu7o39YuG+JvOcL4wmXtFpMyvUoiGgqE/EHJtsyoD6PoMvo+WmI5FYm/L@vger.kernel.org, AJvYcCXnzdcgxI0lvSrKwLRHgGGKTQIR5L3Gr0JhXlij0Mm9KWpU/rnUItpEHwZIT9a60ytX+gKvqqhooA+Hql91@vger.kernel.org X-Gm-Message-State: AOJu0YwTZIUUn4iP5H5CspILESDQWcCTaQ+9pO75qukKHFjiHTVAgfY2 RkPVuJHusqHw4ed4Sp+cqOo+AQ5Smllm8flCj0QsFY6ndXs2XtPU X-Gm-Gg: ASbGncvpYmh5jCqxNRs8/DV5YeWK+8qxOzV3oCz22kduwfdeK10Bxv8yMYHS0RdMtee /YTK/bm+IF+z+4fs8vY+Dg8UTOJxiPDWLBNs8WZL8XmhYQhctuAVlmS6i6K2TyeOVTJaDkBu0mJ T/PdhboMIlIzncT3Jn2kHjOA5WNtsEwrvZmyxHWrxasEY+0trEVs09+sQ1RJNV6DW8rNFRHz3Bn WuSgjjsHK13znIpC+BF2TbZPQ2Vyn30f1Ik9Wg+VmhxvxGGVuUK5NT76DzPhkn5uT+b0X8E2AE7 eprTsMWxK8uyoQGFo/z/TtlgKhMuZ/UttKW2mREyLCLdWWEgQ3Q= X-Google-Smtp-Source: AGHT+IGWymGKOu6AZA9EMBC8ePoYK0OBTREO6kFiVCpG5la6qLD3EgSFy/3XPagXuN5bVvUi0MeXnA== X-Received: by 2002:a05:6512:39c7:b0:545:76e:31a with SMTP id 2adb3069b0e04-54c227678e5mr3453707e87.11.1744025800582; Mon, 07 Apr 2025 04:36:40 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e635c25sm1213461e87.115.2025.04.07.04.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:36:39 -0700 (PDT) Date: Mon, 7 Apr 2025 14:36:35 +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 v3 5/8] iio: adc: ti-adc128s052: Simplify using guard(mutex) 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: Error path in ADC reading function can be slighly simplified using the guard(mutex). Use guard(mutex) and document the mutex purpose. Signed-off-by: Matti Vaittinen --- Revision history: v2 => - No changes v1 => v2: - Protect the shared message data - Add message data protection to the mutex doc - Reword the commit message --- drivers/iio/adc/ti-adc128s052.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index d90a5caa028f..fa0099356be7 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -9,6 +9,7 @@ * https://www.ti.com/lit/ds/symlink/adc124s021.pdf */ +#include #include #include #include @@ -26,6 +27,10 @@ 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; union { @@ -38,19 +43,16 @@ static int adc128_adc_conversion(struct adc128 *adc, u8 channel) { int ret; - mutex_lock(&adc->lock); + guard(mutex)(&adc->lock); adc->buffer[0] = channel << 3; adc->buffer[1] = 0; ret = spi_write(adc->spi, &adc->buffer, sizeof(adc->buffer)); - if (ret < 0) { - mutex_unlock(&adc->lock); + if (ret < 0) return ret; - } ret = spi_read(adc->spi, &adc->buffer16, sizeof(adc->buffer16)); - mutex_unlock(&adc->lock); if (ret < 0) return ret; From patchwork Mon Apr 7 11:36:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040279 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 7880E238D27; Mon, 7 Apr 2025 11:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025816; cv=none; b=AwbE0zhBQKVOtXtVb5qcuq2fpO2/hZx0cv2xb+SGHId7FC/wytGxZwk9i0BA536cFM3NniE4DEKqgbE+rnki43QAk/LQR94UaK8ps4qtqCIJO1eFoDNdGVytw4aPhE66wwq/Z3Sj3jH7tqMSYYe/XpWjxOPkcdcLLT5X9pfZTr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025816; c=relaxed/simple; bh=kpJnzEPJ5DBpJTe5Y3Q9ZCqetJ9R7nSpDjl72oKh5CY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kj69S5Ag4FXKc8qQ3zrVZL5HzBenSiJOrPGy9gRhbC0eswSAAdL/9frydsm5dmwJM7WCsvbQhrraEBH5If/1BOveQtCFz5a9wZco6LA3o55XM3qhAhBGXpNaJcHp30kod5k95q7QKDV4FfpjBMazahDX8pUCee/uyvY07GLDjdg= 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=Jzp2BqfK; arc=none smtp.client-ip=209.85.167.41 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="Jzp2BqfK" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-548430564d9so4845432e87.2; Mon, 07 Apr 2025 04:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025812; x=1744630612; 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=JeJtpPmNV6fcrn2H+o0MwC8iIldJ9JWXCVKDhrhoghY=; b=Jzp2BqfKgFSQa+e7wgwuf6/O5CIgkvH5qLN4a2CdyVmn9ji/NLigaSyJNz911HyPPI jmVfRgOxCo0spFw51NDumnTPFVoJPfPCxS0uiTS8cx/UTFQMKI8fJhWZj2B+l1WRP02Q KCulEV0J1nYqpWPrRiV1u0KQpHjgtpA7I3wkVbGeMWgbOo4stozgWvRk1hWISv9ssOTd 48tIZkIr6Ku/c4GbpuEkpdlA1t1NFR9VPF6FjQ272z8VGSbA6R4kH6NDGE4yR211o/e3 EVEOVlHPFRDS42ySfJ0iIRvSYifFQySC0vaYFpkSXEcdtFak8MovJsjRsoskaQGzHz8A wgwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025812; x=1744630612; 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=JeJtpPmNV6fcrn2H+o0MwC8iIldJ9JWXCVKDhrhoghY=; b=o2MMe2X9H5KL64BhjFSh+Xk8lDvZy346FLAxNTuQLVuISA9Rxn+eeg0fzGAz7w8QSM QwP7Jm5X88WWJdWiLha7kJ41OG0rp3xECTcQ4mWs2gbEWk4kzQMcM+3kJZEuV399d5cT yzoOYnOwXtkmz05TaJeOfQH3BYG8cOaEj3ZU6b/gV3a9/nLKj8wODzrJHfPgPDR+2bo6 WffpOcuVQj6BhGRm09AxTCApwUmjtjd77Z/7dgykDj0qyWUR3yCjqMBArGU9iHqHbFEs EoqFitH2THtl2hEWHuuNhUKHjZsYXLDbPn9bIqKrPI+Vql1QOupfb5vqsRtO1GUDCkUn wZOQ== X-Forwarded-Encrypted: i=1; AJvYcCUexPZ8iFS6EKN7kZVBLbF6XXwyGF1nnXBnekhVe9tYcOyAuKZnHxxxv3jdHyLIpfi790ZnbeKmOWFQ5q1j@vger.kernel.org, AJvYcCVIhQgq6xCimVd6mTJGKZ/FFgRLutO12GNZNrGzEZ4dtvRmnlq4s7HCiiAUpYd/QLWtgHl0/ROkesDm@vger.kernel.org, AJvYcCWboGjcIPkn2qI0HxoNhb6pFXxAZedGvD4746wWjPM+uKdBBqakiseU44Bup9W0+3+zyBf1YWBs5WED@vger.kernel.org X-Gm-Message-State: AOJu0YwKTLHfIuZRqSx3S7RVR27dd6FzbE8vOF0+GlhSg7OMB6yzx2rM ooJQ0g1yuiOqsdSDcUsRQ2LiaNvAKgwymObCj7Xn/kA7E884aKbn X-Gm-Gg: ASbGncs8D36PmKtCAaPmD8+GAAL2Wb/jz66KYhqQo2fhsIP2ou92WEsOInO08i7eAEG s/tHrhssiHjXtyDtHzzg2ZkMIRMofe7xevv0lVPVfWUZ0t4dNn1cn9FaI8j8RIdhIMECz/m0wHk bpo5BmkMBR1Mr//0bdEKR5JfRE+C7zBNKU5zoS4CAwK0mFG0ihKOb9/rYyr8cTTTa9ZUWWRrk1r a1HRiIyFLWYrjo6UbdWv6QctpGQxJcc/VpVsXnWehbalbfTYVGcBNF9RbGCj2tOKdIeduBc2Skm F9bgdmv8zadnTtIVRWhw1V62XnqPswqP9TXYniz6yrKsMo6UcrSv7/0QaVYfvA== X-Google-Smtp-Source: AGHT+IG+Q9KD2qeqzs8zVpl3Y94ulKfjn2Hl5MtyIDuv4DilVpp02mFzgE1yTF+ezGnyYDe7JuRq9w== X-Received: by 2002:a05:6512:1255:b0:549:9143:4e8d with SMTP id 2adb3069b0e04-54c297b7221mr1969212e87.8.1744025812321; Mon, 07 Apr 2025 04:36:52 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c2e33fb7fsm588377e87.24.2025.04.07.04.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:36:50 -0700 (PDT) Date: Mon, 7 Apr 2025 14:36:47 +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 v3 6/8] iio: adc: ti-adc128s052: Support ROHM BD79104 Message-ID: <36ffa72cbdf8dbbdf1e612040db82ebcdf73fa24.1744022065.git.mazziesaccount@gmail.com> 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: The ROHM BD79104 ADC has identical SPI communication logic as the ti-adc128s052. Eg, SPI transfer should be 16 clk cycles, conversion is started when the CS is pulled low, and channel selection is done by writing the channel ID after two zero bits. Data is contained in big-endian format in the last 12 bits. The BD79104 has two input voltage pins. Data sheet uses terms "vdd" and "iovdd". The "vdd" is used also as an analog reference voltage. Hence the driver expects finding these from the device-tree, instead of having the "vref" only as TI's driver. NOTE: The TI's data sheet[1] does show that the TI's IC does actually have two voltage inputs as well. Pins are called Va (analog reference) and Vd (digital supply pin) - but I keep the existing driver behaviour for the TI's IC "as is", because I have no HW to test changes, and because I have no real need to touch it. NOTE II: The BD79104 requires SPI MODE 3. NOTE III: I used evaluation board "BD79104FV-EVK-001" made by ROHM. With this board I had to drop the SPI speed below the 20M which is mentioned in the data-sheet [2]. This, however, may be a limitation of the EVK board, not the component itself. Signed-off-by: Matti Vaittinen Datasheet: https://www.ti.com/lit/ds/symlink/adc128s052.pdf # [1] Datasheet: https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79104fv-la-e.pdf # [2] --- Revision history: v2 => - No changes v1 => v2: - Use Datasheet tags in commit message. --- drivers/iio/adc/Kconfig | 2 +- drivers/iio/adc/ti-adc128s052.c | 40 +++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 6529df1a498c..bbad7b3d41bf 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1469,7 +1469,7 @@ config TI_ADC128S052 depends on SPI help If you say yes here you get support for Texas Instruments ADC128S052, - ADC122S021 and ADC124S021 chips. + ADC122S021, ADC124S021 and ROHM Semiconductor BD79104 chips. This driver can also be built as a module. If so, the module will be called ti-adc128s052. diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index fa0099356be7..d4721ad90f2c 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -21,6 +21,9 @@ struct adc128_configuration { const struct iio_chan_spec *channels; u8 num_channels; + const char *refname; + int num_other_regulators; + const char * const (*other_regulators)[]; }; struct adc128 { @@ -124,10 +127,28 @@ static const struct iio_chan_spec adc124s021_channels[] = { ADC128_VOLTAGE_CHANNEL(3), }; +static const char * const bd79104_regulators[] = { "iovdd" }; + static const struct adc128_configuration adc128_config[] = { - { adc128s052_channels, ARRAY_SIZE(adc128s052_channels) }, - { adc122s021_channels, ARRAY_SIZE(adc122s021_channels) }, - { adc124s021_channels, ARRAY_SIZE(adc124s021_channels) }, + { + .channels = adc128s052_channels, + .num_channels = ARRAY_SIZE(adc128s052_channels), + .refname = "vref", + }, { + .channels = adc122s021_channels, + .num_channels = ARRAY_SIZE(adc122s021_channels), + .refname = "vref", + }, { + .channels = adc124s021_channels, + .num_channels = ARRAY_SIZE(adc124s021_channels), + .refname = "vref", + }, { + .channels = adc128s052_channels, + .num_channels = ARRAY_SIZE(adc128s052_channels), + .refname = "vdd", + .other_regulators = &bd79104_regulators, + .num_other_regulators = 1, + }, }; static const struct iio_info adc128_info = { @@ -162,7 +183,7 @@ 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, "vref"); + adc->reg = devm_regulator_get(&spi->dev, config->refname); if (IS_ERR(adc->reg)) return PTR_ERR(adc->reg); @@ -174,6 +195,15 @@ static int adc128_probe(struct spi_device *spi) if (ret) return ret; + if (config->num_other_regulators) { + ret = devm_regulator_bulk_get_enable(&spi->dev, + config->num_other_regulators, + *config->other_regulators); + if (ret) + return dev_err_probe(&spi->dev, ret, + "Failed to enable regulators\n"); + } + ret = devm_mutex_init(&spi->dev, &adc->lock); if (ret) return ret; @@ -189,6 +219,7 @@ static const struct of_device_id adc128_of_match[] = { { .compatible = "ti,adc124s021", .data = &adc128_config[2] }, { .compatible = "ti,adc124s051", .data = &adc128_config[2] }, { .compatible = "ti,adc124s101", .data = &adc128_config[2] }, + { .compatible = "rohm,bd79104", .data = &adc128_config[3] }, { } }; MODULE_DEVICE_TABLE(of, adc128_of_match); @@ -201,6 +232,7 @@ static const struct spi_device_id adc128_id[] = { { "adc124s021", (kernel_ulong_t)&adc128_config[2] }, { "adc124s051", (kernel_ulong_t)&adc128_config[2] }, { "adc124s101", (kernel_ulong_t)&adc128_config[2] }, + { "bd79104", (kernel_ulong_t)&adc128_config[3] }, { } }; MODULE_DEVICE_TABLE(spi, adc128_id); From patchwork Mon Apr 7 11:36:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040280 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 3AE8F51C5A; Mon, 7 Apr 2025 11:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025829; cv=none; b=obSrSaRSg1+4KXNC3mAsX4YaY/Ok0oB6PICnFpo3sxnk5yu5vEKN0C1gydkHt0MqrlOv7PgO+Ak4h2j+ERSNXK1djQIlMFYWQe1P1mCsyEhZRHuVyEkTNFry3AePOy02JnbSdwHFcOyPVzIMivnNoOwvG4fiRkNtYH8gHvTbFn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025829; c=relaxed/simple; bh=ne9ci4Cv6lRLDs/fOO/SIJtr05AcXjv8D8vYR/SAoIE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OSouLYYQYrYLlYR6+g3gD4FOT7MnWFNSnWtyfJBHmaRbleLfX4xMbpRPRnG+8sR1oM2xVbXY8FSY13qrlpsgdfk+1psZqsbv3YddPygxnVbdMJHs9/q6hGbsWJQIh7Y+i58NcFzR3LT7Aawm/CA13rONUN1yeSlo7YdadHml3P4= 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=eae/EiU0; arc=none smtp.client-ip=209.85.167.53 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="eae/EiU0" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-54af20849adso4164327e87.1; Mon, 07 Apr 2025 04:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025825; x=1744630625; 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=MIogLCE25czlv8xNdvtECl+eiGQ9SQ35kVz8Q7EAQEA=; b=eae/EiU0lZB4x+sToUz91U31q4/Ns3oEtw2pmTncje7eX1oVbB/x9XJ89LCNEXBeM0 3PSV67FPfRDurcuPR7mfdH66gaecsBiE/rKxXVvhoFPvxYsuXmMu4bFbdqa2erVrFDRH /+CaBeh+27R5JO3U/SM71IF1Mi1I2E++zm+9kY9YM/2lv+FSQSW1JbtGCVaQ3ICX7LMO LKjdW0vWc//hDFRS6GFn8yFAqKMzv9VlkZmIxivNQRkg8xa2VLwHVEiY4XVXJVS9nO5A K2q6qN+KVZRQPudmk90fSKd0nPi5smFpnsYpF+7L0nieK0JsvudaxoU+8wE3qsE0x9N4 TwMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025825; x=1744630625; 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=MIogLCE25czlv8xNdvtECl+eiGQ9SQ35kVz8Q7EAQEA=; b=bKpa+X64V7uRHN4ZIzIiXbcARIWrHR4K6brBexwjiBY4lErMMYKH0j7yuhX7P87VV/ +M9qypIzgrSGAhpKFphxwKL/O0CiUhVMopoR18qcyV0vWxa3MrfL+VtwLY59USXyC8Ho ezfO8EMZPTjQ68AkM8/DsVmt3IwbJl5UQF5EHiLtVviRh1yQAsez6XGIXmAyBDlBvRpr zSl6ienF6ZD9l/fSpUkP4CwjQMgbtAJNXx1p9pkK0rbi1AcQNRQQo0qr+gtcZhe3fmdH 7wWGtnGl+w2Mfmi+pmc5lFeJKYCji0RodOS7XTp7YDMaZ/1KhpfzNKfJFR+c2vvB1FUb CoxQ== X-Forwarded-Encrypted: i=1; AJvYcCVq1rfzzUM1gL70egQOZYPTUEVBQ+V/ggJT/eaPmhowLt6yk6DNl9Ia2dSLJR978lVABvw5VUMJacEO@vger.kernel.org, AJvYcCWv03F9VOv+wQ6bURp5n6UqBcc0WMaGouVb/LXm7gGv4ZmQV/vN6bx8RvNfGkZ/V7Ru9MSCjChWz1AYLllX@vger.kernel.org, AJvYcCXEIT1IWPiHGE+7HIc1gNigdD7x2jFaX3HO6wCFLOKF9Mw7hkAeDJ6mdzmpJkV5TYhPS7ae+/QTa2T5@vger.kernel.org X-Gm-Message-State: AOJu0YyktPOCCy2ZEoHSrbtHUiGI3TKINbxKnGJ8EWi8lOWgClh81Ew3 4rFfFQAmZ7SOZC0+IBESOgmStTV9sAWNu9gDTFPPmOeBbwFWV7vn X-Gm-Gg: ASbGncsGyYgwWw2O7fkI4LQOrVf3t8sa1dZbjnxsRIIYcX6YmcpyosMmNhPp9mYALd7 l9Oul+L9G+AR2faZIv2O7d9cO8h489IYOxJF9Vw2cJg6LcqjqxlxbnoY8pFNRFxEGPrneLWecBY XNLgbziJDRW/+MKFGM1rPYac65vXIjAbfonYMzhvDnMSHVlOWNCmns5lNrISlv+Jf/79nz4bIle fbPgCy96ghsK3o6a05GCH3x/7sOwVVsFsOxCV9VxbBe8fwkEyM2/Iy4UW3L/h9n+uLUkzJQNbQl JxzSJJd32r6dRWt2vUM6XrowzIq/ahkw+aXhznFKJ49lBKkeW48= X-Google-Smtp-Source: AGHT+IHPjqSB+GMfYyqjrh0Aak/fd3rm/itfCJmw71upKIgTCVa+ejcRCY+2WOdK6x+/sOM0mRE1Kg== X-Received: by 2002:a05:6512:36cc:b0:549:965f:5960 with SMTP id 2adb3069b0e04-54c1ca66e14mr4256481e87.16.1744025825176; Mon, 07 Apr 2025 04:37:05 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e65d57csm1209885e87.182.2025.04.07.04.37.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:37:03 -0700 (PDT) Date: Mon, 7 Apr 2025 14:36:59 +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 v3 7/8] MAINTAINERS: A driver for TI/ROHM ADCs 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: Add undersigned as a maintainer for the ti-adc128s052.c which supports a few TI's ADCs and the ROHM Semiconductor BD79704 ADC. Signed-off-by: Matti Vaittinen --- Revision history: v2 => v3: - New patch I only have access to the ROHM BD79704. Maintainers with access to the TIs ICs (and time, energy and the knowledge) would be welcome :) --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 96b827049501..bb705fac9279 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -24088,6 +24088,12 @@ M: Robert Richter S: Odd Fixes F: drivers/gpio/gpio-thunderx.c +TI ADC12xs and ROHM BD79104 ADC driver +M: Matti Vaittinen +S: Maintained +F: drivers/iio/adc/ti-adc128s052.c +L: linux-iio@vger.kernel.org + TI ADS1119 ADC DRIVER M: Francesco Dolcini M: João Paulo Gonçalves From patchwork Mon Apr 7 11:37:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 14040281 Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (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 A447E1EF1D; Mon, 7 Apr 2025 11:37:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025881; cv=none; b=BUl/tkg0W/Mu0800CBv2JFaCXMH0YTeQOO18xyrDlxCTQmdB9vwai4VmF6C3VSjVCVIyMKS9bpg2c3bCEZkS7V0tvlMxuBHxOWTRAWjrihurSxg7yCwfSccEie6vdnmtv8pHwe45biRc1El5iXAYSfjuGBNL/Fn97bOGkITVleA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744025881; c=relaxed/simple; bh=bsDKEmqgO0I2EGpzutpYFXCP3t7mHPazIKYXeIXoc14=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h4imAn73Khi1nkOSKvczxut49iquoqRFe5A+QBmmleMnbTHpwObyEI+ECGRwbHyTxYh0ltnwlUa7grJ5pseRaKfpcEVZJafVkWewlTQebOqbox/5iuohM5zfyze1aGg7iC2ZyEAFJrvCza2/ugRni8MRZS8s9Uyo/6ksJ9Xygo0= 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=XEAJKD5A; arc=none smtp.client-ip=209.85.167.48 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="XEAJKD5A" Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-54993c68ba0so4717730e87.2; Mon, 07 Apr 2025 04:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744025878; x=1744630678; 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=C0bW7XRgSgAoBBUc68G36J8+gSyA5kZtB4e9OyIg/to=; b=XEAJKD5Au9iYxiZafjgVbJpHt5ftDf5m/WfiaooUl6a4wtEvYpZzrYneF4Q0HHgYkn L7SrhukR0DerQxQFB6Qn9NtdLuX8XXuu08rTFP7+Kih1pXEgMze9TNsArT6r+Yek7471 fUzVysPwE14adzRFTRz3q/upUldIxi6hg1g2rSIk3xk1VcO2oeJDXG1JU2l+n1GPH9ul rt7YPaFd7HQmeFu75BYSTUSRjn/Z/VczLgClAYVp8FdsF1sNe+7tebPM+6MjEA6FRcYO BXI05OPUMEs5NUFC1IfwOioXeSCoxotFT0GftBIujmoUHK7jtTr4WUrQcUL8beIZ2jAJ Tz8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744025878; x=1744630678; 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=C0bW7XRgSgAoBBUc68G36J8+gSyA5kZtB4e9OyIg/to=; b=OfmlhKhj03PRyNf+PXchK95PpoZQyZltb1e1NYvWDYe9zIaa6Hk8wfidrGIvMn+rin 3oebMULkum2b6PA5Pb9ZEPLno0/j5B4vc2j6VaAtPmSaAt6nXXFOci/X6G3Z8sPXEgqB hza/HGHnw8K/te10IWeA6EDyC9hgClC1/pNIfcgzDVXruHSQnWq5yhIEpgTiI04pNii9 NyfTGTmXc7vi+BXJJTKs3Evx4XulmL116HImNFXAv6ZQbZyg0kxVCbmQRwZUcBHwcC6A LYzERJ3dviLhW7YsPgSqw3oQiSn0bln0cqlYL+WBAv6V21okoJoehlOCZk1kuDId+61v +VUg== X-Forwarded-Encrypted: i=1; AJvYcCWj1FO85icKqKhsJJWoU6vvQBH7/z9WoL+DLY2IPdLyJCBezUJ0Cv6h5PbFxWpG8GBdiu/P6/kN9oDSWwZr@vger.kernel.org, AJvYcCX6XUuAzIiQlkN+Ffr5ekT9SfYabjtMZZ1YBINbPpwRV6+S1ZKZw9Is+uSqAwtpAGxDo1rnr6mn72As@vger.kernel.org, AJvYcCXyfB6xosJacGJ+FfbXMon+iqo45SD3J+mjyARJ11ruGYSf1vgVEbO6UfpTxYNAIEmFQm01hXMDlf49@vger.kernel.org X-Gm-Message-State: AOJu0Yxgui7vWJjuK65o5U5QmQy01KpCKCpUVclgXm1hWReWVnDrtkyp miuDCeKqrNw+sC87xEa49wRwxcz0zC2o9ZYpv2Kf4L9IvVu+PmRn X-Gm-Gg: ASbGnctEq1F8Yd7YV6GFZUYvltYl788BlPUSwNisVg2iNiwViv99KenkQnXuEjavEZq pZr7dXHyuolAc8B6GgJz4fUjb+PsWGaQnIZ/vzjqvJkol1K8yyAJwZaGVCgV8bEoIYbCo83Rnq3 kFRn0tDIdTwbmbtFnblKY9niU0S7xI82pVAzKkHeWp81diMsXXMLznyET1KvfdYrgQTZLR3LMBd 8xNrt39JUyRItMHQxkUTqvM7G/BR3gObtGRyuAU/p3Es5iarFwYWlP1i+dyNU9/3aRUH6AmbaDA Pabarj0XwqlbWBKT9Kg5fdX/MoLr3R/IL7PeUrmOLRS1JX0JqK4= X-Google-Smtp-Source: AGHT+IGyVZ/zW67Y/NNpMoE1zJsgrkYKSJz2zRA0jkIHBBPaqRlJygoJDYO/LmcFcb2Ox+M4uNGpWQ== X-Received: by 2002:a05:6512:3b8b:b0:545:9e1:e824 with SMTP id 2adb3069b0e04-54c2280c34fmr3027378e87.48.1744025877566; Mon, 07 Apr 2025 04:37:57 -0700 (PDT) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54c1e670d0csm1209187e87.217.2025.04.07.04.37.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 04:37:56 -0700 (PDT) Date: Mon, 7 Apr 2025 14:37:52 +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 v3 8/8] 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 => v3: - Rename vref => vref_mv to make units visible - Divide vref once in the probe to avoid division every time the scale is requested v2: - New patch --- drivers/iio/adc/ti-adc128s052.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index d4721ad90f2c..c38468f299ce 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_mv; union { __be16 buffer16; u8 buffer[2]; @@ -81,11 +80,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_mv; *val2 = 12; return IIO_VAL_FRACTIONAL_LOG2; @@ -155,11 +150,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; @@ -183,17 +173,12 @@ 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); + adc->vref_mv = devm_regulator_get_enable_read_voltage(&spi->dev, + config->refname); + if (adc->vref_mv < 0) + return adc->vref_mv; - 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_mv /= 1000; if (config->num_other_regulators) { ret = devm_regulator_bulk_get_enable(&spi->dev,