int sculld_init(void) { int result, i; dev_t dev = MKDEV(sculld_major, 0); /* * Register your major, and accept a dynamic number. */ if (sculld_major) result = register_chrdev_region(dev, sculld_devs, "sculld"); else { result = alloc_chrdev_region(&dev, 0, sculld_devs, "sculld"); sculld_major = MAJOR(dev); } if (result < 0) return result; /* * Register with the driver core. */ register_ldd_driver(&sculld_driver); /* * allocate the devices -- we can't have them static, as the number * can be specified at load time */ sculld_devices = kmalloc(sculld_devs*sizeof (struct sculld_dev), GFP_KERNEL); if (!sculld_devices) { result = -ENOMEM; goto fail_malloc; } memset(sculld_devices, 0, sculld_devs*sizeof (struct sculld_dev)); for (i = 0; i < sculld_devs; i++) { sculld_devices[i].order = sculld_order; sculld_devices[i].qset = sculld_qset; sema_init (&sculld_devices[i].sem, 1); sculld_setup_cdev(sculld_devices + i, i); sculld_register_dev(sculld_devices + i, i); } #ifdef SCULLD_USE_PROC /* only when available */ create_proc_read_entry("sculldmem", 0, NULL, sculld_read_procmem, NULL); #endif return 0; /* succeed */ fail_malloc: unregister_chrdev_region(dev, sculld_devs); return result; }
/* Create tl880 entries in /proc */ int tl880_create_proc_entry() { struct proc_dir_entry *entry; entry = create_proc_read_entry("tl880", 0, NULL, tl880_proc_read, NULL); if(!entry) { printk(KERN_ERR "tl880: failed to create /proc entry\n"); return -EIO; } else { entry->owner = THIS_MODULE; return 0; } }
void init_smtc_stats(void) { int i; for (i=0; i<NR_CPUS; i++) { smtc_cpu_stats[i].timerints = 0; smtc_cpu_stats[i].selfipis = 0; } atomic_set(&smtc_fpu_recoveries, 0); smtc_stats = create_proc_read_entry("smtc", 0444, NULL, proc_read_smtc, NULL); }
void __init proc_app_info_init(void) { static struct { char *name; int (*read_proc)(char*,char**,off_t,int,int*,void*); } *p, simple_ones[] = { {"app_info", app_version_read_proc}, {NULL,} }; for (p = simple_ones; p->name; p++) create_proc_read_entry(p->name, 0, NULL, p->read_proc, NULL); }
static int __init logcap_init(void) { struct proc_dir_entry *proc_entry; printk(KERN_DEBUG TAG": allocate storage for %d registers, %d bytes\n", MAX_REGS, sizeof(ar_logcap_regs)); store = vmalloc(sizeof(ar_logcap_regs)); memset(store, 0, sizeof(ar_logcap_regs)); proc_root = proc_mkdir(TAG, NULL); create_proc_read_entry("rd_count", 0444, proc_root, proc_rd_count_read, NULL); create_proc_read_entry("wr_count", 0444, proc_root, proc_wr_count_read, NULL); create_proc_read_entry("map", 0444, proc_root, proc_map_read, NULL); proc_entry = create_proc_read_entry("log_enable", 0666, proc_root, proc_log_enable_read, NULL); proc_entry->write_proc = proc_log_enable_write; if (log_enable & L_DMESG) capcap_dumpnames(); hook_init(); hooked = true; return 0; }
static int __init netlink_proto_init(void) { struct sk_buff *dummy_skb; if (sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb)) { printk(KERN_CRIT "netlink_init: panic\n"); return -1; } sock_register(&netlink_family_ops); #ifdef CONFIG_PROC_FS create_proc_read_entry("net/netlink", 0, 0, netlink_read_proc, NULL); #endif return 0; }
void register_charging_i2c_dev(struct device * dev) /* todo add destructor call for caller */ { dev_info(dev, "%s %d\n", __func__, __LINE__); if (!charger_extra_sysfs.dev) { charger_extra_sysfs.dev = dev ; #ifdef AB8500_PROC_DEBUG_ENTRY charger_extra_sysfs.proc_entry = create_proc_read_entry("AB8500_CHG",0444,NULL,charging_readproc,dev); #endif //AB8500_PROC_DEBUG_ENTRY make_dfms_battery_device ( ) ; wake_lock_init(&charger_extra_sysfs.test_wake_lock, WAKE_LOCK_SUSPEND, "suspend lock"); } }
static int __init msm8k_amr_init(void) { int rc; D("%s\n", __func__); rc = misc_register(&msm8k_amr_misc); #ifdef CONFIG_PROC_FS create_proc_read_entry(MSM8K_AMR_PROC_NAME, 0, NULL, msm8k_amr_read_proc, NULL); #endif return rc; }
int __init prominfo_init(void) { struct proc_dir_entry **entp; cnodeid_t cnodeid; nasid_t nasid; char name[NODE_NAME_LEN]; if (!ia64_platform_is("sn2")) return 0; TRACE(); DPRINTK("running on cpu %d\n", smp_processor_id()); DPRINTK("numnodes %d\n", numnodes); proc_entries = kmalloc(numnodes * sizeof(struct proc_dir_entry *), GFP_KERNEL); sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); for (cnodeid = 0, entp = proc_entries; cnodeid < numnodes; cnodeid++, entp++) { sprintf(name, "node%d", cnodeid); *entp = proc_mkdir(name, sgi_prominfo_entry); nasid = cnodeid_to_nasid(cnodeid); create_proc_read_entry( "fit", 0, *entp, read_fit_entry, lookup_fit(nasid)); create_proc_read_entry( "version", 0, *entp, read_version_entry, lookup_fit(nasid)); } return 0; }
/** * \fn static int __init ifx_wdt_init_module(void) * \brief Initialize WDT module * * \return -ENOMEM Failed to allocate memory * -EINVAL Failed to register char device * 0 OK * \ingroup IFX_WDT_INTERNAL */ static int __init ifx_wdt_init_module(void) { int result =0; char ver_str[128] = {0}; #if 1 /* ctc */ struct proc_dir_entry* proc_file_conf; #endif ifx_wdt_dev = (wdt_dev*)kmalloc(sizeof(wdt_dev),GFP_KERNEL); ifx_wdt_drv_ver(ver_str); if (ifx_wdt_dev == NULL){ return -ENOMEM; } memset(ifx_wdt_dev,0,sizeof(wdt_dev)); strcpy(ifx_wdt_dev->name, DEVICE_NAME); #if 1 /* ctc */ result = register_chrdev(0,ifx_wdt_dev->name,&wdt_fops); #else result = register_chrdev(251,ifx_wdt_dev->name,&wdt_fops); #endif if (result < 0) { IFX_WDT_EMSG("cannot register device\n"); kfree(ifx_wdt_dev); return -EINVAL; } ifx_wdt_dev->major = result; /* Create proc file */ #if 0 /* ctc 20100407 modified to added write procedure */ create_proc_read_entry("ifx_wdt", 0, NULL, wdt_register_proc_read , NULL); #else proc_file_conf = create_proc_entry("ifx_wdt", 0666, NULL); if (proc_file_conf == NULL) { printk( "error creating entry in /proc/ifx_wdt\n" ); } else { proc_file_conf->write_proc = wdt_register_proc_write; proc_file_conf->read_proc = wdt_register_proc_read; } #endif return 0; }
static int __init ttlio_init(void) { printk(KERN_INFO "MT6N TTL-I/O driver (release %s)\n", TTLIO_VERSION); misc_register(&ttlio_dev); create_proc_read_entry ("driver/ttlio", 0, 0, ttlio_read_proc, NULL); set_GPIO_IRQ_edge(GPIO_TTLIO_IRQ, GPIO_FALLING_EDGE); if (request_irq(TTLIO_IRQ, ttlio_interrupt, SA_INTERRUPT, "ttlio irq", NULL)) { printk(KERN_ERR "ttlio: irq %d already in use\n", TTLIO_IRQ); return 1; } return 0; }
void create_testmode_status(void) { static uint32_t *p_smem_testmode_status ; static int l_testmode_status ; int size ; p_smem_testmode_status = smem_get_entry( SMEM_ID_VENDOR0 ,&size ) ; if( p_smem_testmode_status ) l_testmode_status = *p_smem_testmode_status ; create_proc_read_entry("is_phone_testmode", S_IRUGO, NULL , testmode_read_proc,&l_testmode_status); }
int __init prominfo_init(void) { struct proc_dir_entry **entp; struct proc_dir_entry *p; cnodeid_t cnodeid; unsigned long nasid; char name[NODE_NAME_LEN]; if (!ia64_platform_is("sn2")) return 0; proc_entries = kmalloc(num_online_nodes() * sizeof(struct proc_dir_entry *), GFP_KERNEL); sgi_prominfo_entry = proc_mkdir("sgi_prominfo", NULL); entp = proc_entries; for_each_online_node(cnodeid) { sprintf(name, "node%d", cnodeid); *entp = proc_mkdir(name, sgi_prominfo_entry); nasid = cnodeid_to_nasid(cnodeid); p = create_proc_read_entry( "fit", 0, *entp, read_fit_entry, (void *)nasid); if (p) p->owner = THIS_MODULE; p = create_proc_read_entry( "version", 0, *entp, read_version_entry, (void *)nasid); if (p) p->owner = THIS_MODULE; entp++; } return 0; }
int xfs_init_procfs(void) { if (!proc_mkdir("fs/xfs", NULL)) goto out; if (!create_proc_read_entry("fs/xfs/stat", 0, NULL, xfs_read_xfsstats, NULL)) goto out_remove_entry; return 0; out_remove_entry: remove_proc_entry("fs/xfs", NULL); out: return -ENOMEM; }
void create_qpst_enable_status(void) { short *p_smem_qpst_enable_status ; static int qpst_enable_status = -1 ; int size ; p_smem_qpst_enable_status = smem_get_entry( SMEM_ID_VENDOR2 ,&size ) ; if( p_smem_qpst_enable_status ) qpst_enable_status = *p_smem_qpst_enable_status ; if(qpst_enable_status!=-1) //QPST_DISABLED = -1, osbl_dload_mproc.c create_proc_read_entry("qpst_enable", S_IRUGO, NULL , qpst_enable_read_proc,&qpst_enable_status); }
// ------------------------------------------------------------------------- int __init bks_createProcDirEntry(void* private_data) { int rc = 0; struct proc_dir_entry* entry = 0; printk(KERN_INFO "[bks] bks_createProcDirEntry()\n"); entry = create_proc_read_entry(BKS_PROC_DIR_NAME, 0, 0, bks_procfile_read, private_data); if (!entry) { printk(KERN_ERR "[bks] unable to create dir /proc/%s\n", BKS_PROC_DIR_NAME); rc = -ENOMEM; } return rc; }
static int __init dicer_init(void) { dicer = proc_mkdir("dicer", NULL); if (!dicer) goto error; num_dice_p = create_proc_read_entry("num_dice", 0, dicer, read_proc, NULL); if (!num_dice_p) goto cleanup; num_dice_p->write_proc = write_proc; return 0; cleanup: remove_proc_entry(dicer->name, NULL); error: printk(KERN_ALERT "DICE: Failed to create /proc entries\n"); return -1; }
/*This function initializes all needed resources (only) once, during system init.*/ void curse_init (void) { int j; curse_id_t t; //1. Initialize curse lookup table. curse_list_pointer = (struct syscurse *)kzalloc((MAX_CURSE_NO + 1) * sizeof(struct syscurse), GFP_KERNEL); if (curse_list_pointer == NULL) { printk(KERN_CRIT "CRITICAL: Curse system was not able to allocate memory. The system will probably crash later."); goto out; } for (j = 1, t = 0x01; j < MAX_CURSE_NO; ++j, t <<= 1) { curse_list_pointer[j].entry = (struct curse_list_entry *)&curse_full_list[j]; curse_list_pointer[j].curse_bit = t; atomic_set(&(curse_list_pointer[j].ref_count), 0); curse_list_pointer[j].var_flags = _INHER_MASK; SET_INHER(j); curse_list_pointer[j].status = IMPLEMENTED; spin_lock_init(&(curse_list_pointer[j].flag_lock)); curse_list_pointer[j].functions = &fun_array[j]; } curse_list_pointer[0].status = INVALID_CURSE; curse_list_pointer[0].curse_bit = 0x0; atomic_set(&(curse_list_pointer[0].ref_count), 0); curse_list_pointer[0].entry = (struct curse_list_entry *)&curse_full_list[0]; spin_lock_init(&(curse_list_pointer[0].flag_lock)); curse_list_pointer[0].functions = &fun_array[0]; //2. Initialize active status boolean. :: Could default on an initial status here (based on build options). CURSE_SYSTEM_DOWN; //3. Populate entries in /proc filesystem. if (!(dir_node = proc_mkdir(PROC_DIR_NAME, NULL))) goto out; if (!(output_node = create_proc_read_entry(PROC_OUT_NODE_NAME, (S_IRUSR | S_IRGRP | S_IROTH), dir_node, proc_curse_read, curse_list_pointer))) goto out_dirred; //FIXME: Is there anything else to be done here? goto out; //out_nodded: remove_proc_entry(PROC_OUT_NODE_NAME, dir_node); out_dirred: remove_proc_entry(PROC_DIR_NAME, NULL); out: return; //Stub: there might be others below. }
/** * @brief create wlan proc file * * @param priv pointer wlan_private * @param dev pointer net_device * @return N/A */ void wlan_proc_entry(wlan_private * priv, struct net_device *dev) { #ifdef CONFIG_PROC_FS diag_printf("Creating Proc Interface\n"); if (!priv->proc_entry) { priv->proc_entry = proc_mkdir("wlan", proc_net); if (priv->proc_entry) { priv->proc_dev = create_proc_read_entry ("info", 0, priv->proc_entry, wlan_proc_read, dev); } } #endif }
static int __init __noinstrument kfi_init(void) { int ret = misc_register(&kfi_miscdev); if (ret) { err("Register misc driver failed, errno is %d\n", ret); return ret; } #ifdef CONFIG_KFI_STATIC_RUN run_tail = kfi_last_run; next_run_id = kfi_num_runs; #endif create_proc_read_entry("kfi", 0, NULL, kfi_read_proc, NULL); return 0; }
static int __init msm8k_pcm_init(void) { int rc; D("%s\n", __func__); rc = misc_register(&msm8k_pcm_misc); wake_lock_init(&pcm_wakelock, WAKE_LOCK_SUSPEND, "audio_pcm"); wake_lock_init(&pcm_idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); mutex_init(&pcm_lock); #ifdef CONFIG_PROC_FS create_proc_read_entry(MSM8K_PCM_PROC_NAME, 0, NULL, msm8k_pcm_read_proc, NULL); #endif return rc; }
static int __init gpt_mod_init(void) { create_proc_read_entry("gpt_stat", S_IRUGO, NULL, gpt_stat_read, NULL); #if 0 #ifndef CONFIG_MT6582_FPGA printk("GPT: chipver=%d\n", mt_get_chip_sw_ver()); #else printk("GPT: FPGA2\n" ); #endif #endif printk("GPT: iniit\n" ); return 0; }
void create_smpl_reset_status(void) { static uint32_t *p_smem_pwr_on_status ; static int l_power_on_status ; int size ; p_smem_pwr_on_status = smem_get_entry( SMEM_POWER_ON_STATUS_INFO, &size ) ; if( p_smem_pwr_on_status ) l_power_on_status = *p_smem_pwr_on_status ; l_power_on_status = (l_power_on_status & 0x8) ? 1 : 0; create_proc_read_entry("smpl_reset", S_IRUGO, NULL , smpl_reset_read_proc,&l_power_on_status); }
void __init dpm_generic_md_proc_init(struct proc_dir_entry *proc_dpm_md) { proc_dpm_md_opts = create_proc_read_entry("opts", S_IRUGO, proc_dpm_md, read_proc_dpm_md_opts, NULL); proc_dpm_md_cmd = create_proc_entry("cmd", S_IWUSR, proc_dpm_md); if (proc_dpm_md_cmd) proc_dpm_md_cmd->write_proc = write_proc_dpm_md_cmd; }
int register_rtc(struct rtc_ops *ops) { int ret = -EBUSY; mutex_lock(&rtc_mutex); if (rtc_ops == NULL) { rtc_ops = ops; ret = misc_register(&rtc_miscdev); if (ret == 0) create_proc_read_entry("driver/rtc", 0, NULL, rtc_read_proc, ops); } mutex_unlock(&rtc_mutex); return ret; }
int init_module(void) { struct pci_dev *dev; int err; printk(KERN_INFO "khyt1331: start initialization\n"); if (register_chrdev(HYT1331_MAJOR, "hyt1331", &khyt1331_fops)) { printk(KERN_ERR "khyt1331: unable to get major %d\n", HYT1331_MAJOR); return -EBUSY; } /* PCI scan */ dev = NULL; dev = pci_find_device(0x1196, 0x5331, dev); if (dev != NULL) { io_base = pci_resource_start(dev, 3); irq = dev->irq; printk(KERN_INFO "khyt1331: Found 5331 card at %X, irq %d\n", io_base, irq); /* request IO ports */ if ((err = check_region(io_base, 0x40)) < 0) { printk(KERN_INFO "khyt1331: Cannot request IO address %X\n", io_base); return err; } request_region(io_base, 0x40, "khyt1331"); /* request interrupt */ if (request_irq(irq, khyt1331_interrupt, SA_SHIRQ, "khyt1331", &khyt1331_fops)) { printk(KERN_INFO "khyt1331: Cannot request interrupt %d\n", irq); irq = -1; } } else { printk(KERN_INFO "khyt1331: No 5331 card found\n"); return -ENODEV; } /* register /proc/khyt1331 interface */ create_proc_read_entry("khyt1331", 0, NULL, khyt1331_read_procmem, NULL); printk(KERN_INFO "khyt1331: initialization finished\n"); return 0; }
//----------------------------------------------------------------------------- // /proc setup //----------------------------------------------------------------------------- int s1d13521proc_init(void) { // First setup a subdirectory for s1d13521fb s1d13521fb_dir = proc_mkdir("s1d13521fb", NULL); if (!s1d13521fb_dir) return -ENOMEM; s1d13521fb_dir->owner = THIS_MODULE; info_file = create_proc_read_entry("info", 0444, s1d13521fb_dir, proc_read_fb, (void*)PROC_INFO); if (info_file == NULL) return -ENOMEM; ft_file = create_proc_entry("ft", 0644, s1d13521fb_dir); if (ft_file == NULL) return -ENOMEM; ft_file->data = (void *)PROC_FRAME; ft_file->read_proc = proc_read_fb; ft_file->write_proc = proc_write_fb; ft_file->owner = THIS_MODULE; init_file = create_proc_entry("init", 0644, s1d13521fb_dir); if (init_file == NULL) return -ENOMEM; init_file->data = (void *)PROC_INIT; init_file->read_proc = proc_read_fb; init_file->write_proc = proc_write_fb; init_file->owner = THIS_MODULE; reg_file = create_proc_entry("regio", 0644, s1d13521fb_dir); if (reg_file == NULL) return -ENOMEM; reg_file->data = (void *)PROC_REG; reg_file->read_proc = proc_read_fb; reg_file->write_proc = proc_write_fb; reg_file->owner = THIS_MODULE; return 0; }
int hisi_init_adc(void) { int retval = 0; his_adc.adc_file = create_proc_read_entry(adc_proc_name, 0, NULL, hisi_adc_proc_read, NULL); if (his_adc.adc_file == NULL) { pr_warning("%s: %s fail!\n", __func__, adc_proc_name); return -ENOMEM; } retval = request_irq(ADC_IRQ, sar_adc_interrupt, 0, "SAR_ADC", NULL); if(0 != retval){ pr_warning("hi3518 ADC: failed to register IRQ(%d)\n", retval); goto ADC_INIT_FAIL1; } his_adc.sar_adc_reg_base = ioremap_nocache((unsigned long)SAR_ADC_BASE, 0x20); if (NULL == his_adc.sar_adc_reg_base){ pr_warning("function %s line %u failed\n", __FUNCTION__, __LINE__); retval = -EFAULT; goto ADC_INIT_FAIL2; } //-------------------------------- // power ADC function //-------------------------------- writel(ADC_POWER_ENABLE, his_adc.sar_adc_reg_base + ADC_POWER); //---------------------------------- // enable CLK and cancell soft reset //---------------------------------- writel(ADC_CLK_ENABLE, IO_ADDRESS(PERI_CRG32_BASE)); his_adc.flag = 0; init_waitqueue_head(&his_adc.irq_wait); return 0; ADC_INIT_FAIL2: free_irq(ADC_IRQ, NULL); ADC_INIT_FAIL1: remove_proc_entry(adc_proc_name, NULL); return retval; }
static int __init boot_mod_init(void) { int ret; /* allocate device major number */ if (alloc_chrdev_region(&boot_dev_num, 0, 1, BOOT_DEV_NAME) < 0) { printk("[%s] fail to register chrdev\n",MOD); return -1; } /* add character driver */ cdev_init(&boot_cdev, &boot_fops); ret = cdev_add(&boot_cdev, boot_dev_num, 1); if (ret < 0) { printk("[%s] fail to add cdev\n",MOD); return ret; } /* create class (device model) */ boot_class = class_create(THIS_MODULE, BOOT_DEV_NAME); if (IS_ERR(boot_class)) { printk("[%s] fail to create class\n",MOD); return (int)boot_class; } boot_device = device_create(boot_class, NULL, boot_dev_num, NULL, BOOT_DEV_NAME); if (IS_ERR(boot_device)) { printk("[%s] fail to create device\n",MOD); return (int)boot_device; } /* add kobject */ ret = kobject_init_and_add(&boot_kobj, &boot_ktype, &(boot_device->kobj), BOOT_SYSFS); if (ret < 0) { printk("[%s] fail to add kobject\n",MOD); return ret; } printk("[%s] chip hw code = 0x%x\n",MOD,get_chip_code()); printk("[%s] chip eco version = 0x%x\n",MOD,get_chip_eco_ver()); /* create proc entry at /proc/boot_mode */ create_proc_read_entry("boot_mode", S_IRUGO, NULL, boot_mode_proc, NULL); return 0; }
int img_scale_probe(struct platform_device *pdev) { int ret = 0; int i = 0; struct scale_user *p_user = NULL; SCALE_TRACE("scale_probe called \n"); ret = misc_register(&img_scale_dev); if (ret) { SCALE_TRACE("cannot register miscdev (%d)\n", ret); goto exit; } img_scale_proc_file = create_proc_read_entry("driver/scale", 0444, NULL, img_scale_proc_read, NULL); if (unlikely(NULL == img_scale_proc_file)) { printk("Can't create an entry for scale in /proc \n"); ret = ENOMEM; goto exit; } /* initialize locks */ mutex_init(&scale_param_cfg_mutex); mutex_init(&scale_dev_open_mutex); g_scale_user = kzalloc(SCALE_USER_MAX * sizeof(struct scale_user), GFP_KERNEL); if (NULL == g_scale_user) { printk("scale_user, no mem"); return -1; } p_user = g_scale_user; for (i = 0; i < SCALE_USER_MAX; i++) { p_user->pid = INVALID_USER_ID; sema_init(&p_user->sem_done, 0); p_user++; } cur_task_pid = INVALID_USER_ID; exit: return ret; }