From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 72125221F1F; Tue, 17 Jun 2025 15:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750174504; cv=none; b=ehlnV9wQRs8o8Fww7GiS1fKRuHVu/z4RlsLjYsK4bmln5pu4G5oRkbK6F6Jd1AxehE9eVdb7vlxDS2FocL8jR7aaB9Dz+r1izPB8lHfilyo3z30AhENGfEI4zaFiLlyXbJVXAYpb5ifZTqxEnP6o3YQ5kXbT5Lt6HlsDM/Xtyx0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750174504; c=relaxed/simple; bh=CPRfJWrde/3/SeuvcgoE8XZLSXfJKM2tDw/cNUxij6U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZWDh0jFnSZUZxbwGTvkJ49e18Wf3BbJD91kDCRwfPHNz8dx7V6gtWx+RWrKCtrMEbvSC/5zjqxs+IkMysZjmCjpsVO7ieGSEm5mZDrQOWonqbBbpwqHXxrePeIt/M+xfbl/f28Gf9sSHEyv52x+y1NSkYCq3LamHZC4k8eSPFaA= 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=Je3VwXQw; arc=none smtp.client-ip=209.85.128.49 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="Je3VwXQw" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-43edecbfb46so44169115e9.0; Tue, 17 Jun 2025 08:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750174501; x=1750779301; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=MeUMhKUUGmcp9qUgtKmUDGAht+h0f117nU5fk45ORA8=; b=Je3VwXQwmtcB/PPaOgIT+SfH781dLGkPHfaz7fLEJOxW8yPsyQKQ6gHKeB6S8TxFEt WbVp2VzkgMWZj87cgveusv8mn2YO4R+PKgPiwjE3bEknR2klLsPN0n7+nJphHrjUtSmF q5GDYH38AiuXCOOVHiJJBqY4kqSEi/J4dPZLcpfrM8L8HNoWS8fQUx1QK1BJOCIDAxwz 3QmGJGSbWa7wANp4FjR3FiYBkExHTVr+rwhfESnoGXVxbpS4x7hmjCJgfuUhDc5HKdf8 wiYmzdqx2RWYAz7KIKCwexdSJxeAyl0WQULVEilJhpd60XhlbzYTuTSiJD4RTz8gvfGo jgaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750174501; x=1750779301; h=in-reply-to:content-transfer-encoding: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=MeUMhKUUGmcp9qUgtKmUDGAht+h0f117nU5fk45ORA8=; b=YMneWsuDmTBwESR1Jk2rmW5zRBGllgvphoCLqrAtST2zy9O857+Etq1Ls1t1X2Oir+ JSjHWIBNW0uRTCCvYat/p5EM5k4yNl47FHXUuvCgT/xoWo+jTPZ+5GGptMUbbsgq5XMA iTqR3aS5jekkZo1J/g7gHsMZjRJ0e7fUDN91TW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HYAjHxDyGoRskSLEinVeVf/Lje30f4qgn4Xj+l Fb9234ZvniZxqgDZyKdWOTkXqtfZ5v8q7bJNpI4MseObjl6+nTB6wLALUF8bIALJREYqya6r0OU mF0N8l70= X-Google-Smtp-Source: AGHT+IEcSofaIoMWRLHHOm6SNzbPQq+A9aFchPMIuRecoiBLLWlnkmk5gbcFgeFTvXVj0u/dPRX0kg== X-Received: by 2002:a05:6000:2289:b0:3a4:f723:3e73 with SMTP id ffacd0b85a97d-3a5723a3627mr11983013f8f.16.1750174500651; Tue, 17 Jun 2025 08:35:00 -0700 (PDT) Received: from HYB-DlYm71t3hSl.ad.analog.com ([137.71.226.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e224600sm180824845e9.8.2025.06.17.08.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 08:35:00 -0700 (PDT) Date: Tue, 17 Jun 2025 17:34:56 +0200 From: Jorge Marques To: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= Cc: Jorge Marques , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , David Lechner , Nuno =?utf-8?B?U8Oh?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-pwm@vger.kernel.org Subject: Re: [PATCH v3 4/8] iio: adc: Add support for ad4052 Message-ID: References: <20250610-iio-driver-ad4052-v3-0-cf1e44c516d4@analog.com> <20250610-iio-driver-ad4052-v3-4-cf1e44c516d4@analog.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jun 17, 2025 at 04:59:48PM +0200, Uwe Kleine-König wrote: > On Tue, Jun 10, 2025 at 09:34:37AM +0200, Jorge Marques wrote: > > +static int ad4052_get_samp_freq(struct iio_dev *indio_dev, > > + struct iio_chan_spec const *chan, > > + int *val, > > + int *val2) > > +{ > > + struct ad4052_state *st = iio_priv(indio_dev); > > + > > + *val = DIV_ROUND_UP_ULL(NSEC_PER_SEC, st->pwm_st.period); > > + return IIO_VAL_INT; > > st->pwm_st.period is the period that was requested before. If you want > the real period that is currently emitted, check pwm_get_state_hw(). > Hi Uwe, I believe only ad4695.c uses this method and the reason for that is if the pwm is disabled we still want to obtain the requested value. Reverting slightly to v2, the semantic to allow fetching from hw when enabled, and using the managed state when disabled, would be: struct pwm_state pwm_st; int ret ret = pwm_get_state_hw(st->cnv_pwm, &pwm_st); if (ret) goto out_release; if (!pwm_st.enabled) pwm_st = st->pwm_st; *val = DIV_ROUND_UP_ULL(NSEC_PER_SEC, pwm_st.period); Is this ok? Best regards, Jorge > > +} > > Best regards > Uwe