Make fops per driver instead of global, remove default flush, poll, read
functionsmain
parent
0bff0d9eb6
commit
3aef3841d0
|
@ -523,11 +523,6 @@ typedef struct drm_vbl_sig {
|
|||
struct drm_device;
|
||||
|
||||
struct drm_driver_fn {
|
||||
u32 driver_features;
|
||||
int dev_priv_size;
|
||||
int permanent_maps;
|
||||
drm_ioctl_desc_t *ioctls;
|
||||
int num_ioctls;
|
||||
int (*preinit)(struct drm_device *, unsigned long flags);
|
||||
void (*prerelease)(struct drm_device *, struct file *filp);
|
||||
void (*pretakedown)(struct drm_device *);
|
||||
|
@ -558,6 +553,13 @@ struct drm_driver_fn {
|
|||
unsigned long (*get_reg_ofs)(struct drm_device *dev);
|
||||
void (*set_version)(struct drm_device *dev, drm_set_version_t *sv);
|
||||
int (*version)(drm_version_t *version);
|
||||
/* variables */
|
||||
u32 driver_features;
|
||||
int dev_priv_size;
|
||||
int permanent_maps;
|
||||
drm_ioctl_desc_t *ioctls;
|
||||
int num_ioctls;
|
||||
struct file_operations fops;
|
||||
};
|
||||
|
||||
|
||||
|
@ -691,8 +693,6 @@ typedef struct drm_device {
|
|||
drm_sigdata_t sigdata; /**< For block_all_signals */
|
||||
sigset_t sigmask;
|
||||
|
||||
struct file_operations *fops; /**< file operations */
|
||||
|
||||
struct drm_driver_fn *fn_tbl;
|
||||
drm_local_map_t *agp_buffer_map;
|
||||
} drm_device_t;
|
||||
|
@ -757,12 +757,10 @@ extern int drm_unlock(struct inode *inode, struct file *filp,
|
|||
extern int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev,
|
||||
const struct pci_device_id *ent, struct drm_driver_fn *driver_fn);
|
||||
extern int drm_fb_loaded;
|
||||
extern struct file_operations drm_fops;
|
||||
|
||||
/* Device support (drm_fops.h) */
|
||||
extern int drm_open_helper(struct inode *inode, struct file *filp,
|
||||
drm_device_t *dev);
|
||||
extern int drm_flush(struct file *filp);
|
||||
extern int drm_fasync(int fd, struct file *filp, int on);
|
||||
|
||||
/* Mapping support (drm_vm.h) */
|
||||
|
@ -772,8 +770,6 @@ extern void drm_vm_shm_close(struct vm_area_struct *vma);
|
|||
extern int drm_mmap_dma(struct file *filp,
|
||||
struct vm_area_struct *vma);
|
||||
extern int drm_mmap(struct file *filp, struct vm_area_struct *vma);
|
||||
extern unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
|
||||
extern ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off);
|
||||
|
||||
/* Memory management support (drm_memory.h) */
|
||||
#include "drm_memory.h"
|
||||
|
|
|
@ -76,18 +76,6 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
|
|||
|
||||
int drm_fb_loaded = 0;
|
||||
|
||||
struct file_operations drm_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.flush = drm_flush,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
.poll = drm_poll,
|
||||
.read = drm_read,
|
||||
};
|
||||
|
||||
/** Ioctl table */
|
||||
drm_ioctl_desc_t drm_ioctls[] = {
|
||||
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 },
|
||||
|
@ -384,7 +372,6 @@ int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, const struct pci_de
|
|||
sema_init( &dev->ctxlist_sem, 1 );
|
||||
|
||||
dev->name = DRIVER_NAME;
|
||||
dev->fops = &drm_fops;
|
||||
dev->pdev = pdev;
|
||||
|
||||
#ifdef __alpha__
|
||||
|
@ -630,7 +617,7 @@ void __exit drm_exit (struct pci_driver *driver)
|
|||
minor = &drm_minors[i];
|
||||
dev = minor->dev;
|
||||
DRM_DEBUG("fb loaded release minor %d\n", dev->minor);
|
||||
if ((minor->class == DRM_MINOR_PRIMARY) && (dev->fops == &drm_fops)) {
|
||||
if (minor->class == DRM_MINOR_PRIMARY) {
|
||||
/* release the pci driver */
|
||||
if (dev->pdev)
|
||||
pci_dev_put(dev->pdev);
|
||||
|
|
|
@ -115,18 +115,6 @@ out_free:
|
|||
return ret;
|
||||
}
|
||||
|
||||
/** No-op. */
|
||||
int drm_flush(struct file *filp)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
drm_device_t *dev = priv->dev;
|
||||
|
||||
DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
|
||||
current->pid, (long)old_encode_dev(dev->device), dev->open_count);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_flush);
|
||||
|
||||
/** No-op. */
|
||||
int drm_fasync(int fd, struct file *filp, int on)
|
||||
{
|
||||
|
@ -140,16 +128,3 @@ int drm_fasync(int fd, struct file *filp, int on)
|
|||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_fasync);
|
||||
|
||||
/** No-op. */
|
||||
unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** No-op. */
|
||||
ssize_t drm_read(struct file *filp, char __user *buf, size_t count, loff_t *off)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ static int stub_open(struct inode *inode, struct file *filp)
|
|||
return -ENODEV;
|
||||
|
||||
old_fops = filp->f_op;
|
||||
filp->f_op = fops_get(dev->fops);
|
||||
filp->f_op = fops_get(&dev->fn_tbl->fops);
|
||||
if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) {
|
||||
fops_put(filp->f_op);
|
||||
filp->f_op = fops_get(old_fops);
|
||||
|
|
|
@ -670,3 +670,4 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
|
|||
drm_vm_open(vma);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_mmap);
|
||||
|
|
|
@ -321,6 +321,14 @@ static struct drm_driver_fn ffb_driver_fn = {
|
|||
.reclaim_buffers = drm_core_reclaim_buffers,
|
||||
.postinit = postinit,
|
||||
.version = version,
|
||||
fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -109,15 +109,6 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct file_operations i810_buffer_fops = {
|
||||
.open = drm_open,
|
||||
.flush = drm_flush,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = i810_mmap_buffers,
|
||||
.fasync = drm_fasync,
|
||||
};
|
||||
|
||||
int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
|
@ -151,22 +142,19 @@ static int i810_map_buffer(drm_buf_t *buf, struct file *filp)
|
|||
drm_device_t *dev = priv->dev;
|
||||
drm_i810_buf_priv_t *buf_priv = buf->dev_private;
|
||||
drm_i810_private_t *dev_priv = dev->dev_private;
|
||||
struct file_operations *old_fops;
|
||||
int retcode = 0;
|
||||
|
||||
if (buf_priv->currently_mapped == I810_BUF_MAPPED)
|
||||
return -EINVAL;
|
||||
|
||||
down_write( ¤t->mm->mmap_sem );
|
||||
old_fops = filp->f_op;
|
||||
filp->f_op = &i810_buffer_fops;
|
||||
dev_priv->mmap_buffer = buf;
|
||||
buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
|
||||
PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED,
|
||||
buf->bus_address);
|
||||
dev_priv->mmap_buffer = NULL;
|
||||
filp->f_op = old_fops;
|
||||
|
||||
if ((unsigned long)buf_priv->virtual > -1024UL) {
|
||||
/* Real error */
|
||||
DRM_ERROR("mmap error\n");
|
||||
|
|
|
@ -107,6 +107,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.version = version,
|
||||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = i810_mmap_buffers,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -110,15 +110,6 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct file_operations i830_buffer_fops = {
|
||||
.open = drm_open,
|
||||
.flush = drm_flush,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = i830_mmap_buffers,
|
||||
.fasync = drm_fasync,
|
||||
};
|
||||
|
||||
int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
|
||||
{
|
||||
drm_file_t *priv = filp->private_data;
|
||||
|
@ -152,20 +143,17 @@ static int i830_map_buffer(drm_buf_t *buf, struct file *filp)
|
|||
drm_device_t *dev = priv->dev;
|
||||
drm_i830_buf_priv_t *buf_priv = buf->dev_private;
|
||||
drm_i830_private_t *dev_priv = dev->dev_private;
|
||||
struct file_operations *old_fops;
|
||||
unsigned long virtual;
|
||||
int retcode = 0;
|
||||
|
||||
if(buf_priv->currently_mapped == I830_BUF_MAPPED) return -EINVAL;
|
||||
|
||||
down_write( ¤t->mm->mmap_sem );
|
||||
old_fops = filp->f_op;
|
||||
filp->f_op = &i830_buffer_fops;
|
||||
dev_priv->mmap_buffer = buf;
|
||||
virtual = do_mmap(filp, 0, buf->total, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED, buf->bus_address);
|
||||
dev_priv->mmap_buffer = NULL;
|
||||
filp->f_op = old_fops;
|
||||
|
||||
if (IS_ERR((void *)virtual)) { /* ugh */
|
||||
/* Real error */
|
||||
DRM_ERROR("mmap error\n");
|
||||
|
|
|
@ -116,6 +116,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.version = version,
|
||||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = i830_mmap_buffers,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -83,6 +83,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.version = version,
|
||||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -99,6 +99,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.dma_ioctl = mach64_dma_buffers,
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -103,6 +103,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.dma_ioctl = mga_dma_buffers,
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -113,6 +113,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.dma_ioctl = r128_cce_buffers,
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -154,6 +154,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.dma_ioctl = radeon_cp_buffers,
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -292,6 +292,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.version = version,
|
||||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -83,6 +83,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.version = version,
|
||||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -74,6 +74,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.get_reg_ofs = drm_core_get_reg_ofs,
|
||||
.postinit = postinit,
|
||||
.version = version,
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
|
@ -99,6 +99,14 @@ static struct drm_driver_fn driver_fn = {
|
|||
.version = version,
|
||||
.ioctls = ioctls,
|
||||
.num_ioctls = DRM_ARRAY_SIZE(ioctls),
|
||||
.fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = drm_open,
|
||||
.release = drm_release,
|
||||
.ioctl = drm_ioctl,
|
||||
.mmap = drm_mmap,
|
||||
.fasync = drm_fasync,
|
||||
},
|
||||
};
|
||||
|
||||
static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
|
Loading…
Reference in New Issue