Hi All,
I am using ep93xx_ts.c driver for my touchscreen device. It is a very old version of the file.

In my project we are using FLTK + nano-X as our graphics library. Recently we upgraded to higher version of both library. After up gradation we saw a dramatic fall in performance. After lot of debugging we were able to trace it to our driver.

The driver code in its read function strangely goes to sleep for 10 mili second when ever there is a pen up condition. This sleep occurs within a spin lock which to me is more surprising.

Once I removed the 10 mili second sleep the performance improved significantly.

Can somebody please tell me why the sleep is put there? I am unable to figure out the usefulness of the sleep. I am copying the relevant part of the code below:

The code is form the file ep93xx_ts.c

Code:
static ssize_t ep93xx_ts_read(struct file *filp, char *buf, size_t count, loff_t *l)
{

    unsigned short data[3];
    int     iReturn = 0;

#ifdef PRINT_CALIBRATION_FACTORS
    static int lala=0;
    if( bFreshTouchData && (lala++ > 9) )
    {
        DPRINTK("%4d, %4d - range [%4d to %4d],[%4d to %4d]\n",
            f, currentY, iMinX, iMaxX, iMinY, iMaxY );
        lala = 0;
    }
#endif

   if(count >= sizeof(data))
   {
      data[0] = (unsigned short) gSample.currentX;
      data[1] = (unsigned short) gSample.currentY;

      spin_lock(&penup_lock);
      if(bCurrentPenUp)
      {
         data[2] = 0;
         msleep(10);
      }
      else
      {
         data[2] = 1024;
      }
      spin_unlock(&penup_lock);

      bFreshTouchData = 0;

      if (copy_to_user(buf, data, sizeof(data)))
         return -EFAULT;

      count -= sizeof(data);

      /* return the # of bytes that got read */
      iReturn = sizeof(data);
   }

    return iReturn;
}