int ndas_ctrldev_cleanup(void) { #if LINUX_VERSION_25_ABOVE #if LINUX_VERSION_HAS_CLASS_CREATE #if LINUX_VERSION_HAS_DEVICE_CREATE device_destroy(ndas_ctrldev_class, MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR)); #else class_device_destroy(ndas_ctrldev_class, MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR)); #endif //#if LINUX_VERSION_HAS_DEVICE_CREATE class_destroy(ndas_ctrldev_class); #else class_simple_device_remove(MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR)); class_simple_destroy(ndas_ctrldev_class); #endif /* LINUX_VERSION_HAS_CLASS_CREATE */ #endif /* LINUX_VERSION_25_ABOVE */ #ifdef NDAS_DEVFS devfs_unregister(devfs_control_handle); #else unregister_chrdev(NDAS_CHR_DEV_MAJOR, "ndas"); #endif return 0; }
int dvblo_char_exit(void) { int rv = SUCCESS, i, j; switch(initlev) { case 3: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) class_destroy(dvblo_class); #else class_simple_destroy(dvblo_class); #endif case 2: /* NOTE: we have to lock dvblo_char_chardevs_sem to avoid that after * releasing all devices a new device is created again, becaus our char * device driver is still registered. */ down(&dvblo_char_chardevs_sem); for(j=0; j<DVBLO_CHAR_DEVMAX; j++) { if(chardevs[j].used != 0) { // Wait, until all open file handles have been closed int waitc = 0; while(chardevs[j].hcount > 0) { mprintk(KERN_INFO, "There are %i open file handles for device %s. %s...\n", chardevs[j].hcount, chardevs[j].name, waitc > 0 ? "Still waiting" : "Waiting"); up(&dvblo_char_chardevs_sem); wait_event(dvblo_char_chardevs_wq, (chardevs[j].hcount == 0)); down(&dvblo_char_chardevs_sem); waitc++; } // now that all file handles are closed, release the device i = dvblo_chardev_release(&chardevs[j]); if(i != SUCCESS) { mprintk(KERN_ALERT, "failed to release char device %s: %d\n", chardevs[j].name, i); if(rv == 0) rv = i; } } } #if defined(USE_CDEV) && USE_CDEV != 0 cdev_del(&dvblo_char_cdev); #else i = unregister_chrdev(dvblo_char_major, DVBLO_NAME); if (i < 0) { mprintk(KERN_ALERT, "failed to unregister char device: %d\n", i); if(rv == 0) rv = i; } #endif up(&dvblo_char_chardevs_sem); case 1: #if defined(USE_CDEV) && USE_CDEV != 0 unregister_chrdev_region(MKDEV(dvblo_char_major, 0), DVBLO_CHAR_DEVMAX); #endif dvblo_char_major = 0; default: break; } initlev = 0; return rv; }
void __exit gpio_exit(void) { __D("In gpio_exit()\n"); /* Remove the /proc entry */ remove_proc_entry("gpio", NULL); #if (USE_UDEV==1) #ifdef USE_CLASS_SIMPLE class_simple_device_remove(MKDEV(gpio_major, 0)); class_simple_destroy(gpio_class); #else #ifdef USE_CLASS_DEVICE class_device_destroy(gpio_class, MKDEV(gpio_major, 0)); #else device_destroy(gpio_class, MKDEV(gpio_major, 0)); #endif // USE_CLASS_DEVICE class_destroy(gpio_class); #endif // USE_CLASS_SIMPLE #endif // USE_UDEV __D("Unregistering character device mem\n"); unregister_chrdev(gpio_major, "gpio"); printk(KERN_INFO "gpio unregistered\n"); }
static void __exit dsp56k_cleanup_driver(void) { class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0)); class_simple_destroy(dsp56k_class); unregister_chrdev(DSP56K_MAJOR, "dsp56k"); devfs_remove("dsp56k"); }
static void __exit cpuid_exit(void) { int cpu = 0; for_each_online_cpu(cpu) class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu)); class_simple_destroy(cpuid_class); unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); unregister_cpu_notifier(&cpuid_class_cpu_notifier); }
/** * This function should neatly unregister 1.Destroy Udev Info and release sysfs Nodes 2.Release dev_t objects 3.Unregister Cdev * */ void exit_char_device(void) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) class_simple_device_remove(mydev); class_simple_destroy(veda_class); #else device_destroy(veda_class,mydev); class_destroy(veda_class); #endif unregister_chrdev_region(mydev,1); cdev_del(veda_cdev); }
void cleanup_module(void) { /* * Unregister the device */ devfs_remove("dvb/adapter0/frontend0"); class_simple_device_remove(MKDEV(DVB_MAJOR, 3)); devfs_remove("dvb"); class_simple_destroy(my_class); cdev_del(&device_cdev); unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), 64); printk(KERN_INFO "[td-dvb-fe] unload successful\n"); }
static void exit_kb(void) { free_irq(KB_INT,&some_data); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) class_simple_device_remove(mydev); class_simple_destroy(veda_class); #else device_destroy(veda_class,mydev); class_destroy(veda_class); #endif unregister_chrdev_region(mydev,1); cdev_del(veda_cdev); printk("\n Module removed"); }
/** * This function should neatly unregister itself and return * */ static void exit_char_device(void) { int i; kfree(char_device_buf_minor0); kfree(char_device_buf_minor1); kfree(char_device_buf_minor2); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) for(i=0;i<3;i++) class_simple_device_remove(MKDEV(char_device_id,i)); class_simple_destroy(veda_class); #else for(i=0;i<3;i++) device_destroy(veda_class,MKDEV(char_device_id,i)); class_destroy(veda_class); #endif for(i=0;i<3;i++) unregister_chrdev_region(MKDEV(char_device_id,i),0); cdev_del(veda_cdev); printk("\n Module Removed"); }
static int __init cpuid_init(void) { int i, err = 0; i = 0; if (register_chrdev(CPUID_MAJOR, "cpu/cpuid", &cpuid_fops)) { printk(KERN_ERR "cpuid: unable to get major %d for cpuid\n", CPUID_MAJOR); err = -EBUSY; goto out; } cpuid_class = class_simple_create(THIS_MODULE, "cpuid"); if (IS_ERR(cpuid_class)) { err = PTR_ERR(cpuid_class); goto out_chrdev; } for_each_online_cpu(i) { err = cpuid_class_simple_device_add(i); if (err != 0) goto out_class; } register_cpu_notifier(&cpuid_class_cpu_notifier); err = 0; goto out; out_class: i = 0; for_each_online_cpu(i) { class_simple_device_remove(MKDEV(CPUID_MAJOR, i)); } class_simple_destroy(cpuid_class); out_chrdev: unregister_chrdev(CPUID_MAJOR, "cpu/cpuid"); out: return err; }
static int __init dsp56k_init_driver(void) { int err = 0; if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) { printk("DSP56k driver: Hardware not present\n"); return -ENODEV; } if(register_chrdev(DSP56K_MAJOR, "dsp56k", &dsp56k_fops)) { printk("DSP56k driver: Unable to register driver\n"); return -ENODEV; } dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k"); if (IS_ERR(dsp56k_class)) { err = PTR_ERR(dsp56k_class); goto out_chrdev; } class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k"); err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k"); if(err) goto out_class; printk(banner); goto out; out_class: class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0)); class_simple_destroy(dsp56k_class); out_chrdev: unregister_chrdev(DSP56K_MAJOR, "dsp56k"); out: return err; }
void usb_major_cleanup(void) { class_simple_destroy(usb_class); devfs_remove("usb"); unregister_chrdev(USB_MAJOR, "usb"); }
static void __exit mod_exit(void) { struct list_head *u; struct list_head *unext; struct list_head *registeredlistp; struct registered_user *user; int found_user; int i; #ifdef USE_CLASS_SIMPLE class_simple_device_remove(MKDEV(major, 0)); class_simple_destroy(dma_class); #else #ifdef USE_CLASS_DEVICE class_device_destroy(dma_class, MKDEV(major, 0)); #else device_destroy(dma_class, MKDEV(major, 0)); #endif // USE_CLASS_DEVICE class_destroy(dma_class); #endif // USE_CLASS_SIMPLE unregister_chrdev(major, "edma"); /* * Free all "owned" channels now. They're supposed to get either * explicitly freed, or auto-freed when the file descriptor for * this device driver is closed by a process (which itself might happen * during auto-close if the process doesn't explicitly close the file * descriptor), but a process might crash or otherwise not get to the * auto-close point. The following code will run when the module is * removed from the kernel (w/ rmmod). */ for (i = 0; i < NCHAN; i++) { found_user = 0; if (mutex_lock_interruptible(&edma_mutex)) { return; } registeredlistp = &channels[i].users; u = registeredlistp->next; while (u != registeredlistp) { found_user = 1; unext = u->next; user = list_entry(u, struct registered_user, element); list_del(u); kfree(user); u = unext; } if (found_user) { release_channel(i); } mutex_unlock(&edma_mutex); } __D("edma unregistered\n"); }