Thread (17 messages) 17 messages, 4 authors, 2020-12-13

Re: [PATCH 3/6] iio:pressure:ms5637: limit available sample frequencies

From: Jonathan Cameron <jic23@kernel.org>
Date: 2020-12-13 17:19:37
Also in: linux-devicetree, linux-iio, lkml

On Sat, 12 Dec 2020 20:26:16 +0200
Andy Shevchenko [off-list ref] wrote:
On Thu, Dec 10, 2020 at 2:03 AM Alexandre Belloni
[off-list ref] wrote:
quoted
Avoid exposing all the sampling frequencies for chip that only support a
subset.  
quoted
+static ssize_t ms5637_show_samp_freq(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+       struct ms_tp_dev *dev_data = iio_priv(indio_dev);
+       int i, len = 0;
+
+       for (i = 0; i <= dev_data->hw->max_res_index; i++)
+               len += scnprintf(buf + len, PAGE_SIZE - len, "%u ", ms5637_samp_freq[i]);  
Doesn't IIO core have a helper?
read_avail() callback and matching masks provide the infrastructure to do this.
It's not a huge saving in code by the time you've wired it up, but has the
advantage that consumer drivers can get hold of the values.  Mind you
I'm not sure what consumers we are likely to get for pressure drivers any
time soon.
Also, it's better to use sysfs_emit().
New one to me. Thanks.  sysfs_emit_at() here I guess.

Nice.

Jonathan
quoted
+       buf[len - 1] = '\n';
+
+       return len;
+}  

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help