* Call ioctl, restarting if it is interupted
*/
static int
-drmIoctl(int fd, int request, void *arg)
+drmIoctl(int fd, unsigned long request, void *arg)
{
int ret;
group = (serv_group >= 0) ? serv_group : DRM_DEV_GID;
}
+#if !defined(UDEV)
if (stat(DRM_DIR_NAME, &st)) {
if (!isroot)
return DRM_ERR_NOT_ROOT;
chown(buf, user, group);
chmod(buf, devmode);
}
+#else
+ /* if we modprobed then wait for udev */
+ {
+ int udev_count = 0;
+wait_for_udev:
+ if (stat(DRM_DIR_NAME, &st)) {
+ usleep(20);
+ udev_count++;
+
+ if (udev_count == 50)
+ return -1;
+ goto wait_for_udev;
+ }
+
+ if (stat(buf, &st)) {
+ usleep(20);
+ udev_count++;
+
+ if (udev_count == 50)
+ return -1;
+ goto wait_for_udev;
+ }
+ }
+#endif
fd = open(buf, O_RDWR, 0);
drmMsg("drmOpenDevice: open result is %d, (%s)\n",
return 0;
}
-
-#define DRM_IOCTL_TIMEOUT_USEC 3000000UL
-
-static unsigned long
-drmTimeDiff(struct timeval *now, struct timeval *then)
-{
- uint64_t val;
-
- val = now->tv_sec - then->tv_sec;
- val *= 1000000LL;
- val += now->tv_usec;
- val -= then->tv_usec;
-
- return (unsigned long) val;
-}
-
-static int
-drmIoctlTimeout(int fd, unsigned long request, void *argp)
-{
- int haveThen = 0;
- struct timeval then, now;
- int ret;
-
- do {
- ret = drmIoctl(fd, request, argp);
- if (ret != 0 && errno == EAGAIN) {
- if (!haveThen) {
- gettimeofday(&then, NULL);
- haveThen = 1;
- }
- gettimeofday(&now, NULL);
- }
- } while (ret != 0 && errno == EAGAIN &&
- drmTimeDiff(&now, &then) < DRM_IOCTL_TIMEOUT_USEC);
-
- if (ret != 0)
- return ((errno == EAGAIN) ? -EBUSY : -errno);
-
- return 0;
-}
-
-
-
#define DRM_MAX_FDS 16
static struct {
char *BusID;