@@ -389,7 +389,6 @@ xf86TslibUninit(__attribute__ ((unused)) InputDriverPtr drv,
389389 free (priv -> samp_mt );
390390 free (priv -> last_mt );
391391#endif
392- close (pInfo -> fd );
393392 valuator_mask_free (& priv -> valuators );
394393 xf86TslibControlProc (pInfo -> dev , DEVICE_OFF );
395394 ts_close (priv -> ts );
@@ -421,6 +420,7 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
421420 struct ts_lib_version_data * ver = ts_libversion ();
422421#endif
423422 long absbit [BITS_TO_LONGS (ABS_CNT )];
423+ int fd_temp ;
424424
425425 priv = calloc (1 , sizeof (struct ts_priv ));
426426 if (!priv )
@@ -475,22 +475,24 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
475475 if (!priv -> valuators )
476476 return BadValue ;
477477
478+ pInfo -> fd = ts_fd (priv -> ts );
479+
478480#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 );
480482#else
481483 if (!s ) {
482484 xf86IDrvMsg (pInfo , X_ERROR , "Please provide Option path or Device" );
483485 return BadValue ;
484486 }
485487
486- pInfo -> fd = open (s , O_RDONLY );
488+ fd_temp = open (s , O_RDONLY );
487489#endif
488- if (pInfo -> fd == -1 ) {
490+ if (fd_temp == -1 ) {
489491 xf86IDrvMsg (pInfo , X_ERROR , "Couldn't open %s\n" , s );
490492 return BadValue ;
491493 }
492494
493- if (ioctl (pInfo -> fd , EVIOCGBIT (EV_ABS , sizeof (absbit )), absbit ) < 0 ) {
495+ if (ioctl (fd_temp , EVIOCGBIT (EV_ABS , sizeof (absbit )), absbit ) < 0 ) {
494496 xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOCGBIT failed" );
495497 return BadValue ;
496498 }
@@ -553,13 +555,13 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
553555 }
554556
555557 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 ) {
557559 xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
558560 return BadValue ;
559561 }
560562 priv -> width = absinfo .maximum ;
561563
562- if (ioctl (pInfo -> fd , EVIOCGABS (ABS_Y ), & absinfo ) < 0 ) {
564+ if (ioctl (fd_temp , EVIOCGABS (ABS_Y ), & absinfo ) < 0 ) {
563565 xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
564566 return BadValue ;
565567 }
@@ -575,13 +577,13 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
575577 priv -> pmax = absinfo .maximum ;
576578 }
577579 } 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 ) {
579581 xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
580582 return BadValue ;
581583 }
582584 priv -> width = absinfo .maximum ;
583585
584- if (ioctl (pInfo -> fd , EVIOCGABS (ABS_MT_POSITION_Y ), & absinfo ) < 0 ) {
586+ if (ioctl (fd_temp , EVIOCGABS (ABS_MT_POSITION_Y ), & absinfo ) < 0 ) {
585587 xf86IDrvMsg (pInfo , X_ERROR , "ioctl EVIOGABS failed" );
586588 return BadValue ;
587589 }
@@ -598,6 +600,8 @@ static int xf86TslibInit(__attribute__ ((unused)) InputDriverPtr drv,
598600 }
599601 }
600602
603+ close (fd_temp );
604+
601605 /* Return the configured device */
602606 return Success ;
603607}
0 commit comments