Make fops per driver instead of global, remove default flush, poll, read

functions
main
Jon Smirl 2004-09-30 18:13:33 +00:00
parent 0bff0d9eb6
commit 3aef3841d0
19 changed files with 109 additions and 78 deletions

View File

@ -523,11 +523,6 @@ typedef struct drm_vbl_sig {
struct drm_device; struct drm_device;
struct drm_driver_fn { 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); int (*preinit)(struct drm_device *, unsigned long flags);
void (*prerelease)(struct drm_device *, struct file *filp); void (*prerelease)(struct drm_device *, struct file *filp);
void (*pretakedown)(struct drm_device *); void (*pretakedown)(struct drm_device *);
@ -558,6 +553,13 @@ struct drm_driver_fn {
unsigned long (*get_reg_ofs)(struct drm_device *dev); unsigned long (*get_reg_ofs)(struct drm_device *dev);
void (*set_version)(struct drm_device *dev, drm_set_version_t *sv); void (*set_version)(struct drm_device *dev, drm_set_version_t *sv);
int (*version)(drm_version_t *version); 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 */ drm_sigdata_t sigdata; /**< For block_all_signals */
sigset_t sigmask; sigset_t sigmask;
struct file_operations *fops; /**< file operations */
struct drm_driver_fn *fn_tbl; struct drm_driver_fn *fn_tbl;
drm_local_map_t *agp_buffer_map; drm_local_map_t *agp_buffer_map;
} drm_device_t; } drm_device_t;
@ -757,13 +757,11 @@ extern int drm_unlock(struct inode *inode, struct file *filp,
extern int drm_fill_in_dev(drm_device_t *dev, struct pci_dev *pdev, 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); const struct pci_device_id *ent, struct drm_driver_fn *driver_fn);
extern int drm_fb_loaded; extern int drm_fb_loaded;
extern struct file_operations drm_fops;
/* Device support (drm_fops.h) */ /* Device support (drm_fops.h) */
extern int drm_open_helper(struct inode *inode, struct file *filp, extern int drm_open_helper(struct inode *inode, struct file *filp,
drm_device_t *dev); drm_device_t *dev);
extern int drm_flush(struct file *filp); extern int drm_fasync(int fd, struct file *filp, int on);
extern int drm_fasync(int fd, struct file *filp, int on);
/* Mapping support (drm_vm.h) */ /* Mapping support (drm_vm.h) */
extern void drm_vm_open(struct vm_area_struct *vma); extern void drm_vm_open(struct vm_area_struct *vma);
@ -772,8 +770,6 @@ extern void drm_vm_shm_close(struct vm_area_struct *vma);
extern int drm_mmap_dma(struct file *filp, extern int drm_mmap_dma(struct file *filp,
struct vm_area_struct *vma); struct vm_area_struct *vma);
extern int drm_mmap(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) */ /* Memory management support (drm_memory.h) */
#include "drm_memory.h" #include "drm_memory.h"

View File

@ -76,18 +76,6 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
int drm_fb_loaded = 0; 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 */ /** Ioctl table */
drm_ioctl_desc_t drm_ioctls[] = { drm_ioctl_desc_t drm_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { drm_version, 0, 0 }, [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 ); sema_init( &dev->ctxlist_sem, 1 );
dev->name = DRIVER_NAME; dev->name = DRIVER_NAME;
dev->fops = &drm_fops;
dev->pdev = pdev; dev->pdev = pdev;
#ifdef __alpha__ #ifdef __alpha__
@ -630,7 +617,7 @@ void __exit drm_exit (struct pci_driver *driver)
minor = &drm_minors[i]; minor = &drm_minors[i];
dev = minor->dev; dev = minor->dev;
DRM_DEBUG("fb loaded release minor %d\n", dev->minor); 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 */ /* release the pci driver */
if (dev->pdev) if (dev->pdev)
pci_dev_put(dev->pdev); pci_dev_put(dev->pdev);

View File

@ -115,18 +115,6 @@ out_free:
return ret; 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. */ /** No-op. */
int drm_fasync(int fd, struct file *filp, int on) 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; return 0;
} }
EXPORT_SYMBOL(drm_fasync); 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;
}

View File

@ -77,7 +77,7 @@ static int stub_open(struct inode *inode, struct file *filp)
return -ENODEV; return -ENODEV;
old_fops = filp->f_op; 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))) { if (filp->f_op->open && (err = filp->f_op->open(inode, filp))) {
fops_put(filp->f_op); fops_put(filp->f_op);
filp->f_op = fops_get(old_fops); filp->f_op = fops_get(old_fops);

View File

@ -670,3 +670,4 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
drm_vm_open(vma); drm_vm_open(vma);
return 0; return 0;
} }
EXPORT_SYMBOL(drm_mmap);

View File

@ -321,6 +321,14 @@ static struct drm_driver_fn ffb_driver_fn = {
.reclaim_buffers = drm_core_reclaim_buffers, .reclaim_buffers = drm_core_reclaim_buffers,
.postinit = postinit, .postinit = postinit,
.version = version, .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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -109,15 +109,6 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf)
return 0; 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) int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{ {
drm_file_t *priv = filp->private_data; 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_device_t *dev = priv->dev;
drm_i810_buf_priv_t *buf_priv = buf->dev_private; drm_i810_buf_priv_t *buf_priv = buf->dev_private;
drm_i810_private_t *dev_priv = dev->dev_private; drm_i810_private_t *dev_priv = dev->dev_private;
struct file_operations *old_fops;
int retcode = 0; int retcode = 0;
if (buf_priv->currently_mapped == I810_BUF_MAPPED) if (buf_priv->currently_mapped == I810_BUF_MAPPED)
return -EINVAL; return -EINVAL;
down_write( &current->mm->mmap_sem ); down_write( &current->mm->mmap_sem );
old_fops = filp->f_op;
filp->f_op = &i810_buffer_fops;
dev_priv->mmap_buffer = buf; dev_priv->mmap_buffer = buf;
buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
PROT_READ|PROT_WRITE, PROT_READ|PROT_WRITE,
MAP_SHARED, MAP_SHARED,
buf->bus_address); buf->bus_address);
dev_priv->mmap_buffer = NULL; dev_priv->mmap_buffer = NULL;
filp->f_op = old_fops;
if ((unsigned long)buf_priv->virtual > -1024UL) { if ((unsigned long)buf_priv->virtual > -1024UL) {
/* Real error */ /* Real error */
DRM_ERROR("mmap error\n"); DRM_ERROR("mmap error\n");

View File

@ -107,6 +107,14 @@ static struct drm_driver_fn driver_fn = {
.version = version, .version = version,
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -110,15 +110,6 @@ static int i830_freelist_put(drm_device_t *dev, drm_buf_t *buf)
return 0; 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) int i830_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{ {
drm_file_t *priv = filp->private_data; 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_device_t *dev = priv->dev;
drm_i830_buf_priv_t *buf_priv = buf->dev_private; drm_i830_buf_priv_t *buf_priv = buf->dev_private;
drm_i830_private_t *dev_priv = dev->dev_private; drm_i830_private_t *dev_priv = dev->dev_private;
struct file_operations *old_fops;
unsigned long virtual; unsigned long virtual;
int retcode = 0; int retcode = 0;
if(buf_priv->currently_mapped == I830_BUF_MAPPED) return -EINVAL; if(buf_priv->currently_mapped == I830_BUF_MAPPED) return -EINVAL;
down_write( &current->mm->mmap_sem ); down_write( &current->mm->mmap_sem );
old_fops = filp->f_op;
filp->f_op = &i830_buffer_fops;
dev_priv->mmap_buffer = buf; dev_priv->mmap_buffer = buf;
virtual = do_mmap(filp, 0, buf->total, PROT_READ|PROT_WRITE, virtual = do_mmap(filp, 0, buf->total, PROT_READ|PROT_WRITE,
MAP_SHARED, buf->bus_address); MAP_SHARED, buf->bus_address);
dev_priv->mmap_buffer = NULL; dev_priv->mmap_buffer = NULL;
filp->f_op = old_fops;
if (IS_ERR((void *)virtual)) { /* ugh */ if (IS_ERR((void *)virtual)) { /* ugh */
/* Real error */ /* Real error */
DRM_ERROR("mmap error\n"); DRM_ERROR("mmap error\n");

View File

@ -116,6 +116,14 @@ static struct drm_driver_fn driver_fn = {
.version = version, .version = version,
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -83,6 +83,14 @@ static struct drm_driver_fn driver_fn = {
.version = version, .version = version,
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -99,6 +99,14 @@ static struct drm_driver_fn driver_fn = {
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls), .num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = mach64_dma_buffers, .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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -103,6 +103,14 @@ static struct drm_driver_fn driver_fn = {
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls), .num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = mga_dma_buffers, .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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -113,6 +113,14 @@ static struct drm_driver_fn driver_fn = {
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls), .num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = r128_cce_buffers, .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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -154,6 +154,14 @@ static struct drm_driver_fn driver_fn = {
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(ioctls), .num_ioctls = DRM_ARRAY_SIZE(ioctls),
.dma_ioctl = radeon_cp_buffers, .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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -292,6 +292,14 @@ static struct drm_driver_fn driver_fn = {
.version = version, .version = version,
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -83,6 +83,14 @@ static struct drm_driver_fn driver_fn = {
.version = version, .version = version,
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -74,6 +74,14 @@ static struct drm_driver_fn driver_fn = {
.get_reg_ofs = drm_core_get_reg_ofs, .get_reg_ofs = drm_core_get_reg_ofs,
.postinit = postinit, .postinit = postinit,
.version = version, .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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)

View File

@ -99,6 +99,14 @@ static struct drm_driver_fn driver_fn = {
.version = version, .version = version,
.ioctls = ioctls, .ioctls = ioctls,
.num_ioctls = DRM_ARRAY_SIZE(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) static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)