aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_fops.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-04-21 02:47:32 -0400
committerDave Airlie <airlied@linux.ie>2008-04-26 03:55:07 -0400
commit2c14f28be2a3f2a2e9861b156d64fbe2bc7000c3 (patch)
treedbf55c07d1b245a45330e0d879833df29954fe12 /drivers/char/drm/drm_fops.c
parent7b832b56bd971348329c3f4c753ca0abfdf3a3d1 (diff)
drm: reorganise minor number handling using backported modesetting code.
rips out the head crap and replaces it with an idr and drm_minor structure Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/char/drm/drm_fops.c')
-rw-r--r--drivers/char/drm/drm_fops.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index f09d4b5002b0..df7bf48be692 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -129,16 +129,15 @@ static int drm_setup(struct drm_device * dev)
129int drm_open(struct inode *inode, struct file *filp) 129int drm_open(struct inode *inode, struct file *filp)
130{ 130{
131 struct drm_device *dev = NULL; 131 struct drm_device *dev = NULL;
132 int minor = iminor(inode); 132 int minor_id = iminor(inode);
133 struct drm_minor *minor;
133 int retcode = 0; 134 int retcode = 0;
134 135
135 if (!((minor >= 0) && (minor < drm_cards_limit))) 136 minor = idr_find(&drm_minors_idr, minor_id);
137 if (!minor)
136 return -ENODEV; 138 return -ENODEV;
137 139
138 if (!drm_heads[minor]) 140 if (!(dev = minor->dev))
139 return -ENODEV;
140
141 if (!(dev = drm_heads[minor]->dev))
142 return -ENODEV; 141 return -ENODEV;
143 142
144 retcode = drm_open_helper(inode, filp, dev); 143 retcode = drm_open_helper(inode, filp, dev);
@@ -168,19 +167,18 @@ EXPORT_SYMBOL(drm_open);
168int drm_stub_open(struct inode *inode, struct file *filp) 167int drm_stub_open(struct inode *inode, struct file *filp)
169{ 168{
170 struct drm_device *dev = NULL; 169 struct drm_device *dev = NULL;
171 int minor = iminor(inode); 170 struct drm_minor *minor;
171 int minor_id = iminor(inode);
172 int err = -ENODEV; 172 int err = -ENODEV;
173 const struct file_operations *old_fops; 173 const struct file_operations *old_fops;
174 174
175 DRM_DEBUG("\n"); 175 DRM_DEBUG("\n");
176 176
177 if (!((minor >= 0) && (minor < drm_cards_limit))) 177 minor = idr_find(&drm_minors_idr, minor_id);
178 return -ENODEV; 178 if (!minor)
179
180 if (!drm_heads[minor])
181 return -ENODEV; 179 return -ENODEV;
182 180
183 if (!(dev = drm_heads[minor]->dev)) 181 if (!(dev = minor->dev))
184 return -ENODEV; 182 return -ENODEV;
185 183
186 old_fops = filp->f_op; 184 old_fops = filp->f_op;
@@ -225,7 +223,7 @@ static int drm_cpu_valid(void)
225static int drm_open_helper(struct inode *inode, struct file *filp, 223static int drm_open_helper(struct inode *inode, struct file *filp,
226 struct drm_device * dev) 224 struct drm_device * dev)
227{ 225{
228 int minor = iminor(inode); 226 int minor_id = iminor(inode);
229 struct drm_file *priv; 227 struct drm_file *priv;
230 int ret; 228 int ret;
231 229
@@ -234,7 +232,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
234 if (!drm_cpu_valid()) 232 if (!drm_cpu_valid())
235 return -EINVAL; 233 return -EINVAL;
236 234
237 DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor); 235 DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id);
238 236
239 priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES); 237 priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
240 if (!priv) 238 if (!priv)
@@ -245,8 +243,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
245 priv->filp = filp; 243 priv->filp = filp;
246 priv->uid = current->euid; 244 priv->uid = current->euid;
247 priv->pid = task_pid_nr(current); 245 priv->pid = task_pid_nr(current);
248 priv->minor = minor; 246 priv->minor = idr_find(&drm_minors_idr, minor_id);
249 priv->head = drm_heads[minor];
250 priv->ioctl_count = 0; 247 priv->ioctl_count = 0;
251 /* for compatibility root is always authenticated */ 248 /* for compatibility root is always authenticated */
252 priv->authenticated = capable(CAP_SYS_ADMIN); 249 priv->authenticated = capable(CAP_SYS_ADMIN);
@@ -297,11 +294,11 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
297int drm_fasync(int fd, struct file *filp, int on) 294int drm_fasync(int fd, struct file *filp, int on)
298{ 295{
299 struct drm_file *priv = filp->private_data; 296 struct drm_file *priv = filp->private_data;
300 struct drm_device *dev = priv->head->dev; 297 struct drm_device *dev = priv->minor->dev;
301 int retcode; 298 int retcode;
302 299
303 DRM_DEBUG("fd = %d, device = 0x%lx\n", fd, 300 DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
304 (long)old_encode_dev(priv->head->device)); 301 (long)old_encode_dev(priv->minor->device));
305 retcode = fasync_helper(fd, filp, on, &dev->buf_async); 302 retcode = fasync_helper(fd, filp, on, &dev->buf_async);
306 if (retcode < 0) 303 if (retcode < 0)
307 return retcode; 304 return retcode;
@@ -324,7 +321,7 @@ EXPORT_SYMBOL(drm_fasync);
324int drm_release(struct inode *inode, struct file *filp) 321int drm_release(struct inode *inode, struct file *filp)
325{ 322{
326 struct drm_file *file_priv = filp->private_data; 323 struct drm_file *file_priv = filp->private_data;
327 struct drm_device *dev = file_priv->head->dev; 324 struct drm_device *dev = file_priv->minor->dev;
328 int retcode = 0; 325 int retcode = 0;
329 unsigned long irqflags; 326 unsigned long irqflags;
330 327
@@ -341,7 +338,7 @@ int drm_release(struct inode *inode, struct file *filp)
341 338
342 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n", 339 DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
343 task_pid_nr(current), 340 task_pid_nr(current),
344 (long)old_encode_dev(file_priv->head->device), 341 (long)old_encode_dev(file_priv->minor->device),
345 dev->open_count); 342 dev->open_count);
346 343
347 if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) { 344 if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {