/* For trigger consumers the current_trigger interface allows the trigger used for this device to be specified at run time based on the triggers name.  */
static ssize_t iio_trigger_write_current(struct device *dev, struct device_attribute *attr, const char *buf, size_t len)
/* For trigger consumers the current_trigger interface allows the trigger used for this device to be specified at run time based on the triggers name.  */
static ssize_t iio_trigger_write_current(struct device *dev, struct device_attribute *attr, const char *buf, size_t len)
{
	struct iio_dev *dev_info = dev_get_drvdata(dev);
	struct iio_trigger *oldtrig = dev_info->trig;
	mutex_lock(&dev_info->mlock);
	if (dev_info->currentmode == INDIO_RING_TRIGGERED) {
		mutex_unlock(&dev_info->mlock);
		return -EBUSY;
	}
	mutex_unlock(&dev_info->mlock);
	len = len < IIO_TRIGGER_NAME_LENGTH ? len : IIO_TRIGGER_NAME_LENGTH;
	dev_info->trig = iio_trigger_find_by_name(buf, len);
	if (oldtrig && dev_info->trig != oldtrig)
		iio_put_trigger(oldtrig);
	if (dev_info->trig)
		iio_get_trigger(dev_info->trig);
	return len;
}