Commit cb955852 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Jonathan Cameron
Browse files

iio: Remove support for the legacy event config interface



Now that all drivers have been converted to the new event config interface we
can remove for the legacy event config interface. Also drop the '_new' suffix
for the event config interface callbacks, since those are the only callbacks
now.

Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent bb7f9d90
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1039,10 +1039,10 @@ static const struct iio_info max1238_info = {
};

static const struct iio_info max1363_info = {
	.read_event_value_new = &max1363_read_thresh,
	.write_event_value_new = &max1363_write_thresh,
	.read_event_config_new = &max1363_read_event_config,
	.write_event_config_new = &max1363_write_event_config,
	.read_event_value = &max1363_read_thresh,
	.write_event_value = &max1363_write_thresh,
	.read_event_config = &max1363_read_event_config,
	.write_event_config = &max1363_write_event_config,
	.read_raw = &max1363_read_raw,
	.update_scan_mode = &max1363_update_scan_mode,
	.driver_module = THIS_MODULE,
+3 −3
Original line number Diff line number Diff line
@@ -458,9 +458,9 @@ static int ad5421_read_event_value(struct iio_dev *indio_dev,
static const struct iio_info ad5421_info = {
	.read_raw =		ad5421_read_raw,
	.write_raw =		ad5421_write_raw,
	.read_event_config_new = ad5421_read_event_config,
	.write_event_config_new = ad5421_write_event_config,
	.read_event_value_new =	ad5421_read_event_value,
	.read_event_config =	ad5421_read_event_config,
	.write_event_config =	ad5421_write_event_config,
	.read_event_value =	ad5421_read_event_value,
	.driver_module =	THIS_MODULE,
};

+22 −132
Original line number Diff line number Diff line
@@ -242,11 +242,7 @@ static ssize_t iio_ev_state_store(struct device *dev,
	if (ret < 0)
		return ret;

	if (indio_dev->info->write_event_config)
	ret = indio_dev->info->write_event_config(indio_dev,
			this_attr->address, val);
	else
		ret = indio_dev->info->write_event_config_new(indio_dev,
		this_attr->c, iio_ev_attr_type(this_attr),
		iio_ev_attr_dir(this_attr), val);

@@ -261,11 +257,7 @@ static ssize_t iio_ev_state_show(struct device *dev,
	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
	int val;

	if (indio_dev->info->read_event_config)
	val = indio_dev->info->read_event_config(indio_dev,
			this_attr->address);
	else
		val = indio_dev->info->read_event_config_new(indio_dev,
		this_attr->c, iio_ev_attr_type(this_attr),
		iio_ev_attr_dir(this_attr));
	if (val < 0)
@@ -283,14 +275,7 @@ static ssize_t iio_ev_value_show(struct device *dev,
	int val, val2;
	int ret;

	if (indio_dev->info->read_event_value) {
	ret = indio_dev->info->read_event_value(indio_dev,
			this_attr->address, &val);
		if (ret < 0)
			return ret;
		return sprintf(buf, "%d\n", val);
	} else {
		ret = indio_dev->info->read_event_value_new(indio_dev,
		this_attr->c, iio_ev_attr_type(this_attr),
		iio_ev_attr_dir(this_attr), iio_ev_attr_info(this_attr),
		&val, &val2);
@@ -298,7 +283,6 @@ static ssize_t iio_ev_value_show(struct device *dev,
		return ret;
	return iio_format_value(buf, ret, val, val2);
}
}

static ssize_t iio_ev_value_store(struct device *dev,
				  struct device_attribute *attr,
@@ -310,25 +294,16 @@ static ssize_t iio_ev_value_store(struct device *dev,
	int val, val2;
	int ret;

	if (!indio_dev->info->write_event_value &&
		!indio_dev->info->write_event_value_new)
	if (!indio_dev->info->write_event_value)
		return -EINVAL;

	if (indio_dev->info->write_event_value) {
		ret = kstrtoint(buf, 10, &val);
		if (ret)
			return ret;
		ret = indio_dev->info->write_event_value(indio_dev,
			this_attr->address, val);
	} else {
	ret = iio_str_to_fixpoint(buf, 100000, &val, &val2);
	if (ret)
		return ret;
		ret = indio_dev->info->write_event_value_new(indio_dev,
	ret = indio_dev->info->write_event_value(indio_dev,
		this_attr->c, iio_ev_attr_type(this_attr),
		iio_ev_attr_dir(this_attr), iio_ev_attr_info(this_attr),
		val, val2);
	}
	if (ret < 0)
		return ret;

@@ -377,7 +352,7 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
	return attrcount;
}

static int iio_device_add_event_sysfs_new(struct iio_dev *indio_dev,
static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
	struct iio_chan_spec const *chan)
{
	int ret = 0, i, attrcount = 0;
@@ -420,89 +395,6 @@ error_ret:
	return ret;
}

static int iio_device_add_event_sysfs_old(struct iio_dev *indio_dev,
				      struct iio_chan_spec const *chan)
{
	int ret = 0, i, attrcount = 0;
	u64 mask = 0;
	char *postfix;
	if (!chan->event_mask)
		return 0;

	for_each_set_bit(i, &chan->event_mask, sizeof(chan->event_mask)*8) {
		postfix = kasprintf(GFP_KERNEL, "%s_%s_en",
				    iio_ev_type_text[i/IIO_EV_DIR_MAX],
				    iio_ev_dir_text[i%IIO_EV_DIR_MAX]);
		if (postfix == NULL) {
			ret = -ENOMEM;
			goto error_ret;
		}
		if (chan->modified)
			mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel2,
						  i/IIO_EV_DIR_MAX,
						  i%IIO_EV_DIR_MAX);
		else if (chan->differential)
			mask = IIO_EVENT_CODE(chan->type,
					      0, 0,
					      i%IIO_EV_DIR_MAX,
					      i/IIO_EV_DIR_MAX,
					      0,
					      chan->channel,
					      chan->channel2);
		else
			mask = IIO_UNMOD_EVENT_CODE(chan->type,
						    chan->channel,
						    i/IIO_EV_DIR_MAX,
						    i%IIO_EV_DIR_MAX);

		ret = __iio_add_chan_devattr(postfix,
					     chan,
					     &iio_ev_state_show,
					     iio_ev_state_store,
					     mask,
					     0,
					     &indio_dev->dev,
					     &indio_dev->event_interface->
					     dev_attr_list);
		kfree(postfix);
		if (ret)
			goto error_ret;
		attrcount++;
		postfix = kasprintf(GFP_KERNEL, "%s_%s_value",
				    iio_ev_type_text[i/IIO_EV_DIR_MAX],
				    iio_ev_dir_text[i%IIO_EV_DIR_MAX]);
		if (postfix == NULL) {
			ret = -ENOMEM;
			goto error_ret;
		}
		ret = __iio_add_chan_devattr(postfix, chan,
					     iio_ev_value_show,
					     iio_ev_value_store,
					     mask,
					     0,
					     &indio_dev->dev,
					     &indio_dev->event_interface->
					     dev_attr_list);
		kfree(postfix);
		if (ret)
			goto error_ret;
		attrcount++;
	}
	ret = attrcount;
error_ret:
	return ret;
}


static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
				      struct iio_chan_spec const *chan)
{
	if (chan->event_mask)
		return iio_device_add_event_sysfs_old(indio_dev, chan);
	else
		return iio_device_add_event_sysfs_new(indio_dev, chan);
}

static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
{
	int j, ret, attrcount = 0;
@@ -523,8 +415,6 @@ static bool iio_check_for_dynamic_events(struct iio_dev *indio_dev)
	int j;

	for (j = 0; j < indio_dev->num_channels; j++) {
		if (indio_dev->channels[j].event_mask != 0)
			return true;
		if (indio_dev->channels[j].num_event_specs != 0)
			return true;
	}
+4 −4
Original line number Diff line number Diff line
@@ -344,10 +344,10 @@ static const struct iio_info apds9300_info_no_irq = {
static const struct iio_info apds9300_info = {
	.driver_module		= THIS_MODULE,
	.read_raw		= apds9300_read_raw,
	.read_event_value_new	= apds9300_read_thresh,
	.write_event_value_new	= apds9300_write_thresh,
	.read_event_config_new	= apds9300_read_interrupt_config,
	.write_event_config_new	= apds9300_write_interrupt_config,
	.read_event_value	= apds9300_read_thresh,
	.write_event_value	= apds9300_write_thresh,
	.read_event_config	= apds9300_read_interrupt_config,
	.write_event_config	= apds9300_write_interrupt_config,
};

static const struct iio_event_spec apds9300_event_spec[] = {
+4 −4
Original line number Diff line number Diff line
@@ -614,10 +614,10 @@ static const struct iio_info cm36651_info = {
	.driver_module		= THIS_MODULE,
	.read_raw		= &cm36651_read_raw,
	.write_raw		= &cm36651_write_raw,
	.read_event_value_new	= &cm36651_read_prox_thresh,
	.write_event_value_new	= &cm36651_write_prox_thresh,
	.read_event_config_new	= &cm36651_read_prox_event_config,
	.write_event_config_new	= &cm36651_write_prox_event_config,
	.read_event_value	= &cm36651_read_prox_thresh,
	.write_event_value	= &cm36651_write_prox_thresh,
	.read_event_config	= &cm36651_read_prox_event_config,
	.write_event_config	= &cm36651_write_prox_event_config,
	.attrs			= &cm36651_attribute_group,
};

Loading