@@ -1079,33 +1079,31 @@ static inline void input_wakeup_procfs_readers(void)
10791079 wake_up (& input_devices_poll_wait );
10801080}
10811081
1082+ struct input_seq_state {
1083+ unsigned short pos ;
1084+ bool mutex_acquired ;
1085+ int input_devices_state ;
1086+ };
1087+
10821088static __poll_t input_proc_devices_poll (struct file * file , poll_table * wait )
10831089{
1090+ struct seq_file * seq = file -> private_data ;
1091+ struct input_seq_state * state = seq -> private ;
1092+
10841093 poll_wait (file , & input_devices_poll_wait , wait );
1085- if (file -> f_version != input_devices_state ) {
1086- file -> f_version = input_devices_state ;
1094+ if (state -> input_devices_state != input_devices_state ) {
1095+ state -> input_devices_state = input_devices_state ;
10871096 return EPOLLIN | EPOLLRDNORM ;
10881097 }
10891098
10901099 return 0 ;
10911100}
10921101
1093- union input_seq_state {
1094- struct {
1095- unsigned short pos ;
1096- bool mutex_acquired ;
1097- };
1098- void * p ;
1099- };
1100-
11011102static void * input_devices_seq_start (struct seq_file * seq , loff_t * pos )
11021103{
1103- union input_seq_state * state = ( union input_seq_state * ) & seq -> private ;
1104+ struct input_seq_state * state = seq -> private ;
11041105 int error ;
11051106
1106- /* We need to fit into seq->private pointer */
1107- BUILD_BUG_ON (sizeof (union input_seq_state ) != sizeof (seq -> private ));
1108-
11091107 error = mutex_lock_interruptible (& input_mutex );
11101108 if (error ) {
11111109 state -> mutex_acquired = false;
@@ -1124,7 +1122,7 @@ static void *input_devices_seq_next(struct seq_file *seq, void *v, loff_t *pos)
11241122
11251123static void input_seq_stop (struct seq_file * seq , void * v )
11261124{
1127- union input_seq_state * state = ( union input_seq_state * ) & seq -> private ;
1125+ struct input_seq_state * state = seq -> private ;
11281126
11291127 if (state -> mutex_acquired )
11301128 mutex_unlock (& input_mutex );
@@ -1210,25 +1208,23 @@ static const struct seq_operations input_devices_seq_ops = {
12101208
12111209static int input_proc_devices_open (struct inode * inode , struct file * file )
12121210{
1213- return seq_open (file , & input_devices_seq_ops );
1211+ return seq_open_private (file , & input_devices_seq_ops ,
1212+ sizeof (struct input_seq_state ));
12141213}
12151214
12161215static const struct proc_ops input_devices_proc_ops = {
12171216 .proc_open = input_proc_devices_open ,
12181217 .proc_poll = input_proc_devices_poll ,
12191218 .proc_read = seq_read ,
12201219 .proc_lseek = seq_lseek ,
1221- .proc_release = seq_release ,
1220+ .proc_release = seq_release_private ,
12221221};
12231222
12241223static void * input_handlers_seq_start (struct seq_file * seq , loff_t * pos )
12251224{
1226- union input_seq_state * state = ( union input_seq_state * ) & seq -> private ;
1225+ struct input_seq_state * state = seq -> private ;
12271226 int error ;
12281227
1229- /* We need to fit into seq->private pointer */
1230- BUILD_BUG_ON (sizeof (union input_seq_state ) != sizeof (seq -> private ));
1231-
12321228 error = mutex_lock_interruptible (& input_mutex );
12331229 if (error ) {
12341230 state -> mutex_acquired = false;
@@ -1243,7 +1239,7 @@ static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos)
12431239
12441240static void * input_handlers_seq_next (struct seq_file * seq , void * v , loff_t * pos )
12451241{
1246- union input_seq_state * state = ( union input_seq_state * ) & seq -> private ;
1242+ struct input_seq_state * state = seq -> private ;
12471243
12481244 state -> pos = * pos + 1 ;
12491245 return seq_list_next (v , & input_handler_list , pos );
@@ -1252,7 +1248,7 @@ static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos)
12521248static int input_handlers_seq_show (struct seq_file * seq , void * v )
12531249{
12541250 struct input_handler * handler = container_of (v , struct input_handler , node );
1255- union input_seq_state * state = ( union input_seq_state * ) & seq -> private ;
1251+ struct input_seq_state * state = seq -> private ;
12561252
12571253 seq_printf (seq , "N: Number=%u Name=%s" , state -> pos , handler -> name );
12581254 if (handler -> filter )
@@ -1273,14 +1269,15 @@ static const struct seq_operations input_handlers_seq_ops = {
12731269
12741270static int input_proc_handlers_open (struct inode * inode , struct file * file )
12751271{
1276- return seq_open (file , & input_handlers_seq_ops );
1272+ return seq_open_private (file , & input_handlers_seq_ops ,
1273+ sizeof (struct input_seq_state ));
12771274}
12781275
12791276static const struct proc_ops input_handlers_proc_ops = {
12801277 .proc_open = input_proc_handlers_open ,
12811278 .proc_read = seq_read ,
12821279 .proc_lseek = seq_lseek ,
1283- .proc_release = seq_release ,
1280+ .proc_release = seq_release_private ,
12841281};
12851282
12861283static int __init input_proc_init (void )
0 commit comments