[PATCH RFC 4/8] iio: frequency: ad9910: expose sysclk_frequency device attribute

Rodrigo Alencar via B4 Relay posted 8 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH RFC 4/8] iio: frequency: ad9910: expose sysclk_frequency device attribute
Posted by Rodrigo Alencar via B4 Relay 1 month, 1 week ago
From: Rodrigo Alencar <rodrigo.alencar@analog.com>

Add read-only sysclk_frequency sysfs attribute. This value is important
for userspace to calculate values to populate the Parallel Port or the
RAM data buffer.

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
 drivers/iio/frequency/ad9910.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/iio/frequency/ad9910.c b/drivers/iio/frequency/ad9910.c
index bb280972e84c..a72e3685f676 100644
--- a/drivers/iio/frequency/ad9910.c
+++ b/drivers/iio/frequency/ad9910.c
@@ -789,10 +789,31 @@ static int ad9910_reg_access(struct iio_dev *indio_dev,
 	return ret;
 }
 
+static ssize_t sysclk_frequency_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buf)
+{
+	struct ad9910_state *st = iio_priv(dev_to_iio_dev(dev));
+
+	return sysfs_emit(buf, "%u\n", st->data.sysclk_freq_hz);
+}
+
+static IIO_DEVICE_ATTR_RO(sysclk_frequency, 0);
+
+static struct attribute *ad9910_attrs[] = {
+	&iio_dev_attr_sysclk_frequency.dev_attr.attr,
+	NULL
+};
+
+static const struct attribute_group ad9910_attrs_group = {
+	.attrs = ad9910_attrs,
+};
+
 static const struct iio_info ad9910_info = {
 	.read_raw = ad9910_read_raw,
 	.write_raw = ad9910_write_raw,
 	.write_raw_get_fmt = ad9910_write_raw_get_fmt,
+	.attrs = &ad9910_attrs_group,
 	.debugfs_reg_access = &ad9910_reg_access,
 };
 

-- 
2.43.0
Re: [PATCH RFC 4/8] iio: frequency: ad9910: expose sysclk_frequency device attribute
Posted by Jonathan Cameron 1 month ago
On Fri, 20 Feb 2026 16:46:08 +0000
Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:

> From: Rodrigo Alencar <rodrigo.alencar@analog.com>
> 
> Add read-only sysclk_frequency sysfs attribute. This value is important
> for userspace to calculate values to populate the Parallel Port or the
> RAM data buffer.
> 
> Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
Can we not use sampling_frequency (kind of backwards but IIRC we've done it
before) to provide information on what the frequency of the DAC updating is?

Jonathan

> ---
>  drivers/iio/frequency/ad9910.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/iio/frequency/ad9910.c b/drivers/iio/frequency/ad9910.c
> index bb280972e84c..a72e3685f676 100644
> --- a/drivers/iio/frequency/ad9910.c
> +++ b/drivers/iio/frequency/ad9910.c
> @@ -789,10 +789,31 @@ static int ad9910_reg_access(struct iio_dev *indio_dev,
>  	return ret;
>  }
>  
> +static ssize_t sysclk_frequency_show(struct device *dev,
> +				     struct device_attribute *attr,
> +				     char *buf)
> +{
> +	struct ad9910_state *st = iio_priv(dev_to_iio_dev(dev));
> +
> +	return sysfs_emit(buf, "%u\n", st->data.sysclk_freq_hz);
> +}
> +
> +static IIO_DEVICE_ATTR_RO(sysclk_frequency, 0);
> +
> +static struct attribute *ad9910_attrs[] = {
> +	&iio_dev_attr_sysclk_frequency.dev_attr.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group ad9910_attrs_group = {
> +	.attrs = ad9910_attrs,
> +};
> +
>  static const struct iio_info ad9910_info = {
>  	.read_raw = ad9910_read_raw,
>  	.write_raw = ad9910_write_raw,
>  	.write_raw_get_fmt = ad9910_write_raw_get_fmt,
> +	.attrs = &ad9910_attrs_group,
>  	.debugfs_reg_access = &ad9910_reg_access,
>  };
>  
>