@@ -72,7 +72,8 @@ EXPORT_SYMBOL(iio_push_event);
72
72
static unsigned int iio_event_poll (struct file * filep ,
73
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
77
unsigned int events = 0 ;
77
78
78
79
poll_wait (filep , & ev_int -> wait , wait );
@@ -90,7 +91,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
90
91
size_t count ,
91
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
96
unsigned int copied ;
95
97
int ret ;
96
98
@@ -121,7 +123,8 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
121
123
122
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
129
spin_lock_irq (& ev_int -> wait .lock );
127
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
136
kfifo_reset_out (& ev_int -> det_events );
134
137
spin_unlock_irq (& ev_int -> wait .lock );
135
138
139
+ iio_device_put (indio_dev );
140
+
136
141
return 0 ;
137
142
}
138
143
@@ -158,12 +163,15 @@ int iio_event_getfd(struct iio_dev *indio_dev)
158
163
return - EBUSY ;
159
164
}
160
165
spin_unlock_irq (& ev_int -> wait .lock );
161
- fd = anon_inode_getfd ("iio:event" ,
162
- & iio_event_chrdev_fileops , ev_int , O_RDONLY );
166
+ iio_device_get (indio_dev );
167
+
168
+ fd = anon_inode_getfd ("iio:event" , & iio_event_chrdev_fileops ,
169
+ indio_dev , O_RDONLY );
163
170
if (fd < 0 ) {
164
171
spin_lock_irq (& ev_int -> wait .lock );
165
172
__clear_bit (IIO_BUSY_BIT_POS , & ev_int -> flags );
166
173
spin_unlock_irq (& ev_int -> wait .lock );
174
+ iio_device_put (indio_dev );
167
175
}
168
176
return fd ;
169
177
}
0 commit comments