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 lirc_dev_init(void) { int i; for (i=0; i < MAX_IRCTL_DEVICES; ++i) { init_irctl(&irctls[i]); init_MUTEX(&irctls[i].lock); init_waitqueue_head(&irctls[i].wait_poll); } #ifndef LIRC_HAVE_DEVFS i = register_chrdev(IRCTL_DEV_MAJOR, #else i = devfs_register_chrdev(IRCTL_DEV_MAJOR, #endif IRCTL_DEV_NAME, &fops); if (i < 0) { printk ("lirc_dev: device registration failed with %d\n", i); return i; } printk("lirc_dev: IR Remote Control driver registered, at major %d \n", IRCTL_DEV_MAJOR); return SUCCESS; }
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 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 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; }
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; }
int __init chr_dev_init(void) { if (devfs_register_chrdev(MEM_MAJOR,"mem",&memory_fops)) printk("unable to get major %d for memory devs\n", MEM_MAJOR); memory_devfs_register(); rand_initialize(); #ifdef CONFIG_I2C i2c_init_all(); #endif #if defined (CONFIG_FB) fbmem_init(); #endif #if defined (CONFIG_PROM_CONSOLE) prom_con_init(); #endif #if defined (CONFIG_MDA_CONSOLE) mda_console_init(); #endif tty_init(); #ifdef CONFIG_M68K_PRINTER lp_m68k_init(); #endif misc_init(); #if CONFIG_QIC02_TAPE qic02_tape_init(); #endif #ifdef CONFIG_FTAPE ftape_init(); #endif #if defined(CONFIG_S390_TAPE) && defined(CONFIG_S390_TAPE_CHAR) tapechar_init(); #endif return 0; }
// ------------------- INIT ------------------------ static int GPIO_LED_CTL_init(void) { int ret = -ENODEV; printk("--------------------------------------------\n\n"); // init GPIO //=== PORT F GROUP //Ports : GPF7 GPF6 GPF5 GPF4 GPF3 GPF2 GPF1 GPF0 //Signal : nLED_8 nLED_4 nLED_2 nLED_1 nIRQ_PCMCIA EINT2 KBDINT EINT0 //Setting: Output Output Output Output EINT3 EINT2 EINT1 EINT0 //Binary : 01 01 , 01 01 , 10 10 , 10 10 GPFCON = 0x55aa; // 设置端口为I/O输出模式 GPFUP = 0xff; // 关闭上拉功能 GPFDAT =0xf;//初始值为高电平熄灭LED灯 ret = devfs_register_chrdev(GPIO_LED_MAJOR, "gpio_led_ctl", &GPIO_LED_ctl_ops); if( ret < 0 ) { printk (" S3C2410: init_module failed with %d\n", ret); return ret; } else { printk("S3C2410 gpio_led_driver register success!!! \n"); } return ret; }
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; }
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 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 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; }
/* 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 __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; }
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; }
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 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; }
/* * Initialization and exit routines */ int __init led_init(void) { int retval; retval = devfs_register_chrdev(LED_MAJOR,"led",&led_fops); //registered as a char device if (retval) { printk(KERN_ERR"led: can't register on minor=%d\n",LED_MAJOR); return retval; } dev_handle = devfs_register( NULL, "led", DEVFS_FL_DEFAULT, LED_MAJOR, 0, S_IFCHR, &led_fops, NULL); return retval; }
int __init ms77xxxx_led_init(void) { int rc; rc = devfs_register_chrdev(LED_MAJOR, LED_NAME, &ms77xxxx_led_fops); if (rc < 0) return rc; devfs_register(NULL, LED_NAME, DEVFS_FL_NONE, LED_MAJOR, 0, 0666 | S_IFCHR, &ms77xxxx_led_fops, NULL); #if defined(CONFIG_SH_7760_SOLUTION_ENGINE) printk(KERN_INFO "MS7760CP01 LED driver initialized.\n"); #else #error No Platform #endif return rc; }
static int __init gfx_inf_init(void) { int rtn = gfx_inf_h_init(GFX_MAX_ALLOWED_SURFACES); // print the driver verision info for futher reference PVERSION(GFX_DRIVER_NAME); if(rtn < 0) { PFATALE("GFX: Failed to initialize device!\n"); return -1; } if (devfs_register_chrdev(GFX_DEV_MAJOR, GFX_DRIVER_NAME, &GfxFops) < 0) { gfx_inf_h_deinit(2); PFATALE("GFX: Failed to register device!\n"); return -1; } devfs_handle = devfs_find_handle(NULL, "stbgfx", 0, 0, DEVFS_SPECIAL_CHR,0); if(devfs_handle == NULL) { devfs_handle = devfs_register(NULL, "stbgfx", DEVFS_FL_DEFAULT, GFX_DEV_MAJOR, 0, S_IFCHR | S_IRUSR | S_IWUSR, &GfxFops, NULL); } else devfs_handle = NULL; /* * Initialize the dma module -- BJC 102102 */ if(gfx_atom_init() != 0) { PFATALE("GFX: Failed to initialize graphics atom!\n"); } return 0; }
/* init module */ int __init sci_module_init(void) { int rc; devfs_handle_t devfs_handle; int i; if (sci_osd_init(detect_p, vcc_p) == SCI_ERROR_OK) { /* Register the character device (at least try) */ if ((rc = devfs_register_chrdev(MAJOR_NUM, DEVICE_NAME, &Fops)) >= 0) { PDEBUG("success\n"); rc = 0; } 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, 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; } } } else { PDEBUG("failed\n"); rc = -1; } return (rc); }
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; }
int __init dsp56k_init(void) { if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) { printk("DSP56k driver: Hardware not present\n"); return -ENODEV; } if(devfs_register_chrdev(DSP56K_MAJOR, "dsp56k", &dsp56k_fops)) { printk("DSP56k driver: Unable to register driver\n"); return -ENODEV; } devfs_handle = devfs_register (NULL, "dsp56k", DEVFS_FL_DEFAULT, DSP56K_MAJOR, 0, S_IFCHR | S_IRUSR | S_IWUSR, &dsp56k_fops, NULL); dsp56k.in_use = 0; printk("DSP56k driver installed\n"); return 0; }
int __init ra_nvram_init(void) { int i; #ifndef CONFIG_DEVFS_FS int r = 0; #endif #ifdef CONFIG_DEVFS_FS if (devfs_register_chrdev(ralink_nvram_major, RALINK_NVRAM_DEVNAME, &ralink_nvram_fops)) { printk(KERN_ERR NAME ": unable to register character device\n"); return -EIO; } devfs_handle = devfs_register(NULL, RALINK_NVRAM_DEVNAME, DEVFS_FL_DEFAULT, ralink_nvram_major, 0, S_IFCHR | S_IRUGO | S_IWUGO, &ralink_nvram_fops, NULL); #else r = register_chrdev(ralink_nvram_major, RALINK_NVRAM_DEVNAME, &ralink_nvram_fops); if (r < 0) { printk(KERN_ERR "ralink_nvram: unable to register character device\n"); return r; } if (ralink_nvram_major == 0) { ralink_nvram_major = r; printk(KERN_DEBUG "ralink_nvram: got dynamic major %d\n", r); } #endif init_MUTEX(&nvram_sem); down(&nvram_sem); for (i = 0; i < FLASH_BLOCK_NUM; i++) init_nvram_block(i); up(&nvram_sem); return 0; }
int __init h3600_stowaway_init_module( void ) { /* register our character device */ SFDEBUG(0,"registering char device\n"); g_stowaway_major = devfs_register_chrdev(0, H3600_STOWAWAY_MODULE_NAME, &stowaway_fops); if (g_stowaway_major < 0) { printk(KERN_ALERT __FUNCTION__ ": can't get major number\n"); return g_stowaway_major; } devfs_stowaway = devfs_register( NULL, H3600_STOWAWAY_DEVICE_NAME, DEVFS_FL_DEFAULT, g_stowaway_major, 0, S_IFCHR | S_IRUSR | S_IWUSR, &stowaway_fops, NULL ); /* Register in /proc filesystem */ create_proc_read_entry(H3600_STOWAWAY_PROC_STATS, 0, proc_dir, h3600_stowaway_proc_stats_read, NULL ); h3600_stowaway_sysctl_header = register_sysctl_table(h3600_stowaway_dir_table, 0); return 0; }
static int __init dtlk_init(void) { dtlk_port_lpc = 0; dtlk_port_tts = 0; dtlk_busy = 0; dtlk_major = devfs_register_chrdev(0, "dtlk", &dtlk_fops); if (dtlk_major == 0) { printk(KERN_ERR "DoubleTalk PC - cannot register device\n"); return 0; } if (dtlk_dev_probe() == 0) printk(", MAJOR %d\n", dtlk_major); devfs_handle = devfs_register (NULL, "dtlk", DEVFS_FL_DEFAULT, dtlk_major, DTLK_MINOR, S_IFCHR | S_IRUSR | S_IWUSR, &dtlk_fops, NULL); init_timer(&dtlk_timer); dtlk_timer.function = dtlk_timer_tick; init_waitqueue_head(&dtlk_process_list); 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(¬ifier); #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; }
static int __init capi_init(void) { char *p; char *compileinfo; MOD_INC_USE_COUNT; if ((p = strchr(revision, ':')) != 0 && p[1]) { strncpy(rev, p + 2, sizeof(rev)); rev[sizeof(rev)-1] = 0; if ((p = strchr(rev, '$')) != 0 && p > rev) *(p-1) = 0; } else strcpy(rev, "1.0"); if (devfs_register_chrdev(capi_major, "capi20", &capi_fops)) { printk(KERN_ERR "capi20: unable to get major %d\n", capi_major); MOD_DEC_USE_COUNT; return -EIO; } #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE if (devfs_register_chrdev(capi_rawmajor, "capi/r%d", &capinc_raw_fops)) { devfs_unregister_chrdev(capi_major, "capi20"); printk(KERN_ERR "capi20: unable to get major %d\n", capi_rawmajor); MOD_DEC_USE_COUNT; return -EIO; } devfs_register_series (NULL, "capi/r%u", CAPINC_NR_PORTS, DEVFS_FL_DEFAULT, capi_rawmajor, 0, S_IFCHR | S_IRUSR | S_IWUSR, &capinc_raw_fops, NULL); #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ devfs_register (NULL, "isdn/capi20", DEVFS_FL_DEFAULT, capi_major, 0, S_IFCHR | S_IRUSR | S_IWUSR, &capi_fops, NULL); printk(KERN_NOTICE "capi20: started up with major %d\n", capi_major); if ((capifuncs = attach_capi_interface(&cuser)) == 0) { MOD_DEC_USE_COUNT; devfs_unregister_chrdev(capi_major, "capi20"); #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE devfs_unregister_chrdev(capi_rawmajor, "capi/r%d"); #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ devfs_unregister(devfs_find_handle(NULL, "capi20", capi_major, 0, DEVFS_SPECIAL_CHR, 0)); return -EIO; } #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE if (capinc_tty_init() < 0) { (void) detach_capi_interface(&cuser); devfs_unregister_chrdev(capi_major, "capi20"); devfs_unregister_chrdev(capi_rawmajor, "capi/r%d"); MOD_DEC_USE_COUNT; return -ENOMEM; } #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ if (alloc_init() < 0) { #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE unsigned int j; devfs_unregister_chrdev(capi_rawmajor, "capi/r%d"); for (j = 0; j < CAPINC_NR_PORTS; j++) { char devname[32]; sprintf(devname, "capi/r%u", j); devfs_unregister(devfs_find_handle(NULL, devname, capi_rawmajor, j, DEVFS_SPECIAL_CHR, 0)); } capinc_tty_exit(); #endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ (void) detach_capi_interface(&cuser); devfs_unregister_chrdev(capi_major, "capi20"); devfs_unregister(devfs_find_handle(NULL, "capi20", capi_major, 0, DEVFS_SPECIAL_CHR, 0)); MOD_DEC_USE_COUNT; return -ENOMEM; } (void)proc_init(); #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE #if defined(CONFIG_ISDN_CAPI_CAPIFS) || defined(CONFIG_ISDN_CAPI_CAPIFS_MODULE) compileinfo = " (middleware+capifs)"; #else compileinfo = " (no capifs)"; #endif #else compileinfo = " (no middleware)"; #endif printk(KERN_NOTICE "capi20: Rev %s: started up with major %d%s\n", rev, capi_major, compileinfo); MOD_DEC_USE_COUNT; return 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 <*****@*****.**> and Simon G. Vogl <*****@*****.**>"); MODULE_DESCRIPTION("I2C /dev entries driver"); MODULE_LICENSE("GPL"); int init_module(void) { return i2c_dev_init(); } int cleanup_module(void) { return i2cdev_cleanup(); }
static int __init dev_nvram_init(void) { int order = 0, ret = 0; struct page *page, *end; unsigned int i; /* Allocate and reserve memory to mmap() */ while ((PAGE_SIZE << order) < NVRAM_SPACE) order++; end = virt_to_page(nvram_buf + (PAGE_SIZE << order) - 1); for (page = virt_to_page(nvram_buf); page <= end; page++) mem_map_reserve(page); #ifdef CONFIG_MTD /* Find associated MTD device */ for (i = 0; i < MAX_MTD_DEVICES; i++) { nvram_mtd = get_mtd_device(NULL, i); if (nvram_mtd) { if (!strcmp(nvram_mtd->name, "nvram") && nvram_mtd->size >= NVRAM_SPACE) break; put_mtd_device(nvram_mtd); } } if (i >= MAX_MTD_DEVICES) nvram_mtd = NULL; #endif /* Initialize hash table lock */ spin_lock_init(&nvram_lock); /* Initialize commit semaphore */ init_MUTEX(&nvram_sem); /* Register char device */ if ((nvram_major = devfs_register_chrdev(0, "nvram", &dev_nvram_fops)) < 0) { ret = nvram_major; goto err; } /* Initialize hash table */ _nvram_init(sbh); /* Create /dev/nvram handle */ nvram_handle = devfs_register(NULL, "nvram", DEVFS_FL_NONE, nvram_major, 0, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, &dev_nvram_fops, NULL); /* Set the SDRAM NCDL value into NVRAM if not already done */ if (getintvar(NULL, "sdram_ncdl") == 0) { unsigned int ncdl; char buf[] = "0x00000000"; if ((ncdl = sb_memc_get_ncdl(sbh))) { sprintf(buf, "0x%08x", ncdl); nvram_set("sdram_ncdl", buf); nvram_commit(); } } return 0; err: dev_nvram_exit(); return ret; }