本文整理汇总了C++中cdev_del函数的典型用法代码示例。如果您正苦于以下问题:C++ cdev_del函数的具体用法?C++ cdev_del怎么用?C++ cdev_del使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cdev_del函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sstore_init
static int __init sstore_init (void)
{
int i;
int rv;
if(alloc_chrdev_region(&sstore_dev_number,
sstore_minor, NUM_SSTORE_DEVICES, DEV_NAME) < 0){
printk(KERN_DEBUG "sstore: unable to register device.\n");
rv = -EPERM;
goto init_out;
}
sstore_major = MAJOR(sstore_dev_number);
sstore_class = class_create(THIS_MODULE, DEV_NAME);
for(i = 0; i < NUM_SSTORE_DEVICES; ++i){
/* Allocate memory for the per-device structure */
sstore_devp[i] = kmalloc(sizeof(struct sstore_dev), GFP_KERNEL);
if (!sstore_devp[i]){
printk(KERN_DEBUG "sstore: bad kmalloc\n");
rv = -ENOMEM;
goto no_devs;
}
sstore_devp[i]->open_count = 0;
sstore_devp[i]->read_count = 0;
sstore_devp[i]->write_count = 0;
sstore_devp[i]->del_count = 0;
sstore_devp[i]->sstore_number = i;
sstore_devp[i]->sstore_blobp = kzalloc(num_of_blobs *
sizeof(struct sstore_dev *), GFP_KERNEL);
if (!sstore_devp[i]->sstore_blobp){
printk(KERN_DEBUG "sstore: bad kzalloc\n");
rv = -ENOMEM;
goto no_blobs;
}
/* Init lock(s) */
mutex_init(&sstore_devp[i]->sstore_lock);
init_waitqueue_head(&sstore_devp[i]->sstore_wq);
/* Connect the file operations with the cdev */
cdev_init(&sstore_devp[i]->cdev, &sstore_fops);
sstore_devp[i]->cdev.owner = THIS_MODULE;
/* Connect the major/minor number to the cdev */
rv = cdev_add(&sstore_devp[i]->cdev,
MKDEV(sstore_major, sstore_minor + i), 1);
if (rv) {
printk(KERN_DEBUG "sstore: bad cdev\n");
goto no_cdev_connection;
}
/* Send uevents to udev, so it'll create /dev nodes */
device_create(sstore_class, NULL,
MKDEV(sstore_major, sstore_minor + i), "sstore%d", i);
}
rv = sstore_proc_init();
if(rv){
printk(KERN_DEBUG "sstore: unable to init /proc files.\n");
goto no_proc_files;
}
printk(KERN_INFO "sstore: driver initialized.\n");
return 0;
/* Evil goto error handling. */
no_proc_files:
for(; i >=0; --i){
device_destroy (sstore_class, MKDEV(sstore_major, sstore_minor + i));
cdev_del(&sstore_devp[i]->cdev);
no_cdev_connection:
kfree(sstore_devp[i]->sstore_blobp);
no_blobs:
kfree(sstore_devp[i]);
no_devs:
continue;
}
class_destroy(sstore_class);
init_out:
return rv;
}
开发者ID:cboylan,项目名称:device_drivers,代码行数:85,代码来源:sstore.c
示例2: vc_mem_connected_init
void
vc_mem_connected_init(void)
{
int rc = -EFAULT;
struct device *dev;
LOG_DBG("%s: called", __func__);
vc_mem_get_size();
printk("vc-mem: mm_vc_mem_phys_addr = 0x%08lx\n", mm_vc_mem_phys_addr);
printk("vc-mem: mm_vc_mem_size = 0x%08x (%u MiB)\n",
mm_vc_mem_size, mm_vc_mem_size / (1024 * 1024));
if ((rc = alloc_chrdev_region(&vc_mem_devnum, 0, 1, DRIVER_NAME)) < 0) {
LOG_ERR("%s: alloc_chrdev_region failed (rc=%d)", __func__, rc);
goto out_err;
}
cdev_init(&vc_mem_cdev, &vc_mem_fops);
if ((rc = cdev_add(&vc_mem_cdev, vc_mem_devnum, 1)) != 0) {
LOG_ERR("%s: cdev_add failed (rc=%d)", __func__, rc);
goto out_unregister;
}
vc_mem_class = class_create(THIS_MODULE, DRIVER_NAME);
if (IS_ERR(vc_mem_class)) {
rc = PTR_ERR(vc_mem_class);
LOG_ERR("%s: class_create failed (rc=%d)", __func__, rc);
goto out_cdev_del;
}
dev = device_create(vc_mem_class, NULL, vc_mem_devnum, NULL,
DRIVER_NAME);
if (IS_ERR(dev)) {
rc = PTR_ERR(dev);
LOG_ERR("%s: device_create failed (rc=%d)", __func__, rc);
goto out_class_destroy;
}
vc_mem_proc_entry = create_proc_entry(DRIVER_NAME, 0444, NULL);
if (vc_mem_proc_entry == NULL) {
rc = -EFAULT;
LOG_ERR("%s: create_proc_entry failed", __func__);
goto out_device_destroy;
}
vc_mem_proc_entry->read_proc = vc_mem_proc_read;
vc_mem_proc_entry->write_proc = vc_mem_proc_write;
vc_mem_inited = 1;
return;
out_device_destroy:
device_destroy(vc_mem_class, vc_mem_devnum);
out_class_destroy:
class_destroy(vc_mem_class);
vc_mem_class = NULL;
out_cdev_del:
cdev_del(&vc_mem_cdev);
out_unregister:
unregister_chrdev_region(vc_mem_devnum, 1);
out_err:
return;
}
开发者ID:KiwiSteve,项目名称:broadcom-kernel-raspberry-pi,代码行数:68,代码来源:vc_mem.c
示例3: globalfifo_exit
void globalfifo_exit(void)
{
cdev_del(&globalfifo_devp->cdev);
kfree(globalfifo_devp);
unregister_chrdev_region(MKDEV(globalfifo_major, 0), 1);
}
开发者ID:liuyang201666,项目名称:akae_sdk,代码行数:6,代码来源:block_another.c
示例4: WMT_init
static int WMT_init(void)
{
dev_t devID = MKDEV(gWmtMajor, 0);
INT32 cdevErr = -1;
INT32 ret = -1;
WMT_INFO_FUNC("WMT Version= %s DATE=%s\n" , MTK_WMT_VERSION, MTK_WMT_DATE);
/* Prepare a UCHAR device */
/*static allocate chrdev*/
stp_drv_init();
ret = register_chrdev_region(devID, WMT_DEV_NUM, WMT_DRIVER_NAME);
if (ret) {
WMT_ERR_FUNC("fail to register chrdev\n");
return ret;
}
cdev_init(&gWmtCdev, &gWmtFops);
gWmtCdev.owner = THIS_MODULE;
cdevErr = cdev_add(&gWmtCdev, devID, WMT_DEV_NUM);
if (cdevErr) {
WMT_ERR_FUNC("cdev_add() fails (%d) \n", cdevErr);
goto error;
}
WMT_INFO_FUNC("driver(major %d) installed \n", gWmtMajor);
#if 0
pWmtDevCtx = wmt_drv_create();
if (!pWmtDevCtx) {
WMT_ERR_FUNC("wmt_drv_create() fails \n");
goto error;
}
ret = wmt_drv_init(pWmtDevCtx);
if (ret) {
WMT_ERR_FUNC("wmt_drv_init() fails (%d) \n", ret);
goto error;
}
WMT_INFO_FUNC("stp_btmcb_reg\n");
wmt_cdev_btmcb_reg();
ret = wmt_drv_start(pWmtDevCtx);
if (ret) {
WMT_ERR_FUNC("wmt_drv_start() fails (%d) \n", ret);
goto error;
}
#endif
ret = wmt_lib_init();
if (ret) {
WMT_ERR_FUNC("wmt_lib_init() fails (%d) \n", ret);
goto error;
}
#if CFG_WMT_DBG_SUPPORT
wmt_dev_dbg_setup();
#endif
#if defined(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OPEN)
WMT_INFO_FUNC("wmt_dev_tm_setup\n");
wmt_dev_tm_setup();
mtk_wcn_hif_sdio_update_cb_reg(wmt_dev_tra_sdio_update);
#endif
WMT_INFO_FUNC("success \n");
return 0;
error:
wmt_lib_deinit();
#if CFG_WMT_DBG_SUPPORT
wmt_dev_dbg_remove();
#endif
if (cdevErr == 0) {
cdev_del(&gWmtCdev);
}
if (ret == 0) {
unregister_chrdev_region(devID, WMT_DEV_NUM);
gWmtMajor = -1;
}
WMT_ERR_FUNC("fail \n");
return -1;
}
开发者ID:agrloki,项目名称:android_kernel_ousheng_V9,代码行数:86,代码来源:wmt_dev.c
示例5: second_exit
/*模块卸载函数*/
void second_exit(void)
{
cdev_del(&second_devp->cdev); /*注销cdev*/
kfree(second_devp); /*释放设备结构体内存*/
unregister_chrdev_region(MKDEV(second_major, 0), 1); /*释放设备号*/
}
开发者ID:nsood,项目名称:LinuxDriver_CodeList,代码行数:7,代码来源:second.c
示例6: frandom_init_module
static int frandom_init_module(void)
{
int result;
/* The buffer size MUST be at least 256 bytes, because we assume that
minimal length in init_rand_state().
*/
if (frandom_bufsize < 256) {
printk(KERN_ERR "frandom: Refused to load because frandom_bufsize=%d < 256\n",frandom_bufsize);
return -EINVAL;
}
if ((frandom_chunklimit != 0) && (frandom_chunklimit < 256)) {
printk(KERN_ERR "frandom: Refused to load because frandom_chunklimit=%d < 256 and != 0\n",frandom_chunklimit);
return -EINVAL;
}
erandom_state = kmalloc(sizeof(struct frandom_state), GFP_KERNEL);
if (!erandom_state)
return -ENOMEM;
/* This specific buffer is only used for seeding, so we need
256 bytes exactly */
erandom_state->buf = kmalloc(256, GFP_KERNEL);
if (!erandom_state->buf) {
kfree(erandom_state);
return -ENOMEM;
}
sema_init(&erandom_state->sem, 1); /* Init semaphore as a mutex */
erandom_seeded = 0;
frandom_class = class_create(THIS_MODULE, "fastrng");
if (IS_ERR(frandom_class)) {
result = PTR_ERR(frandom_class);
printk(KERN_WARNING "frandom: Failed to register class fastrng\n");
goto error0;
}
/*
* Register your major, and accept a dynamic number. This is the
* first thing to do, in order to avoid releasing other module's
* fops in frandom_cleanup_module()
*/
cdev_init(&frandom_cdev, &frandom_fops);
frandom_cdev.owner = THIS_MODULE;
result = cdev_add(&frandom_cdev, MKDEV(frandom_major, frandom_minor), 1);
if (result) {
printk(KERN_WARNING "frandom: Failed to add cdev for /dev/frandom\n");
goto error1;
}
result = register_chrdev_region(MKDEV(frandom_major, frandom_minor), 1, "/dev/frandom");
if (result < 0) {
printk(KERN_WARNING "frandom: can't get major/minor %d/%d\n", frandom_major, frandom_minor);
goto error2;
}
frandom_device = device_create(frandom_class, NULL, MKDEV(frandom_major, frandom_minor), NULL, "frandom");
if (IS_ERR(frandom_device)) {
printk(KERN_WARNING "frandom: Failed to create frandom device\n");
goto error3;
}
cdev_init(&erandom_cdev, &frandom_fops);
erandom_cdev.owner = THIS_MODULE;
result = cdev_add(&erandom_cdev, MKDEV(frandom_major, erandom_minor), 1);
if (result) {
printk(KERN_WARNING "frandom: Failed to add cdev for /dev/erandom\n");
goto error4;
}
result = register_chrdev_region(MKDEV(frandom_major, erandom_minor), 1, "/dev/erandom");
if (result < 0) {
printk(KERN_WARNING "frandom: can't get major/minor %d/%d\n", frandom_major, erandom_minor);
goto error5;
}
erandom_device = device_create(frandom_class, NULL, MKDEV(frandom_major, erandom_minor), NULL, "erandom");
if (IS_ERR(erandom_device)) {
printk(KERN_WARNING "frandom: Failed to create erandom device\n");
goto error6;
}
return 0; /* succeed */
error6:
unregister_chrdev_region(MKDEV(frandom_major, erandom_minor), 1);
error5:
cdev_del(&erandom_cdev);
error4:
device_destroy(frandom_class, MKDEV(frandom_major, frandom_minor));
error3:
unregister_chrdev_region(MKDEV(frandom_major, frandom_minor), 1);
error2:
cdev_del(&frandom_cdev);
error1:
class_destroy(frandom_class);
//.........这里部分代码省略.........
开发者ID:BlackSoulxxx,项目名称:XerXes,代码行数:101,代码来源:frandom.c
示例7: simple_cleanup
static void simple_cleanup(void)
{
cdev_del(SimpleDevs);
cdev_del(SimpleDevs + 1);
unregister_chrdev_region(MKDEV(simple_major, 0), 2);
}
开发者ID:yushu9,项目名称:linux_kernel_driver,代码行数:6,代码来源:simple.c
示例8: tf_device_register
//.........这里部分代码省略.........
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(&(g_tf_dev.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:
unregister_syscore_ops(&g_tf_device_syscore_ops);
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;
}
开发者ID:aicjofs,项目名称:android_kernel_fuhu_t8400n,代码行数:101,代码来源:tf_device.c
示例9: hello_driver_exit
__exit static void hello_driver_exit (void)
{
unregister_chrdev_region (MKDEV(major, minor), 1) ;
cdev_del (&hello_cdev) ;
printk(KERN_ALERT"cleanup module\r\n") ;
}
开发者ID:kk821521286,项目名称:kangkai,代码行数:6,代码来源:hello_driver.c
示例10: globalmem_exit
static void __exit globalmem_exit(void)
{
cdev_del(&globalmem_devp->cdev);
kfree(globalmem_devp);
unregister_chrdev_region(MKDEV(globalmem_major, 0), 1);
}
开发者ID:21cnbao,项目名称:training,代码行数:6,代码来源:globalmem.c
示例11: globalfifo_exit
void globalfifo_exit(void)
{
cdev_del(&devp->cdev);//注销cdev
kfree((void*)devp);//释放设备结构体内存
unregister_chrdev_region(MKDEV(globalfifo_major,0),1);//释放设备号
}
开发者ID:jefby,项目名称:LDD,代码行数:6,代码来源:globalfifo.c
示例12: hello_init
/*模块加载方法*/
static int __init hello_init(void){
int err = -1;
dev_t dev = 0;
struct device* temp = NULL;
printk(KERN_ALERT"Initializing hello device.\n");
/*动态分配主设备和从设备号*/
err = alloc_chrdev_region(&dev, 0, 1, HELLO_DEVICE_NODE_NAME);
if(err < 0) {
printk(KERN_ALERT"Failed to alloc char dev region.\n");
goto fail;
}
hello_major = MAJOR(dev);
hello_minor = MINOR(dev);
/*分配helo设备结构体变量*/
hello_dev = kmalloc(sizeof(struct hello_android_dev), GFP_KERNEL);
if(!hello_dev) {
err = -ENOMEM;
printk(KERN_ALERT"Failed to alloc hello_dev.\n");
goto unregister;
}
/*初始化设备*/
err = __hello_setup_dev(hello_dev);
if(err) {
printk(KERN_ALERT"Failed to setup dev: %d.\n", err);
goto cleanup;
}
/*在/sys/class/目录下创建设备类别目录hello*/
hello_class = class_create(THIS_MODULE, HELLO_DEVICE_CLASS_NAME);
if(IS_ERR(hello_class)) {
err = PTR_ERR(hello_class);
printk(KERN_ALERT"Failed to create hello class.\n");
goto destroy_cdev;
}
/*在/dev/目录和/sys/class/hello目录下分别创建设备文件hello*/
temp = device_create(hello_class, NULL, dev, "%s", HELLO_DEVICE_FILE_NAME);
if(IS_ERR(temp)) {
err = PTR_ERR(temp);
printk(KERN_ALERT"Failed to create hello device.");
goto destroy_class;
}
/*在/sys/class/hello/hello目录下创建属性文件val*/
err = device_create_file(temp, &dev_attr_val);
if(err < 0) {
printk(KERN_ALERT"Failed to create attribute val.");
goto destroy_device;
}
dev_set_drvdata(temp, hello_dev);
/*创建/proc/hello文件*/
hello_create_proc();
printk(KERN_ALERT"Succedded to initialize hello device.\n");
return 0;
destroy_device:
device_destroy(hello_class, dev);
destroy_class:
class_destroy(hello_class);
destroy_cdev:
cdev_del(&(hello_dev->dev));
cleanup:
kfree(hello_dev);
unregister:
unregister_chrdev_region(MKDEV(hello_major, hello_minor), 1);
fail:
return err;
}
开发者ID:dailianyu,项目名称:android,代码行数:82,代码来源:hello.c
示例13: dsps_probe
/**
* platform driver
*
*/
static int __devinit dsps_probe(struct platform_device *pdev)
{
int ret;
pr_debug("%s.\n", __func__);
if (pdev->dev.platform_data == NULL) {
pr_err("%s: platform data is NULL.\n", __func__);
return -ENODEV;
}
drv = kzalloc(sizeof(*drv), GFP_KERNEL);
if (drv == NULL) {
pr_err("%s: kzalloc fail.\n", __func__);
goto alloc_err;
}
atomic_set(&drv->crash_in_progress, 0);
drv->pdata = pdev->dev.platform_data;
drv->dev_class = class_create(THIS_MODULE, DRV_NAME);
if (drv->dev_class == NULL) {
pr_err("%s: class_create fail.\n", __func__);
goto res_err;
}
ret = alloc_chrdev_region(&drv->dev_num, 0, 1, DRV_NAME);
if (ret) {
pr_err("%s: alloc_chrdev_region fail.\n", __func__);
goto alloc_chrdev_region_err;
}
drv->dev = device_create(drv->dev_class, NULL,
drv->dev_num,
drv, DRV_NAME);
if (IS_ERR(drv->dev)) {
pr_err("%s: device_create fail.\n", __func__);
goto device_create_err;
}
drv->cdev = cdev_alloc();
if (drv->cdev == NULL) {
pr_err("%s: cdev_alloc fail.\n", __func__);
goto cdev_alloc_err;
}
cdev_init(drv->cdev, &dsps_fops);
drv->cdev->owner = THIS_MODULE;
ret = cdev_add(drv->cdev, drv->dev_num, 1);
if (ret) {
pr_err("%s: cdev_add fail.\n", __func__);
goto cdev_add_err;
}
ret = dsps_alloc_resources(pdev);
if (ret) {
pr_err("%s: failed to allocate dsps resources.\n", __func__);
goto cdev_add_err;
}
ret =
smsm_state_cb_register(SMSM_DSPS_STATE, SMSM_RESET,
dsps_smsm_state_cb, 0);
if (ret) {
pr_err("%s: smsm_state_cb_register fail %d\n", __func__,
ret);
goto smsm_register_err;
}
dsps_dev = subsys_register(&dsps_ssrops);
if (IS_ERR(dsps_dev)) {
ret = PTR_ERR(dsps_dev);
pr_err("%s: subsys_register fail %d\n", __func__,
ret);
goto ssr_register_err;
}
return 0;
ssr_register_err:
smsm_state_cb_deregister(SMSM_DSPS_STATE, SMSM_RESET,
dsps_smsm_state_cb,
0);
smsm_register_err:
cdev_del(drv->cdev);
cdev_add_err:
kfree(drv->cdev);
cdev_alloc_err:
device_destroy(drv->dev_class, drv->dev_num);
device_create_err:
unregister_chrdev_region(drv->dev_num, 1);
alloc_chrdev_region_err:
class_destroy(drv->dev_class);
res_err:
kfree(drv);
drv = NULL;
//.........这里部分代码省略.........
开发者ID:Arunvasu,项目名称:taoshan,代码行数:101,代码来源:msm_dsps.c
示例14: timing_dev_init
/* function called at module load time */
static int __init timing_dev_init(void) {
int i, rc;
dev_t dev_num;
#if DEBUG != 0
printk(KERN_DEBUG "timing_dev_init entry\n");
#endif
/* dynamically assign device number */
rc = alloc_chrdev_region(&dev_num, FIRST_MINOR,
TIMING_DEV_COUNT, MODULE_NAME);
if (rc) {
printk(KERN_ALERT "Error allocating dev numbers - timing.c\n");
return rc;
}
/* record major number */
timing_maj_num = MAJOR(dev_num);
/* set up individual data for each char dev */
/* for the 8 IO Ports */
for ( i = 0; i < TIMING_DEV_COUNT; i++ ) {
timing_card[i].offset = 0x00;
/* device number */
timing_card[i].num = MKDEV(timing_maj_num, FIRST_MINOR + i);
/* part of device that this addresses */
if ( i < TIMING_IOPORT_COUNT )
timing_card[i].component = PCI7300_ID;
else if ( i < TIMING_IOPORT_COUNT + TIMING_8254_COUNT )
timing_card[i].component = TIMER8254_ID;
else
timing_card[i].component = PLX9080_ID;
/* vital driver structures */
timing_card[i].driver = &timing_driver;
timing_card[i].fops = &timing_fops ;
/* set up actual cdev */
cdev_init(&timing_card[i].cdev, &timing_fops);
timing_card[i].cdev.owner = THIS_MODULE;
timing_card[i].cdev.ops = &timing_fops;
/* actual cdev registration */ /* magic # 1 is "count" */
rc = cdev_add(&timing_card[i].cdev, timing_card[i].num, 1);
if ( rc < 0 ) {
printk(KERN_ALERT "Error adding timing cdev %d to sys\n", i);
goto del_cdev;
}
} /* end data initialization for IO port loop */
#if DEBUG != 0
printk(KERN_DEBUG "timing_dev_init() exit success\n");
#endif
/* finally, register as pci dev */
/* END FLOW OF NORMAL OPERATION */
return pci_register_driver(&timing_driver);
/* ERROR HANDLING */
del_cdev:
/* unregister char drivers */
unregister_chrdev_region(dev_num, TIMING_DEV_COUNT);
/* delete the cdevs that succeeded (up to i) */
for ( ; !(i < 0); i-- )
cdev_del(&timing_card[i].cdev);
return rc;
} /* end timing_init */
开发者ID:kerb-huang,项目名称:timing_driver,代码行数:76,代码来源:timing.c
示例15: dev_release
/*文件释放函数*/
static int dev_release(struct inode *inode, struct file *filp){ cdev_del(&mydevice->cdev); /*注销cdev*/
printk(KERN_INFO "mydev closed!\n");
return 0;
}
开发者ID:nope8,项目名称:linux-driver,代码行数:6,代码来源:i2c.c
示例16: sk_exit
static void __exit sk_exit(void)
{
printk("The module is down...\n");
cdev_del(&sk_cdev);
unregister_chrdev_region(sk_dev, 1);
}
开发者ID:uvvu,项目名称:mds_edu,代码行数:6,代码来源:sk.c
示例17: globalfifo_exit
/*模块卸载函数*/
void globalfifo_exit(void)
{
cdev_del(&globalfifo_devp->cdev); /*注销cdev*/
kfree(globalfifo_devp); /*释放设备结构体内存*/
unregister_chrdev_region(MKDEV(globalfifo_major, 0), 1); /*释放设备号*/
}
开发者ID:LuckJC,项目名称:i-driver,代码行数:7,代码来源:globalfifo_async.c
示例18: wmt_detect_init
static int wmt_detect_init(void)
{
dev_t devID = MKDEV(gWmtDetectMajor, 0);
int cdevErr = -1;
int ret = -1;
ret = register_chrdev_region(devID, WMT_DETECT_DEV_NUM, WMT_DETECT_DRVIER_NAME);
if (ret) {
WMT_DETECT_ERR_FUNC("fail to register chrdev\n");
return ret;
}
cdev_init(&gWmtDetectCdev, &gWmtDetectFops);
gWmtDetectCdev.owner = THIS_MODULE;
cdevErr = cdev_add(&gWmtDetectCdev, devID, WMT_DETECT_DEV_NUM);
if (cdevErr) {
WMT_DETECT_ERR_FUNC("cdev_add() fails (%d) \n", cdevErr);
goto err1;
}
pDetectClass = class_create(THIS_MODULE, WMT_DETECT_DEVICE_NAME);
if(IS_ERR(pDetectClass))
{
WMT_DETECT_ERR_FUNC("class create fail, error code(%ld)\n",PTR_ERR(pDetectClass));
goto err1;
}
pDetectDev = device_create(pDetectClass,NULL,devID,NULL,WMT_DETECT_DEVICE_NAME);
if(IS_ERR(pDetectDev))
{
WMT_DETECT_ERR_FUNC("device create fail, error code(%ld)\n",PTR_ERR(pDetectDev));
goto err2;
}
WMT_DETECT_INFO_FUNC("driver(major %d) installed success\n", gWmtDetectMajor);
/*init SDIO-DETECT module*/
sdio_detect_init();
return 0;
err2:
if(pDetectClass)
{
class_destroy(pDetectClass);
pDetectClass = NULL;
}
err1:
if (cdevErr == 0) {
cdev_del(&gWmtDetectCdev);
}
if (ret == 0) {
unregister_chrdev_region(devID, WMT_DETECT_DEV_NUM);
gWmtDetectMajor = -1;
}
WMT_DETECT_ERR_FUNC("fail \n");
return -1;
}
开发者ID:SelfImp,项目名称:m75,代码行数:65,代码来源:wmt_detect.c
示例19: bt_hwctl_init
static int __init bt_hwctl_init(void)
{
int ret = -1, err = -1;
platform_driver_register(&mt6622_driver);
if (!(bh = kzalloc(sizeof(struct bt_hwctl), GFP_KERNEL)))
{
BT_HWCTL_ERR("bt_hwctl_init allocate dev struct failed\n");
err = -ENOMEM;
goto ERR_EXIT;
}
ret = alloc_chrdev_region(&bh->dev_t, 0, 1, BTHWCTL_NAME);
if (ret) {
BT_HWCTL_ERR("alloc chrdev region failed\n");
goto ERR_EXIT;
}
BT_HWCTL_INFO("alloc %s: %d:%d\n", BTHWCTL_NAME, MAJOR(bh->dev_t), MINOR(bh->dev_t));
cdev_init(&bh->cdev, &bt_hwctl_fops);
bh->cdev.owner = THIS_MODULE;
bh->cdev.ops = &bt_hwctl_fops;
err = cdev_add(&bh->cdev, bh->dev_t, 1);
if (err) {
BT_HWCTL_ERR("add chrdev failed\n");
goto ERR_EXIT;
}
bh->cls = class_create(THIS_MODULE, BTHWCTL_NAME);
if (IS_ERR(bh->cls)) {
err = PTR_ERR(bh->cls);
BT_HWCTL_ERR("class_create failed, errno:%d\n", err);
goto ERR_EXIT;
}
bh->dev = device_create(bh->cls, NULL, bh->dev_t, NULL, BTHWCTL_NAME);
mutex_init(&bh->sem);
init_waitqueue_head(&eint_wait);
wake_lock_init(&mt6622_irq_wakelock, WAKE_LOCK_SUSPEND, "mt6622_irq_wakelock");
/* request gpio used by BT */
//mt_bt_gpio_init();
BT_HWCTL_INFO("Bluetooth hardware control driver initialized\n");
return 0;
ERR_EXIT:
if (err == 0)
cdev_del(&bh->cdev);
if (ret == 0)
unregister_chrdev_region(bh->dev_t, 1);
if (bh){
kfree(bh);
bh = NULL;
}
return -1;
}
开发者ID:cubelibre,项目名称:rk3188-kernel,代码行数:65,代码来源:bt_hwctl_dev.c
示例20: power_loss_init
static int __init power_loss_init(void)
{
int err;
printk(KERN_NOTICE "%s Power Loss Test Module Init\n", TAG);
err = alloc_chrdev_region(&sg_pwr_loss_devno, PWR_LOSS_FIRST_MINOR, PWR_LOSS_MAX_MINOR_COUNT, PWR_LOSS_DEVNAME);
if (err != 0){
printk(KERN_ERR "%s Power Loss Test: alloc_chardev_region Failed!\n", TAG);
return err;
}
#ifdef PWR_LOSS_DEBUG
printk(KERN_NOTICE "%s Power Loss Test: MAJOR =%d, MINOR=%d\n", TAG,
MAJOR(sg_pwr_loss_devno), MINOR(sg_pwr_loss_devno));
#endif
sg_pwr_loss_dev = cdev_alloc();
if (NULL == sg_pwr_loss_dev){
printk(KERN_ERR "%s Power Loss Test: cdev_alloc Failed\n", TAG);
goto out2;
}
sg_pwr_loss_dev->owner = THIS_MODULE;
sg_pwr_loss_dev->ops = &pwr_loss_fops;
err = cdev_add(sg_pwr_loss_dev, sg_pwr_loss_devno, 1);
if (err != 0){
printk(KERN_ERR "%s Power Loss Test: cdev_add Failed!\n", TAG);
goto out2;
}
sg_pwr_loss_dev_class = class_create(THIS_MODULE, PWR_LOSS_DEVNAME);
if (NULL == sg_pwr_loss_dev_class){
printk(KERN_ERR "%s Power Loss Test: class_create Failed!\n", TAG);
goto out1;
}
sg_pwr_loss_dev_file = device_create(sg_pwr_loss_dev_class, NULL, sg_pwr_loss_devno, NULL, PWR_LOSS_DEVNAME);
if (NULL == sg_pwr_loss_dev_file){
printk(KERN_ERR "%s Power Loss Test: device_create Failed!\n", TAG);
goto out;
}
#ifdef PWR_LOSS_SW_RESET
power_loss_info_init();
err = power_loss_debug_init();
if(err < 0)
goto out;
#endif
printk(KERN_ERR "%s Power Loss Test: Init Successfully!\n", TAG);
#ifdef PWR_LOSS_SW_RESET
kernel_thread(pwr_loss_reset_thread, NULL, CLONE_VM); //CLONE_KERNEL
printk(KERN_ERR "%s Power Loss Test: kernel thread create Successful!\n", TAG);
#endif
return 0;
out:
class_destroy(sg_pwr_loss_dev_class);
out1:
cdev_del(sg_pwr_loss_dev);
out2:
unregister_chrdev_region(sg_pwr_loss_devno, PWR_LOSS_MAX_MINOR_COUNT);
#ifdef PWR_LOSS_SW_RESET
remove_proc_entry("power_loss_debug", NULL);
#endif
return err;
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:71,代码来源:power_loss_test.c
注:本文中的cdev_del函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论