当前位置: 首页>>代码示例>>C++>>正文


C++ devfs_register函数代码示例

本文整理汇总了C++中devfs_register函数的典型用法代码示例。如果您正苦于以下问题:C++ devfs_register函数的具体用法?C++ devfs_register怎么用?C++ devfs_register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了devfs_register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: scull_access_init

int scull_access_init(void)
{
    /* assign quantum and quantumset */
    scull_s_device.quantum = scull_quantum;
    scull_s_device.qset    = scull_qset;
    scull_u_device.quantum = scull_quantum;
    scull_u_device.qset    = scull_qset;
    scull_w_device.quantum = scull_quantum;
    scull_w_device.qset    = scull_qset;

    /* Initialize spinlocks */
    spin_lock_init(&scull_s_lock);
    spin_lock_init(&scull_u_lock);
    spin_lock_init(&scull_w_lock);
    spin_lock_init(&scull_c_lock);

    /* and semaphores (used by read and write) */
    sema_init(&scull_s_device.sem, 1);
    sema_init(&scull_u_device.sem, 1);
    sema_init(&scull_w_device.sem, 1);

#ifdef CONFIG_DEVFS_FS
    /* finally, create the devfs entry points */
    scull_s_device.handle =
        devfs_register(scull_devfs_dir, "single",
                       DEVFS_FL_AUTO_DEVNUM,
                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                       &scull_sngl_fops,
                       &scull_s_device);
    scull_u_device.handle =
        devfs_register(scull_devfs_dir, "user",
                       DEVFS_FL_AUTO_DEVNUM,
                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                       &scull_user_fops,
                       &scull_u_device);

    scull_w_device.handle =
        devfs_register(scull_devfs_dir, "wuser",
                       DEVFS_FL_AUTO_DEVNUM,
                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                       &scull_wusr_fops,
                       &scull_w_device);
    scull_priv_handle =
        devfs_register(scull_devfs_dir, "priv",
                       DEVFS_FL_AUTO_DEVNUM,
                       0, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                       &scull_priv_fops,
                       &scull_priv_fops); /* any non-null value */
#endif    
    return 0;
}
开发者ID:dot-Sean,项目名称:linux_drivers,代码行数:51,代码来源:access.c

示例2: scull_p_init

int scull_p_init(void)
{
    int i;

    SET_MODULE_OWNER(&scull_pipe_fops);
    scull_p_devices = kmalloc(scull_p_nr_devs * sizeof(Scull_Pipe),
                              GFP_KERNEL);
    if (scull_p_devices == NULL)
        return -ENOMEM;
    memset(scull_p_devices, 0, scull_p_nr_devs * sizeof(Scull_Pipe));
    for (i = 0; i < scull_p_nr_devs; i++) {
        init_waitqueue_head(&(scull_p_devices[i].inq));
        init_waitqueue_head(&(scull_p_devices[i].outq));
        sema_init(&scull_p_devices[i].sem, 1);
#ifdef CONFIG_DEVFS_FS
        sprintf(pipename, "pipe%i", i);
        scull_p_devices[i].handle =
            devfs_register(scull_devfs_dir, pipename,
                           DEVFS_FL_AUTO_DEVNUM,
                           0, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                           &scull_pipe_fops,
                           scull_p_devices + i);
        if (!scull_p_devices[i].handle) {
            /* ignore errors, at worse we have less devices */
            printk(KERN_WARNING
                   "scull: can't register pipe device nr. %i\n", i);
        }
#endif
    }
#ifdef SCULL_DEBUG
    create_proc_read_entry("scullpipe", 0, NULL, scull_read_p_mem, NULL);
#endif
    return 0;
}
开发者ID:crond,项目名称:dd,代码行数:34,代码来源:pipe.c

示例3: rdm_init

static int rdm_init(void)

{

#ifdef  CONFIG_DEVFS_FS
    if(devfs_register_chrdev(rdm_major, RDM_DEVNAME , &rdm_fops)) {
	printk(KERN_WARNING " ps: can't create device node - ps\n");
	return -EIO;
    }

    devfs_handle = devfs_register(NULL, RDM_DEVNAME, DEVFS_FL_DEFAULT, rdm_major, 0, 
				S_IFCHR | S_IRUGO | S_IWUGO, &rdm_fops, NULL);
#else
    int result=0;
    result = register_chrdev(rdm_major, RDM_DEVNAME, &rdm_fops);
    if (result < 0) {
        printk(KERN_WARNING "ps: can't get major %d\n",rdm_major);
        return result;
    }

    if (rdm_major == 0) {
	rdm_major = result; /* dynamic */
    }
#endif

    printk("rdm_major = %d\n", rdm_major);
    return 0;

}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:29,代码来源:rdm.c

示例4: s3c2410_adc_init

int __init s3c2410_adc_init(void)
{
	int ret;

	/* normal ADC */
	ADCTSC = 0; //XP_PST(NOP_MODE);

	ret = request_irq(IRQ_ADC_DONE, adcdone_int_handler, SA_INTERRUPT, DEVICE_NAME, NULL);
	if (ret) {
		return ret;
	}

	ret = register_chrdev(0, DEVICE_NAME, &s3c2410_fops);
	if (ret < 0) {
		printk(DEVICE_NAME " can't get major number\n");
		return ret;
	}
	adcMajor=ret;

#ifdef CONFIG_DEVFS_FS
	devfs_adc_dir = devfs_mk_dir(NULL, "adc", NULL);
	devfs_adcraw = devfs_register(devfs_adc_dir, "0raw", DEVFS_FL_DEFAULT,
				adcMajor, ADCRAW_MINOR, S_IFCHR | S_IRUSR | S_IWUSR, &s3c2410_fops, NULL);
#endif
	printk (DEVICE_NAME"\tinitialized\n");

	return 0;
}
开发者ID:AxelLin,项目名称:Drv,代码行数:28,代码来源:s3c2410-adc.c

示例5: info

static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
		       const struct usb_device_id *id)
{
	struct rio_usb_data *rio = &rio_instance;

	info("USB Rio found at address %d", dev->devnum);

	rio->present = 1;
	rio->rio_dev = dev;

	if (!(rio->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) {
		err("probe_rio: Not enough memory for the output buffer");
		return NULL;
	}
	dbg("probe_rio: obuf address:%p", rio->obuf);

	if (!(rio->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) {
		err("probe_rio: Not enough memory for the input buffer");
		kfree(rio->obuf);
		return NULL;
	}
	dbg("probe_rio: ibuf address:%p", rio->ibuf);

	rio->devfs = devfs_register(usb_devfs_handle, "rio500",
				    DEVFS_FL_DEFAULT, USB_MAJOR,
				    RIO_MINOR,
				    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP |
				    S_IWGRP, &usb_rio_fops, NULL);
	if (rio->devfs == NULL)
		dbg("probe_rio: device node registration failed");

	init_MUTEX(&(rio->lock));

	return rio;
}
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-e-f_fw-20-10-7-5,代码行数:35,代码来源:rio500.c

示例6: memory_devfs_register

void __init memory_devfs_register (void)
{
    /*  These are never unregistered  */
    static const struct {
	unsigned short minor;
	char *name;
	umode_t mode;
	struct file_operations *fops;
    } list[] = { /* list of minor devices */
	{1, "mem",     S_IRUSR | S_IWUSR | S_IRGRP, &mem_fops},
	{2, "kmem",    S_IRUSR | S_IWUSR | S_IRGRP, &kmem_fops},
	{3, "null",    S_IRUGO | S_IWUGO,           &null_fops},
#if defined(CONFIG_ISA) || !defined(__mc68000__)
	{4, "port",    S_IRUSR | S_IWUSR | S_IRGRP, &port_fops},
#endif
	{5, "zero",    S_IRUGO | S_IWUGO,           &zero_fops},
	{7, "full",    S_IRUGO | S_IWUGO,           &full_fops},
	{8, "random",  S_IRUGO | S_IWUSR,           &random_fops},
	{9, "urandom", S_IRUGO | S_IWUSR,           &urandom_fops}
    };
    int i;

    for (i=0; i<(sizeof(list)/sizeof(*list)); i++)
	devfs_register (NULL, list[i].name, DEVFS_FL_NONE,
			MEM_MAJOR, list[i].minor,
			list[i].mode | S_IFCHR,
			list[i].fops, NULL);
}
开发者ID:leonsh,项目名称:eldk30ppc,代码行数:28,代码来源:mem.c

示例7: lvm_fs_create_vg

void lvm_fs_create_vg(vg_t *vg_ptr) {
	struct proc_dir_entry *pde;

	if (!vg_ptr)
		return;

	vg_devfs_handle[vg_ptr->vg_number] =
		devfs_mk_dir(0, vg_ptr->vg_name, NULL);

	ch_devfs_handle[vg_ptr->vg_number] = devfs_register(
		vg_devfs_handle[vg_ptr->vg_number] , "group",
		DEVFS_FL_DEFAULT, LVM_CHAR_MAJOR, vg_ptr->vg_number,
		S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
		&lvm_chr_fops, NULL);

	vg_ptr->vg_dir_pde = create_proc_entry(vg_ptr->vg_name, S_IFDIR,
					       lvm_proc_vg_subdir);

	if((pde = create_proc_entry("group", S_IFREG, vg_ptr->vg_dir_pde))) {
		pde->read_proc = _proc_read_vg;
		pde->data = vg_ptr;
	}

	vg_ptr->lv_subdir_pde =
		create_proc_entry(LVM_LV_SUBDIR, S_IFDIR, vg_ptr->vg_dir_pde);

	vg_ptr->pv_subdir_pde =
		create_proc_entry(LVM_PV_SUBDIR, S_IFDIR, vg_ptr->vg_dir_pde);
}
开发者ID:jameshilliard,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:29,代码来源:lvm-fs.c

示例8: i2s_mod_init

int __init i2s_mod_init(void)
{
	/* register device with kernel */
#ifdef  CONFIG_DEVFS_FS
    if(devfs_register_chrdev(i2sdrv_major, I2SDRV_DEVNAME , &i2s_fops)) {
		printk(KERN_WARNING " i2s: can't create device node - %s\n", I2SDRV_DEVNAME);
		return -EIO;
    }

    devfs_handle = devfs_register(NULL, I2SDRV_DEVNAME, DEVFS_FL_DEFAULT, i2sdrv_major, 0, 
	    S_IFCHR | S_IRUGO | S_IWUGO, &i2s_fops, NULL);
#else
    int result=0;
    result = register_chrdev(i2sdrv_major, I2SDRV_DEVNAME, &i2s_fops);
    if (result < 0) {
		printk(KERN_WARNING "i2s: can't get major %d\n",i2sdrv_major);
        return result;
    }

    if (i2sdrv_major == 0) {
		i2sdrv_major = result; /* dynamic */
    }
#endif

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)
#else	
	i2smodule_class=class_create(THIS_MODULE, I2SDRV_DEVNAME);
	if (IS_ERR(i2smodule_class)) 
		return -EFAULT;
	device_create(i2smodule_class, NULL, MKDEV(i2sdrv_major, 0), I2SDRV_DEVNAME);
#endif	
	return 0;
}
开发者ID:jhbsz,项目名称:wifiaudio,代码行数:33,代码来源:i2s_ctrl.c

示例9: fpga_init

int __init fpga_init(void)
{
	int ret;

/*	ret = request_irq(IRQ_ADC_DONE, adcdone_int_handler, SA_INTERRUPT, DEVICE_NAME, NULL);
	if (ret) {
		return ret;
	}*/
	s3c2410_fpga_base= (unsigned long) ioremap(FPGA_PHY_START, SZ_4K); 
	if(!s3c2410_fpga_base) {
		printk("ioremap S3C2410 fpga failed\n");
		return -EINVAL;
	}

	ret = register_chrdev(0, DEVICE_NAME, &s3c2410_fops);
	if (ret < 0) {
		printk(DEVICE_NAME " can't get major number\n");
		return ret;
	}
	fpgaMajor=ret;

#ifdef CONFIG_DEVFS_FS
	devfs_fpga_dir = devfs_mk_dir(NULL, "fpga", NULL);
	devfs_fpgaraw = devfs_register(devfs_fpga_dir, "0raw", DEVFS_FL_DEFAULT,
				fpgaMajor, FPGARAW_MINOR, S_IFCHR | S_IRUSR | S_IWUSR, &s3c2410_fops, NULL);
#endif
	printk (DEVICE_NAME"\tdevice initialized\n");

	return 0;
}
开发者ID:AxelLin,项目名称:Drv,代码行数:30,代码来源:s3c2410-fpga.c

示例10: init_module

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 */
}
开发者ID:Azure,项目名称:sonic-buildimage,代码行数:60,代码来源:gmodule.c

示例11: ioCluster_init

static void ioCluster_init(struct cluster_s *cluster, uint_t id)
{
    struct device_s *pic;
    int i;

    /* First of all: Initialize TTYs */
    ibmpc_tty_init(&ttys_tbl[0], __tty_addr, 1, 0);   // IRQ 0 is taken by Timer 0

    boot_dmsg("\nSetup Terminal \t\t\t\tOK\n");

    cluster_init(cluster, id, __CPU_NR);

    boot_dmsg("Setup PIC      ");
    pic = kbootMem_calloc(sizeof(*pic));
    ibmpc_pic_init(pic, __pic_addr, 0);
    ibmpc_pic_bind(pic, &ttys_tbl[0]);
    devfs_register(&ttys_tbl[0]);

    for(i=0; i < __CPU_NR; i++)
        arch_cpu_set_irq_entry(&cluster->cpu_tbl[i], 0, &pic->action);

    boot_dmsg("\t\t\t\tOK\nSetup Timer    ");
    rt_timer_init(TIC, 1);
    ibmpc_pic_bind(pic, &rt_timer);

    boot_dmsg("\t\t\t\tOK\nSetup H.D.D    ");
    ibmpc_ata_init(&__sys_blk, (void*)ATA0_DRIVE0, 14);
    ibmpc_pic_bind(pic, &__sys_blk);

    boot_dmsg("\t\t\t\tOK\nActivating IRQs");
    pic->op.icu.set_mask(pic, ICU_MASK, 0, 0);
    boot_dmsg("\t\t\t\tOK\n");
}
开发者ID:walafc0,项目名称:almos-mk,代码行数:33,代码来源:arch_init.c

示例12: xp_sys_hook

inline int xp_sys_hook()
{
	/* Called insmod when inserting the module. */

	/* register the dazuko device */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
	dev_major = register_chrdev(CONFIG_RSBAC_DAZ_DEV_MAJOR, DEVICE_NAME, &fops);

	devfs_mk_cdev(MKDEV(dev_major, CONFIG_RSBAC_DAZ_DEV_MAJOR), S_IFCHR | S_IRUSR | S_IWUSR, DEVICE_NAME);
#else
	#ifdef CONFIG_DEVFS_FS
		dev_major = devfs_register_chrdev(CONFIG_RSBAC_DAZ_DEV_MAJOR, DEVICE_NAME, &fops);
		devfs_register(NULL, DEVICE_NAME, DEVFS_FL_DEFAULT,
			dev_major, 0, S_IFCHR | S_IRUSR | S_IWUSR,
			&fops, NULL);
	#else
		dev_major = register_chrdev(CONFIG_RSBAC_DAZ_DEV_MAJOR, DEVICE_NAME, &fops);
	#endif
#endif
	if (dev_major < 0)
	{
		xp_print("dazuko: unable to register device chrdev, err=%d\n", dev_major);
		return dev_major;
	}

	/* initialization complete */

	return 0;
}
开发者ID:eqmcc,项目名称:dazuko,代码行数:29,代码来源:dazuko_rsbac.c

示例13: wps_led_init

static int __init
wps_led_init(void)
{
#ifndef CONFIG_DEVFS_FS
    int ret_val;
    /*
    * Register the character device (atleast try)
    */
    ret_val = register_chrdev(WPS_LED_MAJOR_NUM, "wps_led", &wps_led_fops);
    /*
    * Negative values signify an error
    */
    if (ret_val < 0) 
    {
        printf("%s failed with %d\n","Sorry, registering the character device wps_led", ret_val);
        return ret_val;
    } 
#else /* CONFIG_DEVFS_FS */
    if ((wps_led_major = devfs_register_chrdev(WPS_LED_MAJOR_NUM, "wps_led", &wps_led_fops)) < 0)
        return wps_led_major;

    wps_leddev_handle = devfs_register(NULL, "wps_led", DEVFS_FL_DEFAULT,
                                    wps_led_major, 0, S_IFCHR | S_IRUGO | S_IWUGO,
                                    &wps_led_fops, NULL);
#endif /* CONFIG_DEVFS_FS */
    return 0;
}
开发者ID:jeremyd2019,项目名称:r6300v2,代码行数:27,代码来源:wps_led.c

示例14: gpio_init

static int __init
gpio_init(void)
{
	if (!(gpio_sih = si_kattach(SI_OSH)))
		return -ENODEV;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
	if ((gpio_major = register_chrdev(0, "gpio", &gpio_fops)) < 0)
#else
	if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
#endif
		return gpio_major;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
	gpiodev_class = class_create(THIS_MODULE, "gpio");
	if (IS_ERR(gpiodev_class)) {
		printk("Error creating gpio class\n");
		return -1;
	}

	/* Add the device gpio0 */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
	device_create(gpiodev_class, NULL, MKDEV(gpio_major, 0), NULL, "gpio", 0);
#else
	class_device_create(gpiodev_class, NULL, MKDEV(gpio_major, 0), NULL, "gpio");
#endif /* linux-2.6.36 */
#else
	gpiodev_handle = devfs_register(NULL, "gpio", DEVFS_FL_DEFAULT,
	                                gpio_major, 0, S_IFCHR | S_IRUGO | S_IWUGO,
	                                &gpio_fops, NULL);
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) */

	return 0;
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:33,代码来源:linux_gpio.c

示例15: aviaEXT_init

static int __init aviaEXT_init(void)
{
	if (!(devfs_h = devfs_register(NULL,"dbox/aviaEXT", DEVFS_FL_DEFAULT, 0, 0, 
					S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, &aviaEXT_fops, NULL))){
		printk(KERN_ERR "aviaEXT: could not register with devfs.\n");
		return -EIO;
	}
	return 0;
}
开发者ID:UkCvs,项目名称:commando,代码行数:9,代码来源:aviaEXT.c


注:本文中的devfs_register函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。