aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_stub.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/drm_stub.c')
-rw-r--r--drivers/char/drm/drm_stub.c63
1 files changed, 10 insertions, 53 deletions
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c
index 60b6f8e8bf69..42d766359caa 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,47 +124,10 @@ 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
131/**
132 * File \c open operation.
133 *
134 * \param inode device inode.
135 * \param filp file pointer.
136 *
137 * Puts the dev->fops corresponding to the device minor number into
138 * \p filp, call the \c open method, and restore the file operations.
139 */
140int drm_stub_open(struct inode *inode, struct file *filp)
141{
142 drm_device_t *dev = NULL;
143 int minor = iminor(inode);
144 int err = -ENODEV;
145 struct file_operations *old_fops;
146
147 DRM_DEBUG("\n");
148
149 if (!((minor >= 0) && (minor < drm_cards_limit)))
150 return -ENODEV;
151
152 if (!drm_heads[minor])
153 return -ENODEV;
154
155 if (!(dev = drm_heads[minor]->dev))
156 return -ENODEV;
157
158 old_fops = filp->f_op;
159 filp->f_op = fops_get(&dev->driver->fops);
160 if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) {
161 fops_put(filp->f_op);
162 filp->f_op = fops_get(old_fops);
163 }
164 fops_put(old_fops);
165
166 return err;
167}
168 131
169/** 132/**
170 * Get a secondary minor number. 133 * Get a secondary minor number.
@@ -200,11 +163,7 @@ static int drm_get_head(drm_device_t * dev, drm_head_t * head)
200 goto err_g1; 163 goto err_g1;
201 } 164 }
202 165
203 head->dev_class = drm_sysfs_device_add(drm_class, 166 head->dev_class = drm_sysfs_device_add(drm_class, head);
204 MKDEV(DRM_MAJOR,
205 minor),
206 &dev->pdev->dev,
207 "card%d", minor);
208 if (IS_ERR(head->dev_class)) { 167 if (IS_ERR(head->dev_class)) {
209 printk(KERN_ERR 168 printk(KERN_ERR
210 "DRM: Error sysfs_device_add.\n"); 169 "DRM: Error sysfs_device_add.\n");
@@ -258,11 +217,10 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
258 } 217 }
259 if ((ret = drm_get_head(dev, &dev->primary))) 218 if ((ret = drm_get_head(dev, &dev->primary)))
260 goto err_g1; 219 goto err_g1;
261 220
262 /* postinit is a required function to display the signon banner */ 221 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
263 /* drivers add secondary heads here if needed */ 222 driver->name, driver->major, driver->minor, driver->patchlevel,
264 if ((ret = dev->driver->postinit(dev, ent->driver_data))) 223 driver->date, dev->primary.minor);
265 goto err_g1;
266 224
267 return 0; 225 return 0;
268 226
@@ -318,10 +276,9 @@ int drm_put_head(drm_head_t * head)
318 DRM_DEBUG("release secondary minor %d\n", minor); 276 DRM_DEBUG("release secondary minor %d\n", minor);
319 277
320 drm_proc_cleanup(minor, drm_proc_root, head->dev_root); 278 drm_proc_cleanup(minor, drm_proc_root, head->dev_root);
321 drm_sysfs_device_remove(MKDEV(DRM_MAJOR, head->minor)); 279 drm_sysfs_device_remove(head->dev_class);
322 280
323 *head = (drm_head_t) { 281 *head = (drm_head_t) {.dev = NULL};
324 .dev = NULL};
325 282
326 drm_heads[minor] = NULL; 283 drm_heads[minor] = NULL;
327 284