From 805a07714f05833a1ed4e4a01f8086fafd46e849 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 4 Jun 2005 06:18:11 +0000 Subject: [PATCH] misc cleanup patch from Adrian Bunk --- linux-core/ati_pcigart.c | 2 +- linux-core/drmP.h | 20 +------ linux-core/drm_auth.c | 4 +- linux-core/drm_bufs.c | 6 +- linux-core/drm_context.c | 4 +- linux-core/drm_drv.c | 5 +- linux-core/drm_fops.c | 4 +- linux-core/drm_irq.c | 2 +- linux-core/drm_lock.c | 8 ++- linux-core/drm_proc.c | 2 +- linux-core/drm_stub.c | 123 ++++++++++++++++++++------------------- linux-core/drm_vm.c | 11 ++-- 12 files changed, 93 insertions(+), 98 deletions(-) diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c index 3a45c099..f990635a 100644 --- a/linux-core/ati_pcigart.c +++ b/linux-core/ati_pcigart.c @@ -52,7 +52,7 @@ # define ATI_MAX_PCIGART_PAGES 8192 /**< 32 MB aperture, 4K pages */ # define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */ -unsigned long drm_ati_alloc_pcigart_table(void) +static unsigned long drm_ati_alloc_pcigart_table(void) { unsigned long address; struct page *page; diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 720503b6..40579bfa 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -761,8 +761,6 @@ extern int __devinit drm_init(struct drm_driver *driver, struct pci_device_id *pciidlist); extern void __exit drm_exit(struct drm_driver *driver); extern void __exit drm_cleanup_pci(struct pci_dev *pdev); -extern int drm_version(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); extern int drm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int drm_takedown(drm_device_t * dev); @@ -770,17 +768,11 @@ extern int drm_takedown(drm_device_t * dev); /* Device support (drm_fops.h) */ extern int drm_open(struct inode *inode, struct file *filp); extern int drm_stub_open(struct inode *inode, struct file *filp); -extern int drm_open_helper(struct inode *inode, struct file *filp, - drm_device_t * dev); extern int drm_fasync(int fd, struct file *filp, int on); extern int drm_release(struct inode *inode, struct file *filp); unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); /* Mapping support (drm_vm.h) */ -extern void drm_vm_open(struct vm_area_struct *vma); -extern void drm_vm_close(struct vm_area_struct *vma); -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 long drm_core_get_map_ofs(drm_map_t * map); extern unsigned long drm_core_get_reg_ofs(struct drm_device *dev); @@ -837,7 +829,6 @@ extern int drm_newctx(struct inode *inode, struct file *filp, extern int drm_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_context_switch(drm_device_t * dev, int old, int new); extern int drm_context_switch_complete(drm_device_t * dev, int new); extern int drm_ctxbitmap_init(drm_device_t * dev); @@ -856,9 +847,6 @@ extern int drm_rmdraw(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); /* Authentication IOCTL support (drm_auth.h) */ -extern int drm_add_magic(drm_device_t * dev, drm_file_t * priv, - drm_magic_t magic); -extern int drm_remove_magic(drm_device_t * dev, drm_magic_t magic); extern int drm_getmagic(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int drm_authmagic(struct inode *inode, struct file *filp, @@ -870,12 +858,8 @@ extern int drm_lock(struct inode *inode, struct file *filp, extern int drm_unlock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context); -extern int drm_lock_transfer(drm_device_t * dev, - __volatile__ unsigned int *lock, - unsigned int context); extern int drm_lock_free(drm_device_t * dev, __volatile__ unsigned int *lock, unsigned int context); -extern int drm_notifier(void *priv); /* Buffer management support (drm_bufs.h) */ extern int drm_addmap(struct inode *inode, struct file *filp, @@ -916,9 +900,8 @@ extern void drm_core_reclaim_buffers(drm_device_t *dev, struct file *filp); /* IRQ support (drm_irq.h) */ extern int drm_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int drm_irq_install(drm_device_t * dev); -extern int drm_irq_uninstall(drm_device_t * dev); extern irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); +extern int drm_irq_uninstall(drm_device_t *dev); extern void drm_driver_irq_preinstall(drm_device_t * dev); extern void drm_driver_irq_postinstall(drm_device_t * dev); extern void drm_driver_irq_uninstall(drm_device_t * dev); @@ -960,7 +943,6 @@ extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle); extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, struct drm_driver *driver); extern int drm_put_dev(drm_device_t * dev); -extern int drm_get_head(drm_device_t * dev, drm_head_t *head); extern int drm_put_head(drm_head_t * head); extern unsigned int drm_debug; /* 1 to enable debug output */ extern unsigned int cards_limit; diff --git a/linux-core/drm_auth.c b/linux-core/drm_auth.c index 7393e99b..e3293089 100644 --- a/linux-core/drm_auth.c +++ b/linux-core/drm_auth.c @@ -87,7 +87,7 @@ static drm_file_t *drm_find_file(drm_device_t * dev, drm_magic_t magic) * associated the magic number hash key in drm_device::magiclist, while holding * the drm_device::struct_sem lock. */ -int drm_add_magic(drm_device_t * dev, drm_file_t * priv, drm_magic_t magic) +static int drm_add_magic(drm_device_t * dev, drm_file_t * priv, drm_magic_t magic) { int hash; drm_magic_entry_t *entry; @@ -125,7 +125,7 @@ int drm_add_magic(drm_device_t * dev, drm_file_t * priv, drm_magic_t magic) * Searches and unlinks the entry in drm_device::magiclist with the magic * number hash key, while holding the drm_device::struct_sem lock. */ -int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) +static int drm_remove_magic(drm_device_t * dev, drm_magic_t magic) { drm_magic_entry_t *prev = NULL; drm_magic_entry_t *pt; diff --git a/linux-core/drm_bufs.c b/linux-core/drm_bufs.c index a683146f..50182160 100644 --- a/linux-core/drm_bufs.c +++ b/linux-core/drm_bufs.c @@ -444,7 +444,7 @@ static void drm_cleanup_buf_error(drm_device_t * dev, drm_buf_entry_t * entry) * reallocates the buffer list of the same size order to accommodate the new * buffers. */ -int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) +static int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) { drm_device_dma_t *dma = dev->dma; drm_buf_entry_t *entry; @@ -598,7 +598,7 @@ int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request) } #endif /* __OS_HAS_AGP */ -int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) +static int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) { drm_device_dma_t *dma = dev->dma; int count; @@ -815,7 +815,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) } -int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) +static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) { drm_device_dma_t *dma = dev->dma; drm_buf_entry_t *entry; diff --git a/linux-core/drm_context.c b/linux-core/drm_context.c index bab985ac..fd3f0280 100644 --- a/linux-core/drm_context.c +++ b/linux-core/drm_context.c @@ -85,7 +85,7 @@ void drm_ctxbitmap_free(drm_device_t * dev, int ctx_handle) * drm_device::context_sareas to accommodate the new entry while holding the * drm_device::struct_sem lock. */ -int drm_ctxbitmap_next(drm_device_t * dev) +static int drm_ctxbitmap_next(drm_device_t * dev) { int bit; @@ -302,7 +302,7 @@ int drm_setsareactx(struct inode *inode, struct file *filp, * * Attempt to set drm_device::context_flag. */ -int drm_context_switch(drm_device_t * dev, int old, int new) +static int drm_context_switch(drm_device_t * dev, int old, int new) { if (test_and_set_bit(0, &dev->context_flag)) { DRM_ERROR("Reentering -- FIXME\n"); diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 46f51725..ac551e40 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -53,6 +53,9 @@ static void __exit drm_cleanup(drm_device_t * dev); int drm_fb_loaded = 0; +static int drm_version(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + /** Ioctl table */ drm_ioctl_desc_t drm_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = {drm_version, 0, 0}, @@ -552,7 +555,7 @@ module_exit(drm_core_exit); * * Fills in the version information in \p arg. */ -int drm_version(struct inode *inode, struct file *filp, +static int drm_version(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index 27da405c..20cbf343 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -37,6 +37,8 @@ #include "drmP.h" #include +static int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t * dev); + static int drm_setup(drm_device_t * dev) { int i; @@ -218,7 +220,7 @@ static int drm_cpu_valid(void) * Creates and initializes a drm_file structure for the file private data in \p * filp and add it into the double linked list in \p dev. */ -int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t * dev) +static int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t * dev) { int minor = iminor(inode); drm_file_t *priv; diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c index 27c9bc18..37c89762 100644 --- a/linux-core/drm_irq.c +++ b/linux-core/drm_irq.c @@ -86,7 +86,7 @@ int drm_irq_by_busid(struct inode *inode, struct file *filp, * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions * before and after the installation. */ -int drm_irq_install(drm_device_t * dev) +static int drm_irq_install(drm_device_t * dev) { int ret; unsigned long sh_flags = 0; diff --git a/linux-core/drm_lock.c b/linux-core/drm_lock.c index 048f084f..5557f30f 100644 --- a/linux-core/drm_lock.c +++ b/linux-core/drm_lock.c @@ -35,6 +35,10 @@ #include "drmP.h" +static int drm_lock_transfer(drm_device_t * dev, + __volatile__ unsigned int *lock, unsigned int context); +static int drm_notifier(void *priv); + /** * Lock ioctl. * @@ -224,7 +228,7 @@ int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context) * Resets the lock file pointer. * Marks the lock as held by the given context, via the \p cmpxchg instruction. */ -int drm_lock_transfer(drm_device_t * dev, +static int drm_lock_transfer(drm_device_t * dev, __volatile__ unsigned int *lock, unsigned int context) { unsigned int old, new, prev; @@ -280,7 +284,7 @@ int drm_lock_free(drm_device_t * dev, * \return one if the signal should be delivered normally, or zero if the * signal should be blocked. */ -int drm_notifier(void *priv) +static int drm_notifier(void *priv) { drm_sigdata_t *s = (drm_sigdata_t *) priv; unsigned int old, new, prev; diff --git a/linux-core/drm_proc.c b/linux-core/drm_proc.c index b385df5f..94aea2b7 100644 --- a/linux-core/drm_proc.c +++ b/linux-core/drm_proc.c @@ -57,7 +57,7 @@ static int drm_vma_info(char *buf, char **start, off_t offset, /** * Proc file list. */ -struct drm_proc_list { +static struct drm_proc_list { const char *name; /**< file name */ int (*f) (char *, char **, off_t, int, int *, void *); /**< proc callback*/ } drm_proc_list[] = { diff --git a/linux-core/drm_stub.c b/linux-core/drm_stub.c index 687550fa..cb6d6c69 100644 --- a/linux-core/drm_stub.c +++ b/linux-core/drm_stub.c @@ -133,6 +133,68 @@ error_out_unreg: return retcode; } +/** + * Get a secondary minor number. + * + * \param dev device data structure + * \param sec-minor structure to hold the assigned minor + * \return negative number on failure. + * + * Search an empty entry and initialize it to the given parameters, and + * create the proc init entry via proc_init(). This routines assigns + * minor numbers to secondary heads of multi-headed cards + */ +static int drm_get_head(drm_device_t * dev, drm_head_t * head) +{ + drm_head_t **heads = drm_heads; + int ret; + int minor; + + DRM_DEBUG("\n"); + + for (minor = 0; minor < cards_limit; minor++, heads++) { + if (!*heads) { + + *head = (drm_head_t) { + .dev = dev, + .device = MKDEV(DRM_MAJOR, minor), + .minor = minor, + }; + if ((ret = + drm_proc_init(dev, minor, drm_proc_root, + &head->dev_root))) { + printk(KERN_ERR + "DRM: Failed to initialize /proc/dri.\n"); + goto err_g1; + } + + head->dev_class = drm_sysfs_device_add(drm_class, + MKDEV(DRM_MAJOR, + minor), + DRM_PCI_DEV(dev->pdev), + "card%d", minor); + if (IS_ERR(head->dev_class)) { + printk(KERN_ERR + "DRM: Error sysfs_device_add.\n"); + ret = PTR_ERR(head->dev_class); + goto err_g2; + } + *heads = head; + + DRM_DEBUG("new minor assigned %d\n", minor); + return 0; + } + } + DRM_ERROR("out of minors\n"); + return -ENOMEM; +err_g2: + drm_proc_cleanup(minor, drm_proc_root, head->dev_root); +err_g1: + *head = (drm_head_t) { + .dev = NULL}; + return ret; +} + /** * Register. * @@ -186,67 +248,6 @@ err_g1: } EXPORT_SYMBOL(drm_get_dev); -/** - * Get a secondary minor number. - * - * \param dev device data structure - * \param sec-minor structure to hold the assigned minor - * \return negative number on failure. - * - * Search an empty entry and initialize it to the given parameters, and - * create the proc init entry via proc_init(). This routines assigns - * minor numbers to secondary heads of multi-headed cards - */ -int drm_get_head(drm_device_t * dev, drm_head_t * head) -{ - drm_head_t **heads = drm_heads; - int ret; - int minor; - - DRM_DEBUG("\n"); - - for (minor = 0; minor < cards_limit; minor++, heads++) { - if (!*heads) { - - *head = (drm_head_t) { - .dev = dev, - .device = MKDEV(DRM_MAJOR, minor), - .minor = minor, - }; - if ((ret = - drm_proc_init(dev, minor, drm_proc_root, - &head->dev_root))) { - printk(KERN_ERR - "DRM: Failed to initialize /proc/dri.\n"); - goto err_g1; - } - - head->dev_class = drm_sysfs_device_add(drm_class, - MKDEV(DRM_MAJOR, - minor), - DRM_PCI_DEV(dev->pdev), - "card%d", minor); - if (IS_ERR(head->dev_class)) { - printk(KERN_ERR - "DRM: Error sysfs_device_add.\n"); - ret = PTR_ERR(head->dev_class); - goto err_g2; - } - *heads = head; - - DRM_DEBUG("new minor assigned %d\n", minor); - return 0; - } - } - DRM_ERROR("out of minors\n"); - return -ENOMEM; -err_g2: - drm_proc_cleanup(minor, drm_proc_root, head->dev_root); -err_g1: - *head = (drm_head_t) { - .dev = NULL}; - return ret; -} /** * Put a device minor number. diff --git a/linux-core/drm_vm.c b/linux-core/drm_vm.c index 67910e6d..227dc663 100644 --- a/linux-core/drm_vm.c +++ b/linux-core/drm_vm.c @@ -38,6 +38,9 @@ #include #endif +static void drm_vm_close(struct vm_area_struct *vma); +static void drm_vm_open(struct vm_area_struct *vma); + /** * \c nopage method for AGP virtual memory. * @@ -172,7 +175,7 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma, * Deletes map information if we are the last * person to close a mapping and it's not in the global maplist. */ -void drm_vm_shm_close(struct vm_area_struct *vma) +static void drm_vm_shm_close(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->head->dev; @@ -422,7 +425,7 @@ static struct vm_operations_struct drm_vm_sg_ops = { * Create a new drm_vma_entry structure as the \p vma private data entry and * add it to drm_device::vmalist. */ -void drm_vm_open(struct vm_area_struct *vma) +static void drm_vm_open(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->head->dev; @@ -451,7 +454,7 @@ void drm_vm_open(struct vm_area_struct *vma) * Search the \p vma private data entry in drm_device::vmalist, unlink it, and * free it. */ -void drm_vm_close(struct vm_area_struct *vma) +static void drm_vm_close(struct vm_area_struct *vma) { drm_file_t *priv = vma->vm_file->private_data; drm_device_t *dev = priv->head->dev; @@ -486,7 +489,7 @@ void drm_vm_close(struct vm_area_struct *vma) * Sets the virtual memory area operations structure to vm_dma_ops, the file * pointer, and calls vm_open(). */ -int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) +static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) { drm_file_t *priv = filp->private_data; drm_device_t *dev;