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);
}
static __init int init_ipmi_devintf(void)
{
	int rv;

	if (ipmi_major < 0)
		return -EINVAL;

	rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
	if (rv < 0) {
		printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
		return rv;
	}

	if (ipmi_major == 0) {
		ipmi_major = rv;
	}

	devfs_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL);

	rv = ipmi_smi_watcher_register(&smi_watcher);
	if (rv) {
		unregister_chrdev(ipmi_major, DEVICE_NAME);
		printk(KERN_WARNING "ipmi: can't register smi watcher");
		return rv;
	}

	printk(KERN_INFO "ipmi: device interface at char major %d\n",
	       ipmi_major);

	return 0;
}
Example #3
0
int init_module(void)
{
	int ret;
	dev_t dev = MKDEV(DVB_MAJOR, 0);

	if ((ret = register_chrdev_region(dev, 64, DEVICE_NAME)) != 0) {
		printk(KERN_INFO "td-dvb-fe: unable to get major %d\n", DVB_MAJOR);
		goto error;
	}

	cdev_init(&device_cdev, &fops);
	if ((ret = cdev_add(&device_cdev, dev, 64)) != 0) {
		printk(KERN_INFO "td-dvb-fe: unable to get major %d\n", DVB_MAJOR);
		goto error;
	}

	devfs_mk_dir("dvb");
	my_class = class_simple_create(THIS_MODULE, DEVICE_NAME);

	if (IS_ERR(my_class)) {
		ret = PTR_ERR(my_class);
		goto error;
	}

	devfs_mk_cdev(MKDEV(DVB_MAJOR, 3), S_IFCHR | S_IRUSR | S_IWUSR, "dvb/adapter0/frontend0");
	class_simple_device_add(my_class, MKDEV(DVB_MAJOR, 3), NULL, "dvb0.frontend0");

	printk(KERN_INFO "[td-dvb-fe] loaded\n");
	return 0;
error:
	cdev_del(&device_cdev);
	unregister_chrdev_region(dev, 64);
	return ret;
}
Example #4
0
/* xd_init: register the block device number and set up pointer tables */
int __init xd_init(void)
{
	init_timer (&xd_watchdog_int); 
	xd_watchdog_int.function = xd_watchdog;

	if (!xd_dma_buffer)
		xd_dma_buffer = (char *)xd_dma_mem_alloc(xd_maxsectors * 0x200);
	if (!xd_dma_buffer)
	{
		printk(KERN_ERR "xd: Out of memory.\n");
		return -ENOMEM;
	}

	if (devfs_register_blkdev(MAJOR_NR,"xd",&xd_fops)) {
		printk(KERN_ERR "xd: Unable to get major number %d\n",MAJOR_NR);
		return -1;
	}
	devfs_handle = devfs_mk_dir (NULL, xd_gendisk.major_name, NULL);
	blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), DEVICE_REQUEST);
	read_ahead[MAJOR_NR] = 8;	/* 8 sector (4kB) read ahead */
	add_gendisk(&xd_gendisk);
	xd_geninit();

	return 0;
}
Example #5
0
static __init int init_ipmi_devintf(void)
{
	int rv;

	if (ipmi_major < 0)
		return -EINVAL;

	printk(KERN_INFO "ipmi device interface version "
	       IPMI_DEVINTF_VERSION "\n");

	rv = register_chrdev(ipmi_major, DEVICE_NAME, &ipmi_fops);
	if (rv < 0) {
		printk(KERN_ERR "ipmi: can't get major %d\n", ipmi_major);
		return rv;
	}

	if (ipmi_major == 0) {
		ipmi_major = rv;
	}

	devfs_mk_dir(DEVICE_NAME);

	rv = ipmi_smi_watcher_register(&smi_watcher);
	if (rv) {
		unregister_chrdev(ipmi_major, DEVICE_NAME);
		printk(KERN_WARNING "ipmi: can't register smi watcher\n");
		return rv;
	}

	return 0;
}
int __init hiddev_init(void)
{
	hiddev_devfs_handle =
		devfs_mk_dir(devfs_find_handle(NULL, "usb", 0, 0, 0, 0), "hid", NULL);
	usb_register(&hiddev_driver);
	return 0;
}
Example #7
0
static int __init bpp_init(void)
{
	int rc;
	unsigned idx;

	rc = collectLptPorts();
	if (rc == 0)
		return -ENODEV;

	rc = register_chrdev(BPP_MAJOR, dev_name, &bpp_fops);
	if (rc < 0)
		return rc;

	for (idx = 0; idx < BPP_NO; idx++) {
		instances[idx].opened = 0;
		probeLptPort(idx);
	}
	devfs_mk_dir("bpp");
	for (idx = 0; idx < BPP_NO; idx++) {
		devfs_mk_cdev(MKDEV(BPP_MAJOR, idx),
				S_IFCHR | S_IRUSR | S_IWUSR, "bpp/%d", idx);
	}

	return 0;
}
Example #8
0
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;
}
Example #9
0
static int __init
xts_init(void)
{
	int index = 0;
	int retval;

	if ((retval = devfs_register_chrdev(xts_major, XTS_NAME, &fops)) < 0) {
		printk(KERN_ERR "%s: unable to register major %d.\n", XTS_NAME,
		       xts_major);
		return retval;
	}
	if (xts_major == 0)
		xts_major = retval;

	devfs_dir = devfs_mk_dir(NULL, "touchscreen", NULL);

	/* Try to initialize all the touchscreens. */
	while (probe(index++) == 0) ;

	if (index > 1) {
		/* We found at least one. */
		init_completion(&task_sync);
		init_waitqueue_head(&irq_wait);
		if ((retval = kernel_thread(xts_thread, 0, 0)) >= 0) {
			wait_for_completion(&task_sync);
			return 0;
		}
	} else
		retval = -ENODEV;

	/* None found or error starting thread, clean up and get out of here. */
	xts_cleanup();
	return retval;
}
Example #10
0
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;
}
Example #11
0
static int __init
gpio_init(void)
{
    int i;

    if (!(gpio_sih = si_kattach(SI_OSH)))
        return -ENODEV;

    si_gpiosetcore(gpio_sih);

    if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
        return gpio_major;

    gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);

    for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
        gpio_file[i].handle = devfs_register(gpio_dir,
                                             gpio_file[i].name,
                                             DEVFS_FL_DEFAULT, gpio_major, i,
                                             S_IFCHR | S_IRUGO | S_IWUGO,
                                             &gpio_fops, NULL);
    }

    return 0;
}
Example #12
0
static int vfc_probe(void)
{
	struct sbus_bus *sbus;
	struct sbus_dev *sdev = NULL;
	int ret;
	int instance = 0, cards = 0;

	for_all_sbusdev(sdev, sbus) {
		if (strcmp(sdev->prom_name, "vfc") == 0) {
			cards++;
			continue;
		}
	}

	if (!cards)
		return -ENODEV;

	vfc_dev_lst = (struct vfc_dev **)kmalloc(sizeof(struct vfc_dev *) *
						 (cards+1),
						 GFP_KERNEL);
	if (vfc_dev_lst == NULL)
		return -ENOMEM;
	memset(vfc_dev_lst, 0, sizeof(struct vfc_dev *) * (cards + 1));
	vfc_dev_lst[cards] = NULL;

	ret = devfs_register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops);
	if(ret) {
		printk(KERN_ERR "Unable to get major number %d\n", VFC_MAJOR);
		kfree(vfc_dev_lst);
		return -EIO;
	}
	devfs_handle = devfs_mk_dir (NULL, "vfc", NULL);

	instance = 0;
	for_all_sbusdev(sdev, sbus) {
		if (strcmp(sdev->prom_name, "vfc") == 0) {
			vfc_dev_lst[instance]=(struct vfc_dev *)
				kmalloc(sizeof(struct vfc_dev), GFP_KERNEL);
			if (vfc_dev_lst[instance] == NULL)
				return -ENOMEM;
			ret = init_vfc_device(sdev,
					      vfc_dev_lst[instance],
					      instance);
			if(ret) {
				printk(KERN_ERR "Unable to initialize"
				       " vfc%d device\n",
				       instance);
			} else {
			}
		
			instance++;
			continue;
		}
	}

	return 0;
}
Example #13
0
static int __init mbd_init(void)
{
	int err = -ENOMEM;
	int i;

	for (i = 0; i < MAX_MBD; i++) {
		struct gendisk *disk = alloc_disk(1);
		if (!disk)
			goto out;
		mbd_dev[i].disk = disk;
		/*
		 * The new linux 2.5 block layer implementation requires
		 * every gendisk to have its very own request_queue struct.
		 * These structs are big so we dynamically allocate them.
		 */
		disk->queue = blk_init_queue(do_mbd_request, &mbd_lock);
		if (!disk->queue) {
			put_disk(disk);
			goto out;
		}
	}

	if (register_blkdev(MAJOR_NR, "mbd")) {
		err = -EIO;
		goto out;
	}
#ifdef MODULE
	printk("mambo bogus disk: registered device at major %d\n", MAJOR_NR);
#else
	printk("mambo bogus disk: compiled in with kernel\n");
#endif

	devfs_mk_dir("mambobd");
	for (i = 0; i < MAX_MBD; i++) {	/* load defaults */
		struct gendisk *disk = mbd_dev[i].disk;
		mbd_dev[i].initialized = 0;
		mbd_dev[i].refcnt = 0;
		mbd_dev[i].flags = 0;
		disk->major = MAJOR_NR;
		disk->first_minor = i;
		disk->fops = &mbd_fops;
		disk->private_data = &mbd_dev[i];
		sprintf(disk->disk_name, "mambobd%d", i);
		sprintf(disk->devfs_name, "mambobd%d", i);
		set_capacity(disk, 0x7ffffc00ULL << 1);	/* 2 TB */
		add_disk(disk);
	}

	return 0;
      out:
	while (i--) {
		if (mbd_dev[i].disk->queue)
			blk_cleanup_queue(mbd_dev[i].disk->queue);
		put_disk(mbd_dev[i].disk);
	}
	return -EIO;
}
Example #14
0
/*
 * hwgraph_mk_dir - Creates a directory entry with devfs.
 *	Note that a directory entry in devfs can have children 
 *	but it cannot be a char|block special file.
 */
vertex_hdl_t
hwgraph_mk_dir(vertex_hdl_t de, const char *name,
                unsigned int namelen, void *info)
{

	int rv;
	labelcl_info_t *labelcl_info = NULL;
	vertex_hdl_t new_devfs_handle = NULL;
	vertex_hdl_t parent = NULL;

	/*
	 * Create the device info structure for hwgraph compatiblity support.
	 */
	labelcl_info = labelcl_info_create();
	if (!labelcl_info)
		return(NULL);

	/*
	 * Create a devfs entry.
	 */
	new_devfs_handle = devfs_mk_dir(de, name, (void *)labelcl_info);
	if (!new_devfs_handle) {
		labelcl_info_destroy(labelcl_info);
		return(NULL);
	}

	/*
	 * Get the parent handle.
	 */
	parent = devfs_get_parent (new_devfs_handle);

	/*
	 * To provide the same semantics as the hwgraph, set the connect point.
	 */
	rv = hwgraph_connectpt_set(new_devfs_handle, parent);
	if (!rv) {
		/*
		 * We need to clean up!
		 */
	}

	/*
	 * If the caller provides a private data pointer, save it in the 
	 * labelcl info structure(fastinfo).  This can be retrieved via
	 * hwgraph_fastinfo_get()
	 */
	if (info)
		hwgraph_fastinfo_set(new_devfs_handle, (arbitrary_info_t)info);
		
	return(new_devfs_handle);

}
Example #15
0
File: rd.c Project: nhanh0/hah
/* This is the registration and initialization section of the RAM disk driver */
int __init rd_init (void)
{
	int		i;

	if (rd_blocksize > PAGE_SIZE || rd_blocksize < 512 ||
	    (rd_blocksize & (rd_blocksize-1)))
	{
		printk("RAMDISK: wrong blocksize %d, reverting to defaults\n",
		       rd_blocksize);
		rd_blocksize = BLOCK_SIZE;
	}

	if (register_blkdev(MAJOR_NR, "ramdisk", &rd_bd_op)) {
		printk("RAMDISK: Could not get major %d", MAJOR_NR);
		return -EIO;
	}

	blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR), &rd_make_request);

	for (i = 0; i < NUM_RAMDISKS; i++) {
		/* rd_size is given in kB */
		rd_length[i] = rd_size << 10;
		rd_hardsec[i] = rd_blocksize;
		rd_blocksizes[i] = rd_blocksize;
		rd_kbsize[i] = rd_size;
	}
	devfs_handle = devfs_mk_dir (NULL, "rd", NULL);
	devfs_register_series (devfs_handle, "%u", NUM_RAMDISKS,
			       DEVFS_FL_DEFAULT, MAJOR_NR, 0,
			       S_IFBLK | S_IRUSR | S_IWUSR,
			       &rd_bd_op, NULL);

	for (i = 0; i < NUM_RAMDISKS; i++)
		register_disk(NULL, MKDEV(MAJOR_NR,i), 1, &rd_bd_op, rd_size<<1);

#ifdef CONFIG_BLK_DEV_INITRD
	/* We ought to separate initrd operations here */
	register_disk(NULL, MKDEV(MAJOR_NR,INITRD_MINOR), 1, &rd_bd_op, rd_size<<1);
#endif

	hardsect_size[MAJOR_NR] = rd_hardsec;		/* Size of the RAM disk blocks */
	blksize_size[MAJOR_NR] = rd_blocksizes;		/* Avoid set_blocksize() check */
	blk_size[MAJOR_NR] = rd_kbsize;			/* Size of the RAM disk in kB  */

		/* rd_size is given in kB */
	printk("RAMDISK driver initialized: "
	       "%d RAM disks of %dK size %d blocksize\n",
	       NUM_RAMDISKS, rd_size, rd_blocksize);

	return 0;
}
Example #16
0
static void __init unix98_pty_init(void)
{
	devfs_mk_dir("pts");
	ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX);
	if (!ptm_driver)
		panic("Couldn't allocate Unix98 ptm driver");
	pts_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX);
	if (!pts_driver)
		panic("Couldn't allocate Unix98 pts driver");

	ptm_driver->owner = THIS_MODULE;
	ptm_driver->driver_name = "pty_master";
	ptm_driver->name = "ptm";
	ptm_driver->major = UNIX98_PTY_MASTER_MAJOR;
	ptm_driver->minor_start = 0;
	ptm_driver->type = TTY_DRIVER_TYPE_PTY;
	ptm_driver->subtype = PTY_TYPE_MASTER;
	ptm_driver->init_termios = tty_std_termios;
	ptm_driver->init_termios.c_iflag = 0;
	ptm_driver->init_termios.c_oflag = 0;
	ptm_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
	ptm_driver->init_termios.c_lflag = 0;
	ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
		TTY_DRIVER_NO_DEVFS | TTY_DRIVER_DEVPTS_MEM;
	ptm_driver->other = pts_driver;
	tty_set_operations(ptm_driver, &pty_ops);
	ptm_driver->ioctl = pty_unix98_ioctl;

	pts_driver->owner = THIS_MODULE;
	pts_driver->driver_name = "pty_slave";
	pts_driver->name = "pts";
	pts_driver->major = UNIX98_PTY_SLAVE_MAJOR;
	pts_driver->minor_start = 0;
	pts_driver->type = TTY_DRIVER_TYPE_PTY;
	pts_driver->subtype = PTY_TYPE_SLAVE;
	pts_driver->init_termios = tty_std_termios;
	pts_driver->init_termios.c_cflag = B38400 | CS8 | CREAD;
	pts_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW |
		TTY_DRIVER_NO_DEVFS | TTY_DRIVER_DEVPTS_MEM;
	pts_driver->other = ptm_driver;
	tty_set_operations(pts_driver, &pty_ops);
	
	if (tty_register_driver(ptm_driver))
		panic("Couldn't register Unix98 ptm driver");
	if (tty_register_driver(pts_driver))
		panic("Couldn't register Unix98 pts driver");

	pty_table[1].data = &ptm_driver->refcount;
}
Example #17
0
static int __init s3c2410_kbd_init(void)
{
	int ret;
	int oldiiccon;
	int flags;

	ret = set_external_irq(IRQ_KBD, EXT_FALLING_EDGE, GPIO_PULLUP_EN);

	local_irq_save(flags);
	IIC_init();
	
	Set_IIC_mode(ZLG7289_IICCON, &oldiiccon);
	ret=IIC_Read(ZLG7290_ADDR, 0);

	//restore IICCON
	Set_IIC_mode(oldiiccon, NULL);
	local_irq_save(flags);

	DPRINTK("zlg7290 system register=0x%x\n", ret);

	KBD_CLOSE_INT();

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

	/* Enable touch interrupt */
	ret = request_irq(IRQ_KBD, s3c2410_isr_kbd,SA_INTERRUPT,
			DEVICE_NAME, s3c2410_isr_kbd);
	if (ret) {
		return ret;
	}
	kbddev.head = kbddev.tail = 0;
	kbddev.kbdmode= KEY_NULL;
	init_waitqueue_head(&(kbddev.wq));

#ifdef CONFIG_DEVFS_FS
	devfs_kbd_dir = devfs_mk_dir(NULL, "keyboard", NULL);
	devfs_kbdraw = devfs_register(devfs_kbd_dir, "0raw", DEVFS_FL_DEFAULT,
				kbdMajor, KBDRAW_MINOR, S_IFCHR | S_IRUSR | S_IWUSR, &s3c2410_fops, NULL);
#endif
	printk (DEVICE_NAME"\tinitialized\n");

	return 0;
}
void devfs_add_partitioned(struct gendisk *disk)
{
	char dirname[64], symlink[16];

	devfs_mk_dir(disk->devfs_name);
	devfs_mk_bdev(MKDEV(disk->major, disk->first_minor),
			S_IFBLK|S_IRUSR|S_IWUSR,
			"%s/disc", disk->devfs_name);

	disk->number = alloc_unique_number(&disc_numspace);

	sprintf(symlink, "discs/disc%d", disk->number);
	sprintf(dirname, "../%s", disk->devfs_name);
	devfs_mk_symlink(symlink, dirname);

}
Example #19
0
File: gpio.c Project: cilynx/dd-wrt
static int __init
gpio_init(void)
{
	int i;

	if (!(gpio_sbh = sb_kattach(SB_OSH)))
		return -ENODEV;

	sb_gpiosetcore(gpio_sbh);

	if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0)
		return gpio_major;

	gpio_dir = devfs_mk_dir(NULL, "gpio", NULL);

	for (i = 0; i < ARRAYSIZE(gpio_file); i++) {
		gpio_file[i].handle = devfs_register(gpio_dir,
						     gpio_file[i].name,
						     DEVFS_FL_DEFAULT, gpio_major, i,
						     S_IFCHR | S_IRUGO | S_IWUGO,
						     &gpio_fops, NULL);
	}
	gpio_init_flag = 1;

if (iswrt350n)
{
//	printk(KERN_EMERG "WRT350N GPIO Init\n");
	/* For WRT350N USB LED control */
	sb_gpioreserve(gpio_sbh, 0x400, GPIO_HI_PRIORITY);
	sb_gpioouten(gpio_sbh, 0x400, 0x400, GPIO_HI_PRIORITY);
	sb_gpioreserve(gpio_sbh, 0x800, GPIO_HI_PRIORITY);
	sb_gpioouten(gpio_sbh, 0x800, 0x800, GPIO_HI_PRIORITY);

	//if (nvram_match("disabled_5397", "1")) {
//		printk("5397 switch GPIO-Reset \n");
		sb_gpioreserve(gpio_sbh, 0x4, GPIO_HI_PRIORITY);
		sb_gpioouten(gpio_sbh, 0x4, 0x4, GPIO_HI_PRIORITY);
		sb_gpioout(gpio_sbh, 0x4, 0x4, GPIO_HI_PRIORITY);
	//}
		
	USB_SET_LED(USB_DISCONNECT); //2005-02-24 by kanki for USB LED

}

	return 0;
}
Example #20
0
static int __init module_lpc_init(void) 
    {
    int i, val, ret;
    char c;
    
//    if (!DbgInit())  return -ENOMEM;
    info(DRIVER_DESC " " DRIVER_VERSION);

    ret = register_chrdev(major, DRIVER_DEV_NAME, &lpc_fops);
    if (ret < 0) 
        {
        err("register_chrdev(major=%d, \"" DRIVER_DEV_NAME "\")=%d -> failed", major, ret);
//        DbgExit();
        return ret;
        }
    if (major == 0)  major = ret;  // dynamic major

#ifdef CONFIG_DEVFS_FS
#warning CONFIG_DEVFS_FS not tested
	ret = devfs_mk_dir("lpc");
    dbg1("major=%d   devfs_mk_dir()=%08X", major, ret);
#else
#warning Info: CONFIG_DEVFS_FS not used
#endif

    ret = pci_module_init(&lpp_driver);
    
    if( isa ) 
        {
        i = 0;
        while( *isa && (i < MAX_LPCS*4) ) 
            {
            c = *isa++;
            val = -1;
            if((c >= '0') && (c <= '9')) val = c - '0';
            if((c >= 'A') && (c <= 'F')) val = c + 10 - 'A';
            if((c >= 'a') && (c <= 'f')) val = c + 10 - 'a';
            if(val >= 0) 
                {
                lpcs[i >> 2] = (lpcs[i >> 2] << 4) | val;
                i++;
                }
            }
        }
Example #21
0
static int __init mmc_blk_init(void)
{
	int res = -ENOMEM;

	res = register_blkdev(major, "mmc");
	if (res < 0) {
		printk(KERN_WARNING "Unable to get major %d for MMC media: %d\n",
		       major, res);
		goto out;
	}
	if (major == 0)
		major = res;

	devfs_mk_dir("mmc");
	return mmc_register_driver(&mmc_driver);

 out:
	return res;
}
Example #22
0
int slm_init( void )

{
	if (devfs_register_chrdev( MAJOR_NR, "slm", &slm_fops )) {
		printk( KERN_ERR "Unable to get major %d for ACSI SLM\n", MAJOR_NR );
		return -EBUSY;
	}
	
	if (!(SLMBuffer = atari_stram_alloc( SLM_BUFFER_SIZE, "SLM" ))) {
		printk( KERN_ERR "Unable to get SLM ST-Ram buffer.\n" );
		devfs_unregister_chrdev( MAJOR_NR, "slm" );
		return -ENOMEM;
	}
	BufferP = SLMBuffer;
	SLMState = IDLE;
	
	devfs_handle = devfs_mk_dir (NULL, "slm", NULL);
	devfs_register_series (devfs_handle, "%u", MAX_SLM, DEVFS_FL_DEFAULT,
			       MAJOR_NR, 0, S_IFCHR | S_IRUSR | S_IWUSR,
			       &slm_fops, NULL);
	return 0;
}
Example #23
0
int usb_major_init(void)
{
	int error;

	error = register_chrdev(USB_MAJOR, "usb", &usb_fops);
	if (error) {
		err("unable to get major %d for usb devices", USB_MAJOR);
		goto out;
	}

	usb_class = class_simple_create(THIS_MODULE, "usb");
	if (IS_ERR(usb_class)) {
		err("class_simple_create failed for usb devices");
		unregister_chrdev(USB_MAJOR, "usb");
		goto out;
	}

	devfs_mk_dir("usb");

out:
	return error;
}
Example #24
0
static int __init adc_init(void)
{
 int ret;
 
 ret = register_chrdev(0,DEVICE_NAME,&adc_fops);
   if(ret < 0) {  
  printk("adc: can't get major number\n");
        return ret;
 }
 
 adc_major = ret;

 peter_base_addr= ioremap(S3C2410_PA_ADC,0x20);

 #ifdef CONFIG_DEVFS_FS
  devfs_mk_dir("adc");
  devfs_mk_cdev(MKDEV(adc_major, 0), S_IFCHR|S_IRUGO|S_IWUSR, "adc/%d", 0);
 #endif
    
     printk("s3c2410_adc driver initial\n");
    
 return 0;
}
static int __init init_mtdchar(void)
{
#ifdef CONFIG_DEVFS_FS
	if (devfs_register_chrdev(MTD_CHAR_MAJOR, "mtd", &mtd_fops))
	{
		printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n",
		       MTD_CHAR_MAJOR);
		return -EAGAIN;
	}

	devfs_dir_handle = devfs_mk_dir(NULL, "mtd", NULL);

	register_mtd_user(&notifier);
#else
	if (register_chrdev(MTD_CHAR_MAJOR, "mtd", &mtd_fops))
	{
		printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n",
		       MTD_CHAR_MAJOR);
		return -EAGAIN;
	}
#endif

	return 0;
}
Example #26
0
int __init pty_init(void)
{
	int i;

	/* Traditional BSD devices */

	memset(&pty_state, 0, sizeof(pty_state));
	for (i = 0; i < NR_PTYS; i++)
		init_waitqueue_head(&pty_state[i].open_wait);
	memset(&pty_driver, 0, sizeof(struct tty_driver));
	pty_driver.magic = TTY_DRIVER_MAGIC;
	pty_driver.driver_name = "pty_master";
#ifdef CONFIG_DEVFS_FS
	pty_driver.name = "pty/m%d";
#else
	pty_driver.name = "pty";
#endif
	pty_driver.major = PTY_MASTER_MAJOR;
	pty_driver.minor_start = 0;
	pty_driver.num = NR_PTYS;
	pty_driver.type = TTY_DRIVER_TYPE_PTY;
	pty_driver.subtype = PTY_TYPE_MASTER;
	pty_driver.init_termios = tty_std_termios;
	pty_driver.init_termios.c_iflag = 0;
	pty_driver.init_termios.c_oflag = 0;
	pty_driver.init_termios.c_cflag = B38400 | CS8 | CREAD;
	pty_driver.init_termios.c_lflag = 0;
	pty_driver.flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
	pty_driver.refcount = &pty_refcount;
	pty_driver.table = pty_table;
	pty_driver.termios = pty_termios;
	pty_driver.termios_locked = pty_termios_locked;
	pty_driver.driver_state = pty_state;
	pty_driver.other = &pty_slave_driver;

	pty_driver.open = pty_open;
	pty_driver.close = pty_close;
	pty_driver.write = pty_write;
	pty_driver.write_room = pty_write_room;
	pty_driver.flush_buffer = pty_flush_buffer;
	pty_driver.chars_in_buffer = pty_chars_in_buffer;
	pty_driver.unthrottle = pty_unthrottle;
	pty_driver.set_termios = pty_set_termios;

	pty_slave_driver = pty_driver;
	pty_slave_driver.driver_name = "pty_slave";
	pty_slave_driver.proc_entry = 0;
#ifdef CONFIG_DEVFS_FS
	pty_slave_driver.name = "pty/s%d";
#else
	pty_slave_driver.name = "ttyp";
#endif
	pty_slave_driver.subtype = PTY_TYPE_SLAVE;
	pty_slave_driver.major = PTY_SLAVE_MAJOR;
	pty_slave_driver.minor_start = 0;
	pty_slave_driver.init_termios = tty_std_termios;
	pty_slave_driver.init_termios.c_cflag = B38400 | CS8 | CREAD;
	/* Slave ptys are registered when their corresponding master pty
	 * is opened, and unregistered when the pair is closed.
	 */
	pty_slave_driver.flags |= TTY_DRIVER_NO_DEVFS;
	pty_slave_driver.table = ttyp_table;
	pty_slave_driver.termios = ttyp_termios;
	pty_slave_driver.termios_locked = ttyp_termios_locked;
	pty_slave_driver.driver_state = pty_state;
	pty_slave_driver.other = &pty_driver;

	if (tty_register_driver(&pty_driver))
		panic("Couldn't register pty driver");
	if (tty_register_driver(&pty_slave_driver))
		panic("Couldn't register pty slave driver");

	/* 
	 * only the master pty gets this ioctl (which is why we
	 * assign it here, instead of up with the rest of the
	 * pty_driver initialization. <[email protected]>
	 */
	pty_driver.ioctl = pty_bsd_ioctl;

	/* Unix98 devices */
#ifdef CONFIG_UNIX98_PTYS
	devfs_mk_dir (NULL, "pts", NULL);
	printk("pty: %d Unix98 ptys configured\n", UNIX98_NR_MAJORS*NR_PTYS);
	for ( i = 0 ; i < UNIX98_NR_MAJORS ; i++ ) {
		int j;

		ptm_driver[i] = pty_driver;
		ptm_driver[i].name = "ptm";
		ptm_driver[i].proc_entry = 0;
		ptm_driver[i].major = UNIX98_PTY_MASTER_MAJOR+i;
		ptm_driver[i].minor_start = 0;
		ptm_driver[i].name_base = i*NR_PTYS;
		ptm_driver[i].num = NR_PTYS;
		ptm_driver[i].other = &pts_driver[i];
		ptm_driver[i].flags |= TTY_DRIVER_NO_DEVFS;
		ptm_driver[i].table = ptm_table[i];
		ptm_driver[i].termios = ptm_termios[i];
		ptm_driver[i].termios_locked = ptm_termios_locked[i];
		ptm_driver[i].driver_state = ptm_state[i];

		for (j = 0; j < NR_PTYS; j++)
			init_waitqueue_head(&ptm_state[i][j].open_wait);
		
		pts_driver[i] = pty_slave_driver;
#ifdef CONFIG_DEVFS_FS
		pts_driver[i].name = "pts/%d";
#else
		pts_driver[i].name = "pts";
#endif
		pts_driver[i].proc_entry = 0;
		pts_driver[i].major = UNIX98_PTY_SLAVE_MAJOR+i;
		pts_driver[i].minor_start = 0;
		pts_driver[i].name_base = i*NR_PTYS;
		pts_driver[i].num = ptm_driver[i].num;
		pts_driver[i].other = &ptm_driver[i];
		pts_driver[i].table = pts_table[i];
		pts_driver[i].termios = pts_termios[i];
		pts_driver[i].termios_locked = pts_termios_locked[i];
		pts_driver[i].driver_state = ptm_state[i];
		
		ptm_driver[i].ioctl = pty_unix98_ioctl;
		
		if (tty_register_driver(&ptm_driver[i]))
			panic("Couldn't register Unix98 ptm driver major %d",
			      ptm_driver[i].major);
		if (tty_register_driver(&pts_driver[i]))
			panic("Couldn't register Unix98 pts driver major %d",
			      pts_driver[i].major);
	}
#endif
	return 0;
}
Example #27
0
static inline void mtdchar_devfs_init(void)
{
	devfs_mk_dir("mtd");
	register_mtd_user(&notifier);
}
Example #28
0
int init_module() {

  printk(KERN_DEBUG "HIP: init_module\n");

  SET_MODULE_OWNER(&file_ops);

  devfs_hip_root = devfs_mk_dir(NULL, "hip", NULL);
  if (!devfs_hip_root) {
    printk(KERN_DEBUG "HIP: devfs_mk_dir failed\n");
    return(-EBUSY);
  }
  printk(KERN_DEBUG "HIP: devfs_mk_dir ok\n");


  /**
   *devfs_register - Register a device entry.
   *@dir: The handle to the parent devfs directory entry. If this is %NULL the
   *new name is relative to the root of the devfs.
   *@name: The name of the entry.
   *@flags: A set of bitwise-ORed flags (DEVFS_FL_*).
   *@major: The major number. Not needed for regular files.
   *@minor: The minor number. Not needed for regular files.
   *@mode: The default file mode.
   *@ops: The &file_operations or &block_device_operations structure.
   *This must not be externally deallocated.
   *@info: An arbitrary pointer which will be written to the @private_data
   *field of the &file structure passed to the device driver. You can set
   *this to whatever you like, and change it once the file is opened (the next
   *file opened will not see this change).
   *
   *Returns a handle which may later be used in a call to devfs_unregister().
   *On failure %NULL is returned.
   */
  /*
  devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
				 unsigned int flags,
				 unsigned int major, unsigned int minor,
				 umode_t mode, void *ops, void *info)


*/


  devfs_hip_dev = devfs_register(devfs_hip_root, "hipsocket",
				 DEVFS_FL_NONE,
				 HIP_CHAR_MAJOR,
				 0,
				 S_IFCHR | S_IRUSR | S_IWUSR,
                                 &file_ops,
				 NULL);

  if (!devfs_hip_dev) {
    devfs_unregister(devfs_hip_root);
    printk(KERN_DEBUG "HIP: devfs_register failed\n");
    return(-EBUSY);
  }

printk(KERN_DEBUG "HIP: devfs_register ok\n");


  return 0;
}
Example #29
0
int __init i2c_dev_init(void)
{
	int res;

	printk(KERN_INFO "i2c-dev.o: i2c /dev entries driver module version %s (%s)\n", I2C_VERSION, I2C_DATE);

	i2cdev_initialized = 0;
#ifdef CONFIG_DEVFS_FS
	if (devfs_register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops)) {
#else
	if (register_chrdev(I2C_MAJOR,"i2c",&i2cdev_fops)) {
#endif
		printk(KERN_ERR "i2c-dev.o: unable to get major %d for i2c bus\n",
		       I2C_MAJOR);
		return -EIO;
	}
#ifdef CONFIG_DEVFS_FS
	devfs_handle = devfs_mk_dir(NULL, "i2c", NULL);
#endif
	i2cdev_initialized ++;

	if ((res = i2c_add_driver(&i2cdev_driver))) {
		printk(KERN_ERR "i2c-dev.o: Driver registration failed, module not inserted.\n");
		i2cdev_cleanup();
		return res;
	}
	i2cdev_initialized ++;
	return 0;
}

int i2cdev_cleanup(void)
{
	int res;

	if (i2cdev_initialized >= 2) {
		if ((res = i2c_del_driver(&i2cdev_driver))) {
			printk("i2c-dev.o: Driver deregistration failed, "
			       "module not removed.\n");
			return res;
		}
	i2cdev_initialized --;
	}

	if (i2cdev_initialized >= 1) {
#ifdef CONFIG_DEVFS_FS
		devfs_unregister(devfs_handle);
		if ((res = devfs_unregister_chrdev(I2C_MAJOR, "i2c"))) {
#else
		if ((res = unregister_chrdev(I2C_MAJOR,"i2c"))) {
#endif
			printk("i2c-dev.o: unable to release major %d for i2c bus\n",
			       I2C_MAJOR);
			return res;
		}
		i2cdev_initialized --;
	}
	return 0;
}

EXPORT_NO_SYMBOLS;

#ifdef MODULE

MODULE_AUTHOR("Frodo Looijaard <[email protected]> and Simon G. Vogl <[email protected]>");
MODULE_DESCRIPTION("I2C /dev entries driver");
MODULE_LICENSE("GPL");

int init_module(void)
{
	return i2c_dev_init();
}

int cleanup_module(void)
{
	return i2cdev_cleanup();
}
Example #30
0
/*! 
  - ajout de sa structure de données dans smdstate
  - création et connexion des segments + IT SCI
  - création du rep DEVFS pour ce noeud
*/
int smd_add_snode(char *nom_node, 
		  long no_sci) {
  
  servernode_t *sn;
  u32 no_snode; 

  PDEBUG("entering. Param : nom_node =%s no_sci=%ld\n",
	 nom_node,
	 no_sci);

  no_snode = unused_elt_indice((void *)smd.snodes, NBMAX_SNODES);
  if (no_snode == NBMAX_SNODES) {
    PERROR("can't add the new server node because max number "
	   "( = %d) reached\n",
	   NBMAX_SNODES);
    return ERROR;
  }

  PDEBUG("free elt indice %d of smd.snodes[] chosen\n", no_snode);

  sn = vmalloc(sizeof(struct servernode));
  if (sn == NULL) {
    PERROR("can't allocate memory for new snode '%s'\n", nom_node);
    goto error_vmalloc;
  }
  
  smd.snodes[no_snode] = sn;  
  sn->status = INSANE;
  sscanf(nom_node, "%s", sn->name); 
  sn->dev_rep = devfs_mk_dir(smd.dev_rep, sn->name, NULL);
  PDEBUG("sn->dev_rep = devfs_mk_dir(smd.dev_rep, sn->name, NULL) == %p\n",
	 sn->dev_rep);
  if (sn->dev_rep == NULL) {
    PERROR("can't create devfs rep for ze node %s\n",sn->name);
    goto error_devfs;
  }
  sn->no_sci = no_sci;
  sn->busy = IDLE; 
  sn->creq.kreq = NULL;

  //for (i=0; i<NBMAX_DEVS; i++) sn->wreqs.nd = NULL
  nullify_table((void *)sn->ndevs, NBMAX_NDEVS);

  PDEBUG("devfs rep '%s' created\n", sn->name);

  // init sci pour ce nouveau server node
  if (smd_add_snode_sci(sn,no_sci)) {
    printk(KERN_ERR "smd_add_snode_sci failed\n");
    goto error_sci;
  }				

  PDEBUG("sci structures for snode '%s' created\n", sn->name);
  sn->maxsize_req = smd.dataseg_size / SMD_HARDSECT; 
  reset_sn_stats(sn);

  //sn->status = UP;
  smd.snodes[no_snode] = sn;  
  smd.nb_snodes++;

  PDEBUG("server node '%s' added\n", sn->name);
  return SUCCESS;

 error_sci:
  PDEBUG("devfs_unregister(sn->dev_rep = %p)\n", sn->dev_rep);
  devfs_unregister(sn->dev_rep);
 error_devfs:
  vfree(sn);
  smd.snodes[no_snode] = NULL;
 error_vmalloc:
  return ERROR;
}