static void bq27541_battery_sysdev_ctrl_exit(void) { sysdev_remove_file(&bq27541_battery_device, &attr_battery_id); sysdev_remove_file(&bq27541_battery_device, &attr_battery_current); sysdev_remove_file(&bq27541_battery_device, &attr_battery_voltage); sysdev_remove_file(&bq27541_battery_device, &attr_battery_temperature); sysdev_remove_file(&bq27541_battery_device, &attr_battery_capacity); sysdev_remove_file(&bq27541_battery_device, &attr_battery_mAH); sysdev_remove_file(&bq27541_battery_device, &attr_battery_voltage_thresholds); sysdev_remove_file(&bq27541_battery_device, &attr_battery_polling_intervals); sysdev_remove_file(&bq27541_battery_device, &attr_battery_temp_thresholds); sysdev_remove_file(&bq27541_battery_device, &attr_battery_i2c_address); sysdev_remove_file(&bq27541_battery_device, &attr_battery_error); sysdev_remove_file(&bq27541_battery_device, &attr_battery_suspend_current); sysdev_remove_file(&bq27541_battery_device, &attr_battery_current_diags); sysdev_remove_file(&bq27541_battery_device, &attr_battery_suspend_current_diags); sysdev_remove_file(&bq27541_battery_device, &attr_battery_cycl); sysdev_remove_file(&bq27541_battery_device, &attr_battery_lmd); sysdev_remove_file(&bq27541_battery_device, &attr_battery_cyct); sysdev_remove_file(&bq27541_battery_device, &attr_resume_stats); sysdev_remove_file(&bq27541_battery_device, &attr_battreg); sysdev_remove_file(&bq27541_battery_device, &attr_battreg_value); sysdev_unregister(&bq27541_battery_device); sysdev_class_unregister(&bq27541_battery_sysclass); }
/** * cmm_sysfs_register - Register with sysfs * * Return value: * 0 on success / other on failure **/ static int cmm_sysfs_register(struct sys_device *sysdev) { int i, rc; if ((rc = sysdev_class_register(&cmm_sysdev_class))) return rc; sysdev->id = 0; sysdev->cls = &cmm_sysdev_class; if ((rc = sysdev_register(sysdev))) goto class_unregister; for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++) { if ((rc = sysdev_create_file(sysdev, cmm_attrs[i]))) goto fail; } return 0; fail: while (--i >= 0) sysdev_remove_file(sysdev, cmm_attrs[i]); sysdev_unregister(sysdev); class_unregister: sysdev_class_unregister(&cmm_sysdev_class); return rc; }
static void dvfs_sysdev_ctrl_exit(void) { sysdev_remove_file(&dvfs_device, &attr_enable); sysdev_remove_file(&dvfs_device, &attr_status); sysdev_unregister(&dvfs_device); sysdev_class_unregister(&dvfs_sysclass); }
/* * sysdev_class_unregister() * * unregister the 'edac' from /sys/devices/system */ static void edac_unregister_sysfs_edac_name(void) { /* only if currently registered, then unregister it */ if (edac_class_valid) sysdev_class_unregister(&edac_class); edac_class_valid = 0; }
/** * cmm_unregister_sysfs - Unregister from sysfs * **/ static void cmm_unregister_sysfs(struct sys_device *sysdev) { int i; for (i = 0; i < ARRAY_SIZE(cmm_attrs); i++) sysdev_remove_file(sysdev, cmm_attrs[i]); sysdev_unregister(sysdev); sysdev_class_unregister(&cmm_sysdev_class); }
static __exit void unregister_balloon(struct sys_device *sysdev) { int i; sysfs_remove_group(&sysdev->kobj, &balloon_info_group); for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) sysdev_remove_file(sysdev, balloon_attrs[i]); sysdev_unregister(sysdev); sysdev_class_unregister(&balloon_sysdev_class); }
static void bootstrap_exit(void) { kfree(save_buffer); sysdev_driver_unregister(&mioa701_sysclass, &driver_bootstrap); sysdev_unregister(&sysdev_bootstrap); sysdev_class_unregister(&mioa701_sysclass); printk(KERN_CRIT "Unregistering mioa701 suspend will hang next" "resume !!!\n"); }
static int __init init_sysfs(void) { int error; error = sysdev_class_register(&oprofile_sysclass); if (error) return error; error = sysdev_register(&device_oprofile); if (error) sysdev_class_unregister(&oprofile_sysclass); return error; }
/* * MC teardown: * the '..../edac/mc' kobject followed by '..../edac' itself */ static void edac_sysfs_memctrl_teardown(void) { debugf0("MC: " __FILE__ ": %s()\n", __func__); /* Unregister the MC's kobject and wait for reference count to reach * 0. */ init_completion(&edac_memctrl_kobj_complete); kobject_unregister(&edac_memctrl_kobj); wait_for_completion(&edac_memctrl_kobj_complete); /* Unregister the 'edac' object */ sysdev_class_unregister(&edac_class); }
/* * MSM LED Trigger Sys Device Register * * 1. Torch Mode * enable: $ echo "1" > /sys/devices/system/led-flash/led-flash0/torch * disable: $ echo "0" > /sys/devices/system/led-flash/led-flash0/torch * * 2. Flash Mode * enable: $ echo "1" > /sys/devices/system/led-flash/led-flash0/flash * disable: $ echo "0" > /sys/devices/system/led-flash/led-flash0/flash */ static int32_t msm_led_trigger_register_sysdev(struct msm_led_flash_ctrl_t *fctrl) { int32_t i, rc; rc = sysdev_class_register(&msm_led_trigger_sysdev_class); if (rc) { return rc; } msm_led_trigger_sysdev.id = 0; msm_led_trigger_sysdev.cls = &msm_led_trigger_sysdev_class; rc = sysdev_register(&msm_led_trigger_sysdev); if (rc) { sysdev_class_unregister(&msm_led_trigger_sysdev_class); return rc; } for (i = 0; i < ARRAY_SIZE(msm_led_trigger_sysdev_attrs); ++i) { rc = sysdev_create_file(&msm_led_trigger_sysdev, msm_led_trigger_sysdev_attrs[i]); if (rc) { goto msm_led_trigger_register_sysdev_failed; } } msm_led_trigger_sysdev_fctrl = fctrl; return 0; msm_led_trigger_register_sysdev_failed: while (--i >= 0) sysdev_remove_file(&msm_led_trigger_sysdev, msm_led_trigger_sysdev_attrs[i]); sysdev_unregister(&msm_led_trigger_sysdev); sysdev_class_unregister(&msm_led_trigger_sysdev_class); return rc; }
/* * Sys device register * * sysdev file: * * /sys/devices/system/zte_ftm/zte_ftm0/fusion * /sys/devices/system/zte_ftm/zte_ftm0/simlocking */ static int32_t ftm_register_sysdev(struct sys_device *sysdev) { int32_t ret; int32_t i; ret = sysdev_class_register(&ftm_sysdev_class); if (ret) { return ret; } sysdev->id = 0; sysdev->cls = &ftm_sysdev_class; ret = sysdev_register(sysdev); if (ret) { sysdev_class_unregister(&ftm_sysdev_class); return ret; } for (i = 0; i < ARRAY_SIZE(ftm_attrs); i++) { ret = sysdev_create_file(sysdev, ftm_attrs[i]); if (ret) { goto ftm_fail; } } return 0; ftm_fail: while (--i >= 0) sysdev_remove_file(sysdev, ftm_attrs[i]); sysdev_unregister(sysdev); sysdev_class_unregister(&ftm_sysdev_class); return ret; }
static int __init register_balloon(struct sys_device *sysdev) { int i, error; error = sysdev_class_register(&balloon_sysdev_class); if (error) return error; sysdev->id = 0; sysdev->cls = &balloon_sysdev_class; error = sysdev_register(sysdev); if (error) { sysdev_class_unregister(&balloon_sysdev_class); return error; } for (i = 0; i < ARRAY_SIZE(balloon_attrs); i++) { error = sysdev_create_file(sysdev, balloon_attrs[i]); if (error) goto fail; } error = sysfs_create_group(&sysdev->kobj, &balloon_info_group); if (error) goto fail; return 0; fail: while (--i >= 0) sysdev_remove_file(sysdev, balloon_attrs[i]); sysdev_unregister(sysdev); sysdev_class_unregister(&balloon_sysdev_class); return error; }
/** * pseries_suspend_sysfs_register - Register with sysfs * * Return value: * 0 on success / other on failure **/ static int pseries_suspend_sysfs_register(struct sys_device *sysdev) { int rc; if ((rc = sysdev_class_register(&suspend_sysdev_class))) return rc; sysdev->id = 0; sysdev->cls = &suspend_sysdev_class; if ((rc = sysdev_class_create_file(&suspend_sysdev_class, &attr_hibernate))) goto class_unregister; return 0; class_unregister: sysdev_class_unregister(&suspend_sysdev_class); return rc; }
static void __exit msm_show_resume_irq_exit(void) { sysdev_unregister(&msm_show_resume_irq_device); sysdev_class_unregister(&msm_show_resume_irq_sysclass); }
/* * tbase_ioctl: * a user space program can drive the test functions * through a call to ioctl once the correct file * descriptor has been attained */ static int tbase_ioctl(struct inode *ino, struct file *f, unsigned int cmd, unsigned long l) { int rc; tmod_interface_t tif; caddr_t *inparms; caddr_t *outparms; printk("Enter tbase_ioctl\n"); inparms = NULL; outparms = NULL; rc = 0; /* * the following calls are used to setup the * parameters that might need to be passed * between user and kernel space, using the tif * pointer that is passed in as the last * parameter to the ioctl * */ if (copy_from_user(&tif, (void *)l, sizeof(tif))) { /* Bad address */ return(-EFAULT); } /* * Setup inparms and outparms as needed */ if (tif.in_len > 0) { inparms = (caddr_t *)kmalloc(tif.in_len, GFP_KERNEL); if (!inparms) { return(-ENOMEM); } rc = copy_from_user(inparms, tif.in_data, tif.in_len); if (rc) { kfree(inparms); return(-EFAULT); } } if (tif.out_len > 0) { outparms = (caddr_t *)kmalloc(tif.out_len, GFP_KERNEL); if (!outparms) { kfree(inparms); return(-ENOMEM); } } /* * Use a switch statement to determine which function * to call, based on the cmd flag that is specified * in user space. Pass in inparms or outparms as * needed * */ switch(cmd) { case REG_DEVICE: rc = test_device_register(); break; case UNREG_DEVICE: rc = test_device_unregister(); break; case BUS_ADD: rc = test_bus_add(); break; case GET_DRV: rc = test_get_drv(); break; case PUT_DRV: rc = test_put_drv(); break; case REG_FIRM: rc = test_reg_firm(); break; case CREATE_FILE: rc = test_create_file(); break; case DEV_SUSPEND: rc = test_dev_suspend(); break; case DEV_FILE: rc = test_dev_file(); break; case BUS_RESCAN: rc = test_bus_rescan(); break; case BUS_FILE: rc = test_bus_file(); break; case CLASS_REG: rc = test_class_reg(); break; case CLASS_UNREG: class_unregister(&test_class); break; case CLASS_GET: rc = test_class_get(); break; case CLASS_FILE: rc = test_class_file(); break; case CLASSDEV_REG: rc = test_classdev_reg(); break; case CLASSINT_REG: rc = test_classint_reg(); break; case SYSDEV_CLS_REG: rc = test_sysdev_cls_reg(); break; case SYSDEV_CLS_UNREG: sysdev_class_unregister(&test_sysclass); break; case SYSDEV_REG: rc = test_sysdev_reg(); break; case SYSDEV_UNREG: sys_device_unregister(&test_sys_device); break; default: printk("tbase: Mismatching ioctl command\n"); break; } /* * copy in the test return code, the reason we * this is so that in user space we can tell the * difference between an error in one of our test * calls or an error in the ioctl function */ tif.out_rc = rc; rc = 0; /* * setup the rest of tif pointer for returning to * to user space, using copy_to_user if needed */ /* if outparms then copy outparms into tif.out_data */ if (outparms) { if (copy_to_user(tif.out_data, outparms, tif.out_len)) { printk("tbase: Unsuccessful copy_to_user of outparms\n"); rc = -EFAULT; } } /* copy tif structure into l so that can be used by user program */ if (copy_to_user((void*)l, &tif, sizeof(tif))) { printk("tbase: Unsuccessful copy_to_user of tif\n"); rc = -EFAULT; } /* * free inparms and outparms */ if (inparms) { kfree(inparms); } if (outparms) { kfree(outparms); } return rc; }
static void mx50_accessory_sysdev_ctrl_exit(void) { sysdev_remove_file(&mx50_accessory_device, &attr_mx50_accessory_state); sysdev_unregister(&mx50_accessory_device); sysdev_class_unregister(&mx50_accessory_sysclass); }
void edac_put_sysfs_class(void) { /* last user unregisters it */ if (atomic_dec_and_test(&edac_class_valid)) sysdev_class_unregister(&edac_class); }
static void rtl_teardown_sysfs(void) { int i; for (i = 0; rtl_attributes[i]; i ++) sysdev_class_remove_file(&class_rtl, rtl_attributes[i]); sysdev_class_unregister(&class_rtl); }
static void exit_sysfs(void) { sysdev_unregister(&device_oprofile); sysdev_class_unregister(&oprofile_sysclass); }
static void __exit hw_lradc_exit(void) { platform_driver_unregister(&mxs_lradc_drv); sysdev_class_unregister(&mxs_lradc_sysclass); }
/* * First routine called when the kernel module is loaded */ static int __init tf_device_register(void) { int error; struct tf_device *dev = &g_tf_dev; dprintk(KERN_INFO "tf_device_register()\n"); /* * Initialize the device */ dev->dev_number = MKDEV(device_major_number, TF_DEVICE_MINOR_NUMBER); cdev_init(&dev->cdev, &g_tf_device_file_ops); dev->cdev.owner = THIS_MODULE; g_tf_sysdev.id = 0; g_tf_sysdev.cls = &g_tf_device_sys_class; INIT_LIST_HEAD(&dev->connection_list); spin_lock_init(&dev->connection_list_lock); #if defined(MODULE) && defined(CONFIG_TF_ZEBRA) error = (*tf_comm_early_init)(); if (error) goto module_early_init_failed; error = tf_device_mshield_init(smc_mem); if (error) goto mshield_init_failed; #ifdef CONFIG_TF_DRIVER_CRYPTO_FIPS error = tf_crypto_hmac_module_init(); if (error) goto hmac_init_failed; error = tf_self_test_register_device(); if (error) goto self_test_register_device_failed; #endif #endif /* register the sysfs object driver stats */ error = kobject_init_and_add(&dev->kobj, &tf_ktype, NULL, "%s", TF_DEVICE_BASE_NAME); if (error) { printk(KERN_ERR "tf_device_register(): " "kobject_init_and_add failed (error %d)!\n", error); kobject_put(&dev->kobj); goto kobject_init_and_add_failed; } /* * Register the system device. */ error = sysdev_class_register(&g_tf_device_sys_class); if (error != 0) { printk(KERN_ERR "tf_device_register():" " sysdev_class_register failed (error %d)!\n", error); goto sysdev_class_register_failed; } error = sysdev_register(&g_tf_sysdev); if (error != 0) { dprintk(KERN_ERR "tf_device_register(): " "sysdev_register failed (error %d)!\n", error); goto sysdev_register_failed; } /* * Register the char device. */ printk(KERN_INFO "Registering char device %s (%u:%u)\n", TF_DEVICE_BASE_NAME, MAJOR(dev->dev_number), MINOR(dev->dev_number)); error = register_chrdev_region(dev->dev_number, 1, TF_DEVICE_BASE_NAME); if (error != 0) { printk(KERN_ERR "tf_device_register():" " register_chrdev_region failed (error %d)!\n", error); goto register_chrdev_region_failed; } error = cdev_add(&dev->cdev, dev->dev_number, 1); if (error != 0) { printk(KERN_ERR "tf_device_register(): " "cdev_add failed (error %d)!\n", error); goto cdev_add_failed; } /* * Initialize the communication with the Secure World. */ #ifdef CONFIG_TF_TRUSTZONE dev->sm.soft_int_irq = soft_interrupt; #endif error = tf_init(&g_tf_dev.sm); if (error != S_SUCCESS) { dprintk(KERN_ERR "tf_device_register(): " "tf_init failed (error %d)!\n", error); goto init_failed; } #ifdef CONFIG_TF_DRIVER_CRYPTO_FIPS error = tf_self_test_post_init(&(dev_stats->kobj)); /* N.B. error > 0 indicates a POST failure, which will not prevent the module from loading. */ if (error < 0) { dprintk(KERN_ERR "tf_device_register(): " "tf_self_test_post_vectors failed (error %d)!\n", error); goto post_failed; } #endif #ifdef CONFIG_ANDROID tf_class = class_create(THIS_MODULE, TF_DEVICE_BASE_NAME); device_create(tf_class, NULL, dev->dev_number, NULL, TF_DEVICE_BASE_NAME); #endif #ifdef CONFIG_TF_ZEBRA /* * Initializes the /dev/tf_ctrl device node. */ error = tf_ctrl_device_register(); if (error) goto ctrl_failed; #endif #ifdef CONFIG_TF_DRIVER_DEBUG_SUPPORT address_cache_property((unsigned long) &tf_device_register); #endif /* * Successful completion. */ dprintk(KERN_INFO "tf_device_register(): Success\n"); return 0; /* * Error: undo all operations in the reverse order */ #ifdef CONFIG_TF_ZEBRA ctrl_failed: #endif #ifdef CONFIG_TF_DRIVER_CRYPTO_FIPS tf_self_test_post_exit(); post_failed: #endif init_failed: cdev_del(&dev->cdev); cdev_add_failed: unregister_chrdev_region(dev->dev_number, 1); register_chrdev_region_failed: sysdev_unregister(&g_tf_sysdev); sysdev_register_failed: sysdev_class_unregister(&g_tf_device_sys_class); sysdev_class_register_failed: kobject_init_and_add_failed: kobject_del(&g_tf_dev.kobj); #if defined(MODULE) && defined(CONFIG_TF_ZEBRA) #ifdef CONFIG_TF_DRIVER_CRYPTO_FIPS tf_self_test_unregister_device(); self_test_register_device_failed: tf_crypto_hmac_module_exit(); hmac_init_failed: #endif tf_device_mshield_exit(); mshield_init_failed: module_early_init_failed: #endif dprintk(KERN_INFO "tf_device_register(): Failure (error %d)\n", error); return error; }
static void __exit exit_driverfs(void) { sysdev_unregister(&device_oprofile); sysdev_class_unregister(&oprofile_sysclass); }