From: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Michal Simek" <michal.simek@amd.com>,
"Conall O'Griofa" <conall.ogriofa@amd.com>
Cc: <linux-iio@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <git@amd.com>,
Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>,
Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Subject: [PATCH v6 10/16] iio: adc: xilinx-xadc: Add unit suffixes to macro names
Date: Wed, 25 Nov 2026 22:40:24 +0530 [thread overview]
Message-ID: <20261125171045.1246381-11-dileepkumar.nagavarapu@amd.com> (raw)
In-Reply-To: <20261125171045.1246381-1-dileepkumar.nagavarapu@amd.com>
Append the unit to the relevant macro names (_Hz, _MS, _CYCLES, _SPS)
so that the expected unit of each value is clear at the point of use
and to avoid ambiguity.
No functional change intended
Co-developed-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
Signed-off-by: Dileep Kumar Nagavarapu <dileepkumar.nagavarapu@amd.com>
---
drivers/iio/adc/xilinx-xadc-core.c | 37 +++++++++++++++---------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
index 8801bbc7431c..813caf66b11a 100644
--- a/drivers/iio/adc/xilinx-xadc-core.c
+++ b/drivers/iio/adc/xilinx-xadc-core.c
@@ -27,6 +27,7 @@
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/types.h>
+#include <linux/units.h>
#include <linux/iio/buffer.h>
#include <linux/iio/events.h>
@@ -38,7 +39,7 @@
#include "xilinx-xadc.h"
-static const unsigned int XADC_ZYNQ_UNMASK_TIMEOUT = 500;
+static const unsigned int XADC_ZYNQ_UNMASK_TIMEOUT_MS = 500;
/* ZYNQ register definitions */
#define XADC_ZYNQ_REG_CFG 0x00
@@ -120,7 +121,7 @@ static const unsigned int XADC_ZYNQ_UNMASK_TIMEOUT = 500;
* limits the maximum samplerate 150kSPS. At this rate the CPU is fairly busy,
* but still responsive.
*/
-#define XADC_MAX_SAMPLERATE 150000
+#define XADC_MAX_SAMPLERATE_SPS (150 * KILO)
static void xadc_write_reg(struct xadc *xadc, unsigned int reg, u32 val)
{
@@ -276,7 +277,7 @@ static void xadc_zynq_unmask_worker(struct work_struct *work)
/* if still pending some alarm re-trigger the timer */
if (xadc->zynq_masked_alarm) {
schedule_delayed_work(&xadc->zynq_unmask_work,
- msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT));
+ msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT_MS));
}
}
@@ -315,15 +316,15 @@ static irqreturn_t xadc_zynq_interrupt_handler(int irq, void *devid)
/* unmask the required interrupts in timer. */
schedule_delayed_work(&xadc->zynq_unmask_work,
- msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT));
+ msecs_to_jiffies(XADC_ZYNQ_UNMASK_TIMEOUT_MS));
}
return IRQ_HANDLED;
}
-#define XADC_ZYNQ_TCK_RATE_MAX 50000000
-#define XADC_ZYNQ_IGAP_DEFAULT 20
-#define XADC_ZYNQ_PCAP_RATE_MAX 200000000
+#define XADC_ZYNQ_TCK_RATE_MAX_Hz (50 * HZ_PER_MHZ)
+#define XADC_ZYNQ_IGAP_DEFAULT_CYCLES 20
+#define XADC_ZYNQ_PCAP_RATE_MAX_Hz (200 * HZ_PER_MHZ)
static int xadc_zynq_setup(struct platform_device *pdev, struct iio_dev *indio_dev, int irq)
{
@@ -336,8 +337,8 @@ static int xadc_zynq_setup(struct platform_device *pdev, struct iio_dev *indio_d
int ret;
/* TODO: Figure out how to make igap and tck_rate configurable */
- igap = XADC_ZYNQ_IGAP_DEFAULT;
- tck_rate = XADC_ZYNQ_TCK_RATE_MAX;
+ igap = XADC_ZYNQ_IGAP_DEFAULT_CYCLES;
+ tck_rate = XADC_ZYNQ_TCK_RATE_MAX_Hz;
xadc->zynq_intmask = ~0;
@@ -345,8 +346,8 @@ static int xadc_zynq_setup(struct platform_device *pdev, struct iio_dev *indio_d
if (!pcap_rate)
return -EINVAL;
- if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) {
- ret = clk_set_rate(xadc->clk, (unsigned long)XADC_ZYNQ_PCAP_RATE_MAX);
+ if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX_Hz) {
+ ret = clk_set_rate(xadc->clk, (unsigned long)XADC_ZYNQ_PCAP_RATE_MAX_Hz);
if (ret)
return ret;
}
@@ -355,7 +356,7 @@ static int xadc_zynq_setup(struct platform_device *pdev, struct iio_dev *indio_d
div = 2;
} else {
div = pcap_rate / tck_rate;
- if (pcap_rate / div > XADC_ZYNQ_TCK_RATE_MAX)
+ if (pcap_rate / div > XADC_ZYNQ_TCK_RATE_MAX_Hz)
div++;
}
@@ -376,7 +377,7 @@ static int xadc_zynq_setup(struct platform_device *pdev, struct iio_dev *indio_d
XADC_ZYNQ_CFG_REDGE | FIELD_PREP(XADC_ZYNQ_CFG_TCKRATE_MASK, tck_div) |
FIELD_PREP(XADC_ZYNQ_CFG_IGAP_MASK, igap));
- if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX) {
+ if (pcap_rate > XADC_ZYNQ_PCAP_RATE_MAX_Hz) {
ret = clk_set_rate(xadc->clk, pcap_rate);
if (ret)
return ret;
@@ -952,8 +953,8 @@ static int xadc_write_samplerate(struct xadc *xadc, int val)
return -EINVAL;
/* Max. 150 kSPS */
- if (val > XADC_MAX_SAMPLERATE)
- val = XADC_MAX_SAMPLERATE;
+ if (val > XADC_MAX_SAMPLERATE_SPS)
+ val = XADC_MAX_SAMPLERATE_SPS;
val *= 26;
@@ -966,7 +967,7 @@ static int xadc_write_samplerate(struct xadc *xadc, int val)
* limit.
*/
div = clk_rate / val;
- if (clk_rate / div / 26 > XADC_MAX_SAMPLERATE)
+ if (clk_rate / div > 26 * XADC_MAX_SAMPLERATE_SPS)
div++;
if (div < 2)
div = 2;
@@ -1343,8 +1344,8 @@ static int xadc_probe(struct platform_device *pdev)
if (ret < 0)
return ret;
- if (ret > XADC_MAX_SAMPLERATE) {
- ret = xadc_write_samplerate(xadc, XADC_MAX_SAMPLERATE);
+ if (ret > XADC_MAX_SAMPLERATE_SPS) {
+ ret = xadc_write_samplerate(xadc, XADC_MAX_SAMPLERATE_SPS);
if (ret < 0)
return ret;
}
--
2.34.1
next prev parent reply other threads:[~2026-11-25 17:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 17:10 [PATCH v6 00/16] iio: adc: xilinx-xadc: Add I2C interface support for System Management Wizard Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 01/16] iio: adc: xilinx-xadc: Correct write edge in CFG Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 02/16] iio: adc: xilinx-xadc: Refine Zynq read/write error handling on timeout/interrupt Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 03/16] iio: adc: xilinx-xadc: Fix coding style issues Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 04/16] iio: adc: xilinx-xadc: Use kernel integer types Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 05/16] iio: adc: xilinx-xadc: Drop unnecessary masking and dead code Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 06/16] iio: adc: xilinx-xadc: Use bitfield helpers and bit macros Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 07/16] iio: adc: xilinx-xadc: Use guard()/scoped_guard() for spinlock locking Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 08/16] iio: adc: xilinx-xadc: Use guard() for mutex locking Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 09/16] iio: adc: xilinx-xadc: Simplify common coding patterns Dileep Kumar Nagavarapu
2026-11-25 17:10 ` Dileep Kumar Nagavarapu [this message]
2026-11-25 17:10 ` [PATCH v6 11/16] iio: adc: xilinx-xadc: Include appropriate header files Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 12/16] iio: adc: xilinx-xadc: Add clarifying comments Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 13/16] iio: adc: xilinx-xadc: Add helper functions for the device setup Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 14/16] iio: adc: xilinx-xadc: Split driver into core and platform files Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 15/16] iio: adc: xilinx-xadc: Add .setup_channels() to struct xadc_ops Dileep Kumar Nagavarapu
2026-11-25 17:10 ` [PATCH v6 16/16] iio: adc: xilinx-xadc: Add I2C interface support Dileep Kumar Nagavarapu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125171045.1246381-11-dileepkumar.nagavarapu@amd.com \
--to=dileepkumar.nagavarapu@amd.com \
--cc=andy@kernel.org \
--cc=conall.ogriofa@amd.com \
--cc=dlechner@baylibre.com \
--cc=git@amd.com \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=nuno.sa@analog.com \
--cc=sai.krishna.potthuri@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®