Remove 2.6 code that allow DRM major device number to be shared. We can add

it back later if needed. Checked DRM on both 2.4 and
2.6 to ensure that it builds and runs.
main
Jon Smirl 2004-09-23 17:22:27 +00:00
parent 55c5e24089
commit 36a257cfe9
6 changed files with 20 additions and 100 deletions

View File

@ -56,9 +56,6 @@
#include <linux/smp_lock.h> /* For (un)lock_kernel */ #include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#include <linux/cdev.h>
#endif
#if defined(__alpha__) || defined(__powerpc__) #if defined(__alpha__) || defined(__powerpc__)
#include <asm/pgtable.h> /* For pte_wrprotect */ #include <asm/pgtable.h> /* For pte_wrprotect */
#endif #endif
@ -697,7 +694,6 @@ typedef struct drm_global {
drm_minor_t *minors; drm_minor_t *minors;
struct drm_sysfs_class *drm_class; struct drm_sysfs_class *drm_class;
struct proc_dir_entry *proc_root; struct proc_dir_entry *proc_root;
struct cdev drm_cdev;
} drm_global_t; } drm_global_t;
static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature) static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature)

View File

@ -142,32 +142,9 @@ static inline struct drm_sysfs_class *DRM(sysfs_create)(struct module *owner, ch
#define pci_pretty_name(x) x->name #define pci_pretty_name(x) x->name
#endif #endif
/* not used in 2.4, just makes the code compile */ struct drm_device;
#define KOBJ_NAME_LEN 20 static inline int radeon_create_i2c_busses(struct drm_device *dev){return 0;};
struct kobject { static inline void radeon_delete_i2c_busses(struct drm_device *dev){};
char name[KOBJ_NAME_LEN];
};
struct cdev {
struct kobject kobj;
struct module *owner;
struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};
static inline void cdev_del(struct cdev *cd){}
static inline void cdev_init(struct cdev *cd, struct file_operations *fop){}
static inline int cdev_add(struct cdev *cd, dev_t dt, unsigned u){ return 0;}
static inline int register_chrdev_region(dev_t device, unsigned minor, char *name) {
return register_chrdev(device, name, NULL);
}
static inline int unregister_chrdev_region(dev_t device, unsigned minor) {
return unregister_chrdev(device, NULL);
}
static inline int kobject_put(struct kobject *kobj){ return 0;};
#endif #endif

View File

@ -248,8 +248,7 @@ int DRM(put_minor)(drm_device_t *dev)
remove_proc_entry("dri", NULL); remove_proc_entry("dri", NULL);
DRM(sysfs_destroy)(DRM(global)->drm_class); DRM(sysfs_destroy)(DRM(global)->drm_class);
cdev_del(&DRM(global)->drm_cdev); unregister_chrdev(DRM_MAJOR, "drm");
unregister_chrdev_region(MKDEV(DRM_MAJOR, 0), DRM_MAX_MINOR);
DRM(free)(DRM(global)->minors, sizeof(*DRM(global)->minors) * DRM(free)(DRM(global)->minors, sizeof(*DRM(global)->minors) *
DRM(global)->cards_limit, DRM_MEM_STUB); DRM(global)->cards_limit, DRM_MEM_STUB);
@ -296,7 +295,6 @@ int DRM(put_secondary_minor)(drm_minor_t *sec_minor)
*/ */
int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent) int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
dev_t dev = MKDEV(DRM_MAJOR, 0);
drm_global_t *global; drm_global_t *global;
int ret = -ENOMEM; int ret = -ENOMEM;
@ -321,30 +319,21 @@ int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
if(!global->minors) if(!global->minors)
goto err_p1; goto err_p1;
if (register_chrdev_region(dev, DRM_MAX_MINOR, "drm")) if (register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops)))
goto err_p1; goto err_p1;
strncpy(global->drm_cdev.kobj.name, "drm", KOBJ_NAME_LEN);
global->drm_cdev.owner = THIS_MODULE;
cdev_init(&global->drm_cdev, &DRM(stub_fops));
if (cdev_add(&global->drm_cdev, dev, DRM_MAX_MINOR)) {
kobject_put(&global->drm_cdev.kobj);
printk (KERN_ERR "DRM: Error registering drm major number.\n");
goto err_p2;
}
global->drm_class = DRM(sysfs_create)(THIS_MODULE, "drm"); global->drm_class = DRM(sysfs_create)(THIS_MODULE, "drm");
if (IS_ERR(global->drm_class)) { if (IS_ERR(global->drm_class)) {
printk (KERN_ERR "DRM: Error creating drm class.\n"); printk (KERN_ERR "DRM: Error creating drm class.\n");
ret = PTR_ERR(global->drm_class); ret = PTR_ERR(global->drm_class);
goto err_p3; goto err_p2;
} }
global->proc_root = create_proc_entry("dri", S_IFDIR, NULL); global->proc_root = create_proc_entry("dri", S_IFDIR, NULL);
if (!global->proc_root) { if (!global->proc_root) {
DRM_ERROR("Cannot create /proc/dri\n"); DRM_ERROR("Cannot create /proc/dri\n");
ret = -1; ret = -1;
goto err_p4; goto err_p3;
} }
DRM_DEBUG("calling inter_module_register\n"); DRM_DEBUG("calling inter_module_register\n");
inter_module_register("drm", THIS_MODULE, global); inter_module_register("drm", THIS_MODULE, global);
@ -353,16 +342,14 @@ int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
if ((ret = get_minor(pdev, ent))) { if ((ret = get_minor(pdev, ent))) {
if (global) if (global)
goto err_p4; goto err_p3;
return ret; return ret;
} }
return 0; return 0;
err_p4:
DRM(sysfs_destroy)(global->drm_class);
err_p3: err_p3:
cdev_del(&global->drm_cdev); DRM(sysfs_destroy)(global->drm_class);
unregister_chrdev_region(dev, DRM_MAX_MINOR);
err_p2: err_p2:
unregister_chrdev(DRM_MAJOR, "drm");
DRM(free)(global->minors, sizeof(*global->minors) * global->cards_limit, DRM_MEM_STUB); DRM(free)(global->minors, sizeof(*global->minors) * global->cards_limit, DRM_MEM_STUB);
err_p1: err_p1:
DRM(free)(global, sizeof(*global), DRM_MEM_STUB); DRM(free)(global, sizeof(*global), DRM_MEM_STUB);

View File

@ -56,9 +56,6 @@
#include <linux/smp_lock.h> /* For (un)lock_kernel */ #include <linux/smp_lock.h> /* For (un)lock_kernel */
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#include <linux/cdev.h>
#endif
#if defined(__alpha__) || defined(__powerpc__) #if defined(__alpha__) || defined(__powerpc__)
#include <asm/pgtable.h> /* For pte_wrprotect */ #include <asm/pgtable.h> /* For pte_wrprotect */
#endif #endif
@ -697,7 +694,6 @@ typedef struct drm_global {
drm_minor_t *minors; drm_minor_t *minors;
struct drm_sysfs_class *drm_class; struct drm_sysfs_class *drm_class;
struct proc_dir_entry *proc_root; struct proc_dir_entry *proc_root;
struct cdev drm_cdev;
} drm_global_t; } drm_global_t;
static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature) static __inline__ int drm_core_check_feature(struct drm_device *dev, int feature)

View File

@ -142,32 +142,9 @@ static inline struct drm_sysfs_class *DRM(sysfs_create)(struct module *owner, ch
#define pci_pretty_name(x) x->name #define pci_pretty_name(x) x->name
#endif #endif
/* not used in 2.4, just makes the code compile */ struct drm_device;
#define KOBJ_NAME_LEN 20 static inline int radeon_create_i2c_busses(struct drm_device *dev){return 0;};
struct kobject { static inline void radeon_delete_i2c_busses(struct drm_device *dev){};
char name[KOBJ_NAME_LEN];
};
struct cdev {
struct kobject kobj;
struct module *owner;
struct file_operations *ops;
struct list_head list;
dev_t dev;
unsigned int count;
};
static inline void cdev_del(struct cdev *cd){}
static inline void cdev_init(struct cdev *cd, struct file_operations *fop){}
static inline int cdev_add(struct cdev *cd, dev_t dt, unsigned u){ return 0;}
static inline int register_chrdev_region(dev_t device, unsigned minor, char *name) {
return register_chrdev(device, name, NULL);
}
static inline int unregister_chrdev_region(dev_t device, unsigned minor) {
return unregister_chrdev(device, NULL);
}
static inline int kobject_put(struct kobject *kobj){ return 0;};
#endif #endif

View File

@ -248,8 +248,7 @@ int DRM(put_minor)(drm_device_t *dev)
remove_proc_entry("dri", NULL); remove_proc_entry("dri", NULL);
DRM(sysfs_destroy)(DRM(global)->drm_class); DRM(sysfs_destroy)(DRM(global)->drm_class);
cdev_del(&DRM(global)->drm_cdev); unregister_chrdev(DRM_MAJOR, "drm");
unregister_chrdev_region(MKDEV(DRM_MAJOR, 0), DRM_MAX_MINOR);
DRM(free)(DRM(global)->minors, sizeof(*DRM(global)->minors) * DRM(free)(DRM(global)->minors, sizeof(*DRM(global)->minors) *
DRM(global)->cards_limit, DRM_MEM_STUB); DRM(global)->cards_limit, DRM_MEM_STUB);
@ -296,7 +295,6 @@ int DRM(put_secondary_minor)(drm_minor_t *sec_minor)
*/ */
int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent) int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
dev_t dev = MKDEV(DRM_MAJOR, 0);
drm_global_t *global; drm_global_t *global;
int ret = -ENOMEM; int ret = -ENOMEM;
@ -321,30 +319,21 @@ int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
if(!global->minors) if(!global->minors)
goto err_p1; goto err_p1;
if (register_chrdev_region(dev, DRM_MAX_MINOR, "drm")) if (register_chrdev(DRM_MAJOR, "drm", &DRM(stub_fops)))
goto err_p1; goto err_p1;
strncpy(global->drm_cdev.kobj.name, "drm", KOBJ_NAME_LEN);
global->drm_cdev.owner = THIS_MODULE;
cdev_init(&global->drm_cdev, &DRM(stub_fops));
if (cdev_add(&global->drm_cdev, dev, DRM_MAX_MINOR)) {
kobject_put(&global->drm_cdev.kobj);
printk (KERN_ERR "DRM: Error registering drm major number.\n");
goto err_p2;
}
global->drm_class = DRM(sysfs_create)(THIS_MODULE, "drm"); global->drm_class = DRM(sysfs_create)(THIS_MODULE, "drm");
if (IS_ERR(global->drm_class)) { if (IS_ERR(global->drm_class)) {
printk (KERN_ERR "DRM: Error creating drm class.\n"); printk (KERN_ERR "DRM: Error creating drm class.\n");
ret = PTR_ERR(global->drm_class); ret = PTR_ERR(global->drm_class);
goto err_p3; goto err_p2;
} }
global->proc_root = create_proc_entry("dri", S_IFDIR, NULL); global->proc_root = create_proc_entry("dri", S_IFDIR, NULL);
if (!global->proc_root) { if (!global->proc_root) {
DRM_ERROR("Cannot create /proc/dri\n"); DRM_ERROR("Cannot create /proc/dri\n");
ret = -1; ret = -1;
goto err_p4; goto err_p3;
} }
DRM_DEBUG("calling inter_module_register\n"); DRM_DEBUG("calling inter_module_register\n");
inter_module_register("drm", THIS_MODULE, global); inter_module_register("drm", THIS_MODULE, global);
@ -353,16 +342,14 @@ int DRM(probe)(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
if ((ret = get_minor(pdev, ent))) { if ((ret = get_minor(pdev, ent))) {
if (global) if (global)
goto err_p4; goto err_p3;
return ret; return ret;
} }
return 0; return 0;
err_p4:
DRM(sysfs_destroy)(global->drm_class);
err_p3: err_p3:
cdev_del(&global->drm_cdev); DRM(sysfs_destroy)(global->drm_class);
unregister_chrdev_region(dev, DRM_MAX_MINOR);
err_p2: err_p2:
unregister_chrdev(DRM_MAJOR, "drm");
DRM(free)(global->minors, sizeof(*global->minors) * global->cards_limit, DRM_MEM_STUB); DRM(free)(global->minors, sizeof(*global->minors) * global->cards_limit, DRM_MEM_STUB);
err_p1: err_p1:
DRM(free)(global, sizeof(*global), DRM_MEM_STUB); DRM(free)(global, sizeof(*global), DRM_MEM_STUB);