|
@@ -322,12 +322,11 @@ static int at91_adc_channel_init(struct iio_dev *idev)
|
|
return idev->num_channels;
|
|
return idev->num_channels;
|
|
}
|
|
}
|
|
|
|
|
|
-static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
|
|
|
|
|
|
+static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
|
|
struct at91_adc_trigger *triggers,
|
|
struct at91_adc_trigger *triggers,
|
|
const char *trigger_name)
|
|
const char *trigger_name)
|
|
{
|
|
{
|
|
struct at91_adc_state *st = iio_priv(idev);
|
|
struct at91_adc_state *st = iio_priv(idev);
|
|
- u8 value = 0;
|
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
for (i = 0; i < st->trigger_number; i++) {
|
|
for (i = 0; i < st->trigger_number; i++) {
|
|
@@ -340,15 +339,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
if (strcmp(trigger_name, name) == 0) {
|
|
if (strcmp(trigger_name, name) == 0) {
|
|
- value = triggers[i].value;
|
|
|
|
kfree(name);
|
|
kfree(name);
|
|
- break;
|
|
|
|
|
|
+ if (triggers[i].value == 0)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+ return triggers[i].value;
|
|
}
|
|
}
|
|
|
|
|
|
kfree(name);
|
|
kfree(name);
|
|
}
|
|
}
|
|
|
|
|
|
- return value;
|
|
|
|
|
|
+ return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
|
|
static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
|
|
@@ -358,14 +358,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
|
|
struct iio_buffer *buffer = idev->buffer;
|
|
struct iio_buffer *buffer = idev->buffer;
|
|
struct at91_adc_reg_desc *reg = st->registers;
|
|
struct at91_adc_reg_desc *reg = st->registers;
|
|
u32 status = at91_adc_readl(st, reg->trigger_register);
|
|
u32 status = at91_adc_readl(st, reg->trigger_register);
|
|
- u8 value;
|
|
|
|
|
|
+ int value;
|
|
u8 bit;
|
|
u8 bit;
|
|
|
|
|
|
value = at91_adc_get_trigger_value_by_name(idev,
|
|
value = at91_adc_get_trigger_value_by_name(idev,
|
|
st->trigger_list,
|
|
st->trigger_list,
|
|
idev->trig->name);
|
|
idev->trig->name);
|
|
- if (value == 0)
|
|
|
|
- return -EINVAL;
|
|
|
|
|
|
+ if (value < 0)
|
|
|
|
+ return value;
|
|
|
|
|
|
if (state) {
|
|
if (state) {
|
|
st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL);
|
|
st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL);
|