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; }
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; }
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; }
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; }
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; }
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); }
int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance) { char devname[8]; if(dev == NULL) { printk(KERN_ERR "VFC: Bogus pointer passed\n"); return -ENOMEM; } printk("Initializing vfc%d\n",instance); dev->regs = NULL; dev->regs = (volatile struct vfc_regs *) sbus_ioremap(&sdev->resource[0], 0, sizeof(struct vfc_regs), vfcstr); dev->which_io = sdev->reg_addrs[0].which_io; dev->phys_regs = (struct vfc_regs *) sdev->reg_addrs[0].phys_addr; if (dev->regs == NULL) return -EIO; printk("vfc%d: registers mapped at phys_addr: 0x%lx\n virt_addr: 0x%lx\n", instance,(unsigned long)sdev->reg_addrs[0].phys_addr,(unsigned long)dev->regs); if (init_vfc_devstruct(dev, instance)) return -EINVAL; if (init_vfc_hw(dev)) return -EIO; sprintf (devname, "%d", instance); dev->de = devfs_register (devfs_handle, devname, DEVFS_FL_DEFAULT, VFC_MAJOR, instance, S_IFCHR | S_IRUSR | S_IWUSR, &vfc_fops, NULL); return 0; }
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); }
int AclRegIoctlHandler(void) { #ifdef CONFIG_DEVFS_FS if(devfs_register_chrdev(acl_major, ACL_DEVNAME , &acl_fops)) { NAT_PRINT(KERN_WARNING " acl: can't create device node - %s\n",ACL_DEVNAME); return -EIO; } devfs_handle = devfs_register(NULL, ACL_DEVNAME, DEVFS_FL_DEFAULT, acl_major, 0, S_IFCHR | S_IRUGO | S_IWUGO, &acl_fops, NULL); #else int result=0; result = register_chrdev(acl_major, ACL_DEVNAME, &acl_fops); if (result < 0) { NAT_PRINT(KERN_WARNING "acl: can't get major %d\n",acl_major); return result; } if (acl_major == 0) { acl_major = result; /* dynamic */ } #endif return 0; }
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; }
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; }
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 */ }
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; }
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"); }
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; }
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; }
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; }
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; }
static void mtd_notify_add(struct mtd_info* mtd) { char name[8]; if (!mtd) return; sprintf(name, "%d", mtd->index); devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2, S_IFCHR | S_IRUGO | S_IWUGO, &mtd_fops, NULL); sprintf(name, "%dro", mtd->index); devfs_ro_handle[mtd->index] = devfs_register(devfs_dir_handle, name, DEVFS_FL_DEFAULT, MTD_CHAR_MAJOR, mtd->index*2+1, S_IFCHR | S_IRUGO, &mtd_fops, NULL); }
/* Initialize the module - Register the character device */ int aud_init_module() { int ret_val; int *ver; struct aud_ucode_info **uc_ptr; devfs_handle_t devfs_handle; int i; /* Register the character device (atleast try) */ ret_val = devfs_register_chrdev(MAJOR_NUM_ADEC, DEVICE_NAME_ADEC, &Fops); /* Negative values signify an error */ if (ret_val < 0) { PDEBUG("AUD: %s failed with %d\n", "Sorry, registering the character device ", ret_val); return ret_val; } for(i=0; i < no_devnodes; i++) { devfs_handle = devfs_find_handle(NULL, devnodes[i].name, 0, 0, DEVFS_SPECIAL_CHR,0); if(devfs_handle == NULL) { devfs_handle = devfs_register(NULL, devnodes[i].name, DEVFS_FL_DEFAULT, MAJOR_NUM_ADEC, devnodes[i].minor, S_IFCHR | S_IRUSR | S_IWUSR, devnodes[i].fops, NULL); devnodes[i].devfs_handle = devfs_handle; } else { devnodes[i].devfs_handle = NULL; } } /* print version numbers for audio microcode */ for (uc_ptr = aud_ucode_info; *uc_ptr != NULL; uc_ptr++) { if (((*uc_ptr)->ucode[248] != 0) || ((*uc_ptr)->ucode[249] != 0)) { ver = (int *)(&(*uc_ptr)->ucode[248]); printk(KERN_NOTICE "audio microcode %s **test version** built on %d/%d/%d\n", (*uc_ptr)->name, (*ver%10000)/100, *ver%100, *ver/10000); } else { printk(KERN_NOTICE "audio microcode %s ver %d.%d\n", (*uc_ptr)->name, (*uc_ptr)->ucode[250], (*uc_ptr)->ucode[251]); } } //DEMUX_REG_AVCB(&aud_callback, 1, 1); PDEBUG("AUD: Initialize adec_dev OK!\n"); return 0; }
int mulle_nor_init(void) { int res = mtd_init(mtd0); if (res >= 0) { /* Register DevFS node */ devfs_register(&mulle_nor_devfs); } return res; }
int __init akmem_init(void) { if (devfs_register_chrdev(AKMEM_MAJOR,"akmem",&akmem_fops)) printk("unable to get major %d for akmem devs\n", AKMEM_MAJOR); devfs_register (NULL, "akmem", DEVFS_FL_NONE, AKMEM_MAJOR, akmem_minor, S_IRUSR | S_IWUSR, &akmem_fops, NULL); return 0; }
snd_info_entry_t *snd_info_create_device(const char *name, unsigned int number, unsigned int mode) { #ifdef CONFIG_DEVFS_FS char dname[32]; #endif unsigned short major = number >> 16; unsigned short minor = (unsigned short) number; snd_info_entry_t *entry; struct proc_dir_entry *p = NULL; if (!major) major = snd_major; if (!mode) mode = S_IFCHR | S_IRUGO | S_IWUGO; mode &= (snd_device_mode & (S_IRUGO | S_IWUGO)) | S_IFCHR | S_IFBLK; entry = snd_info_create_module_entry(THIS_MODULE, name, NULL); if (entry == NULL) return NULL; entry->content = SNDRV_INFO_CONTENT_DEVICE; entry->mode = mode; entry->c.device.major = major; entry->c.device.minor = minor; down(&info_mutex); p = create_proc_entry(entry->name, entry->mode, snd_proc_dev); if (p) { #ifndef TARGET_OS2 snd_info_device_entry_prepare(p, entry); #ifdef LINUX_2_3 p->proc_fops = &snd_fops; #else p->ops = &snd_info_device_inode_operations; #endif #endif } else { up(&info_mutex); snd_info_free_entry(entry); return NULL; } p->gid = snd_device_gid; p->uid = snd_device_uid; p->data = (void *) entry; entry->p = p; up(&info_mutex); #ifdef CONFIG_DEVFS_FS if (strncmp(name, "controlC", 8)) { /* created in sound.c */ sprintf(dname, "snd/%s", name); devfs_register(NULL, dname, DEVFS_FL_DEFAULT, major, minor, mode, &snd_fops, NULL); } #endif return entry; }
int __init h3600_backpaq_fpga_init_module(void) { int result; printk(KERN_ALERT __FILE__ ": registering char device"); /* Register my device driver */ result = devfs_register_chrdev(0,MODULE_NAME, &h3600_backpaq_fpga_fops); if ( result <= 0 ) { printk(" can't get major number\n"); return result; } if ( h3600_backpaq_fpga_major_num == 0 ) h3600_backpaq_fpga_major_num = result; printk(" %d\n", h3600_backpaq_fpga_major_num); /* Clear the default structure */ memset(&h3600_backpaq_fpga_data, 0, sizeof(struct h3600_backpaq_fpga_dev_struct)); /* Create a devfs entry */ #ifdef CONFIG_DEVFS_FS devfs_fpga = devfs_register( NULL, FPGA_DEVICE_NAME, DEVFS_FL_DEFAULT, h3600_backpaq_fpga_major_num, FPGA_MINOR, S_IFCHR | S_IRUSR | S_IWUSR, &h3600_backpaq_fpga_fops, NULL ); #endif #ifdef CONFIG_PROC_FS /* Set up the PROC file system entry */ proc_backpaq_fpga = create_proc_entry(FPGA_PROC_NAME, 0, NULL); if ( !proc_backpaq_fpga ) { /* We probably need to create the "backpaq" directory first */ proc_mkdir(FPGA_PROC_DIR,0); proc_backpaq_fpga = create_proc_entry(FPGA_PROC_NAME, 0, NULL); } if ( proc_backpaq_fpga ) proc_backpaq_fpga->read_proc = proc_h3600_backpaq_read; else { printk(KERN_ALERT __FILE__ ": unable to create proc entry %s\n", FPGA_PROC_NAME); devfs_unregister( devfs_fpga ); devfs_unregister_chrdev( h3600_backpaq_fpga_major_num, MODULE_NAME ); return -ENODEV; } #endif #ifdef CONFIG_PM fpga_backpaq_dev = h3600_backpaq_register_device( H3600_BACKPAQ_FPGA_DEV, 0, h3600_backpaq_fpga_callback ); printk(KERN_ALERT __FILE__ ": registered backpaq callback=%p\n", h3600_backpaq_fpga_callback); #endif return 0; }
static void devfs_register_card(struct em84xx *card) { #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,70) char devname[64]; sprintf(devname, "%s%d", REALMAGIC_DEVICE_NAME, 0); em8300_handle[0] = devfs_register(NULL, devname, DEVFS_FL_DEFAULT, REALMAGIC_MAJOR, 0, S_IFCHR | S_IRUGO | S_IWUGO, &em8300_fops, NULL); sprintf(devname, "%s%d", REALMAGIC_DEVICE_NAME, 1); em8300_handle[0] = devfs_register(NULL, devname, DEVFS_FL_DEFAULT, REALMAGIC_MAJOR, 1, S_IFCHR | S_IRUGO | S_IWUGO, &em8300_fops, NULL); sprintf(devname, "%s%d", REALMAGIC_DEVICE_NAME, 2); em8300_handle[0] = devfs_register(NULL, devname, DEVFS_FL_DEFAULT, REALMAGIC_MAJOR, 2, S_IFCHR | S_IRUGO | S_IWUGO, &em8300_fops, NULL); sprintf(devname, "%s%d", REALMAGIC_DEVICE_NAME, 3); em8300_handle[0] = devfs_register(NULL, devname, DEVFS_FL_DEFAULT, REALMAGIC_MAJOR, 3, S_IFCHR | S_IRUGO | S_IWUGO, &em8300_fops, NULL); #else devfs_mk_cdev(MKDEV(REALMAGIC_MAJOR, 0), S_IFCHR | S_IRUGO | S_IWUGO, "%s%d", REALMAGIC_DEVICE_NAME, 0); devfs_mk_cdev(MKDEV(REALMAGIC_MAJOR, 1), S_IFCHR | S_IRUGO | S_IWUGO, "%s%d", REALMAGIC_DEVICE_NAME, 1); devfs_mk_cdev(MKDEV(REALMAGIC_MAJOR, 2), S_IFCHR | S_IRUGO | S_IWUGO, "%s%d", REALMAGIC_DEVICE_NAME, 2); devfs_mk_cdev(MKDEV(REALMAGIC_MAJOR, 3), S_IFCHR | S_IRUGO | S_IWUGO, "%s%d", REALMAGIC_DEVICE_NAME, 3); #endif }
void shmiq_init (void) { printk ("SHMIQ setup\n"); devfs_register_chrdev(SHMIQ_MAJOR, "shmiq", &shmiq_fops); devfs_register (NULL, "shmiq", DEVFS_FL_DEFAULT, SHMIQ_MAJOR, 0, S_IFCHR | S_IRUSR | S_IWUSR, &shmiq_fops, NULL); devfs_register_series (NULL, "qcntl%u", 2, DEVFS_FL_DEFAULT, SHMIQ_MAJOR, 1, S_IFCHR | S_IRUSR | S_IWUSR, &shmiq_fops, NULL); }
static int __init viadev_init(void) { // Find the device di.pcidev = pci_find_device(PCI_VENDOR_ID_VIA, _PCI_DEVICE_ID_VIA_CLE3122, NULL); MY_ASSERT(di.pcidev, MODULE_NAME ": VIA CLE266 graphics device not found.", -ENODEV); MY_ASSERT(!di.pcidev->driver, MODULE_NAME ": There is already a driver installed.", -EBUSY); // Map physical IO memory address into kernel space. di.io_base_phy = pci_resource_start(di.pcidev, 1); di.size = pci_resource_len(di.pcidev, 1); MY_ASSERT(request_mem_region(di.io_base_phy, di.size, MODULE_NAME), MODULE_NAME ": Memory mapping failed (1).", -EBUSY); di.iobase = ioremap(di.io_base_phy, di.size); MY_ASSERT(di.iobase, MODULE_NAME ": Memory mapping failed (2).", -EBUSY); // TODO: Register PCI device driver. Or not. We don't really need to. // Register a character device. Uses devfs #if CLE266_STATIC_DEVNUM int result; result = register_chrdev(VIADEV_MAJOR, MODULE_NAME, &viadev_fops); MY_ASSERT(!result, MODULE_NAME " Unable to register driver\n", result); #else #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) int result; result = register_chrdev(VIADEV_MAJOR, MODULE_NAME, &viadev_fops); MY_ASSERT(!result, MODULE_NAME " Unable to register driver\n", result); devfs_mk_cdev(MKDEV(VIADEV_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR, MODULE_NAME); #else di.devhnd = devfs_register(NULL, MODULE_NAME, DEVFS_FL_AUTO_DEVNUM, 0, 0, S_IFCHR | S_IRUGO | S_IWUGO, &viadev_fops, &di); MY_ASSERT(di.devhnd, MODULE_NAME ": Could not register a /dev entry.", -EAGAIN); #endif #endif // CLE266_STATIC_DEVNUM printk(MODULE_NAME " installed. Hardware rev %d detected.\n", via_get_revision()); via_enable_mmio(); return 0; }
/**************************************************************************** Description: Initialize the module. Allocate the major number and register the dev nodes (for DEVFS). Arguments: None. Return Value: None Remarks: Called by the kernel. Initializes global mutex, sets trace level and registers the module. It calls also functions to initialize the hardware which is used. ****************************************************************************/ static int __init duslic_module_init(void) { IFX_int32_t result, i; #ifdef CONFIG_DEVFS_FS IFX_int32_t j; IFX_char_t buf[10]; #endif /* CONFIG_DEVFS_FS */ #ifdef CONFIG_DEVFS_FS memset (&(devfs_handle), 0x00, sizeof(devfs_handle)); for (i = 0; i < DUSLIC_MAX_DEVICES; ++i) { for (j = 0; j <= DUSLIC_MAX_CHANNELS; j++ ) { sprintf (buf, "dus%ld%ld", i+1, j); if (( devfs_handle[i*DUSLIC_MAX_CHANNELS + j] = devfs_register( NULL, buf, DEVFS_FL_DEFAULT, DUSLIC_MAJOR, (i+1)*10+j, S_IFCHR | S_IRUGO | S_IWUGO, &DUSLIC_fops, (void *) 0 )) == NULL) { printk("add device error!\n"); result = -ENODEV; } } } #else /* Register the caracter device and allocate the major number */ result = register_chrdev(DUSLIC_MAJOR, DEV_NAME , &DUSLIC_fops); if ( result < 0 ) { TRACE (VINETIC, DBG_LEVEL_HIGH, ("Loading %s module ERROR: major %d not found!", DEV_NAME, DUSLIC_MAJOR)); return result; } #endif /* CONFIG_DEVFS_FS */ init_hardware(); create_proc_read_entry( DEV_NAME, S_IFREG|S_IRUGO, NULL, DUSLIC_Read_Proc, &proc_root ); return IFX_SUCCESS; }
static void ipmi_new_smi(int if_num) { char name[2]; if (if_num > MAX_DEVICES) return; name[0] = if_num + '0'; name[1] = '\0'; handles[if_num] = devfs_register(devfs_handle, name, DEVFS_FL_NONE, ipmi_major, if_num, S_IFCHR | S_IRUSR | S_IWUSR, &ipmi_fops, NULL); }
/* * This is where hid.c calls us to connect a hid device to the hiddev driver */ int hiddev_connect(struct hid_device *hid) { struct hiddev *hiddev; int minor, i; char devfs_name[16]; if ((hid->quirks & HID_QUIRK_HIDDEV) == 0) { for (i = 0; i < hid->maxcollection; i++) if (hid->collection[i].type == HID_COLLECTION_APPLICATION && !IS_INPUT_APPLICATION(hid->collection[i].usage)) break; if (i == hid->maxcollection) return -1; } for (minor = 0; minor < HIDDEV_MINORS && hiddev_table[minor]; minor++); if (minor == HIDDEV_MINORS) { printk(KERN_ERR "hiddev: no more free hiddev devices\n"); return -1; } if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) return -1; memset(hiddev, 0, sizeof(struct hiddev)); init_waitqueue_head(&hiddev->wait); hiddev->minor = minor; hiddev_table[minor] = hiddev; hiddev->hid = hid; hiddev->exist = 1; sprintf(devfs_name, "hiddev%d", minor); hiddev->devfs = devfs_register(hiddev_devfs_handle, devfs_name, DEVFS_FL_DEFAULT, USB_MAJOR, minor + HIDDEV_MINOR_BASE, S_IFCHR | S_IRUGO | S_IWUSR, &hiddev_fops, NULL); hid->minor = minor; hid->hiddev = hiddev; return 0; }