static void __exit cleanup_basic_device_module(void) { class_unregister(&lfs_sysfs_class); // kobject_put(lfs_kobj); device_destroy(lfs_class, MKDEV(major_number, 0)); class_unregister(lfs_class); class_destroy(lfs_class); unregister_chrdev(major_number, DEVICE_NAME); printk(KERN_INFO "LSDDriver: Bye!\n"); }
static int __init fir_init(void) { int ret; ret = register_chrdev(0,DEVICE_NAME, &fir_fops); if(ret < 0) { printk("fir: can't get major number\n"); return ret; } fir_major = ret; fir_class = class_create(THIS_MODULE, "fir_class"); if(IS_ERR(fir_class)) { printk("fir: failed in creating class\n"); unregister_chrdev(fir_major, DEVICE_NAME); return -1; } fir_device = device_create(fir_class,NULL,MKDEV(fir_major,0),NULL,DEVICE_NAME); if(IS_ERR(fir_device)) { printk("fir: failed in creating device!\n"); unregister_chrdev(fir_major, DEVICE_NAME); class_unregister(fir_class); class_destroy(fir_class); return -1; } fir_addr = (unsigned long) ioremap(FIR_BASEADDR, sizeof(u32)); printk("fir installed successfully!\n"); return 0; }
int __init watchdog_dev_init(void) { int err; watchdog_wq = alloc_workqueue("watchdogd", WQ_HIGHPRI | WQ_MEM_RECLAIM, 0); if (!watchdog_wq) { pr_err("Failed to create watchdog workqueue\n"); return -ENOMEM; } err = class_register(&watchdog_class); if (err < 0) { pr_err("couldn't register class\n"); goto err_register; } err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog"); if (err < 0) { pr_err("watchdog: unable to allocate char dev region\n"); goto err_alloc; } return 0; err_alloc: class_unregister(&watchdog_class); err_register: destroy_workqueue(watchdog_wq); return err; }
static void __exit dmabufr_exit(void) { dev_t dev = MKDEV(major, 0); class_unregister(dmabufr_class); unregister_chrdev_region(dev, DMABUFR_NUM_DEVICES); }
static void uart16550_cleanup(void) { int have_com1 =0; int have_com2 = 0; cdev_del(firstcdev); cdev_del(secondcdev); if(behavior==0x3){ have_com1=1; have_com2=1; } else if(behavior==0x2){ have_com1=0; have_com2=1; } else if(behavior==0x1){ have_com1=1; have_com2=0; } if (have_com1) { /* Reset the hardware device for COM1 */ uart16550_hw_cleanup_device(COM1_BASEPORT); /* Remove the sysfs info for /dev/com1 */ device_destroy(uart16550_class, MKDEV(major, 0)); } if (have_com2) { /* Reset the hardware device for COM2 */ uart16550_hw_cleanup_device(COM2_BASEPORT); /* Remove the sysfs info for /dev/com2 */ device_destroy(uart16550_class, MKDEV(major, 1)); } class_unregister(uart16550_class); class_destroy(uart16550_class); }
static void __exit smc_mod_exit(void) { platform_driver_unregister(&smc_driver); class_unregister(&smc_class); unregister_chrdev(smc_major, SMC_DEV_NAME); mutex_destroy(&smc_lock); }
static void __exit rmidev_exit(void) { pr_debug("%s: exiting.\n", __func__); platform_driver_unregister(&rmidev_driver); class_unregister(rmidev_device_class); class_destroy(rmidev_device_class); }
static int __init smc_mod_init(void) { int ret = -1; mutex_init(&smc_lock); smc_major = register_chrdev(0, SMC_DEV_NAME, &smc_fops); if(smc_major<=0) { mutex_destroy(&smc_lock); pr_error("register chrdev error\n"); goto error_register_chrdev; } if(class_register(&smc_class)<0) { pr_error("register class error\n"); goto error_class_register; } if(platform_driver_register(&smc_driver)<0) { pr_error("register platform driver error\n"); goto error_platform_drv_register; } return 0; error_platform_drv_register: class_unregister(&smc_class); error_class_register: unregister_chrdev(smc_major, SMC_DEV_NAME); error_register_chrdev: mutex_destroy(&smc_lock); return ret; }
static int macvtap_init(void) { int err; err = tap_create_cdev(&macvtap_cdev, &macvtap_major, "macvtap"); if (err) goto out1; err = class_register(&macvtap_class); if (err) goto out2; err = register_netdevice_notifier(&macvtap_notifier_block); if (err) goto out3; err = macvlan_link_register(&macvtap_link_ops); if (err) goto out4; return 0; out4: unregister_netdevice_notifier(&macvtap_notifier_block); out3: class_unregister(&macvtap_class); out2: tap_destroy_cdev(macvtap_major, &macvtap_cdev); out1: return err; }
static int __init motor_init(void) { int err; printk(KERN_INFO DRV_DESC ", version " DRV_VERSION "\n"); /*register the class */ motor_class = class_create(THIS_MODULE, "motor_class"); if(IS_ERR(motor_class)){ goto err; } err = motor_add_one(0, mot0); if (err) goto err; err = motor_add_one(1, mot1); if (err) goto err; err = motor_add_one(2, mot2); if (err) goto err; err = motor_add_one(3, mot3); if (err) goto err; return 0; err: class_unregister(motor_class); return -1; }
/** @brief The LKM cleanup function * Similar to the initialization function, it is static. The __exit macro notifies that if this * code is used for a built-in driver (not a LKM) that this function is not required. */ static void __exit sysmon_exit(void) { data_packet_list_node *dp = NULL; unsigned long flags; device_destroy(SYSMONClass, MKDEV(majorNumber, 0)); // remove the device class_unregister(SYSMONClass); // unregister the device class class_destroy(SYSMONClass); // remove the device class unregister_chrdev(majorNumber, DEVICE_NAME); // unregister the major number dp = getNodeFromActiveList(); spin_lock_irqsave(&dp_list_lock, flags); while(dp != NULL) { kfree(dp); dp = getNodeFromActiveList(); } dp = getNodeFromStorageList(false); while(dp != NULL) { kfree(dp); dp = getNodeFromStorageList(false); } spin_unlock_irqrestore(&dp_list_lock, flags); printk(KERN_INFO "SYSMON: Goodbye from the LKM!\n"); }
static int __init ultrasonic_init(void) { int ret; ret = register_chrdev(0,DEVICE_NAME, &ultrasonic_fops); if(ret < 0) { printk("ultrasonic: can't get major number\n"); return ret; } ultrasonic_major = ret; ultrasonic_class = class_create(THIS_MODULE, "ultrasonic_class"); if(IS_ERR(ultrasonic_class)) { printk("ultrasonic: failed in creating class\n"); unregister_chrdev(ultrasonic_major, DEVICE_NAME); return -1; } ultrasonic_device = device_create(ultrasonic_class,\ NULL, \ MKDEV(ultrasonic_major, 0), \ NULL,\ DEVICE_NAME); if(IS_ERR(ultrasonic_device)) { printk("ultrasonic: failed in creating device!\n"); unregister_chrdev(ultrasonic_major, DEVICE_NAME); class_unregister(ultrasonic_class); class_destroy(ultrasonic_class); return -1; } base_addr = (unsigned long) ioremap(ULTRASONIC_PHY_ADDR, sizeof(u32)); printk("Ultrasonic initail successfully\n"); return 0; }
static void __exit ebbchar_exit(void){ device_destroy(ebbcharClass, MKDEV(majorNumber, 0)); class_unregister(ebbcharClass); class_destroy(ebbcharClass); unregister_chrdev(majorNumber, DEVICE_NAME); printk(KERN_INFO "EBBChar: Goodbye from the LKM!\n"); }
/*********************************************************************** * * module section (init&exit) * ************************************************************************/ static int init_ge2d_device(void) { int ret=0; strcpy(ge2d_device.name,"ge2d"); ret=register_chrdev(0,ge2d_device.name,&ge2d_fops); if(ret <=0) { amlog_level(LOG_LEVEL_HIGH,"register ge2d device error\r\n"); return ret ; } ge2d_device.major=ret; ge2d_device.dbg_enable=0; amlog_level(LOG_LEVEL_LOW,"ge2d_dev major:%d\r\n",ret); ret = class_register(&ge2d_class); if(ret<0 ) { amlog_level(LOG_LEVEL_HIGH,"error create ge2d class\r\n"); return ret; } ge2d_device.cla=&ge2d_class ; ge2d_device.dev=device_create(ge2d_device.cla,NULL,MKDEV(ge2d_device.major,0),NULL,ge2d_device.name); if (IS_ERR(ge2d_device.dev)) { amlog_level(LOG_LEVEL_HIGH,"create ge2d device error\n"); class_unregister(ge2d_device.cla); return -1 ; } return ge2d_setup(); }
static void macvtap_exit(void) { rtnl_link_unregister(&macvtap_link_ops); unregister_netdevice_notifier(&macvtap_notifier_block); class_unregister(&macvtap_class); tap_destroy_cdev(macvtap_major, &macvtap_cdev); }
static void __exit hv_cdev_exit(void) { int i; PINFO("EXIT\n"); if (!get_use_mmls_cdev()) { PINFO("%s: nothing to un-init; not using cdev\n", __func__); goto not_using_cdev; } for (i = 0; i < HV_CDEV_N_MINORS; i++) { hv_cdev_device_num = MKDEV(hv_cdev_major, HV_CDEV_FIRST_MINOR+i); device_destroy(devices[i].hv_cdev_class, hv_cdev_device_num); class_unregister(devices[i].hv_cdev_class); class_destroy(devices[i].hv_cdev_class); cdev_del(&devices[i].cdev); } unregister_chrdev_region(hv_cdev_device_num, HV_CDEV_N_MINORS); mmls_iomem_release(); not_using_cdev: return; }
//----------------------------------------------------------------------------------------------// // // // Function Name : Gpio_cleanup // // // // Description : Module destroy function (rmmod) // // // // Return : Nothing // // // //----------------------------------------------------------------------------------------------// static void __exit Gpio_cleanup (void) { // Variable initialization int iCpt = 0; // For all gpio for (iCpt=0; iCpt<DRIVER_DEV_REGISTER_NB; iCpt++) { // Delete its node and its entrie in "/dev" device_destroy (m_pGpioClass, MKDEV (m_uiGpioMajor, m_uiGpioMinor+iCpt)); } // Delete the entries in "/sys/class" class_unregister(m_pGpioClass); class_destroy (m_pGpioClass); // Destroy the 'm_oGpioCDev' global variable cdev_del (&m_oGpioCDev); // Deallocates the driver 'DRV_DEV_NAME' using its first node 'm_oGpioDev' and the number of minor allocated unregister_chrdev_region (m_oGpioDev, DRIVER_DEV_REGISTER_NB); // Restore gpio register default mode for all change mux mode RestoreAllChangedMux (); printk (KERN_NOTICE "%s%s : Driver unloaded\n", DRV_NAME, __func__); }
static void __exit zrcar_wheel_module_exit(void) { device_destroy(wheel_class, MKDEV(wheel_major, 0)); class_unregister(wheel_class); class_destroy(wheel_class); unregister_chrdev(wheel_major, DEVICE_NAME); printk("wheel module exit.\n"); }
static int wifi_power_remove(struct platform_device *pdev) { unregister_chrdev_region(wifi_power_devno,1); class_unregister(&wifi_power_class); device_destroy(NULL, wifi_power_devno); cdev_del(wifi_power_cdev); return 0; }
void cleanup_module(void) { device_destroy(projectdriverClass, MKDEV(majorNumber, 0)); class_unregister(projectdriverClass); class_destroy(projectdriverClass); unregister_chrdev(majorNumber, DEVICE_NAME); printk(KERN_INFO "Goodbye From Brett and Julian\n"); }
static void __exit motor_exit(void) { class_unregister(motor_class); /*free the gpio_pins*/ // for (i=0; i < }
static void __exit ultrasonic_exit(void) { device_destroy(ultrasonic_class, MKDEV(ultrasonic_major, 0)); class_unregister(ultrasonic_class); class_destroy(ultrasonic_class); unregister_chrdev(ultrasonic_major, DEVICE_NAME); printk("ultrasonic module exit.\n"); }
static void __exit simlock_exit(void) { device_destroy(simlock_class, MKDEV(SIMLOCK_MAJOR, 0)); class_unregister(simlock_class); class_destroy(simlock_class); unregister_chrdev(SIMLOCK_MAJOR, DEVICE_NAME); printk(KERN_INFO "simlock_exit: un-registered module ok\n"); }
static void __exit htc_fingerprint_exit(void) { device_destroy(htc_fingerprint_class, MKDEV(htc_fingerprint_major, 0)); class_unregister(htc_fingerprint_class); class_destroy(htc_fingerprint_class); unregister_chrdev(htc_fingerprint_major, DEVICE_NAME); PDEBUG("un-registered module ok"); }
static void __exit fir_exit(void) { device_destroy(fir_class,MKDEV(fir_major, 0)); class_unregister(fir_class); class_destroy(fir_class); unregister_chrdev(fir_major,DEVICE_NAME); printk("fir module exit!"); }
/** @brief The LKM cleanup function * Similar to the initialization function, it is static. The __exit macro notifies that if this * code is used for a built-in driver (not a LKM) that this function is not required. */ static void __exit ebbchar_exit(void){ mutex_destroy(&ebbchar_mutex); /// destroy the dynamically-allocated mutex device_destroy(ebbcharClass, MKDEV(majorNumber, 0)); // remove the device class_unregister(ebbcharClass); // unregister the device class class_destroy(ebbcharClass); // remove the device class unregister_chrdev(majorNumber, DEVICE_NAME); // unregister the major number printk(KERN_INFO "EBBChar: Goodbye from the LKM!\n"); }
int __init watchdog_dev_init(void) { int err; struct sched_param param = {.sched_priority = MAX_RT_PRIO - 1,}; watchdog_kworker = kthread_create_worker(0, "watchdogd"); if (IS_ERR(watchdog_kworker)) { pr_err("Failed to create watchdog kworker\n"); return PTR_ERR(watchdog_kworker); } sched_setscheduler(watchdog_kworker->task, SCHED_FIFO, ¶m); err = class_register(&watchdog_class); if (err < 0) { pr_err("couldn't register class\n"); goto err_register; } err = alloc_chrdev_region(&watchdog_devt, 0, MAX_DOGS, "watchdog"); if (err < 0) { pr_err("watchdog: unable to allocate char dev region\n"); goto err_alloc; } return 0; err_alloc: class_unregister(&watchdog_class); err_register: kthread_destroy_worker(watchdog_kworker); return err; } /* * watchdog_dev_exit: exit dev part of watchdog core * * Release the range of chardev nodes used for watchdog devices */ void __exit watchdog_dev_exit(void) { unregister_chrdev_region(watchdog_devt, MAX_DOGS); class_unregister(&watchdog_class); kthread_destroy_worker(watchdog_kworker); }
static void hello_exit(void) { printk("\n Device is Released or closed \n"); device_destroy(my_class,MKDEV(major_no,0)); class_unregister(my_class); class_destroy(my_class); unregister_chrdev(major_no, DEVICE_NAME); printk("\n===============================================================\n"); }
static void __exit char_exit(void) { printk( KERN_INFO "char_test, called char_init"); device_destroy( ppl_class, MKDEV( dev_major, 0)); class_unregister( ppl_class ); class_destroy( ppl_class ); unregister_chrdev( dev_major, DEVICE_NAME ); }
static void __exit htc_sdservice_exit(void) { device_destroy(htc_sdservice_class, MKDEV(htc_sdservice_major, 0)); class_unregister(htc_sdservice_class); class_destroy(htc_sdservice_class); unregister_chrdev(htc_sdservice_major, DEVICE_NAME); kfree(htc_sdkey); PDEBUG("un-registered module ok\n"); }