Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 259592
b: refs/heads/master
c: 43a4360
h: refs/heads/master
v: v3
  • Loading branch information
Michael Hennerich authored and Greg Kroah-Hartman committed Jun 28, 2011
1 parent 457dc6f commit f57be5d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 03e1672a70be991a9e84d67b2d2143313938e1a8
refs/heads/master: 43a4360ea8f075540cb7c1efc8d643b4261eb901
7 changes: 7 additions & 0 deletions trunk/drivers/staging/iio/iio.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ static inline s64 iio_get_time_ns(void)
#define IIO_VAL_INT_PLUS_MICRO 2
#define IIO_VAL_INT_PLUS_NANO 3

struct iio_trigger; /* forward declaration */

/**
* struct iio_info - constant information about device
* @driver_module: module structure used to ensure correct
Expand All @@ -224,6 +226,8 @@ static inline s64 iio_get_time_ns(void)
* is event dependant. event_code specifies which event.
* @write_event_value: write the value associate with the event.
* Meaning is event dependent.
* @validate_trigger: function to validate the trigger when the
* current trigger gets changed.
**/
struct iio_info {
struct module *driver_module;
Expand Down Expand Up @@ -256,6 +260,9 @@ struct iio_info {
int (*write_event_value)(struct iio_dev *indio_dev,
int event_code,
int val);
int (*validate_trigger)(struct iio_dev *indio_dev,
struct iio_trigger *trig);

};

/**
Expand Down
20 changes: 19 additions & 1 deletion trunk/drivers/staging/iio/industrialio-trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,32 @@ static ssize_t iio_trigger_write_current(struct device *dev,
{
struct iio_dev *dev_info = dev_get_drvdata(dev);
struct iio_trigger *oldtrig = dev_info->trig;
struct iio_trigger *trig;
int ret;

mutex_lock(&dev_info->mlock);
if (dev_info->currentmode == INDIO_RING_TRIGGERED) {
mutex_unlock(&dev_info->mlock);
return -EBUSY;
}
mutex_unlock(&dev_info->mlock);

dev_info->trig = iio_trigger_find_by_name(buf, len);
trig = iio_trigger_find_by_name(buf, len);

if (trig && dev_info->info->validate_trigger) {
ret = dev_info->info->validate_trigger(dev_info, trig);
if (ret)
return ret;
}

if (trig && trig->validate_device) {
ret = trig->validate_device(trig, dev_info);
if (ret)
return ret;
}

dev_info->trig = trig;

if (oldtrig && dev_info->trig != oldtrig)
iio_put_trigger(oldtrig);
if (dev_info->trig)
Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/staging/iio/trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ struct iio_subirq {
* @set_trigger_state: [DRIVER] switch on/off the trigger on demand
* @try_reenable: function to reenable the trigger when the
* use count is zero (may be NULL)
* @validate_device: function to validate the device when the
* current trigger gets changed.
* @subirq_chip: [INTERN] associate 'virtual' irq chip.
* @subirq_base: [INTERN] base number for irqs provided by trigger.
* @subirqs: [INTERN] information about the 'child' irqs.
Expand All @@ -48,6 +50,8 @@ struct iio_trigger {

int (*set_trigger_state)(struct iio_trigger *trig, bool state);
int (*try_reenable)(struct iio_trigger *trig);
int (*validate_device)(struct iio_trigger *trig,
struct iio_dev *indio_dev);

struct irq_chip subirq_chip;
int subirq_base;
Expand Down

0 comments on commit f57be5d

Please sign in to comment.