aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-11-10 06:16:34 -0500
committerDave Airlie <airlied@linux.ie>2005-11-10 06:16:34 -0500
commit22eae947bf76e236ba972f2f11cfd1b083b736ad (patch)
treee18a2cdfef9ac0f606eb249df4924fef5e7daebd /drivers/char/drm
parent3b44f137b9a846c5452d9e6e1271b79b1dbcc942 (diff)
drm: rename driver hooks more understandably
Rename the driver hooks in the DRM to something a little more understandable: preinit -> load postinit -> (removed) presetup -> firstopen postsetup -> (removed) open_helper -> open prerelease -> preclose free_filp_priv -> postclose pretakedown -> lastclose postcleanup -> unload release -> reclaim_buffers_locked version -> (removed) postinit and version were replaced with generic code in the Linux DRM (drivers now set their version numbers and description in the driver structure, like on BSD). postsetup wasn't used at all. Fixes the savage hooks for initializing and tearing down mappings at the right times. Testing involved at least starting X, running glxgears, killing glxgears, exiting X, and repeating. Tested on: FreeBSD (g200, g400, r200, r128) Linux (r200, savage4) From: Eric Anholt <anholt@freebsd.org> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm')
-rw-r--r--drivers/char/drm/drmP.h31
-rw-r--r--drivers/char/drm/drm_drv.c29
-rw-r--r--drivers/char/drm/drm_fops.c35
-rw-r--r--drivers/char/drm/drm_ioctl.c12
-rw-r--r--drivers/char/drm/drm_stub.c15
-rw-r--r--drivers/char/drm/i810_dma.c18
-rw-r--r--drivers/char/drm/i810_drv.c59
-rw-r--r--drivers/char/drm/i810_drv.h10
-rw-r--r--drivers/char/drm/i830_dma.c18
-rw-r--r--drivers/char/drm/i830_drv.c56
-rw-r--r--drivers/char/drm/i830_drv.h8
-rw-r--r--drivers/char/drm/i915_dma.c16
-rw-r--r--drivers/char/drm/i915_drv.c54
-rw-r--r--drivers/char/drm/i915_drv.h5
-rw-r--r--drivers/char/drm/mga_dma.c14
-rw-r--r--drivers/char/drm/mga_drv.c56
-rw-r--r--drivers/char/drm/mga_drv.h6
-rw-r--r--drivers/char/drm/r128_drv.c48
-rw-r--r--drivers/char/drm/r128_drv.h4
-rw-r--r--drivers/char/drm/r128_state.c4
-rw-r--r--drivers/char/drm/radeon_cp.c9
-rw-r--r--drivers/char/drm/radeon_drv.c57
-rw-r--r--drivers/char/drm/radeon_drv.h17
-rw-r--r--drivers/char/drm/radeon_state.c8
-rw-r--r--drivers/char/drm/savage_bci.c44
-rw-r--r--drivers/char/drm/savage_drv.c50
-rw-r--r--drivers/char/drm/savage_drv.h6
-rw-r--r--drivers/char/drm/sis_drv.c42
-rw-r--r--drivers/char/drm/tdfx_drv.c42
-rw-r--r--drivers/char/drm/via_drv.c41
30 files changed, 330 insertions, 484 deletions
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h
index 3dc3c9d79ae4..d842cce11448 100644
--- a/drivers/char/drm/drmP.h
+++ b/drivers/char/drm/drmP.h
@@ -544,16 +544,14 @@ typedef struct ati_pcigart_info {
544struct drm_device; 544struct drm_device;
545 545
546struct drm_driver { 546struct drm_driver {
547 int (*preinit) (struct drm_device *, unsigned long flags); 547 int (*load) (struct drm_device *, unsigned long flags);
548 void (*prerelease) (struct drm_device *, struct file * filp); 548 int (*firstopen) (struct drm_device *);
549 void (*pretakedown) (struct drm_device *); 549 int (*open) (struct drm_device *, drm_file_t *);
550 int (*postcleanup) (struct drm_device *); 550 void (*preclose) (struct drm_device *, struct file * filp);
551 int (*presetup) (struct drm_device *); 551 void (*postclose) (struct drm_device *, drm_file_t *);
552 int (*postsetup) (struct drm_device *); 552 void (*lastclose) (struct drm_device *);
553 int (*unload) (struct drm_device *);
553 int (*dma_ioctl) (DRM_IOCTL_ARGS); 554 int (*dma_ioctl) (DRM_IOCTL_ARGS);
554 int (*open_helper) (struct drm_device *, drm_file_t *);
555 void (*free_filp_priv) (struct drm_device *, drm_file_t *);
556 void (*release) (struct drm_device *, struct file * filp);
557 void (*dma_ready) (struct drm_device *); 555 void (*dma_ready) (struct drm_device *);
558 int (*dma_quiescent) (struct drm_device *); 556 int (*dma_quiescent) (struct drm_device *);
559 int (*context_ctor) (struct drm_device * dev, int context); 557 int (*context_ctor) (struct drm_device * dev, int context);
@@ -579,16 +577,25 @@ struct drm_driver {
579 577
580 /* these have to be filled in */ 578 /* these have to be filled in */
581 579
582 int (*postinit) (struct drm_device *, unsigned long flags); 580 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
583 irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
584 void (*irq_preinstall) (struct drm_device * dev); 581 void (*irq_preinstall) (struct drm_device * dev);
585 void (*irq_postinstall) (struct drm_device * dev); 582 void (*irq_postinstall) (struct drm_device * dev);
586 void (*irq_uninstall) (struct drm_device * dev); 583 void (*irq_uninstall) (struct drm_device * dev);
587 void (*reclaim_buffers) (struct drm_device * dev, struct file * filp); 584 void (*reclaim_buffers) (struct drm_device * dev, struct file * filp);
585 void (*reclaim_buffers_locked) (struct drm_device *drv,
586 struct file *filp);
588 unsigned long (*get_map_ofs) (drm_map_t * map); 587 unsigned long (*get_map_ofs) (drm_map_t * map);
589 unsigned long (*get_reg_ofs) (struct drm_device * dev); 588 unsigned long (*get_reg_ofs) (struct drm_device * dev);
590 void (*set_version) (struct drm_device * dev, drm_set_version_t * sv); 589 void (*set_version) (struct drm_device * dev, drm_set_version_t * sv);
591 int (*version) (drm_version_t * version); 590 int (*version) (drm_version_t * version);
591
592 int major;
593 int minor;
594 int patchlevel;
595 char *name;
596 char *desc;
597 char *date;
598
592 u32 driver_features; 599 u32 driver_features;
593 int dev_priv_size; 600 int dev_priv_size;
594 drm_ioctl_desc_t *ioctls; 601 drm_ioctl_desc_t *ioctls;
@@ -772,7 +779,7 @@ extern int drm_ioctl(struct inode *inode, struct file *filp,
772 unsigned int cmd, unsigned long arg); 779 unsigned int cmd, unsigned long arg);
773extern long drm_compat_ioctl(struct file *filp, 780extern long drm_compat_ioctl(struct file *filp,
774 unsigned int cmd, unsigned long arg); 781 unsigned int cmd, unsigned long arg);
775extern int drm_takedown(drm_device_t * dev); 782extern int drm_lastclose(drm_device_t *dev);
776 783
777 /* Device support (drm_fops.h) */ 784 /* Device support (drm_fops.h) */
778extern int drm_open(struct inode *inode, struct file *filp); 785extern int drm_open(struct inode *inode, struct file *filp);
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 4dff7554eb08..d8ff84bdc3e7 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -129,7 +129,7 @@ static drm_ioctl_desc_t drm_ioctls[] = {
129 * 129 *
130 * \sa drm_device 130 * \sa drm_device
131 */ 131 */
132int drm_takedown(drm_device_t * dev) 132int drm_lastclose(drm_device_t * dev)
133{ 133{
134 drm_magic_entry_t *pt, *next; 134 drm_magic_entry_t *pt, *next;
135 drm_map_list_t *r_list; 135 drm_map_list_t *r_list;
@@ -138,9 +138,9 @@ int drm_takedown(drm_device_t * dev)
138 138
139 DRM_DEBUG("\n"); 139 DRM_DEBUG("\n");
140 140
141 if (dev->driver->pretakedown) 141 if (dev->driver->lastclose)
142 dev->driver->pretakedown(dev); 142 dev->driver->lastclose(dev);
143 DRM_DEBUG("driver pretakedown completed\n"); 143 DRM_DEBUG("driver lastclose completed\n");
144 144
145 if (dev->unique) { 145 if (dev->unique) {
146 drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER); 146 drm_free(dev->unique, strlen(dev->unique) + 1, DRM_MEM_DRIVER);
@@ -233,7 +233,7 @@ int drm_takedown(drm_device_t * dev)
233 } 233 }
234 up(&dev->struct_sem); 234 up(&dev->struct_sem);
235 235
236 DRM_DEBUG("takedown completed\n"); 236 DRM_DEBUG("lastclose completed\n");
237 return 0; 237 return 0;
238} 238}
239 239
@@ -281,7 +281,7 @@ EXPORT_SYMBOL(drm_init);
281/** 281/**
282 * Called via cleanup_module() at module unload time. 282 * Called via cleanup_module() at module unload time.
283 * 283 *
284 * Cleans up all DRM device, calling takedown(). 284 * Cleans up all DRM device, calling drm_lastclose().
285 * 285 *
286 * \sa drm_init 286 * \sa drm_init
287 */ 287 */
@@ -294,7 +294,7 @@ static void drm_cleanup(drm_device_t * dev)
294 return; 294 return;
295 } 295 }
296 296
297 drm_takedown(dev); 297 drm_lastclose(dev);
298 298
299 if (dev->maplist) { 299 if (dev->maplist) {
300 drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS); 300 drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
@@ -317,8 +317,8 @@ static void drm_cleanup(drm_device_t * dev)
317 dev->agp = NULL; 317 dev->agp = NULL;
318 } 318 }
319 319
320 if (dev->driver->postcleanup) 320 if (dev->driver->unload)
321 dev->driver->postcleanup(dev); 321 dev->driver->unload(dev);
322 322
323 drm_put_head(&dev->primary); 323 drm_put_head(&dev->primary);
324 if (drm_put_dev(dev)) 324 if (drm_put_dev(dev))
@@ -432,14 +432,17 @@ static int drm_version(struct inode *inode, struct file *filp,
432 drm_device_t *dev = priv->head->dev; 432 drm_device_t *dev = priv->head->dev;
433 drm_version_t __user *argp = (void __user *)arg; 433 drm_version_t __user *argp = (void __user *)arg;
434 drm_version_t version; 434 drm_version_t version;
435 int ret; 435 int len;
436 436
437 if (copy_from_user(&version, argp, sizeof(version))) 437 if (copy_from_user(&version, argp, sizeof(version)))
438 return -EFAULT; 438 return -EFAULT;
439 439
440 /* version is a required function to return the personality module version */ 440 version.version_major = dev->driver->major;
441 if ((ret = dev->driver->version(&version))) 441 version.version_minor = dev->driver->minor;
442 return ret; 442 version.version_patchlevel = dev->driver->patchlevel;
443 DRM_COPY(version.name, dev->driver->name);
444 DRM_COPY(version.date, dev->driver->date);
445 DRM_COPY(version.desc, dev->driver->desc);
443 446
444 if (copy_to_user(argp, &version, sizeof(version))) 447 if (copy_to_user(argp, &version, sizeof(version)))
445 return -EFAULT; 448 return -EFAULT;
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index bf0a740122bf..f57f7d1a281e 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -45,8 +45,8 @@ static int drm_setup(drm_device_t * dev)
45 int i; 45 int i;
46 int ret; 46 int ret;
47 47
48 if (dev->driver->presetup) { 48 if (dev->driver->firstopen) {
49 ret = dev->driver->presetup(dev); 49 ret = dev->driver->firstopen(dev);
50 if (ret != 0) 50 if (ret != 0)
51 return ret; 51 return ret;
52 } 52 }
@@ -109,8 +109,6 @@ static int drm_setup(drm_device_t * dev)
109 * drm_select_queue fails between the time the interrupt is 109 * drm_select_queue fails between the time the interrupt is
110 * initialized and the time the queues are initialized. 110 * initialized and the time the queues are initialized.
111 */ 111 */
112 if (dev->driver->postsetup)
113 dev->driver->postsetup(dev);
114 112
115 return 0; 113 return 0;
116} 114}
@@ -167,7 +165,7 @@ EXPORT_SYMBOL(drm_open);
167 * If the hardware lock is held then free it, and take it again for the kernel 165 * If the hardware lock is held then free it, and take it again for the kernel
168 * context since it's necessary to reclaim buffers. Unlink the file private 166 * context since it's necessary to reclaim buffers. Unlink the file private
169 * data from its list and free it. Decreases the open count and if it reaches 167 * data from its list and free it. Decreases the open count and if it reaches
170 * zero calls takedown(). 168 * zero calls drm_lastclose().
171 */ 169 */
172int drm_release(struct inode *inode, struct file *filp) 170int drm_release(struct inode *inode, struct file *filp)
173{ 171{
@@ -180,8 +178,8 @@ int drm_release(struct inode *inode, struct file *filp)
180 178
181 DRM_DEBUG("open_count = %d\n", dev->open_count); 179 DRM_DEBUG("open_count = %d\n", dev->open_count);
182 180
183 if (dev->driver->prerelease) 181 if (dev->driver->preclose)
184 dev->driver->prerelease(dev, filp); 182 dev->driver->preclose(dev, filp);
185 183
186 /* ======================================================== 184 /* ========================================================
187 * Begin inline drm_release 185 * Begin inline drm_release
@@ -197,8 +195,8 @@ int drm_release(struct inode *inode, struct file *filp)
197 DRM_DEBUG("File %p released, freeing lock for context %d\n", 195 DRM_DEBUG("File %p released, freeing lock for context %d\n",
198 filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); 196 filp, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
199 197
200 if (dev->driver->release) 198 if (dev->driver->reclaim_buffers_locked)
201 dev->driver->release(dev, filp); 199 dev->driver->reclaim_buffers_locked(dev, filp);
202 200
203 drm_lock_free(dev, &dev->lock.hw_lock->lock, 201 drm_lock_free(dev, &dev->lock.hw_lock->lock,
204 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); 202 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
@@ -207,7 +205,7 @@ int drm_release(struct inode *inode, struct file *filp)
207 hardware at this point, possibly 205 hardware at this point, possibly
208 processed via a callback to the X 206 processed via a callback to the X
209 server. */ 207 server. */
210 } else if (dev->driver->release && priv->lock_count 208 } else if (dev->driver->reclaim_buffers_locked && priv->lock_count
211 && dev->lock.hw_lock) { 209 && dev->lock.hw_lock) {
212 /* The lock is required to reclaim buffers */ 210 /* The lock is required to reclaim buffers */
213 DECLARE_WAITQUEUE(entry, current); 211 DECLARE_WAITQUEUE(entry, current);
@@ -237,15 +235,14 @@ int drm_release(struct inode *inode, struct file *filp)
237 __set_current_state(TASK_RUNNING); 235 __set_current_state(TASK_RUNNING);
238 remove_wait_queue(&dev->lock.lock_queue, &entry); 236 remove_wait_queue(&dev->lock.lock_queue, &entry);
239 if (!retcode) { 237 if (!retcode) {
240 if (dev->driver->release) 238 dev->driver->reclaim_buffers_locked(dev, filp);
241 dev->driver->release(dev, filp);
242 drm_lock_free(dev, &dev->lock.hw_lock->lock, 239 drm_lock_free(dev, &dev->lock.hw_lock->lock,
243 DRM_KERNEL_CONTEXT); 240 DRM_KERNEL_CONTEXT);
244 } 241 }
245 } 242 }
246 243
247 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) 244 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
248 && !dev->driver->release) { 245 !dev->driver->reclaim_buffers_locked) {
249 dev->driver->reclaim_buffers(dev, filp); 246 dev->driver->reclaim_buffers(dev, filp);
250 } 247 }
251 248
@@ -292,8 +289,8 @@ int drm_release(struct inode *inode, struct file *filp)
292 } 289 }
293 up(&dev->struct_sem); 290 up(&dev->struct_sem);
294 291
295 if (dev->driver->free_filp_priv) 292 if (dev->driver->postclose)
296 dev->driver->free_filp_priv(dev, priv); 293 dev->driver->postclose(dev, priv);
297 294
298 drm_free(priv, sizeof(*priv), DRM_MEM_FILES); 295 drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
299 296
@@ -313,7 +310,7 @@ int drm_release(struct inode *inode, struct file *filp)
313 } 310 }
314 spin_unlock(&dev->count_lock); 311 spin_unlock(&dev->count_lock);
315 unlock_kernel(); 312 unlock_kernel();
316 return drm_takedown(dev); 313 return drm_lastclose(dev);
317 } 314 }
318 spin_unlock(&dev->count_lock); 315 spin_unlock(&dev->count_lock);
319 316
@@ -363,8 +360,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
363 priv->authenticated = capable(CAP_SYS_ADMIN); 360 priv->authenticated = capable(CAP_SYS_ADMIN);
364 priv->lock_count = 0; 361 priv->lock_count = 0;
365 362
366 if (dev->driver->open_helper) { 363 if (dev->driver->open) {
367 ret = dev->driver->open_helper(dev, priv); 364 ret = dev->driver->open(dev, priv);
368 if (ret < 0) 365 if (ret < 0)
369 goto out_free; 366 goto out_free;
370 } 367 }
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index 9b0feba6b063..a654ac17a900 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -325,17 +325,13 @@ int drm_setversion(DRM_IOCTL_ARGS)
325 drm_set_version_t retv; 325 drm_set_version_t retv;
326 int if_version; 326 int if_version;
327 drm_set_version_t __user *argp = (void __user *)data; 327 drm_set_version_t __user *argp = (void __user *)data;
328 drm_version_t version;
329 328
330 DRM_COPY_FROM_USER_IOCTL(sv, argp, sizeof(sv)); 329 DRM_COPY_FROM_USER_IOCTL(sv, argp, sizeof(sv));
331 330
332 memset(&version, 0, sizeof(version));
333
334 dev->driver->version(&version);
335 retv.drm_di_major = DRM_IF_MAJOR; 331 retv.drm_di_major = DRM_IF_MAJOR;
336 retv.drm_di_minor = DRM_IF_MINOR; 332 retv.drm_di_minor = DRM_IF_MINOR;
337 retv.drm_dd_major = version.version_major; 333 retv.drm_dd_major = dev->driver->major;
338 retv.drm_dd_minor = version.version_minor; 334 retv.drm_dd_minor = dev->driver->minor;
339 335
340 DRM_COPY_TO_USER_IOCTL(argp, retv, sizeof(sv)); 336 DRM_COPY_TO_USER_IOCTL(argp, retv, sizeof(sv));
341 337
@@ -354,9 +350,9 @@ int drm_setversion(DRM_IOCTL_ARGS)
354 } 350 }
355 351
356 if (sv.drm_dd_major != -1) { 352 if (sv.drm_dd_major != -1) {
357 if (sv.drm_dd_major != version.version_major || 353 if (sv.drm_dd_major != dev->driver->major ||
358 sv.drm_dd_minor < 0 354 sv.drm_dd_minor < 0
359 || sv.drm_dd_minor > version.version_minor) 355 || sv.drm_dd_minor > dev->driver->minor)
360 return EINVAL; 356 return EINVAL;
361 357
362 if (dev->driver->set_version) 358 if (dev->driver->set_version)
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 60b6f8e8bf69..8568a6b373a0 100644
--- a/drivers/char/drm/drm_stub.c
+++ b/drivers/char/drm/drm_stub.c
@@ -93,8 +93,8 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
93 93
94 dev->driver = driver; 94 dev->driver = driver;
95 95
96 if (dev->driver->preinit) 96 if (dev->driver->load)
97 if ((retcode = dev->driver->preinit(dev, ent->driver_data))) 97 if ((retcode = dev->driver->load(dev, ent->driver_data)))
98 goto error_out_unreg; 98 goto error_out_unreg;
99 99
100 if (drm_core_has_AGP(dev)) { 100 if (drm_core_has_AGP(dev)) {
@@ -124,7 +124,7 @@ static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
124 return 0; 124 return 0;
125 125
126 error_out_unreg: 126 error_out_unreg:
127 drm_takedown(dev); 127 drm_lastclose(dev);
128 return retcode; 128 return retcode;
129} 129}
130 130
@@ -258,11 +258,10 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
258 } 258 }
259 if ((ret = drm_get_head(dev, &dev->primary))) 259 if ((ret = drm_get_head(dev, &dev->primary)))
260 goto err_g1; 260 goto err_g1;
261 261
262 /* postinit is a required function to display the signon banner */ 262 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
263 /* drivers add secondary heads here if needed */ 263 driver->name, driver->major, driver->minor, driver->patchlevel,
264 if ((ret = dev->driver->postinit(dev, ent->driver_data))) 264 driver->date, dev->primary.minor);
265 goto err_g1;
266 265
267 return 0; 266 return 0;
268 267
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index dba502373da1..c3178a89615d 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -1319,12 +1319,24 @@ static int i810_flip_bufs(struct inode *inode, struct file *filp,
1319 return 0; 1319 return 0;
1320} 1320}
1321 1321
1322void i810_driver_pretakedown(drm_device_t * dev) 1322int i810_driver_load(drm_device_t *dev, unsigned long flags)
1323{
1324 /* i810 has 4 more counters */
1325 dev->counters += 4;
1326 dev->types[6] = _DRM_STAT_IRQ;
1327 dev->types[7] = _DRM_STAT_PRIMARY;
1328 dev->types[8] = _DRM_STAT_SECONDARY;
1329 dev->types[9] = _DRM_STAT_DMA;
1330
1331 return 0;
1332}
1333
1334void i810_driver_lastclose(drm_device_t * dev)
1323{ 1335{
1324 i810_dma_cleanup(dev); 1336 i810_dma_cleanup(dev);
1325} 1337}
1326 1338
1327void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp) 1339void i810_driver_preclose(drm_device_t * dev, DRMFILE filp)
1328{ 1340{
1329 if (dev->dev_private) { 1341 if (dev->dev_private) {
1330 drm_i810_private_t *dev_priv = dev->dev_private; 1342 drm_i810_private_t *dev_priv = dev->dev_private;
@@ -1334,7 +1346,7 @@ void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp)
1334 } 1346 }
1335} 1347}
1336 1348
1337void i810_driver_release(drm_device_t * dev, struct file *filp) 1349void i810_driver_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
1338{ 1350{
1339 i810_reclaim_buffers(dev, filp); 1351 i810_reclaim_buffers(dev, filp);
1340} 1352}
diff --git a/drivers/char/drm/i810_drv.c b/drivers/char/drm/i810_drv.c
index 070cef6c2b46..e73b731c3be9 100644
--- a/drivers/char/drm/i810_drv.c
+++ b/drivers/char/drm/i810_drv.c
@@ -38,38 +38,6 @@
38 38
39#include "drm_pciids.h" 39#include "drm_pciids.h"
40 40
41static int postinit(struct drm_device *dev, unsigned long flags)
42{
43 /* i810 has 4 more counters */
44 dev->counters += 4;
45 dev->types[6] = _DRM_STAT_IRQ;
46 dev->types[7] = _DRM_STAT_PRIMARY;
47 dev->types[8] = _DRM_STAT_SECONDARY;
48 dev->types[9] = _DRM_STAT_DMA;
49
50 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
51 DRIVER_NAME,
52 DRIVER_MAJOR,
53 DRIVER_MINOR,
54 DRIVER_PATCHLEVEL,
55 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
56 );
57 return 0;
58}
59
60static int version(drm_version_t * version)
61{
62 int len;
63
64 version->version_major = DRIVER_MAJOR;
65 version->version_minor = DRIVER_MINOR;
66 version->version_patchlevel = DRIVER_PATCHLEVEL;
67 DRM_COPY(version->name, DRIVER_NAME);
68 DRM_COPY(version->date, DRIVER_DATE);
69 DRM_COPY(version->desc, DRIVER_DESC);
70 return 0;
71}
72
73static struct pci_device_id pciidlist[] = { 41static struct pci_device_id pciidlist[] = {
74 i810_PCI_IDS 42 i810_PCI_IDS
75}; 43};
@@ -79,16 +47,15 @@ static struct drm_driver driver = {
79 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | 47 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
80 DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE, 48 DRIVER_HAVE_DMA | DRIVER_DMA_QUEUE,
81 .dev_priv_size = sizeof(drm_i810_buf_priv_t), 49 .dev_priv_size = sizeof(drm_i810_buf_priv_t),
82 .pretakedown = i810_driver_pretakedown, 50 .load = i810_driver_load,
83 .prerelease = i810_driver_prerelease, 51 .lastclose = i810_driver_lastclose,
52 .preclose = i810_driver_preclose,
84 .device_is_agp = i810_driver_device_is_agp, 53 .device_is_agp = i810_driver_device_is_agp,
85 .release = i810_driver_release, 54 .reclaim_buffers_locked = i810_driver_reclaim_buffers_locked,
86 .dma_quiescent = i810_driver_dma_quiescent, 55 .dma_quiescent = i810_driver_dma_quiescent,
87 .reclaim_buffers = i810_reclaim_buffers, 56 .reclaim_buffers = i810_reclaim_buffers,
88 .get_map_ofs = drm_core_get_map_ofs, 57 .get_map_ofs = drm_core_get_map_ofs,
89 .get_reg_ofs = drm_core_get_reg_ofs, 58 .get_reg_ofs = drm_core_get_reg_ofs,
90 .postinit = postinit,
91 .version = version,
92 .ioctls = i810_ioctls, 59 .ioctls = i810_ioctls,
93 .fops = { 60 .fops = {
94 .owner = THIS_MODULE, 61 .owner = THIS_MODULE,
@@ -98,13 +65,19 @@ static struct drm_driver driver = {
98 .mmap = drm_mmap, 65 .mmap = drm_mmap,
99 .poll = drm_poll, 66 .poll = drm_poll,
100 .fasync = drm_fasync, 67 .fasync = drm_fasync,
101 } 68 },
102 , 69
103 .pci_driver = { 70 .pci_driver = {
104 .name = DRIVER_NAME, 71 .name = DRIVER_NAME,
105 .id_table = pciidlist, 72 .id_table = pciidlist,
106 } 73 },
107 , 74
75 .name = DRIVER_NAME,
76 .desc = DRIVER_DESC,
77 .date = DRIVER_DATE,
78 .major = DRIVER_MAJOR,
79 .minor = DRIVER_MINOR,
80 .patchlevel = DRIVER_PATCHLEVEL,
108}; 81};
109 82
110static int __init i810_init(void) 83static int __init i810_init(void)
diff --git a/drivers/char/drm/i810_drv.h b/drivers/char/drm/i810_drv.h
index c78f36aaa2f0..a18b80d91920 100644
--- a/drivers/char/drm/i810_drv.h
+++ b/drivers/char/drm/i810_drv.h
@@ -116,9 +116,13 @@ typedef struct drm_i810_private {
116extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp); 116extern void i810_reclaim_buffers(drm_device_t * dev, struct file *filp);
117 117
118extern int i810_driver_dma_quiescent(drm_device_t * dev); 118extern int i810_driver_dma_quiescent(drm_device_t * dev);
119extern void i810_driver_release(drm_device_t * dev, struct file *filp); 119extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
120extern void i810_driver_pretakedown(drm_device_t * dev); 120 struct file *filp);
121extern void i810_driver_prerelease(drm_device_t * dev, DRMFILE filp); 121extern int i810_driver_load(struct drm_device *, unsigned long flags);
122extern void i810_driver_lastclose(drm_device_t * dev);
123extern void i810_driver_preclose(drm_device_t * dev, DRMFILE filp);
124extern void i810_driver_reclaim_buffers_locked(drm_device_t * dev,
125 struct file *filp);
122extern int i810_driver_device_is_agp(drm_device_t * dev); 126extern int i810_driver_device_is_agp(drm_device_t * dev);
123 127
124extern drm_ioctl_desc_t i810_ioctls[]; 128extern drm_ioctl_desc_t i810_ioctls[];
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index dc94f1914425..01dfdb944e1f 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -1517,12 +1517,24 @@ static int i830_setparam(struct inode *inode, struct file *filp,
1517 return 0; 1517 return 0;
1518} 1518}
1519 1519
1520void i830_driver_pretakedown(drm_device_t * dev) 1520int i830_driver_load(drm_device_t *dev, unsigned long flags)
1521{
1522 /* i830 has 4 more counters */
1523 dev->counters += 4;
1524 dev->types[6] = _DRM_STAT_IRQ;
1525 dev->types[7] = _DRM_STAT_PRIMARY;
1526 dev->types[8] = _DRM_STAT_SECONDARY;
1527 dev->types[9] = _DRM_STAT_DMA;
1528
1529 return 0;
1530}
1531
1532void i830_driver_lastclose(drm_device_t * dev)
1521{ 1533{
1522 i830_dma_cleanup(dev); 1534 i830_dma_cleanup(dev);
1523} 1535}
1524 1536
1525void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp) 1537void i830_driver_preclose(drm_device_t * dev, DRMFILE filp)
1526{ 1538{
1527 if (dev->dev_private) { 1539 if (dev->dev_private) {
1528 drm_i830_private_t *dev_priv = dev->dev_private; 1540 drm_i830_private_t *dev_priv = dev->dev_private;
@@ -1532,7 +1544,7 @@ void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp)
1532 } 1544 }
1533} 1545}
1534 1546
1535void i830_driver_release(drm_device_t * dev, struct file *filp) 1547void i830_driver_reclaim_buffers_locked(drm_device_t * dev, struct file *filp)
1536{ 1548{
1537 i830_reclaim_buffers(dev, filp); 1549 i830_reclaim_buffers(dev, filp);
1538} 1550}
diff --git a/drivers/char/drm/i830_drv.c b/drivers/char/drm/i830_drv.c
index acd821e8fe4d..49fd2816de95 100644
--- a/drivers/char/drm/i830_drv.c
+++ b/drivers/char/drm/i830_drv.c
@@ -40,37 +40,6 @@
40 40
41#include "drm_pciids.h" 41#include "drm_pciids.h"
42 42
43static int postinit(struct drm_device *dev, unsigned long flags)
44{
45 dev->counters += 4;
46 dev->types[6] = _DRM_STAT_IRQ;
47 dev->types[7] = _DRM_STAT_PRIMARY;
48 dev->types[8] = _DRM_STAT_SECONDARY;
49 dev->types[9] = _DRM_STAT_DMA;
50
51 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
52 DRIVER_NAME,
53 DRIVER_MAJOR,
54 DRIVER_MINOR,
55 DRIVER_PATCHLEVEL,
56 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
57 );
58 return 0;
59}
60
61static int version(drm_version_t * version)
62{
63 int len;
64
65 version->version_major = DRIVER_MAJOR;
66 version->version_minor = DRIVER_MINOR;
67 version->version_patchlevel = DRIVER_PATCHLEVEL;
68 DRM_COPY(version->name, DRIVER_NAME);
69 DRM_COPY(version->date, DRIVER_DATE);
70 DRM_COPY(version->desc, DRIVER_DESC);
71 return 0;
72}
73
74static struct pci_device_id pciidlist[] = { 43static struct pci_device_id pciidlist[] = {
75 i830_PCI_IDS 44 i830_PCI_IDS
76}; 45};
@@ -83,10 +52,11 @@ static struct drm_driver driver = {
83 .driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ, 52 .driver_features |= DRIVER_HAVE_IRQ | DRIVER_SHARED_IRQ,
84#endif 53#endif
85 .dev_priv_size = sizeof(drm_i830_buf_priv_t), 54 .dev_priv_size = sizeof(drm_i830_buf_priv_t),
86 .pretakedown = i830_driver_pretakedown, 55 .load = i830_driver_load,
87 .prerelease = i830_driver_prerelease, 56 .lastclose = i830_driver_lastclose,
57 .preclose = i830_driver_preclose,
88 .device_is_agp = i830_driver_device_is_agp, 58 .device_is_agp = i830_driver_device_is_agp,
89 .release = i830_driver_release, 59 .reclaim_buffers_locked = i830_driver_reclaim_buffers_locked,
90 .dma_quiescent = i830_driver_dma_quiescent, 60 .dma_quiescent = i830_driver_dma_quiescent,
91 .reclaim_buffers = i830_reclaim_buffers, 61 .reclaim_buffers = i830_reclaim_buffers,
92 .get_map_ofs = drm_core_get_map_ofs, 62 .get_map_ofs = drm_core_get_map_ofs,
@@ -97,8 +67,6 @@ static struct drm_driver driver = {
97 .irq_uninstall = i830_driver_irq_uninstall, 67 .irq_uninstall = i830_driver_irq_uninstall,
98 .irq_handler = i830_driver_irq_handler, 68 .irq_handler = i830_driver_irq_handler,
99#endif 69#endif
100 .postinit = postinit,
101 .version = version,
102 .ioctls = i830_ioctls, 70 .ioctls = i830_ioctls,
103 .fops = { 71 .fops = {
104 .owner = THIS_MODULE, 72 .owner = THIS_MODULE,
@@ -108,13 +76,19 @@ static struct drm_driver driver = {
108 .mmap = drm_mmap, 76 .mmap = drm_mmap,
109 .poll = drm_poll, 77 .poll = drm_poll,
110 .fasync = drm_fasync, 78 .fasync = drm_fasync,
111 } 79 },
112 , 80
113 .pci_driver = { 81 .pci_driver = {
114 .name = DRIVER_NAME, 82 .name = DRIVER_NAME,
115 .id_table = pciidlist, 83 .id_table = pciidlist,
116 } 84 },
117 85
86 .name = DRIVER_NAME,
87 .desc = DRIVER_DESC,
88 .date = DRIVER_DATE,
89 .major = DRIVER_MAJOR,
90 .minor = DRIVER_MINOR,
91 .patchlevel = DRIVER_PATCHLEVEL,
118}; 92};
119 93
120static int __init i830_init(void) 94static int __init i830_init(void)
diff --git a/drivers/char/drm/i830_drv.h b/drivers/char/drm/i830_drv.h
index bc4bd49fb0cc..bf9075b576bd 100644
--- a/drivers/char/drm/i830_drv.h
+++ b/drivers/char/drm/i830_drv.h
@@ -136,10 +136,12 @@ extern irqreturn_t i830_driver_irq_handler(DRM_IRQ_ARGS);
136extern void i830_driver_irq_preinstall(drm_device_t * dev); 136extern void i830_driver_irq_preinstall(drm_device_t * dev);
137extern void i830_driver_irq_postinstall(drm_device_t * dev); 137extern void i830_driver_irq_postinstall(drm_device_t * dev);
138extern void i830_driver_irq_uninstall(drm_device_t * dev); 138extern void i830_driver_irq_uninstall(drm_device_t * dev);
139extern void i830_driver_pretakedown(drm_device_t * dev); 139extern int i830_driver_load(struct drm_device *, unsigned long flags);
140extern void i830_driver_release(drm_device_t * dev, struct file *filp); 140extern void i830_driver_preclose(drm_device_t * dev, DRMFILE filp);
141extern void i830_driver_lastclose(drm_device_t * dev);
142extern void i830_driver_reclaim_buffers_locked(drm_device_t * dev,
143 struct file *filp);
141extern int i830_driver_dma_quiescent(drm_device_t * dev); 144extern int i830_driver_dma_quiescent(drm_device_t * dev);
142extern void i830_driver_prerelease(drm_device_t * dev, DRMFILE filp);
143extern int i830_driver_device_is_agp(drm_device_t * dev); 145extern int i830_driver_device_is_agp(drm_device_t * dev);
144 146
145#define I830_READ(reg) DRM_READ32(dev_priv->mmio_map, reg) 147#define I830_READ(reg) DRM_READ32(dev_priv->mmio_map, reg)
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index f3aa0c370127..9ef3be31a812 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -699,7 +699,19 @@ static int i915_setparam(DRM_IOCTL_ARGS)
699 return 0; 699 return 0;
700} 700}
701 701
702void i915_driver_pretakedown(drm_device_t * dev) 702int i915_driver_load(drm_device_t *dev, unsigned long flags)
703{
704 /* i915 has 4 more counters */
705 dev->counters += 4;
706 dev->types[6] = _DRM_STAT_IRQ;
707 dev->types[7] = _DRM_STAT_PRIMARY;
708 dev->types[8] = _DRM_STAT_SECONDARY;
709 dev->types[9] = _DRM_STAT_DMA;
710
711 return 0;
712}
713
714void i915_driver_lastclose(drm_device_t * dev)
703{ 715{
704 if (dev->dev_private) { 716 if (dev->dev_private) {
705 drm_i915_private_t *dev_priv = dev->dev_private; 717 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -708,7 +720,7 @@ void i915_driver_pretakedown(drm_device_t * dev)
708 i915_dma_cleanup(dev); 720 i915_dma_cleanup(dev);
709} 721}
710 722
711void i915_driver_prerelease(drm_device_t * dev, DRMFILE filp) 723void i915_driver_preclose(drm_device_t * dev, DRMFILE filp)
712{ 724{
713 if (dev->dev_private) { 725 if (dev->dev_private) {
714 drm_i915_private_t *dev_priv = dev->dev_private; 726 drm_i915_private_t *dev_priv = dev->dev_private;
diff --git a/drivers/char/drm/i915_drv.c b/drivers/char/drm/i915_drv.c
index 0508240f4e3b..32b7f8bb420d 100644
--- a/drivers/char/drm/i915_drv.c
+++ b/drivers/char/drm/i915_drv.c
@@ -34,37 +34,6 @@
34 34
35#include "drm_pciids.h" 35#include "drm_pciids.h"
36 36
37static int postinit(struct drm_device *dev, unsigned long flags)
38{
39 dev->counters += 4;
40 dev->types[6] = _DRM_STAT_IRQ;
41 dev->types[7] = _DRM_STAT_PRIMARY;
42 dev->types[8] = _DRM_STAT_SECONDARY;
43 dev->types[9] = _DRM_STAT_DMA;
44
45 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
46 DRIVER_NAME,
47 DRIVER_MAJOR,
48 DRIVER_MINOR,
49 DRIVER_PATCHLEVEL,
50 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
51 );
52 return 0;
53}
54
55static int version(drm_version_t * version)
56{
57 int len;
58
59 version->version_major = DRIVER_MAJOR;
60 version->version_minor = DRIVER_MINOR;
61 version->version_patchlevel = DRIVER_PATCHLEVEL;
62 DRM_COPY(version->name, DRIVER_NAME);
63 DRM_COPY(version->date, DRIVER_DATE);
64 DRM_COPY(version->desc, DRIVER_DESC);
65 return 0;
66}
67
68static struct pci_device_id pciidlist[] = { 37static struct pci_device_id pciidlist[] = {
69 i915_PCI_IDS 38 i915_PCI_IDS
70}; 39};
@@ -73,8 +42,9 @@ static struct drm_driver driver = {
73 .driver_features = 42 .driver_features =
74 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | 43 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
75 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, 44 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
76 .pretakedown = i915_driver_pretakedown, 45 .load = i915_driver_load,
77 .prerelease = i915_driver_prerelease, 46 .lastclose = i915_driver_lastclose,
47 .preclose = i915_driver_preclose,
78 .device_is_agp = i915_driver_device_is_agp, 48 .device_is_agp = i915_driver_device_is_agp,
79 .irq_preinstall = i915_driver_irq_preinstall, 49 .irq_preinstall = i915_driver_irq_preinstall,
80 .irq_postinstall = i915_driver_irq_postinstall, 50 .irq_postinstall = i915_driver_irq_postinstall,
@@ -83,8 +53,6 @@ static struct drm_driver driver = {
83 .reclaim_buffers = drm_core_reclaim_buffers, 53 .reclaim_buffers = drm_core_reclaim_buffers,
84 .get_map_ofs = drm_core_get_map_ofs, 54 .get_map_ofs = drm_core_get_map_ofs,
85 .get_reg_ofs = drm_core_get_reg_ofs, 55 .get_reg_ofs = drm_core_get_reg_ofs,
86 .postinit = postinit,
87 .version = version,
88 .ioctls = i915_ioctls, 56 .ioctls = i915_ioctls,
89 .fops = { 57 .fops = {
90 .owner = THIS_MODULE, 58 .owner = THIS_MODULE,
@@ -97,11 +65,19 @@ static struct drm_driver driver = {
97#ifdef CONFIG_COMPAT 65#ifdef CONFIG_COMPAT
98 .compat_ioctl = i915_compat_ioctl, 66 .compat_ioctl = i915_compat_ioctl,
99#endif 67#endif
100 }, 68 },
69
101 .pci_driver = { 70 .pci_driver = {
102 .name = DRIVER_NAME, 71 .name = DRIVER_NAME,
103 .id_table = pciidlist, 72 .id_table = pciidlist,
104 } 73 },
74
75 .name = DRIVER_NAME,
76 .desc = DRIVER_DESC,
77 .date = DRIVER_DATE,
78 .major = DRIVER_MAJOR,
79 .minor = DRIVER_MINOR,
80 .patchlevel = DRIVER_PATCHLEVEL,
105}; 81};
106 82
107static int __init i915_init(void) 83static int __init i915_init(void)
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index 17e457c73dc7..cd4f5227d0ea 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -104,8 +104,9 @@ extern int i915_max_ioctl;
104 104
105 /* i915_dma.c */ 105 /* i915_dma.c */
106extern void i915_kernel_lost_context(drm_device_t * dev); 106extern void i915_kernel_lost_context(drm_device_t * dev);
107extern void i915_driver_pretakedown(drm_device_t * dev); 107extern int i915_driver_load(struct drm_device *, unsigned long flags);
108extern void i915_driver_prerelease(drm_device_t * dev, DRMFILE filp); 108extern void i915_driver_lastclose(drm_device_t * dev);
109extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp);
109extern int i915_driver_device_is_agp(drm_device_t * dev); 110extern int i915_driver_device_is_agp(drm_device_t * dev);
110 111
111/* i915_irq.c */ 112/* i915_irq.c */
diff --git a/drivers/char/drm/mga_dma.c b/drivers/char/drm/mga_dma.c
index 70dc7f64b7b9..9b09d786b158 100644
--- a/drivers/char/drm/mga_dma.c
+++ b/drivers/char/drm/mga_dma.c
@@ -391,7 +391,7 @@ int mga_freelist_put(drm_device_t * dev, drm_buf_t * buf)
391 * DMA initialization, cleanup 391 * DMA initialization, cleanup
392 */ 392 */
393 393
394int mga_driver_preinit(drm_device_t * dev, unsigned long flags) 394int mga_driver_load(drm_device_t * dev, unsigned long flags)
395{ 395{
396 drm_mga_private_t *dev_priv; 396 drm_mga_private_t *dev_priv;
397 397
@@ -405,6 +405,14 @@ int mga_driver_preinit(drm_device_t * dev, unsigned long flags)
405 dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT; 405 dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
406 dev_priv->chipset = flags; 406 dev_priv->chipset = flags;
407 407
408 dev_priv->mmio_base = drm_get_resource_start(dev, 1);
409 dev_priv->mmio_size = drm_get_resource_len(dev, 1);
410
411 dev->counters += 3;
412 dev->types[6] = _DRM_STAT_IRQ;
413 dev->types[7] = _DRM_STAT_PRIMARY;
414 dev->types[8] = _DRM_STAT_SECONDARY;
415
408 return 0; 416 return 0;
409} 417}
410 418
@@ -1118,7 +1126,7 @@ int mga_dma_buffers(DRM_IOCTL_ARGS)
1118/** 1126/**
1119 * Called just before the module is unloaded. 1127 * Called just before the module is unloaded.
1120 */ 1128 */
1121int mga_driver_postcleanup(drm_device_t * dev) 1129int mga_driver_unload(drm_device_t * dev)
1122{ 1130{
1123 drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER); 1131 drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
1124 dev->dev_private = NULL; 1132 dev->dev_private = NULL;
@@ -1129,7 +1137,7 @@ int mga_driver_postcleanup(drm_device_t * dev)
1129/** 1137/**
1130 * Called when the last opener of the device is closed. 1138 * Called when the last opener of the device is closed.
1131 */ 1139 */
1132void mga_driver_pretakedown(drm_device_t * dev) 1140void mga_driver_lastclose(drm_device_t * dev)
1133{ 1141{
1134 mga_do_cleanup_dma(dev); 1142 mga_do_cleanup_dma(dev);
1135} 1143}
diff --git a/drivers/char/drm/mga_drv.c b/drivers/char/drm/mga_drv.c
index 0cc7c305a7f6..eae2f91994ec 100644
--- a/drivers/char/drm/mga_drv.c
+++ b/drivers/char/drm/mga_drv.c
@@ -38,41 +38,6 @@
38#include "drm_pciids.h" 38#include "drm_pciids.h"
39 39
40static int mga_driver_device_is_agp(drm_device_t * dev); 40static int mga_driver_device_is_agp(drm_device_t * dev);
41static int postinit(struct drm_device *dev, unsigned long flags)
42{
43 drm_mga_private_t *const dev_priv =
44 (drm_mga_private_t *) dev->dev_private;
45
46 dev_priv->mmio_base = pci_resource_start(dev->pdev, 1);
47 dev_priv->mmio_size = pci_resource_len(dev->pdev, 1);
48
49 dev->counters += 3;
50 dev->types[6] = _DRM_STAT_IRQ;
51 dev->types[7] = _DRM_STAT_PRIMARY;
52 dev->types[8] = _DRM_STAT_SECONDARY;
53
54 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
55 DRIVER_NAME,
56 DRIVER_MAJOR,
57 DRIVER_MINOR,
58 DRIVER_PATCHLEVEL,
59 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
60 );
61 return 0;
62}
63
64static int version(drm_version_t * version)
65{
66 int len;
67
68 version->version_major = DRIVER_MAJOR;
69 version->version_minor = DRIVER_MINOR;
70 version->version_patchlevel = DRIVER_PATCHLEVEL;
71 DRM_COPY(version->name, DRIVER_NAME);
72 DRM_COPY(version->date, DRIVER_DATE);
73 DRM_COPY(version->desc, DRIVER_DESC);
74 return 0;
75}
76 41
77static struct pci_device_id pciidlist[] = { 42static struct pci_device_id pciidlist[] = {
78 mga_PCI_IDS 43 mga_PCI_IDS
@@ -83,9 +48,9 @@ static struct drm_driver driver = {
83 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR | 48 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
84 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | 49 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
85 DRIVER_IRQ_VBL, 50 DRIVER_IRQ_VBL,
86 .preinit = mga_driver_preinit, 51 .load = mga_driver_load,
87 .postcleanup = mga_driver_postcleanup, 52 .unload = mga_driver_unload,
88 .pretakedown = mga_driver_pretakedown, 53 .lastclose = mga_driver_lastclose,
89 .dma_quiescent = mga_driver_dma_quiescent, 54 .dma_quiescent = mga_driver_dma_quiescent,
90 .device_is_agp = mga_driver_device_is_agp, 55 .device_is_agp = mga_driver_device_is_agp,
91 .vblank_wait = mga_driver_vblank_wait, 56 .vblank_wait = mga_driver_vblank_wait,
@@ -96,8 +61,6 @@ static struct drm_driver driver = {
96 .reclaim_buffers = drm_core_reclaim_buffers, 61 .reclaim_buffers = drm_core_reclaim_buffers,
97 .get_map_ofs = drm_core_get_map_ofs, 62 .get_map_ofs = drm_core_get_map_ofs,
98 .get_reg_ofs = drm_core_get_reg_ofs, 63 .get_reg_ofs = drm_core_get_reg_ofs,
99 .postinit = postinit,
100 .version = version,
101 .ioctls = mga_ioctls, 64 .ioctls = mga_ioctls,
102 .dma_ioctl = mga_dma_buffers, 65 .dma_ioctl = mga_dma_buffers,
103 .fops = { 66 .fops = {
@@ -113,9 +76,16 @@ static struct drm_driver driver = {
113#endif 76#endif
114 }, 77 },
115 .pci_driver = { 78 .pci_driver = {
116 .name = DRIVER_NAME, 79 .name = DRIVER_NAME,
117 .id_table = pciidlist, 80 .id_table = pciidlist,
118 } 81 },
82
83 .name = DRIVER_NAME,
84 .desc = DRIVER_DESC,
85 .date = DRIVER_DATE,
86 .major = DRIVER_MAJOR,
87 .minor = DRIVER_MINOR,
88 .patchlevel = DRIVER_PATCHLEVEL,
119}; 89};
120 90
121static int __init mga_init(void) 91static int __init mga_init(void)
diff --git a/drivers/char/drm/mga_drv.h b/drivers/char/drm/mga_drv.h
index 461728e6a58a..137bfdd5e92b 100644
--- a/drivers/char/drm/mga_drv.h
+++ b/drivers/char/drm/mga_drv.h
@@ -152,14 +152,14 @@ extern drm_ioctl_desc_t mga_ioctls[];
152extern int mga_max_ioctl; 152extern int mga_max_ioctl;
153 153
154 /* mga_dma.c */ 154 /* mga_dma.c */
155extern int mga_driver_preinit(drm_device_t * dev, unsigned long flags);
156extern int mga_dma_bootstrap(DRM_IOCTL_ARGS); 155extern int mga_dma_bootstrap(DRM_IOCTL_ARGS);
157extern int mga_dma_init(DRM_IOCTL_ARGS); 156extern int mga_dma_init(DRM_IOCTL_ARGS);
158extern int mga_dma_flush(DRM_IOCTL_ARGS); 157extern int mga_dma_flush(DRM_IOCTL_ARGS);
159extern int mga_dma_reset(DRM_IOCTL_ARGS); 158extern int mga_dma_reset(DRM_IOCTL_ARGS);
160extern int mga_dma_buffers(DRM_IOCTL_ARGS); 159extern int mga_dma_buffers(DRM_IOCTL_ARGS);
161extern int mga_driver_postcleanup(drm_device_t * dev); 160extern int mga_driver_load(drm_device_t *dev, unsigned long flags);
162extern void mga_driver_pretakedown(drm_device_t * dev); 161extern int mga_driver_unload(drm_device_t * dev);
162extern void mga_driver_lastclose(drm_device_t * dev);
163extern int mga_driver_dma_quiescent(drm_device_t * dev); 163extern int mga_driver_dma_quiescent(drm_device_t * dev);
164 164
165extern int mga_do_wait_for_idle(drm_mga_private_t * dev_priv); 165extern int mga_do_wait_for_idle(drm_mga_private_t * dev_priv);
diff --git a/drivers/char/drm/r128_drv.c b/drivers/char/drm/r128_drv.c
index 1661e7351402..e20450ae220e 100644
--- a/drivers/char/drm/r128_drv.c
+++ b/drivers/char/drm/r128_drv.c
@@ -37,31 +37,6 @@
37 37
38#include "drm_pciids.h" 38#include "drm_pciids.h"
39 39
40static int postinit(struct drm_device *dev, unsigned long flags)
41{
42 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
43 DRIVER_NAME,
44 DRIVER_MAJOR,
45 DRIVER_MINOR,
46 DRIVER_PATCHLEVEL,
47 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
48 );
49 return 0;
50}
51
52static int version(drm_version_t * version)
53{
54 int len;
55
56 version->version_major = DRIVER_MAJOR;
57 version->version_minor = DRIVER_MINOR;
58 version->version_patchlevel = DRIVER_PATCHLEVEL;
59 DRM_COPY(version->name, DRIVER_NAME);
60 DRM_COPY(version->date, DRIVER_DATE);
61 DRM_COPY(version->desc, DRIVER_DESC);
62 return 0;
63}
64
65static struct pci_device_id pciidlist[] = { 40static struct pci_device_id pciidlist[] = {
66 r128_PCI_IDS 41 r128_PCI_IDS
67}; 42};
@@ -72,8 +47,8 @@ static struct drm_driver driver = {
72 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | 47 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED |
73 DRIVER_IRQ_VBL, 48 DRIVER_IRQ_VBL,
74 .dev_priv_size = sizeof(drm_r128_buf_priv_t), 49 .dev_priv_size = sizeof(drm_r128_buf_priv_t),
75 .prerelease = r128_driver_prerelease, 50 .preclose = r128_driver_preclose,
76 .pretakedown = r128_driver_pretakedown, 51 .lastclose = r128_driver_lastclose,
77 .vblank_wait = r128_driver_vblank_wait, 52 .vblank_wait = r128_driver_vblank_wait,
78 .irq_preinstall = r128_driver_irq_preinstall, 53 .irq_preinstall = r128_driver_irq_preinstall,
79 .irq_postinstall = r128_driver_irq_postinstall, 54 .irq_postinstall = r128_driver_irq_postinstall,
@@ -82,8 +57,6 @@ static struct drm_driver driver = {
82 .reclaim_buffers = drm_core_reclaim_buffers, 57 .reclaim_buffers = drm_core_reclaim_buffers,
83 .get_map_ofs = drm_core_get_map_ofs, 58 .get_map_ofs = drm_core_get_map_ofs,
84 .get_reg_ofs = drm_core_get_reg_ofs, 59 .get_reg_ofs = drm_core_get_reg_ofs,
85 .postinit = postinit,
86 .version = version,
87 .ioctls = r128_ioctls, 60 .ioctls = r128_ioctls,
88 .dma_ioctl = r128_cce_buffers, 61 .dma_ioctl = r128_cce_buffers,
89 .fops = { 62 .fops = {
@@ -97,12 +70,19 @@ static struct drm_driver driver = {
97#ifdef CONFIG_COMPAT 70#ifdef CONFIG_COMPAT
98 .compat_ioctl = r128_compat_ioctl, 71 .compat_ioctl = r128_compat_ioctl,
99#endif 72#endif
100 } 73 },
101 , 74
102 .pci_driver = { 75 .pci_driver = {
103 .name = DRIVER_NAME, 76 .name = DRIVER_NAME,
104 .id_table = pciidlist, 77 .id_table = pciidlist,
105 } 78 },
79
80 .name = DRIVER_NAME,
81 .desc = DRIVER_DESC,
82 .date = DRIVER_DATE,
83 .major = DRIVER_MAJOR,
84 .minor = DRIVER_MINOR,
85 .patchlevel = DRIVER_PATCHLEVEL,
106}; 86};
107 87
108static int __init r128_init(void) 88static int __init r128_init(void)
diff --git a/drivers/char/drm/r128_drv.h b/drivers/char/drm/r128_drv.h
index 5c79e40eb88f..9a779bad3da3 100644
--- a/drivers/char/drm/r128_drv.h
+++ b/drivers/char/drm/r128_drv.h
@@ -154,8 +154,8 @@ extern irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS);
154extern void r128_driver_irq_preinstall(drm_device_t * dev); 154extern void r128_driver_irq_preinstall(drm_device_t * dev);
155extern void r128_driver_irq_postinstall(drm_device_t * dev); 155extern void r128_driver_irq_postinstall(drm_device_t * dev);
156extern void r128_driver_irq_uninstall(drm_device_t * dev); 156extern void r128_driver_irq_uninstall(drm_device_t * dev);
157extern void r128_driver_pretakedown(drm_device_t * dev); 157extern void r128_driver_lastclose(drm_device_t * dev);
158extern void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp); 158extern void r128_driver_preclose(drm_device_t * dev, DRMFILE filp);
159 159
160extern long r128_compat_ioctl(struct file *filp, unsigned int cmd, 160extern long r128_compat_ioctl(struct file *filp, unsigned int cmd,
161 unsigned long arg); 161 unsigned long arg);
diff --git a/drivers/char/drm/r128_state.c b/drivers/char/drm/r128_state.c
index 14479cc08a57..1f04e3372206 100644
--- a/drivers/char/drm/r128_state.c
+++ b/drivers/char/drm/r128_state.c
@@ -1674,7 +1674,7 @@ static int r128_getparam(DRM_IOCTL_ARGS)
1674 return 0; 1674 return 0;
1675} 1675}
1676 1676
1677void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp) 1677void r128_driver_preclose(drm_device_t * dev, DRMFILE filp)
1678{ 1678{
1679 if (dev->dev_private) { 1679 if (dev->dev_private) {
1680 drm_r128_private_t *dev_priv = dev->dev_private; 1680 drm_r128_private_t *dev_priv = dev->dev_private;
@@ -1684,7 +1684,7 @@ void r128_driver_prerelease(drm_device_t * dev, DRMFILE filp)
1684 } 1684 }
1685} 1685}
1686 1686
1687void r128_driver_pretakedown(drm_device_t * dev) 1687void r128_driver_lastclose(drm_device_t * dev)
1688{ 1688{
1689 r128_do_cleanup_cce(dev); 1689 r128_do_cleanup_cce(dev);
1690} 1690}
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 03839ea31092..dc3a15a1819a 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -2103,7 +2103,7 @@ int radeon_cp_buffers(DRM_IOCTL_ARGS)
2103 return ret; 2103 return ret;
2104} 2104}
2105 2105
2106int radeon_driver_preinit(struct drm_device *dev, unsigned long flags) 2106int radeon_driver_load(struct drm_device *dev, unsigned long flags)
2107{ 2107{
2108 drm_radeon_private_t *dev_priv; 2108 drm_radeon_private_t *dev_priv;
2109 int ret = 0; 2109 int ret = 0;
@@ -2140,7 +2140,10 @@ int radeon_driver_preinit(struct drm_device *dev, unsigned long flags)
2140 return ret; 2140 return ret;
2141} 2141}
2142 2142
2143int radeon_presetup(struct drm_device *dev) 2143/* Create mappings for registers and framebuffer so userland doesn't necessarily
2144 * have to find them.
2145 */
2146int radeon_driver_firstopen(struct drm_device *dev)
2144{ 2147{
2145 int ret; 2148 int ret;
2146 drm_local_map_t *map; 2149 drm_local_map_t *map;
@@ -2161,7 +2164,7 @@ int radeon_presetup(struct drm_device *dev)
2161 return 0; 2164 return 0;
2162} 2165}
2163 2166
2164int radeon_driver_postcleanup(struct drm_device *dev) 2167int radeon_driver_unload(struct drm_device *dev)
2165{ 2168{
2166 drm_radeon_private_t *dev_priv = dev->dev_private; 2169 drm_radeon_private_t *dev_priv = dev->dev_private;
2167 2170
diff --git a/drivers/char/drm/radeon_drv.c b/drivers/char/drm/radeon_drv.c
index ee49670d8162..999d74512362 100644
--- a/drivers/char/drm/radeon_drv.c
+++ b/drivers/char/drm/radeon_drv.c
@@ -42,30 +42,6 @@ int radeon_no_wb;
42MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n"); 42MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n");
43module_param_named(no_wb, radeon_no_wb, int, 0444); 43module_param_named(no_wb, radeon_no_wb, int, 0444);
44 44
45static int postinit(struct drm_device *dev, unsigned long flags)
46{
47 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
48 DRIVER_NAME,
49 DRIVER_MAJOR,
50 DRIVER_MINOR,
51 DRIVER_PATCHLEVEL,
52 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
53 );
54 return 0;
55}
56
57static int version(drm_version_t * version)
58{
59 int len;
60
61 version->version_major = DRIVER_MAJOR;
62 version->version_minor = DRIVER_MINOR;
63 version->version_patchlevel = DRIVER_PATCHLEVEL;
64 DRM_COPY(version->name, DRIVER_NAME);
65 DRM_COPY(version->date, DRIVER_DATE);
66 DRM_COPY(version->desc, DRIVER_DESC);
67 return 0;
68}
69 45
70static struct pci_device_id pciidlist[] = { 46static struct pci_device_id pciidlist[] = {
71 radeon_PCI_IDS 47 radeon_PCI_IDS
@@ -77,23 +53,21 @@ static struct drm_driver driver = {
77 DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | 53 DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED |
78 DRIVER_IRQ_VBL, 54 DRIVER_IRQ_VBL,
79 .dev_priv_size = sizeof(drm_radeon_buf_priv_t), 55 .dev_priv_size = sizeof(drm_radeon_buf_priv_t),
80 .preinit = radeon_driver_preinit, 56 .load = radeon_driver_load,
81 .presetup = radeon_presetup, 57 .firstopen = radeon_driver_firstopen,
82 .postcleanup = radeon_driver_postcleanup, 58 .open = radeon_driver_open,
83 .prerelease = radeon_driver_prerelease, 59 .preclose = radeon_driver_preclose,
84 .pretakedown = radeon_driver_pretakedown, 60 .postclose = radeon_driver_postclose,
85 .open_helper = radeon_driver_open_helper, 61 .lastclose = radeon_driver_lastclose,
62 .unload = radeon_driver_unload,
86 .vblank_wait = radeon_driver_vblank_wait, 63 .vblank_wait = radeon_driver_vblank_wait,
87 .irq_preinstall = radeon_driver_irq_preinstall, 64 .irq_preinstall = radeon_driver_irq_preinstall,
88 .irq_postinstall = radeon_driver_irq_postinstall, 65 .irq_postinstall = radeon_driver_irq_postinstall,
89 .irq_uninstall = radeon_driver_irq_uninstall, 66 .irq_uninstall = radeon_driver_irq_uninstall,
90 .irq_handler = radeon_driver_irq_handler, 67 .irq_handler = radeon_driver_irq_handler,
91 .free_filp_priv = radeon_driver_free_filp_priv,
92 .reclaim_buffers = drm_core_reclaim_buffers, 68 .reclaim_buffers = drm_core_reclaim_buffers,
93 .get_map_ofs = drm_core_get_map_ofs, 69 .get_map_ofs = drm_core_get_map_ofs,
94 .get_reg_ofs = drm_core_get_reg_ofs, 70 .get_reg_ofs = drm_core_get_reg_ofs,
95 .postinit = postinit,
96 .version = version,
97 .ioctls = radeon_ioctls, 71 .ioctls = radeon_ioctls,
98 .dma_ioctl = radeon_cp_buffers, 72 .dma_ioctl = radeon_cp_buffers,
99 .fops = { 73 .fops = {
@@ -107,12 +81,19 @@ static struct drm_driver driver = {
107#ifdef CONFIG_COMPAT 81#ifdef CONFIG_COMPAT
108 .compat_ioctl = radeon_compat_ioctl, 82 .compat_ioctl = radeon_compat_ioctl,
109#endif 83#endif
110 } 84 },
111 , 85
112 .pci_driver = { 86 .pci_driver = {
113 .name = DRIVER_NAME, 87 .name = DRIVER_NAME,
114 .id_table = pciidlist, 88 .id_table = pciidlist,
115 } 89 },
90
91 .name = DRIVER_NAME,
92 .desc = DRIVER_DESC,
93 .date = DRIVER_DATE,
94 .major = DRIVER_MAJOR,
95 .minor = DRIVER_MINOR,
96 .patchlevel = DRIVER_PATCHLEVEL,
116}; 97};
117 98
118static int __init radeon_init(void) 99static int __init radeon_init(void)
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 120ee5a8ebcc..3a91d5fc597e 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -331,17 +331,14 @@ extern irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS);
331extern void radeon_driver_irq_preinstall(drm_device_t * dev); 331extern void radeon_driver_irq_preinstall(drm_device_t * dev);
332extern void radeon_driver_irq_postinstall(drm_device_t * dev); 332extern void radeon_driver_irq_postinstall(drm_device_t * dev);
333extern void radeon_driver_irq_uninstall(drm_device_t * dev); 333extern void radeon_driver_irq_uninstall(drm_device_t * dev);
334extern void radeon_driver_prerelease(drm_device_t * dev, DRMFILE filp);
335extern void radeon_driver_pretakedown(drm_device_t * dev);
336extern int radeon_driver_open_helper(drm_device_t * dev,
337 drm_file_t * filp_priv);
338extern void radeon_driver_free_filp_priv(drm_device_t * dev,
339 drm_file_t * filp_priv);
340
341extern int radeon_preinit(struct drm_device *dev, unsigned long flags);
342extern int radeon_postinit(struct drm_device *dev, unsigned long flags);
343extern int radeon_postcleanup(struct drm_device *dev);
344 334
335extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
336extern int radeon_driver_unload(struct drm_device *dev);
337extern int radeon_driver_firstopen(struct drm_device *dev);
338extern void radeon_driver_preclose(drm_device_t * dev, DRMFILE filp);
339extern void radeon_driver_postclose(drm_device_t * dev, drm_file_t * filp);
340extern void radeon_driver_lastclose(drm_device_t * dev);
341extern int radeon_driver_open(drm_device_t * dev, drm_file_t * filp_priv);
345extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd, 342extern long radeon_compat_ioctl(struct file *filp, unsigned int cmd,
346 unsigned long arg); 343 unsigned long arg);
347 344
diff --git a/drivers/char/drm/radeon_state.c b/drivers/char/drm/radeon_state.c
index 231ac1438c69..717f546cc448 100644
--- a/drivers/char/drm/radeon_state.c
+++ b/drivers/char/drm/radeon_state.c
@@ -3069,7 +3069,7 @@ static int radeon_cp_setparam(DRM_IOCTL_ARGS)
3069 * 3069 *
3070 * DRM infrastructure takes care of reclaiming dma buffers. 3070 * DRM infrastructure takes care of reclaiming dma buffers.
3071 */ 3071 */
3072void radeon_driver_prerelease(drm_device_t * dev, DRMFILE filp) 3072void radeon_driver_preclose(drm_device_t * dev, DRMFILE filp)
3073{ 3073{
3074 if (dev->dev_private) { 3074 if (dev->dev_private) {
3075 drm_radeon_private_t *dev_priv = dev->dev_private; 3075 drm_radeon_private_t *dev_priv = dev->dev_private;
@@ -3082,12 +3082,12 @@ void radeon_driver_prerelease(drm_device_t * dev, DRMFILE filp)
3082 } 3082 }
3083} 3083}
3084 3084
3085void radeon_driver_pretakedown(drm_device_t * dev) 3085void radeon_driver_lastclose(drm_device_t * dev)
3086{ 3086{
3087 radeon_do_release(dev); 3087 radeon_do_release(dev);
3088} 3088}
3089 3089
3090int radeon_driver_open_helper(drm_device_t * dev, drm_file_t * filp_priv) 3090int radeon_driver_open(drm_device_t * dev, drm_file_t * filp_priv)
3091{ 3091{
3092 drm_radeon_private_t *dev_priv = dev->dev_private; 3092 drm_radeon_private_t *dev_priv = dev->dev_private;
3093 struct drm_radeon_driver_file_fields *radeon_priv; 3093 struct drm_radeon_driver_file_fields *radeon_priv;
@@ -3107,7 +3107,7 @@ int radeon_driver_open_helper(drm_device_t * dev, drm_file_t * filp_priv)
3107 return 0; 3107 return 0;
3108} 3108}
3109 3109
3110void radeon_driver_free_filp_priv(drm_device_t * dev, drm_file_t * filp_priv) 3110void radeon_driver_postclose(drm_device_t * dev, drm_file_t * filp_priv)
3111{ 3111{
3112 struct drm_radeon_driver_file_fields *radeon_priv = 3112 struct drm_radeon_driver_file_fields *radeon_priv =
3113 filp_priv->driver_priv; 3113 filp_priv->driver_priv;
diff --git a/drivers/char/drm/savage_bci.c b/drivers/char/drm/savage_bci.c
index 6d10515795cc..c3101702a1fe 100644
--- a/drivers/char/drm/savage_bci.c
+++ b/drivers/char/drm/savage_bci.c
@@ -533,16 +533,32 @@ static void savage_fake_dma_flush(drm_savage_private_t * dev_priv)
533 dev_priv->first_dma_page = dev_priv->current_dma_page = 0; 533 dev_priv->first_dma_page = dev_priv->current_dma_page = 0;
534} 534}
535 535
536int savage_driver_load(drm_device_t *dev, unsigned long chipset)
537{
538 drm_savage_private_t *dev_priv;
539
540 dev_priv = drm_alloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
541 if (dev_priv == NULL)
542 return DRM_ERR(ENOMEM);
543
544 memset(dev_priv, 0, sizeof(drm_savage_private_t));
545 dev->dev_private = (void *)dev_priv;
546
547 dev_priv->chipset = (enum savage_family)chipset;
548
549 return 0;
550}
551
552
536/* 553/*
537 * Initalize mappings. On Savage4 and SavageIX the alignment 554 * Initalize mappings. On Savage4 and SavageIX the alignment
538 * and size of the aperture is not suitable for automatic MTRR setup 555 * and size of the aperture is not suitable for automatic MTRR setup
539 * in drm_addmap. Therefore we do it manually before the maps are 556 * in drm_addmap. Therefore we add them manually before the maps are
540 * initialized. We also need to take care of deleting the MTRRs in 557 * initialized, and tear them down on last close.
541 * postcleanup.
542 */ 558 */
543int savage_preinit(drm_device_t * dev, unsigned long chipset) 559int savage_driver_firstopen(drm_device_t *dev)
544{ 560{
545 drm_savage_private_t *dev_priv; 561 drm_savage_private_t *dev_priv = dev->dev_private;
546 unsigned long mmio_base, fb_base, fb_size, aperture_base; 562 unsigned long mmio_base, fb_base, fb_size, aperture_base;
547 /* fb_rsrc and aper_rsrc aren't really used currently, but still exist 563 /* fb_rsrc and aper_rsrc aren't really used currently, but still exist
548 * in case we decide we need information on the BAR for BSD in the 564 * in case we decide we need information on the BAR for BSD in the
@@ -551,14 +567,6 @@ int savage_preinit(drm_device_t * dev, unsigned long chipset)
551 unsigned int fb_rsrc, aper_rsrc; 567 unsigned int fb_rsrc, aper_rsrc;
552 int ret = 0; 568 int ret = 0;
553 569
554 dev_priv = drm_alloc(sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
555 if (dev_priv == NULL)
556 return DRM_ERR(ENOMEM);
557
558 memset(dev_priv, 0, sizeof(drm_savage_private_t));
559 dev->dev_private = (void *)dev_priv;
560 dev_priv->chipset = (enum savage_family)chipset;
561
562 dev_priv->mtrr[0].handle = -1; 570 dev_priv->mtrr[0].handle = -1;
563 dev_priv->mtrr[1].handle = -1; 571 dev_priv->mtrr[1].handle = -1;
564 dev_priv->mtrr[2].handle = -1; 572 dev_priv->mtrr[2].handle = -1;
@@ -595,7 +603,8 @@ int savage_preinit(drm_device_t * dev, unsigned long chipset)
595 DRM_ERROR("strange pci_resource_len %08lx\n", 603 DRM_ERROR("strange pci_resource_len %08lx\n",
596 drm_get_resource_len(dev, 0)); 604 drm_get_resource_len(dev, 0));
597 } 605 }
598 } else if (chipset != S3_SUPERSAVAGE && chipset != S3_SAVAGE2000) { 606 } else if (dev_priv->chipset != S3_SUPERSAVAGE &&
607 dev_priv->chipset != S3_SAVAGE2000) {
599 mmio_base = drm_get_resource_start(dev, 0); 608 mmio_base = drm_get_resource_start(dev, 0);
600 fb_rsrc = 1; 609 fb_rsrc = 1;
601 fb_base = drm_get_resource_start(dev, 1); 610 fb_base = drm_get_resource_start(dev, 1);
@@ -648,7 +657,7 @@ int savage_preinit(drm_device_t * dev, unsigned long chipset)
648/* 657/*
649 * Delete MTRRs and free device-private data. 658 * Delete MTRRs and free device-private data.
650 */ 659 */
651int savage_postcleanup(drm_device_t * dev) 660void savage_driver_lastclose(drm_device_t *dev)
652{ 661{
653 drm_savage_private_t *dev_priv = dev->dev_private; 662 drm_savage_private_t *dev_priv = dev->dev_private;
654 int i; 663 int i;
@@ -658,6 +667,11 @@ int savage_postcleanup(drm_device_t * dev)
658 mtrr_del(dev_priv->mtrr[i].handle, 667 mtrr_del(dev_priv->mtrr[i].handle,
659 dev_priv->mtrr[i].base, 668 dev_priv->mtrr[i].base,
660 dev_priv->mtrr[i].size); 669 dev_priv->mtrr[i].size);
670}
671
672int savage_driver_unload(drm_device_t *dev)
673{
674 drm_savage_private_t *dev_priv = dev->dev_private;
661 675
662 drm_free(dev_priv, sizeof(drm_savage_private_t), DRM_MEM_DRIVER); 676 drm_free(dev_priv, sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
663 677
diff --git a/drivers/char/drm/savage_drv.c b/drivers/char/drm/savage_drv.c
index 22d799cde41c..aa6c0d1a82f8 100644
--- a/drivers/char/drm/savage_drv.c
+++ b/drivers/char/drm/savage_drv.c
@@ -30,31 +30,6 @@
30 30
31#include "drm_pciids.h" 31#include "drm_pciids.h"
32 32
33static int postinit(struct drm_device *dev, unsigned long flags)
34{
35 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
36 DRIVER_NAME,
37 DRIVER_MAJOR,
38 DRIVER_MINOR,
39 DRIVER_PATCHLEVEL,
40 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
41 );
42 return 0;
43}
44
45static int version(drm_version_t * version)
46{
47 int len;
48
49 version->version_major = DRIVER_MAJOR;
50 version->version_minor = DRIVER_MINOR;
51 version->version_patchlevel = DRIVER_PATCHLEVEL;
52 DRM_COPY(version->name, DRIVER_NAME);
53 DRM_COPY(version->date, DRIVER_DATE);
54 DRM_COPY(version->desc, DRIVER_DESC);
55 return 0;
56}
57
58static struct pci_device_id pciidlist[] = { 33static struct pci_device_id pciidlist[] = {
59 savage_PCI_IDS 34 savage_PCI_IDS
60}; 35};
@@ -63,13 +38,13 @@ static struct drm_driver driver = {
63 .driver_features = 38 .driver_features =
64 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_PCI_DMA, 39 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
65 .dev_priv_size = sizeof(drm_savage_buf_priv_t), 40 .dev_priv_size = sizeof(drm_savage_buf_priv_t),
66 .preinit = savage_preinit, 41 .load = savage_driver_load,
67 .postinit = postinit, 42 .firstopen = savage_driver_firstopen,
68 .postcleanup = savage_postcleanup, 43 .lastclose = savage_driver_lastclose,
44 .unload = savage_driver_unload,
69 .reclaim_buffers = savage_reclaim_buffers, 45 .reclaim_buffers = savage_reclaim_buffers,
70 .get_map_ofs = drm_core_get_map_ofs, 46 .get_map_ofs = drm_core_get_map_ofs,
71 .get_reg_ofs = drm_core_get_reg_ofs, 47 .get_reg_ofs = drm_core_get_reg_ofs,
72 .version = version,
73 .ioctls = savage_ioctls, 48 .ioctls = savage_ioctls,
74 .dma_ioctl = savage_bci_buffers, 49 .dma_ioctl = savage_bci_buffers,
75 .fops = { 50 .fops = {
@@ -80,12 +55,19 @@ static struct drm_driver driver = {
80 .mmap = drm_mmap, 55 .mmap = drm_mmap,
81 .poll = drm_poll, 56 .poll = drm_poll,
82 .fasync = drm_fasync, 57 .fasync = drm_fasync,
83 } 58 },
84 , 59
85 .pci_driver = { 60 .pci_driver = {
86 .name = DRIVER_NAME, 61 .name = DRIVER_NAME,
87 .id_table = pciidlist, 62 .id_table = pciidlist,
88 } 63 },
64
65 .name = DRIVER_NAME,
66 .desc = DRIVER_DESC,
67 .date = DRIVER_DATE,
68 .major = DRIVER_MAJOR,
69 .minor = DRIVER_MINOR,
70 .patchlevel = DRIVER_PATCHLEVEL,
89}; 71};
90 72
91static int __init savage_init(void) 73static int __init savage_init(void)
diff --git a/drivers/char/drm/savage_drv.h b/drivers/char/drm/savage_drv.h
index a4b0fa998a95..2f73558fb9cf 100644
--- a/drivers/char/drm/savage_drv.h
+++ b/drivers/char/drm/savage_drv.h
@@ -208,8 +208,10 @@ extern void savage_dma_reset(drm_savage_private_t * dev_priv);
208extern void savage_dma_wait(drm_savage_private_t * dev_priv, unsigned int page); 208extern void savage_dma_wait(drm_savage_private_t * dev_priv, unsigned int page);
209extern uint32_t *savage_dma_alloc(drm_savage_private_t * dev_priv, 209extern uint32_t *savage_dma_alloc(drm_savage_private_t * dev_priv,
210 unsigned int n); 210 unsigned int n);
211extern int savage_preinit(drm_device_t * dev, unsigned long chipset); 211extern int savage_driver_load(drm_device_t *dev, unsigned long chipset);
212extern int savage_postcleanup(drm_device_t * dev); 212extern int savage_driver_firstopen(drm_device_t *dev);
213extern void savage_driver_lastclose(drm_device_t *dev);
214extern int savage_driver_unload(drm_device_t *dev);
213extern int savage_do_cleanup_bci(drm_device_t * dev); 215extern int savage_do_cleanup_bci(drm_device_t * dev);
214extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp); 216extern void savage_reclaim_buffers(drm_device_t * dev, DRMFILE filp);
215 217
diff --git a/drivers/char/drm/sis_drv.c b/drivers/char/drm/sis_drv.c
index 3cef10643a8f..6f6d7d613ede 100644
--- a/drivers/char/drm/sis_drv.c
+++ b/drivers/char/drm/sis_drv.c
@@ -32,31 +32,6 @@
32 32
33#include "drm_pciids.h" 33#include "drm_pciids.h"
34 34
35static int postinit(struct drm_device *dev, unsigned long flags)
36{
37 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
38 DRIVER_NAME,
39 DRIVER_MAJOR,
40 DRIVER_MINOR,
41 DRIVER_PATCHLEVEL,
42 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
43 );
44 return 0;
45}
46
47static int version(drm_version_t * version)
48{
49 int len;
50
51 version->version_major = DRIVER_MAJOR;
52 version->version_minor = DRIVER_MINOR;
53 version->version_patchlevel = DRIVER_PATCHLEVEL;
54 DRM_COPY(version->name, DRIVER_NAME);
55 DRM_COPY(version->date, DRIVER_DATE);
56 DRM_COPY(version->desc, DRIVER_DESC);
57 return 0;
58}
59
60static struct pci_device_id pciidlist[] = { 35static struct pci_device_id pciidlist[] = {
61 sisdrv_PCI_IDS 36 sisdrv_PCI_IDS
62}; 37};
@@ -68,8 +43,6 @@ static struct drm_driver driver = {
68 .reclaim_buffers = drm_core_reclaim_buffers, 43 .reclaim_buffers = drm_core_reclaim_buffers,
69 .get_map_ofs = drm_core_get_map_ofs, 44 .get_map_ofs = drm_core_get_map_ofs,
70 .get_reg_ofs = drm_core_get_reg_ofs, 45 .get_reg_ofs = drm_core_get_reg_ofs,
71 .postinit = postinit,
72 .version = version,
73 .ioctls = sis_ioctls, 46 .ioctls = sis_ioctls,
74 .fops = { 47 .fops = {
75 .owner = THIS_MODULE, 48 .owner = THIS_MODULE,
@@ -79,11 +52,18 @@ static struct drm_driver driver = {
79 .mmap = drm_mmap, 52 .mmap = drm_mmap,
80 .poll = drm_poll, 53 .poll = drm_poll,
81 .fasync = drm_fasync, 54 .fasync = drm_fasync,
82 }, 55 },
83 .pci_driver = { 56 .pci_driver = {
84 .name = DRIVER_NAME, 57 .name = DRIVER_NAME,
85 .id_table = pciidlist, 58 .id_table = pciidlist,
86 } 59 },
60
61 .name = DRIVER_NAME,
62 .desc = DRIVER_DESC,
63 .date = DRIVER_DATE,
64 .major = DRIVER_MAJOR,
65 .minor = DRIVER_MINOR,
66 .patchlevel = DRIVER_PATCHLEVEL,
87}; 67};
88 68
89static int __init sis_init(void) 69static int __init sis_init(void)
diff --git a/drivers/char/drm/tdfx_drv.c b/drivers/char/drm/tdfx_drv.c
index c275cbb6e9ce..baa4416032a8 100644
--- a/drivers/char/drm/tdfx_drv.c
+++ b/drivers/char/drm/tdfx_drv.c
@@ -36,31 +36,6 @@
36 36
37#include "drm_pciids.h" 37#include "drm_pciids.h"
38 38
39static int postinit(struct drm_device *dev, unsigned long flags)
40{
41 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
42 DRIVER_NAME,
43 DRIVER_MAJOR,
44 DRIVER_MINOR,
45 DRIVER_PATCHLEVEL,
46 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
47 );
48 return 0;
49}
50
51static int version(drm_version_t * version)
52{
53 int len;
54
55 version->version_major = DRIVER_MAJOR;
56 version->version_minor = DRIVER_MINOR;
57 version->version_patchlevel = DRIVER_PATCHLEVEL;
58 DRM_COPY(version->name, DRIVER_NAME);
59 DRM_COPY(version->date, DRIVER_DATE);
60 DRM_COPY(version->desc, DRIVER_DESC);
61 return 0;
62}
63
64static struct pci_device_id pciidlist[] = { 39static struct pci_device_id pciidlist[] = {
65 tdfx_PCI_IDS 40 tdfx_PCI_IDS
66}; 41};
@@ -70,8 +45,6 @@ static struct drm_driver driver = {
70 .reclaim_buffers = drm_core_reclaim_buffers, 45 .reclaim_buffers = drm_core_reclaim_buffers,
71 .get_map_ofs = drm_core_get_map_ofs, 46 .get_map_ofs = drm_core_get_map_ofs,
72 .get_reg_ofs = drm_core_get_reg_ofs, 47 .get_reg_ofs = drm_core_get_reg_ofs,
73 .postinit = postinit,
74 .version = version,
75 .fops = { 48 .fops = {
76 .owner = THIS_MODULE, 49 .owner = THIS_MODULE,
77 .open = drm_open, 50 .open = drm_open,
@@ -80,11 +53,18 @@ static struct drm_driver driver = {
80 .mmap = drm_mmap, 53 .mmap = drm_mmap,
81 .poll = drm_poll, 54 .poll = drm_poll,
82 .fasync = drm_fasync, 55 .fasync = drm_fasync,
83 }, 56 },
84 .pci_driver = { 57 .pci_driver = {
85 .name = DRIVER_NAME, 58 .name = DRIVER_NAME,
86 .id_table = pciidlist, 59 .id_table = pciidlist,
87 } 60 },
61
62 .name = DRIVER_NAME,
63 .desc = DRIVER_DESC,
64 .date = DRIVER_DATE,
65 .major = DRIVER_MAJOR,
66 .minor = DRIVER_MINOR,
67 .patchlevel = DRIVER_PATCHLEVEL,
88}; 68};
89 69
90static int __init tdfx_init(void) 70static int __init tdfx_init(void)
diff --git a/drivers/char/drm/via_drv.c b/drivers/char/drm/via_drv.c
index 016665e0c69f..6f3e6b32fa81 100644
--- a/drivers/char/drm/via_drv.c
+++ b/drivers/char/drm/via_drv.c
@@ -29,30 +29,6 @@
29 29
30#include "drm_pciids.h" 30#include "drm_pciids.h"
31 31
32static int postinit(struct drm_device *dev, unsigned long flags)
33{
34 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d: %s\n",
35 DRIVER_NAME,
36 DRIVER_MAJOR,
37 DRIVER_MINOR,
38 DRIVER_PATCHLEVEL,
39 DRIVER_DATE, dev->primary.minor, pci_pretty_name(dev->pdev)
40 );
41 return 0;
42}
43
44static int version(drm_version_t * version)
45{
46 int len;
47
48 version->version_major = DRIVER_MAJOR;
49 version->version_minor = DRIVER_MINOR;
50 version->version_patchlevel = DRIVER_PATCHLEVEL;
51 DRM_COPY(version->name, DRIVER_NAME);
52 DRM_COPY(version->date, DRIVER_DATE);
53 DRM_COPY(version->desc, DRIVER_DESC);
54 return 0;
55}
56 32
57static struct pci_device_id pciidlist[] = { 33static struct pci_device_id pciidlist[] = {
58 viadrv_PCI_IDS 34 viadrv_PCI_IDS
@@ -88,8 +64,6 @@ static struct drm_driver driver = {
88 .reclaim_buffers = drm_core_reclaim_buffers, 64 .reclaim_buffers = drm_core_reclaim_buffers,
89 .get_map_ofs = drm_core_get_map_ofs, 65 .get_map_ofs = drm_core_get_map_ofs,
90 .get_reg_ofs = drm_core_get_reg_ofs, 66 .get_reg_ofs = drm_core_get_reg_ofs,
91 .postinit = postinit,
92 .version = version,
93 .ioctls = ioctls, 67 .ioctls = ioctls,
94 .num_ioctls = DRM_ARRAY_SIZE(ioctls), 68 .num_ioctls = DRM_ARRAY_SIZE(ioctls),
95 .fops = { 69 .fops = {
@@ -100,11 +74,18 @@ static struct drm_driver driver = {
100 .mmap = drm_mmap, 74 .mmap = drm_mmap,
101 .poll = drm_poll, 75 .poll = drm_poll,
102 .fasync = drm_fasync, 76 .fasync = drm_fasync,
103 }, 77 },
104 .pci_driver = { 78 .pci_driver = {
105 .name = DRIVER_NAME, 79 .name = DRIVER_NAME,
106 .id_table = pciidlist, 80 .id_table = pciidlist,
107 } 81 },
82
83 .name = DRIVER_NAME,
84 .desc = DRIVER_DESC,
85 .date = DRIVER_DATE,
86 .major = DRIVER_MAJOR,
87 .minor = DRIVER_MINOR,
88 .patchlevel = DRIVER_PATCHLEVEL,
108}; 89};
109 90
110static int __init via_init(void) 91static int __init via_init(void)