diff options
author | Dave Airlie <airlied@linux.ie> | 2006-08-26 21:11:14 -0400 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2006-09-21 15:32:33 -0400 |
commit | 1f27ce6ab7ad7abf014ef7f181d494cf1107f9db (patch) | |
tree | 85e8a9b3fe35f6ac871b52659fc3fa7921052f29 /drivers/char | |
parent | 46acbf13fb280e69c5cafe7c837d5a27c6e380c3 (diff) |
drm: fixup setversion return codes..
Frederik Deweerdt <deweerdt@free.fr> noticed some badness in setversion
returns, however just making it work, breaks things... this code is hairy
with backwards compat...
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/drm/drm_ioctl.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c index e15899830581..565895547d75 100644 --- a/drivers/char/drm/drm_ioctl.c +++ b/drivers/char/drm/drm_ioctl.c | |||
@@ -141,12 +141,12 @@ static int drm_set_busid(drm_device_t * dev) | |||
141 | int len; | 141 | int len; |
142 | 142 | ||
143 | if (dev->unique != NULL) | 143 | if (dev->unique != NULL) |
144 | return EBUSY; | 144 | return 0; |
145 | 145 | ||
146 | dev->unique_len = 40; | 146 | dev->unique_len = 40; |
147 | dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER); | 147 | dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER); |
148 | if (dev->unique == NULL) | 148 | if (dev->unique == NULL) |
149 | return ENOMEM; | 149 | return -ENOMEM; |
150 | 150 | ||
151 | len = snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", | 151 | len = snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", |
152 | drm_get_pci_domain(dev), dev->pdev->bus->number, | 152 | drm_get_pci_domain(dev), dev->pdev->bus->number, |
@@ -160,7 +160,7 @@ static int drm_set_busid(drm_device_t * dev) | |||
160 | drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len + | 160 | drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len + |
161 | 2, DRM_MEM_DRIVER); | 161 | 2, DRM_MEM_DRIVER); |
162 | if (dev->devname == NULL) | 162 | if (dev->devname == NULL) |
163 | return ENOMEM; | 163 | return -ENOMEM; |
164 | 164 | ||
165 | sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, | 165 | sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, |
166 | dev->unique); | 166 | dev->unique); |
@@ -333,6 +333,7 @@ int drm_setversion(DRM_IOCTL_ARGS) | |||
333 | drm_set_version_t retv; | 333 | drm_set_version_t retv; |
334 | int if_version; | 334 | int if_version; |
335 | drm_set_version_t __user *argp = (void __user *)data; | 335 | drm_set_version_t __user *argp = (void __user *)data; |
336 | int ret; | ||
336 | 337 | ||
337 | if (copy_from_user(&sv, argp, sizeof(sv))) | 338 | if (copy_from_user(&sv, argp, sizeof(sv))) |
338 | return -EFAULT; | 339 | return -EFAULT; |
@@ -342,20 +343,22 @@ int drm_setversion(DRM_IOCTL_ARGS) | |||
342 | retv.drm_dd_major = dev->driver->major; | 343 | retv.drm_dd_major = dev->driver->major; |
343 | retv.drm_dd_minor = dev->driver->minor; | 344 | retv.drm_dd_minor = dev->driver->minor; |
344 | 345 | ||
345 | if (copy_to_user(argp, &retv, sizeof(sv))) | 346 | if (copy_to_user(argp, &retv, sizeof(retv))) |
346 | return -EFAULT; | 347 | return -EFAULT; |
347 | 348 | ||
348 | if (sv.drm_di_major != -1) { | 349 | if (sv.drm_di_major != -1) { |
349 | if (sv.drm_di_major != DRM_IF_MAJOR || | 350 | if (sv.drm_di_major != DRM_IF_MAJOR || |
350 | sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) | 351 | sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) |
351 | return EINVAL; | 352 | return -EINVAL; |
352 | if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor); | 353 | if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor); |
353 | dev->if_version = max(if_version, dev->if_version); | 354 | dev->if_version = max(if_version, dev->if_version); |
354 | if (sv.drm_di_minor >= 1) { | 355 | if (sv.drm_di_minor >= 1) { |
355 | /* | 356 | /* |
356 | * Version 1.1 includes tying of DRM to specific device | 357 | * Version 1.1 includes tying of DRM to specific device |
357 | */ | 358 | */ |
358 | drm_set_busid(dev); | 359 | ret = drm_set_busid(dev); |
360 | if (ret) | ||
361 | return ret; | ||
359 | } | 362 | } |
360 | } | 363 | } |
361 | 364 | ||
@@ -363,7 +366,7 @@ int drm_setversion(DRM_IOCTL_ARGS) | |||
363 | if (sv.drm_dd_major != dev->driver->major || | 366 | if (sv.drm_dd_major != dev->driver->major || |
364 | sv.drm_dd_minor < 0 | 367 | sv.drm_dd_minor < 0 |
365 | || sv.drm_dd_minor > dev->driver->minor) | 368 | || sv.drm_dd_minor > dev->driver->minor) |
366 | return EINVAL; | 369 | return -EINVAL; |
367 | 370 | ||
368 | if (dev->driver->set_version) | 371 | if (dev->driver->set_version) |
369 | dev->driver->set_version(dev, &sv); | 372 | dev->driver->set_version(dev, &sv); |