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; }
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"); }
/** * usb_deregister_dev - deregister a USB device's dynamic minor. * @intf: pointer to the usb_interface that is being deregistered * @class_driver: pointer to the usb_class_driver for this device * * Used in conjunction with usb_register_dev(). This function is called * when the USB driver is finished with the minor numbers gotten from a * call to usb_register_dev() (usually when the device is disconnected * from the system.) * * This function also cleans up the devfs file for the usb device, if devfs * is enabled, and removes the usb class device from the sysfs tree. * * This should be called by all drivers that use the USB major number. */ void usb_deregister_dev(struct usb_interface *intf, struct usb_class_driver *class_driver) { int minor_base = class_driver->minor_base; char name[BUS_ID_SIZE]; #ifdef CONFIG_USB_DYNAMIC_MINORS minor_base = 0; #endif if (intf->minor == -1) return; dbg ("removing %d minor", intf->minor); spin_lock (&minor_lock); usb_minors[intf->minor] = NULL; spin_unlock (&minor_lock); snprintf(name, BUS_ID_SIZE, class_driver->name, intf->minor - minor_base); devfs_remove (name); class_simple_device_remove(MKDEV(USB_MAJOR, intf->minor)); intf->class_dev = NULL; intf->minor = -1; }
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 sound_remove_unit(struct sound_unit **list, int unit) { struct sound_unit *p; spin_lock(&sound_loader_lock); p = __sound_remove_unit(list, unit); spin_unlock(&sound_loader_lock); if (p) { devfs_remove(p->name); class_simple_device_remove(MKDEV(SOUND_MAJOR, p->unit_minor)); kfree(p); } }
static int __devinit cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; switch (action) { case CPU_ONLINE: cpuid_class_simple_device_add(cpu); break; case CPU_DEAD: class_simple_device_remove(MKDEV(CPUID_MAJOR, cpu)); break; } return NOTIFY_OK; }
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"); }
static int dvblo_chardev_release(struct dvblo_chardev *chardev) { int rv = SUCCESS, i; if(chardev->used == 0) { rv = -EINVAL; } else if(chardev->hcount > 0) { rv = -EAGAIN; } else { if(chardev->initdone != 0) dprintk(0, "releasing char device with minor device number %u\n", chardev->minor); switch(chardev->initlev) { case 3: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) for(i=0; i<(sizeof(clsdev_attrs)/sizeof(clsdev_attrs[0])) && rv == SUCCESS; i++) class_device_remove_file(chardev->clsdev, &clsdev_attrs[i]); #endif case 2: #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) class_device_destroy(dvblo_class, MKDEV(dvblo_char_major, chardev->minor)); #else /* The old-style "simple" class API */ class_simple_device_remove(MKDEV(dvblo_char_major, chardev->minor)); #endif case 1: i = dvblo_adap_destroy(chardev->dvblo); if(i < 0) { mprintk(KERN_ALERT, "failed to destroy virtual DVB adapter: %d\n", i); if(rv == 0) rv = i; } default: break; } if(chardev->initdone != 0) mprintk(KERN_INFO, "removed character device %s\n", chardev->name); chardev->initlev = 0; chardev->initdone = 0; chardev->used = 0; } return rv; }
/** * 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; }
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"); }