/* * The cleanup function is used to handle initialization failures as well. * Thefore, it must be careful to work correctly even if some of the items * have not been initialized */ void scull_cleanup_module(void) { int i; #ifndef CONFIG_DEVFS_FS /* cleanup_module is never called if registering failed */ unregister_chrdev(scull_major, "scull"); #endif scull_remove_proc(); if (scull_devices) { for (i=0; i<scull_nr_devs; i++) { scull_trim(scull_devices+i); /* the following line is only used for devfs */ devfs_unregister(scull_devices[i].handle); } kfree(scull_devices); } /* and call the cleanup functions for friend devices */ scull_p_cleanup(); scull_access_cleanup(); /* once again, only for devfs */ devfs_unregister(scull_devfs_dir); }
/* * This is called by cleanup_module or on failure. * It is required to never fail, even if nothing was initialized first */ void scull_access_cleanup(void) { struct scull_listitem *lptr, *prev; scull_trim(&scull_s_device); /* disallocate it */ scull_trim(&scull_u_device); /* disallocate it */ scull_trim(&scull_w_device); /* disallocate it */ /* all the cloned devices */ prev=NULL; for (lptr = scull_c_head; lptr; lptr = lptr->next) { scull_trim(&(lptr->device)); if (prev) kfree(prev); prev=lptr; } if (prev) kfree(prev); scull_c_head = NULL; /* overkill: we're unloading anyways */ /* remove devfs entry points */ devfs_unregister(scull_s_device.handle); devfs_unregister(scull_u_device.handle); devfs_unregister(scull_w_device.handle); devfs_unregister(scull_priv_handle); return; }
void lvm_fs_remove_vg(vg_t *vg_ptr) { int i; if (!vg_ptr) return; devfs_unregister(ch_devfs_handle[vg_ptr->vg_number]); ch_devfs_handle[vg_ptr->vg_number] = NULL; /* remove lv's */ for(i = 0; i < vg_ptr->lv_max; i++) if(vg_ptr->lv[i]) lvm_fs_remove_lv(vg_ptr, vg_ptr->lv[i]); /* must not remove directory before leaf nodes */ devfs_unregister(vg_devfs_handle[vg_ptr->vg_number]); vg_devfs_handle[vg_ptr->vg_number] = NULL; /* remove pv's */ for(i = 0; i < vg_ptr->pv_max; i++) if(vg_ptr->pv[i]) lvm_fs_remove_pv(vg_ptr, vg_ptr->pv[i]); if(vg_ptr->vg_dir_pde) { remove_proc_entry(LVM_LV_SUBDIR, vg_ptr->vg_dir_pde); vg_ptr->lv_subdir_pde = NULL; remove_proc_entry(LVM_PV_SUBDIR, vg_ptr->vg_dir_pde); vg_ptr->pv_subdir_pde = NULL; remove_proc_entry("group", vg_ptr->vg_dir_pde); vg_ptr->vg_dir_pde = NULL; remove_proc_entry(vg_ptr->vg_name, lvm_proc_vg_subdir); } }
static void mtd_notify_remove(struct mtd_info* mtd) { if (!mtd) return; devfs_unregister(devfs_rw_handle[mtd->index]); devfs_unregister(devfs_ro_handle[mtd->index]); }
static void __exit gpio_exit(void) { int i; for (i = 0; i < ARRAYSIZE(gpio_file); i++) devfs_unregister(gpio_file[i].handle); devfs_unregister(gpio_dir); devfs_unregister_chrdev(gpio_major, "gpio"); sb_detach(gpio_sbh);}
void __exit fpga_exit(void) { #ifdef CONFIG_DEVFS_FS devfs_unregister(devfs_fpgaraw); devfs_unregister(devfs_fpga_dir); #endif unregister_chrdev(fpgaMajor, DEVICE_NAME); }
void __exit s3c2410_adc_exit(void) { #ifdef CONFIG_DEVFS_FS devfs_unregister(devfs_adcraw); devfs_unregister(devfs_adc_dir); #endif unregister_chrdev(adcMajor, DEVICE_NAME); free_irq(IRQ_ADC_DONE, NULL); }
static void __exit s3c2410_kbd_exit(void) { #ifdef CONFIG_DEVFS_FS devfs_unregister(devfs_kbdraw); devfs_unregister(devfs_kbd_dir); #endif unregister_chrdev(kbdMajor, DEVICE_NAME); free_irq(IRQ_KBD, s3c2410_isr_kbd); }
static void __exit s3c2410_ts_exit(void) { #ifdef CONFIG_DEVFS_FS devfs_unregister(devfs_tsraw); devfs_unregister(devfs_ts_dir); #endif unregister_chrdev(tsMajor, DEVICE_NAME); #ifdef CONFIG_PM pm_unregister(tsdev.pm_dev); #endif free_irq(IRQ_ADC_DONE, s3c2410_isr_adc); free_irq(IRQ_TC, s3c2410_isr_tc); }
static void devfs_unregister_card(struct em84xx *card) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,69) devfs_unregister(em8300_handle[0]); devfs_unregister(em8300_handle[1]); devfs_unregister(em8300_handle[2]); devfs_unregister(em8300_handle[3]); #else devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 0); devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 1); devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 2); devfs_remove("%s%d", REALMAGIC_DEVICE_NAME, 3); #endif }
static void camera_disconnect(struct usb_device *dev, void *ptr) { struct camera_state *camera = (struct camera_state *) ptr; int subminor = camera->subminor; down (&state_table_mutex); down (&camera->sem); devfs_unregister(camera->devfs); /* If camera's not opened, we can clean up right away. * Else apps see a disconnect on next I/O; the release cleans. */ if (!camera->buf) { minor_data [subminor] = NULL; kfree (camera); camera = NULL; } else camera->dev = NULL; info ("USB Camera #%d disconnected", subminor); usb_dec_dev_use (dev); if (camera != NULL) up (&camera->sem); up (&state_table_mutex); }
static void disconnect_scanner(struct usb_device *dev, void *ptr) { struct scn_usb_data *scn = (struct scn_usb_data *) ptr; down (&scn_mutex); down (&(scn->sem)); if(scn->intr_ep) { dbg("disconnect_scanner(%d): Unlinking IRQ URB", scn->scn_minor); usb_unlink_urb(&scn->scn_irq); } usb_driver_release_interface(&scanner_driver, &scn->scn_dev->actconfig->interface[scn->ifnum]); kfree(scn->ibuf); kfree(scn->obuf); dbg("disconnect_scanner: De-allocating minor:%d", scn->scn_minor); devfs_unregister(scn->devfs); p_scn_table[scn->scn_minor] = NULL; up (&(scn->sem)); kfree (scn); up (&scn_mutex); }
void cleanup_module(void) { devfs_unregister (devfs_handle); if (devfs_unregister_chrdev( MAJOR_NR, "slm" ) != 0) printk( KERN_ERR "acsi_slm: cleanup_module failed\n"); atari_stram_free( SLMBuffer ); }
static void ipmi_smi_gone(int if_num) { if (if_num > MAX_DEVICES) return; devfs_unregister(handles[if_num]); }
/** * skel_disconnect * * Called by the usb core when the device is removed from the system. */ static void skel_disconnect(struct usb_device *udev, void *ptr) { struct usb_skel *dev; int minor; dev = (struct usb_skel *)ptr; down (&minor_table_mutex); down (&dev->sem); minor = dev->minor; /* remove our devfs node */ devfs_unregister(dev->devfs); /* if the device is not opened, then we clean up right now */ if (!dev->open_count) { up (&dev->sem); skel_delete (dev); } else { dev->udev = NULL; up (&dev->sem); } info("USB Skeleton #%d now disconnected", minor); up (&minor_table_mutex); }
int __init init_module(void) { int rc; /* Get our definition */ _gmodule = gmodule_get(); if(!_gmodule) return -ENODEV; /* Register ourselves */ #ifdef GMODULE_CONFIG_DEVFS_FS devfs_handle = devfs_register(NULL, _gmodule->name, DEVFS_FL_NONE, _gmodule->major, _gmodule->minor, S_IFCHR | S_IRUGO | S_IWUGO, &_gmodule_fops, NULL); if(!devfs_handle) { printk(KERN_WARNING "%s: can't register device with devfs", _gmodule->name); } rc = 0; #else rc = register_chrdev(_gmodule->major, _gmodule->name, &_gmodule_fops); if (rc < 0) { printk(KERN_WARNING "%s: can't get major %d", _gmodule->name, _gmodule->major); return rc; } if(_gmodule->major == 0) { _gmodule->major = rc; } #endif /* Specific module Initialization */ if(_gmodule->init) { int rc; if((rc = _gmodule->init()) < 0) { #ifdef GMODULE_CONFIG_DEVFS_FS if(devfs_handle) devfs_unregister(devfs_handle); #else unregister_chrdev(_gmodule->major, _gmodule->name); #endif return rc; } } /* Add a /proc entry, if valid */ if(_gmodule->pprint) { _gmodule_create_proc(); } return 0; /* succeed */ }
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; }
/**************************************************************************** Description: Clean up the module if unloaded. Arguments: None. Return Value: None. Remarks: Called by the kernel. ****************************************************************************/ static void __exit duslic_module_exit(void) { IFX_int32_t i; #ifdef CONFIG_DEVFS_FS IFX_int32_t j; #endif /* CONFIG_DEVFS_FS */ for (i=0; i < DUSLIC_MAX_DEVICES; i++) { #ifdef CONFIG_DEVFS_FS /* remove duslic devices from dev fs */ for (j = 0; j <= DUSLIC_MAX_CHANNELS; j++ ) { if (devfs_handle[i*DUSLIC_MAX_CHANNELS + j]) { //printk("unregister dus%d%d\n",i+1,j); devfs_unregister (devfs_handle[i*DUSLIC_MAX_CHANNELS + j]); } } #else unregister_chrdev (DUSLIC_MAJOR, DEV_NAME); #endif /* CONFIG_DEVFS_FS */ } for (i=0; i < DUSLIC_MAX_DEVICES; i++) { if (pDuslic_Devices[i] != NULL) { ReleaseDevice (pDuslic_Devices[i]); } } remove_proc_entry(DEV_NAME,NULL); }
void __exit h3600_stowaway_cleanup_module( void ) { unregister_sysctl_table(h3600_stowaway_sysctl_header); remove_proc_entry(H3600_STOWAWAY_PROC_STATS, proc_dir); devfs_unregister( devfs_stowaway ); devfs_unregister_chrdev( g_stowaway_major, H3600_STOWAWAY_MODULE_NAME ); }
static void deinit_vfc_device(struct vfc_dev *dev) { if(dev == NULL) return; devfs_unregister (dev->de); sbus_iounmap((unsigned long)dev->regs, sizeof(struct vfc_regs)); kfree(dev); }
void lvm_fin_fs() { #if 0 devfs_unregister (lvm_devfs_handle); #endif remove_proc_entry(LVM_GLOBAL, lvm_proc_dir); remove_proc_entry(LVM_VG_SUBDIR, lvm_proc_dir); remove_proc_entry(LVM_DIR, &proc_root); }
static void __exit gfx_inf_deinit(void) { devfs_unregister_chrdev(GFX_DEV_MAJOR, GFX_DRIVER_NAME); if(devfs_handle != NULL) devfs_unregister(devfs_handle); gfx_inf_h_deinit(2); gfx_atom_deinit(); // BJC 102102 }
void PpeUnRegIoctlHandler(void) { #ifdef CONFIG_DEVFS_FS devfs_unregister_chrdev(hw_nat_major, HW_NAT_DEVNAME); devfs_unregister(devfs_handle); #else unregister_chrdev(hw_nat_major, HW_NAT_DEVNAME); #endif }
static void usblp_cleanup (struct usblp *usblp) { devfs_unregister (usblp->devfs); usblp_table [usblp->minor] = NULL; info ("usblp%d: removed", usblp->minor); kfree (usblp->writeurb.transfer_buffer); kfree (usblp->device_id_string); kfree (usblp); }
void cleanup_module(void) { saa7126_power_save(1); i2c_del_driver(&driver); devfs_unregister ( devfs_handle ); return; }
static void __exit cleanup_mtdchar(void) { #ifdef CONFIG_DEVFS_FS unregister_mtd_user(¬ifier); devfs_unregister(devfs_dir_handle); devfs_unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); #else unregister_chrdev(MTD_CHAR_MAJOR, "mtd"); #endif }
void AclUnRegIoctlHandler(void) { #ifdef CONFIG_DEVFS_FS devfs_unregister_chrdev(acl_major, ACL_DEVNAME); devfs_unregister(devfs_handle); #else unregister_chrdev(acl_major, ACL_DEVNAME); #endif }
int __init h3600_backpaq_fpga_init_module(void) { int result; printk(KERN_ALERT __FILE__ ": registering char device"); /* Register my device driver */ result = devfs_register_chrdev(0,MODULE_NAME, &h3600_backpaq_fpga_fops); if ( result <= 0 ) { printk(" can't get major number\n"); return result; } if ( h3600_backpaq_fpga_major_num == 0 ) h3600_backpaq_fpga_major_num = result; printk(" %d\n", h3600_backpaq_fpga_major_num); /* Clear the default structure */ memset(&h3600_backpaq_fpga_data, 0, sizeof(struct h3600_backpaq_fpga_dev_struct)); /* Create a devfs entry */ #ifdef CONFIG_DEVFS_FS devfs_fpga = devfs_register( NULL, FPGA_DEVICE_NAME, DEVFS_FL_DEFAULT, h3600_backpaq_fpga_major_num, FPGA_MINOR, S_IFCHR | S_IRUSR | S_IWUSR, &h3600_backpaq_fpga_fops, NULL ); #endif #ifdef CONFIG_PROC_FS /* Set up the PROC file system entry */ proc_backpaq_fpga = create_proc_entry(FPGA_PROC_NAME, 0, NULL); if ( !proc_backpaq_fpga ) { /* We probably need to create the "backpaq" directory first */ proc_mkdir(FPGA_PROC_DIR,0); proc_backpaq_fpga = create_proc_entry(FPGA_PROC_NAME, 0, NULL); } if ( proc_backpaq_fpga ) proc_backpaq_fpga->read_proc = proc_h3600_backpaq_read; else { printk(KERN_ALERT __FILE__ ": unable to create proc entry %s\n", FPGA_PROC_NAME); devfs_unregister( devfs_fpga ); devfs_unregister_chrdev( h3600_backpaq_fpga_major_num, MODULE_NAME ); return -ENODEV; } #endif #ifdef CONFIG_PM fpga_backpaq_dev = h3600_backpaq_register_device( H3600_BACKPAQ_FPGA_DEV, 0, h3600_backpaq_fpga_callback ); printk(KERN_ALERT __FILE__ ": registered backpaq callback=%p\n", h3600_backpaq_fpga_callback); #endif return 0; }
static void rdm_exit(void) { printk("rdm_exit\n"); #ifdef CONFIG_DEVFS_FS devfs_unregister_chrdev(rdm_major, RDM_DEVNAME); devfs_unregister(devfs_handle); #else unregister_chrdev(rdm_major, RDM_DEVNAME); #endif }
int lirc_unregister_plugin(int minor) { struct irctl *ir; DECLARE_MUTEX_LOCKED(tn); if (minor < 0 || minor >= MAX_IRCTL_DEVICES) { printk("lirc_dev: lirc_unregister_plugin:" "\" minor\" must be beetween 0 and %d!\n", MAX_IRCTL_DEVICES-1); return -EBADRQC; } ir = &irctls[minor]; down_interruptible(&plugin_lock); if (ir->p.minor != minor) { printk("lirc_dev: lirc_unregister_plugin:" "minor (%d) device not registered!", minor); up(&plugin_lock); return -ENOENT; } if (ir->open) { printk("lirc_dev: lirc_unregister_plugin:" "plugin %s[%d] in use!", ir->p.name, ir->p.minor); up(&plugin_lock); return -EBUSY; } /* end up polling thread */ if (ir->tpid >= 0) { ir->t_notify = &tn; ir->shutdown = 1; down(&tn); ir->t_notify = NULL; } dprintk("lirc_dev: plugin %s unregistered from minor number = %d\n", ir->p.name, ir->p.minor); #ifdef LIRC_HAVE_DEVFS devfs_unregister(ir->devfs_handle); #endif init_irctl(ir); up(&plugin_lock); MOD_DEC_USE_COUNT; return SUCCESS; }