@@ -389,7 +389,6 @@ xf86TslibUninit(__attribute__ ((unused)) InputDriverPtr drv,
389
389
free (priv -> samp_mt );
390
390
free (priv -> last_mt );
391
391
#endif
392
- close (pInfo -> fd );
393
392
valuator_mask_free (& priv -> valuators );
394
393
xf86TslibControlProc (pInfo -> dev , DEVICE_OFF );
395
394
ts_close (priv -> ts );
@@ -421,6 +420,7 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
421
420
struct ts_lib_version_data * ver = ts_libversion ();
422
421
#endif
423
422
long absbit [BITS_TO_LONGS (ABS_CNT )];
423
+ int fd_temp ;
424
424
425
425
priv = calloc (1 , sizeof (struct ts_priv ));
426
426
if (!priv )
@@ -475,22 +475,24 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
475
475
if (!priv -> valuators )
476
476
return BadValue ;
477
477
478
+ pInfo -> fd = ts_fd (priv -> ts );
479
+
478
480
#ifdef TSLIB_VERSION_EVENTPATH
479
- pInfo -> fd = open (ts_get_eventpath (priv -> ts ), O_RDONLY );
481
+ fd_temp = open (ts_get_eventpath (priv -> ts ), O_RDONLY );
480
482
#else
481
483
if (!s ) {
482
484
xf86IDrvMsg (pInfo , X_ERROR , "Please provide Option path or Device" );
483
485
return BadValue ;
484
486
}
485
487
486
- pInfo -> fd = open (s , O_RDONLY );
488
+ fd_temp = open (s , O_RDONLY );
487
489
#endif
488
- if (pInfo -> fd == -1 ) {
490
+ if (fd_temp == -1 ) {
489
491
xf86IDrvMsg (pInfo , X_ERROR , "Couldn't open %s\n" , s );
490
492
return BadValue ;
491
493
}
492
494
493
- if (ioctl (pInfo -> fd , EVIOCGBIT (EV_ABS , sizeof (absbit )), absbit ) < 0 ) {
495
+ if (ioctl (fd_temp , EVIOCGBIT (EV_ABS , sizeof (absbit )), absbit ) < 0 ) {
494
496
xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOCGBIT failed" );
495
497
return BadValue ;
496
498
}
@@ -553,13 +555,13 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
553
555
}
554
556
555
557
if (priv -> abs_x_only ) {
556
- if (ioctl (pInfo -> fd , EVIOCGABS (ABS_X ), & absinfo ) < 0 ) {
558
+ if (ioctl (fd_temp , EVIOCGABS (ABS_X ), & absinfo ) < 0 ) {
557
559
xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
558
560
return BadValue ;
559
561
}
560
562
priv -> width = absinfo .maximum ;
561
563
562
- if (ioctl (pInfo -> fd , EVIOCGABS (ABS_Y ), & absinfo ) < 0 ) {
564
+ if (ioctl (fd_temp , EVIOCGABS (ABS_Y ), & absinfo ) < 0 ) {
563
565
xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
564
566
return BadValue ;
565
567
}
@@ -575,13 +577,13 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
575
577
priv -> pmax = absinfo .maximum ;
576
578
}
577
579
} else {
578
- if (ioctl (pInfo -> fd , EVIOCGABS (ABS_MT_POSITION_X ), & absinfo ) < 0 ) {
580
+ if (ioctl (fd_temp , EVIOCGABS (ABS_MT_POSITION_X ), & absinfo ) < 0 ) {
579
581
xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
580
582
return BadValue ;
581
583
}
582
584
priv -> width = absinfo .maximum ;
583
585
584
- if (ioctl (pInfo -> fd , EVIOCGABS (ABS_MT_POSITION_Y ), & absinfo ) < 0 ) {
586
+ if (ioctl (fd_temp , EVIOCGABS (ABS_MT_POSITION_Y ), & absinfo ) < 0 ) {
585
587
xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
586
588
return BadValue ;
587
589
}
@@ -598,6 +600,8 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
598
600
}
599
601
}
600
602
603
+ close (fd_temp );
604
+
601
605
/* Return the configured device */
602
606
return Success ;
603
607
}
0 commit comments