return ret;
}
-static ssize_t iio_buffer_read_length(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t length_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
return sysfs_emit(buf, "%d\n", buffer->length);
}
-static ssize_t iio_buffer_write_length(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t length_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
return ret ? ret : len;
}
-static ssize_t iio_buffer_show_enable(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
iio_buffer_deactivate_all(indio_dev);
}
-static ssize_t iio_buffer_store_enable(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+static ssize_t enable_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
{
int ret;
bool requested_state;
return (ret < 0) ? ret : len;
}
-static ssize_t iio_buffer_show_watermark(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t watermark_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
return sysfs_emit(buf, "%u\n", buffer->watermark);
}
-static ssize_t iio_buffer_store_watermark(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+static ssize_t watermark_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
return ret ? ret : len;
}
-static ssize_t iio_dma_show_data_available(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t data_available_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct iio_buffer *buffer = to_iio_dev_attr(attr)->buffer;
}
}
-static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
- iio_buffer_write_length);
-static struct device_attribute dev_attr_length_ro = __ATTR(length,
- S_IRUGO, iio_buffer_read_length, NULL);
-static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
- iio_buffer_show_enable, iio_buffer_store_enable);
-static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
- iio_buffer_show_watermark, iio_buffer_store_watermark);
-static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
- S_IRUGO, iio_buffer_show_watermark, NULL);
-static DEVICE_ATTR(data_available, S_IRUGO,
- iio_dma_show_data_available, NULL);
+static DEVICE_ATTR_RW(length);
+static struct device_attribute dev_attr_length_ro = __ATTR_RO(length);
+static DEVICE_ATTR_RW(enable);
+static DEVICE_ATTR_RW(watermark);
+static struct device_attribute dev_attr_watermark_ro = __ATTR_RO(watermark);
+static DEVICE_ATTR_RO(data_available);
static DEVICE_ATTR_RO(direction);
/*
dev_attr->attr.name = name;
if (readfunc) {
- dev_attr->attr.mode |= S_IRUGO;
+ dev_attr->attr.mode |= 0444;
dev_attr->show = readfunc;
}
if (writefunc) {
- dev_attr->attr.mode |= S_IWUSR;
+ dev_attr->attr.mode |= 0200;
dev_attr->store = writefunc;
}
}
}
-static ssize_t iio_show_dev_name(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t name_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return sysfs_emit(buf, "%s\n", indio_dev->name);
}
-static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL);
+static DEVICE_ATTR_RO(name);
-static ssize_t iio_show_dev_label(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t label_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
return sysfs_emit(buf, "%s\n", indio_dev->label);
}
-static DEVICE_ATTR(label, S_IRUGO, iio_show_dev_label, NULL);
+static DEVICE_ATTR_RO(label);
-static ssize_t iio_show_timestamp_clock(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t current_timestamp_clock_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
{
const struct iio_dev *indio_dev = dev_to_iio_dev(dev);
const clockid_t clk = iio_device_get_clock(indio_dev);
return sz;
}
-static ssize_t iio_store_timestamp_clock(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t len)
+static ssize_t current_timestamp_clock_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
clockid_t clk;
int ret;
return 0;
}
-static DEVICE_ATTR(current_timestamp_clock, S_IRUGO | S_IWUSR,
- iio_show_timestamp_clock, iio_store_timestamp_clock);
+static DEVICE_ATTR_RW(current_timestamp_clock);
static int iio_device_register_sysfs(struct iio_dev *indio_dev)
{
static DEFINE_MUTEX(iio_trigger_list_lock);
/**
- * iio_trigger_read_name() - retrieve useful identifying name
+ * name_show() - retrieve useful identifying name
* @dev: device associated with the iio_trigger
* @attr: pointer to the device_attribute structure that is
* being processed
* Return: a negative number on failure or the number of written
* characters on success.
*/
-static ssize_t iio_trigger_read_name(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t name_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct iio_trigger *trig = to_iio_trigger(dev);
return sysfs_emit(buf, "%s\n", trig->name);
}
-static DEVICE_ATTR(name, S_IRUGO, iio_trigger_read_name, NULL);
+static DEVICE_ATTR_RO(name);
static struct attribute *iio_trig_dev_attrs[] = {
&dev_attr_name.attr,
EXPORT_SYMBOL_GPL(iio_dealloc_pollfunc);
/**
- * iio_trigger_read_current() - trigger consumer sysfs query current trigger
+ * current_trigger_show() - trigger consumer sysfs query current trigger
* @dev: device associated with an industrial I/O device
* @attr: pointer to the device_attribute structure that
* is being processed
* Return: a negative number on failure, the number of characters written
* on success or 0 if no trigger is available
*/
-static ssize_t iio_trigger_read_current(struct device *dev,
- struct device_attribute *attr,
- char *buf)
+static ssize_t current_trigger_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
}
/**
- * iio_trigger_write_current() - trigger consumer sysfs set current trigger
+ * current_trigger_store() - trigger consumer sysfs set current trigger
* @dev: device associated with an industrial I/O device
* @attr: device attribute that is being processed
* @buf: string buffer that holds the name of the trigger
* Return: negative error code on failure or length of the buffer
* on success
*/
-static ssize_t iio_trigger_write_current(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+static ssize_t current_trigger_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
return ret;
}
-static DEVICE_ATTR(current_trigger, S_IRUGO | S_IWUSR,
- iio_trigger_read_current,
- iio_trigger_write_current);
+static DEVICE_ATTR_RW(current_trigger);
static struct attribute *iio_trigger_consumer_attrs[] = {
&dev_attr_current_trigger.attr,