diff options
Diffstat (limited to 'drivers/iio/industrialio-event.c')
-rw-r--r-- | drivers/iio/industrialio-event.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 10aa9ef86cec..6be65ef5faa9 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c | |||
@@ -72,7 +72,8 @@ EXPORT_SYMBOL(iio_push_event); | |||
72 | static unsigned int iio_event_poll(struct file *filep, | 72 | static unsigned int iio_event_poll(struct file *filep, |
73 | struct poll_table_struct *wait) | 73 | struct poll_table_struct *wait) |
74 | { | 74 | { |
75 | struct iio_event_interface *ev_int = filep->private_data; | 75 | struct iio_dev *indio_dev = filep->private_data; |
76 | struct iio_event_interface *ev_int = indio_dev->event_interface; | ||
76 | unsigned int events = 0; | 77 | unsigned int events = 0; |
77 | 78 | ||
78 | poll_wait(filep, &ev_int->wait, wait); | 79 | poll_wait(filep, &ev_int->wait, wait); |
@@ -90,7 +91,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep, | |||
90 | size_t count, | 91 | size_t count, |
91 | loff_t *f_ps) | 92 | loff_t *f_ps) |
92 | { | 93 | { |
93 | struct iio_event_interface *ev_int = filep->private_data; | 94 | struct iio_dev *indio_dev = filep->private_data; |
95 | struct iio_event_interface *ev_int = indio_dev->event_interface; | ||
94 | unsigned int copied; | 96 | unsigned int copied; |
95 | int ret; | 97 | int ret; |
96 | 98 | ||
@@ -121,7 +123,8 @@ error_unlock: | |||
121 | 123 | ||
122 | static int iio_event_chrdev_release(struct inode *inode, struct file *filep) | 124 | static int iio_event_chrdev_release(struct inode *inode, struct file *filep) |
123 | { | 125 | { |
124 | struct iio_event_interface *ev_int = filep->private_data; | 126 | struct iio_dev *indio_dev = filep->private_data; |
127 | struct iio_event_interface *ev_int = indio_dev->event_interface; | ||
125 | 128 | ||
126 | spin_lock_irq(&ev_int->wait.lock); | 129 | spin_lock_irq(&ev_int->wait.lock); |
127 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); | 130 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); |
@@ -133,6 +136,8 @@ static int iio_event_chrdev_release(struct inode *inode, struct file *filep) | |||
133 | kfifo_reset_out(&ev_int->det_events); | 136 | kfifo_reset_out(&ev_int->det_events); |
134 | spin_unlock_irq(&ev_int->wait.lock); | 137 | spin_unlock_irq(&ev_int->wait.lock); |
135 | 138 | ||
139 | iio_device_put(indio_dev); | ||
140 | |||
136 | return 0; | 141 | return 0; |
137 | } | 142 | } |
138 | 143 | ||
@@ -158,12 +163,15 @@ int iio_event_getfd(struct iio_dev *indio_dev) | |||
158 | return -EBUSY; | 163 | return -EBUSY; |
159 | } | 164 | } |
160 | spin_unlock_irq(&ev_int->wait.lock); | 165 | spin_unlock_irq(&ev_int->wait.lock); |
161 | fd = anon_inode_getfd("iio:event", | 166 | iio_device_get(indio_dev); |
162 | &iio_event_chrdev_fileops, ev_int, O_RDONLY); | 167 | |
168 | fd = anon_inode_getfd("iio:event", &iio_event_chrdev_fileops, | ||
169 | indio_dev, O_RDONLY); | ||
163 | if (fd < 0) { | 170 | if (fd < 0) { |
164 | spin_lock_irq(&ev_int->wait.lock); | 171 | spin_lock_irq(&ev_int->wait.lock); |
165 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); | 172 | __clear_bit(IIO_BUSY_BIT_POS, &ev_int->flags); |
166 | spin_unlock_irq(&ev_int->wait.lock); | 173 | spin_unlock_irq(&ev_int->wait.lock); |
174 | iio_device_put(indio_dev); | ||
167 | } | 175 | } |
168 | return fd; | 176 | return fd; |
169 | } | 177 | } |
@@ -276,7 +284,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *indio_dev, | |||
276 | goto error_ret; | 284 | goto error_ret; |
277 | } | 285 | } |
278 | if (chan->modified) | 286 | if (chan->modified) |
279 | mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel, | 287 | mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel2, |
280 | i/IIO_EV_DIR_MAX, | 288 | i/IIO_EV_DIR_MAX, |
281 | i%IIO_EV_DIR_MAX); | 289 | i%IIO_EV_DIR_MAX); |
282 | else if (chan->differential) | 290 | else if (chan->differential) |