blob: 47db4df37a692db539db2c90d04bfcc7313fa34e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/**
Dave Airlieb5e89ed2005-09-25 14:28:13 +10002 * \file drm_ioctl.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * IOCTL processing for DRM
4 *
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 * \author Gareth Hughes <gareth@valinux.com>
7 */
8
9/*
10 * Created: Fri Jan 8 09:01:26 1999 by faith@valinux.com
11 *
12 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
13 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
14 * All Rights Reserved.
15 *
16 * Permission is hereby granted, free of charge, to any person obtaining a
17 * copy of this software and associated documentation files (the "Software"),
18 * to deal in the Software without restriction, including without limitation
19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 * and/or sell copies of the Software, and to permit persons to whom the
21 * Software is furnished to do so, subject to the following conditions:
22 *
23 * The above copyright notice and this permission notice (including the next
24 * paragraph) shall be included in all copies or substantial portions of the
25 * Software.
26 *
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
31 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
32 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33 * OTHER DEALINGS IN THE SOFTWARE.
34 */
35
36#include "drmP.h"
37#include "drm_core.h"
38
39#include "linux/pci.h"
40
41/**
42 * Get the bus id.
Dave Airlieb5e89ed2005-09-25 14:28:13 +100043 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 * \param inode device inode.
Eric Anholt6c340ea2007-08-25 20:23:09 +100045 * \param file_priv DRM file private.
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 * \param cmd command.
47 * \param arg user argument, pointing to a drm_unique structure.
48 * \return zero on success or a negative number on failure.
49 *
50 * Copies the bus id from drm_device::unique into user space.
51 */
Eric Anholtc153f452007-09-03 12:06:45 +100052int drm_getunique(struct drm_device *dev, void *data,
53 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054{
Eric Anholtc153f452007-09-03 12:06:45 +100055 struct drm_unique *u = data;
Dave Airlie7c1c2872008-11-28 14:22:24 +100056 struct drm_master *master = file_priv->master;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Dave Airlie7c1c2872008-11-28 14:22:24 +100058 if (u->unique_len >= master->unique_len) {
59 if (copy_to_user(u->unique, master->unique, master->unique_len))
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 return -EFAULT;
61 }
Dave Airlie7c1c2872008-11-28 14:22:24 +100062 u->unique_len = master->unique_len;
Eric Anholtc153f452007-09-03 12:06:45 +100063
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 return 0;
65}
66
Chris Wilson3fb688f2010-08-04 11:09:42 +010067static void
68drm_unset_busid(struct drm_device *dev,
69 struct drm_master *master)
70{
71 kfree(dev->devname);
72 dev->devname = NULL;
73
74 kfree(master->unique);
75 master->unique = NULL;
76 master->unique_len = 0;
77 master->unique_size = 0;
78}
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080/**
81 * Set the bus id.
Dave Airlieb5e89ed2005-09-25 14:28:13 +100082 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 * \param inode device inode.
Eric Anholt6c340ea2007-08-25 20:23:09 +100084 * \param file_priv DRM file private.
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 * \param cmd command.
86 * \param arg user argument, pointing to a drm_unique structure.
87 * \return zero on success or a negative number on failure.
88 *
89 * Copies the bus id from userspace into drm_device::unique, and verifies that
90 * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated
91 * in interface version 1.1 and will return EBUSY when setversion has requested
92 * version 1.1 or greater.
93 */
Eric Anholtc153f452007-09-03 12:06:45 +100094int drm_setunique(struct drm_device *dev, void *data,
95 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Eric Anholtc153f452007-09-03 12:06:45 +100097 struct drm_unique *u = data;
Dave Airlie7c1c2872008-11-28 14:22:24 +100098 struct drm_master *master = file_priv->master;
Dave Airlieb5e89ed2005-09-25 14:28:13 +100099 int domain, bus, slot, func, ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Dave Airlie7c1c2872008-11-28 14:22:24 +1000101 if (master->unique_len || master->unique)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000102 return -EBUSY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Eric Anholtc153f452007-09-03 12:06:45 +1000104 if (!u->unique_len || u->unique_len > 1024)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000105 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Dave Airlie7c1c2872008-11-28 14:22:24 +1000107 master->unique_len = u->unique_len;
Vegard Nossum1147c9c2008-12-02 13:38:47 +1000108 master->unique_size = u->unique_len + 1;
Eric Anholt9a298b22009-03-24 12:23:04 -0700109 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
Chris Wilson3fb688f2010-08-04 11:09:42 +0100110 if (!master->unique) {
111 ret = -ENOMEM;
112 goto err;
113 }
114
115 if (copy_from_user(master->unique, u->unique, master->unique_len)) {
116 ret = -EFAULT;
117 goto err;
118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Dave Airlie7c1c2872008-11-28 14:22:24 +1000120 master->unique[master->unique_len] = '\0';
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Eric Anholt9a298b22009-03-24 12:23:04 -0700122 dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) +
123 strlen(master->unique) + 2, GFP_KERNEL);
Chris Wilson3fb688f2010-08-04 11:09:42 +0100124 if (!dev->devname) {
125 ret = -ENOMEM;
126 goto err;
127 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000129 sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
Dave Airlie7c1c2872008-11-28 14:22:24 +1000130 master->unique);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132 /* Return error if the busid submitted doesn't match the device's actual
133 * busid.
134 */
Dave Airlie7c1c2872008-11-28 14:22:24 +1000135 ret = sscanf(master->unique, "PCI:%d:%d:%d", &bus, &slot, &func);
Chris Wilson3fb688f2010-08-04 11:09:42 +0100136 if (ret != 3) {
137 ret = -EINVAL;
138 goto err;
139 }
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 domain = bus >> 8;
142 bus &= 0xff;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000143
Dave Airlie332296012006-08-07 20:23:42 +1000144 if ((domain != drm_get_pci_domain(dev)) ||
Dave242ef0e2006-07-18 04:01:01 +1000145 (bus != dev->pdev->bus->number) ||
146 (slot != PCI_SLOT(dev->pdev->devfn)) ||
Chris Wilson3fb688f2010-08-04 11:09:42 +0100147 (func != PCI_FUNC(dev->pdev->devfn))) {
148 ret = -EINVAL;
149 goto err;
150 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152 return 0;
Chris Wilson3fb688f2010-08-04 11:09:42 +0100153
154err:
155 drm_unset_busid(dev, master);
156 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157}
158
Dave Airlie7c1c2872008-11-28 14:22:24 +1000159static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160{
Dave Airlie7c1c2872008-11-28 14:22:24 +1000161 struct drm_master *master = file_priv->master;
Chris Wilson3fb688f2010-08-04 11:09:42 +0100162 int len, ret;
163
164 if (master->unique != NULL)
165 drm_unset_busid(dev, master);
Dave Airliefe347652006-01-02 21:19:39 +1100166
Jordan Crousedcdb1672010-05-27 13:40:25 -0600167 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
168 master->unique_len = 10 + strlen(dev->platformdev->name);
169 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Jordan Crousedcdb1672010-05-27 13:40:25 -0600171 if (master->unique == NULL)
172 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Jordan Crousedcdb1672010-05-27 13:40:25 -0600174 len = snprintf(master->unique, master->unique_len,
175 "platform:%s", dev->platformdev->name);
Dave Airliefe347652006-01-02 21:19:39 +1100176
Chris Wilson3fb688f2010-08-04 11:09:42 +0100177 if (len > master->unique_len) {
Jordan Crousedcdb1672010-05-27 13:40:25 -0600178 DRM_ERROR("Unique buffer overflowed\n");
Chris Wilson3fb688f2010-08-04 11:09:42 +0100179 ret = -EINVAL;
180 goto err;
181 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Jordan Crousedcdb1672010-05-27 13:40:25 -0600183 dev->devname =
184 kmalloc(strlen(dev->platformdev->name) +
185 master->unique_len + 2, GFP_KERNEL);
186
Chris Wilson3fb688f2010-08-04 11:09:42 +0100187 if (dev->devname == NULL) {
188 ret = -ENOMEM;
189 goto err;
190 }
Jordan Crousedcdb1672010-05-27 13:40:25 -0600191
192 sprintf(dev->devname, "%s@%s", dev->platformdev->name,
193 master->unique);
194
195 } else {
196 master->unique_len = 40;
197 master->unique_size = master->unique_len;
198 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
199 if (master->unique == NULL)
200 return -ENOMEM;
201
202 len = snprintf(master->unique, master->unique_len,
203 "pci:%04x:%02x:%02x.%d",
204 drm_get_pci_domain(dev),
205 dev->pdev->bus->number,
206 PCI_SLOT(dev->pdev->devfn),
207 PCI_FUNC(dev->pdev->devfn));
Chris Wilson3fb688f2010-08-04 11:09:42 +0100208 if (len >= master->unique_len) {
Jordan Crousedcdb1672010-05-27 13:40:25 -0600209 DRM_ERROR("buffer overflow");
Chris Wilson3fb688f2010-08-04 11:09:42 +0100210 ret = -EINVAL;
211 goto err;
212 } else
Jordan Crousedcdb1672010-05-27 13:40:25 -0600213 master->unique_len = len;
214
215 dev->devname =
216 kmalloc(strlen(dev->driver->pci_driver.name) +
217 master->unique_len + 2, GFP_KERNEL);
218
Chris Wilson3fb688f2010-08-04 11:09:42 +0100219 if (dev->devname == NULL) {
220 ret = -ENOMEM;
221 goto err;
222 }
Jordan Crousedcdb1672010-05-27 13:40:25 -0600223
224 sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
225 master->unique);
226 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
228 return 0;
Chris Wilson3fb688f2010-08-04 11:09:42 +0100229
230err:
231 drm_unset_busid(dev, master);
232 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233}
234
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235/**
236 * Get a mapping information.
237 *
238 * \param inode device inode.
Eric Anholt6c340ea2007-08-25 20:23:09 +1000239 * \param file_priv DRM file private.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 * \param cmd command.
241 * \param arg user argument, pointing to a drm_map structure.
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000242 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 * \return zero on success or a negative number on failure.
244 *
245 * Searches for the mapping with the specified offset and copies its information
246 * into userspace
247 */
Eric Anholtc153f452007-09-03 12:06:45 +1000248int drm_getmap(struct drm_device *dev, void *data,
249 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250{
Eric Anholtc153f452007-09-03 12:06:45 +1000251 struct drm_map *map = data;
Dave Airlie55910512007-07-11 16:53:40 +1000252 struct drm_map_list *r_list = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 struct list_head *list;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000254 int idx;
255 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256
Eric Anholtc153f452007-09-03 12:06:45 +1000257 idx = map->offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258
Dave Airlie30e2fb12006-02-02 19:37:46 +1100259 mutex_lock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 if (idx < 0) {
Dave Airlie30e2fb12006-02-02 19:37:46 +1100261 mutex_unlock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 return -EINVAL;
263 }
264
265 i = 0;
Dave Airliebd1b3312007-05-26 05:01:51 +1000266 list_for_each(list, &dev->maplist) {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000267 if (i == idx) {
Dave Airlie55910512007-07-11 16:53:40 +1000268 r_list = list_entry(list, struct drm_map_list, head);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 break;
270 }
271 i++;
272 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000273 if (!r_list || !r_list->map) {
Dave Airlie30e2fb12006-02-02 19:37:46 +1100274 mutex_unlock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 return -EINVAL;
276 }
277
Eric Anholtc153f452007-09-03 12:06:45 +1000278 map->offset = r_list->map->offset;
279 map->size = r_list->map->size;
280 map->type = r_list->map->type;
281 map->flags = r_list->map->flags;
282 map->handle = (void *)(unsigned long) r_list->user_token;
283 map->mtrr = r_list->map->mtrr;
Dave Airlie30e2fb12006-02-02 19:37:46 +1100284 mutex_unlock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 return 0;
287}
288
289/**
290 * Get client information.
291 *
292 * \param inode device inode.
Eric Anholt6c340ea2007-08-25 20:23:09 +1000293 * \param file_priv DRM file private.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 * \param cmd command.
295 * \param arg user argument, pointing to a drm_client structure.
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000296 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 * \return zero on success or a negative number on failure.
298 *
299 * Searches for the client with the specified index and copies its information
300 * into userspace
301 */
Eric Anholtc153f452007-09-03 12:06:45 +1000302int drm_getclient(struct drm_device *dev, void *data,
303 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304{
Eric Anholtc153f452007-09-03 12:06:45 +1000305 struct drm_client *client = data;
Dave Airlie84b1fd12007-07-11 15:53:27 +1000306 struct drm_file *pt;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000307 int idx;
308 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
Eric Anholtc153f452007-09-03 12:06:45 +1000310 idx = client->idx;
Dave Airlie30e2fb12006-02-02 19:37:46 +1100311 mutex_lock(&dev->struct_mutex);
Dave Airliebc5f4522007-11-05 12:50:58 +1000312
Dave Airliebd1b3312007-05-26 05:01:51 +1000313 i = 0;
314 list_for_each_entry(pt, &dev->filelist, lhead) {
Eric Anholtb018fcd2007-11-22 18:46:54 +1000315 if (i++ >= idx) {
316 client->auth = pt->authenticated;
317 client->pid = pt->pid;
318 client->uid = pt->uid;
319 client->magic = pt->magic;
320 client->iocs = pt->ioctl_count;
321 mutex_unlock(&dev->struct_mutex);
Dave Airliebd1b3312007-05-26 05:01:51 +1000322
Eric Anholtb018fcd2007-11-22 18:46:54 +1000323 return 0;
324 }
325 }
Dave Airlie30e2fb12006-02-02 19:37:46 +1100326 mutex_unlock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Eric Anholtb018fcd2007-11-22 18:46:54 +1000328 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329}
330
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000331/**
332 * Get statistics information.
333 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 * \param inode device inode.
Eric Anholt6c340ea2007-08-25 20:23:09 +1000335 * \param file_priv DRM file private.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 * \param cmd command.
337 * \param arg user argument, pointing to a drm_stats structure.
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000338 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 * \return zero on success or a negative number on failure.
340 */
Eric Anholtc153f452007-09-03 12:06:45 +1000341int drm_getstats(struct drm_device *dev, void *data,
342 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343{
Eric Anholtc153f452007-09-03 12:06:45 +1000344 struct drm_stats *stats = data;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000345 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
Li Zefan246a3d12007-11-05 12:53:09 +1000347 memset(stats, 0, sizeof(*stats));
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000348
Dave Airlie30e2fb12006-02-02 19:37:46 +1100349 mutex_lock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
351 for (i = 0; i < dev->counters; i++) {
352 if (dev->types[i] == _DRM_STAT_LOCK)
Eric Anholtc153f452007-09-03 12:06:45 +1000353 stats->data[i].value =
Dave Airlie7c1c2872008-11-28 14:22:24 +1000354 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000355 else
Eric Anholtc153f452007-09-03 12:06:45 +1000356 stats->data[i].value = atomic_read(&dev->counts[i]);
357 stats->data[i].type = dev->types[i];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 }
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000359
Eric Anholtc153f452007-09-03 12:06:45 +1000360 stats->count = dev->counters;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
Dave Airlie30e2fb12006-02-02 19:37:46 +1100362 mutex_unlock(&dev->struct_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 return 0;
365}
366
367/**
368 * Setversion ioctl.
369 *
370 * \param inode device inode.
Eric Anholt6c340ea2007-08-25 20:23:09 +1000371 * \param file_priv DRM file private.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 * \param cmd command.
373 * \param arg user argument, pointing to a drm_lock structure.
374 * \return zero on success or negative number on failure.
375 *
376 * Sets the requested interface version
377 */
Eric Anholtc153f452007-09-03 12:06:45 +1000378int drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379{
Eric Anholtc153f452007-09-03 12:06:45 +1000380 struct drm_set_version *sv = data;
381 int if_version, retcode = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
Eric Anholtc153f452007-09-03 12:06:45 +1000383 if (sv->drm_di_major != -1) {
384 if (sv->drm_di_major != DRM_IF_MAJOR ||
385 sv->drm_di_minor < 0 || sv->drm_di_minor > DRM_IF_MINOR) {
386 retcode = -EINVAL;
387 goto done;
388 }
389 if_version = DRM_IF_VERSION(sv->drm_di_major,
390 sv->drm_di_minor);
Dave Airlie3d774612006-08-07 20:07:43 +1000391 dev->if_version = max(if_version, dev->if_version);
Eric Anholtc153f452007-09-03 12:06:45 +1000392 if (sv->drm_di_minor >= 1) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 /*
394 * Version 1.1 includes tying of DRM to specific device
Benjamin Herrenschmidtc17c2f82010-08-06 13:55:10 +1000395 * Version 1.4 has proper PCI domain support
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 */
Chris Wilson3fb688f2010-08-04 11:09:42 +0100397 retcode = drm_set_busid(dev, file_priv);
398 if (retcode)
399 goto done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 }
401 }
402
Eric Anholtc153f452007-09-03 12:06:45 +1000403 if (sv->drm_dd_major != -1) {
404 if (sv->drm_dd_major != dev->driver->major ||
405 sv->drm_dd_minor < 0 || sv->drm_dd_minor >
406 dev->driver->minor) {
407 retcode = -EINVAL;
408 goto done;
409 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410
411 if (dev->driver->set_version)
Eric Anholtc153f452007-09-03 12:06:45 +1000412 dev->driver->set_version(dev, sv);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 }
Eric Anholtc153f452007-09-03 12:06:45 +1000414
415done:
416 sv->drm_di_major = DRM_IF_MAJOR;
417 sv->drm_di_minor = DRM_IF_MINOR;
418 sv->drm_dd_major = dev->driver->major;
419 sv->drm_dd_minor = dev->driver->minor;
420
421 return retcode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422}
423
424/** No-op ioctl. */
Eric Anholtc153f452007-09-03 12:06:45 +1000425int drm_noop(struct drm_device *dev, void *data,
426 struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427{
428 DRM_DEBUG("\n");
429 return 0;
430}