int pn544_mmi_init(void) { struct proc_dir_entry *pn544_dir; struct proc_dir_entry *pn544_mmi; PN544_MMI_DEBUG("%s:entered and ready to create proc node to support MMI test\n",__func__); pn544_dir=proc_mkdir("pn544",NULL); if(NULL==pn544_dir) { printk("Can not create folder pn544 in proc system.\n"); return -EIO; } pn544_mmi=proc_create("pn544_mmi", S_IRUGO, pn544_dir, &pn544_mmi_fops); if(NULL==pn544_mmi) { printk("Can not create folder pn544 in proc system.\n"); return -EIO; } return 0; }
static int configure_procfs ( void ) { /* create directory */ dir_pfs = proc_mkdir ( PROBE_PROCFS_DIR_NAME, NULL ); if ( dir_pfs == NULL ) { remove_proc_entry ( PROBE_PROCFS_DIR_NAME, NULL ); log_infok( "error: Could not initialize /proc/%s\n", PROBE_PROCFS_DIR_NAME ); return -ENOMEM; } dir_pfs->owner = THIS_MODULE; if ( !configure_proc_entry ( ivhs_feedback_pfs, &ivhs_feedback_fops, PROBE_PROCFS_FEEDBACK ) ) goto out_trigger; return true_b; out_trigger: remove_proc_entry ( PROBE_PROCFS_FEEDBACK, dir_pfs ); remove_proc_entry ( PROBE_PROCFS_DIR_NAME, NULL ); return false_b; }
int __init scsi_init_procfs(void) { struct proc_dir_entry *pde; proc_scsi = proc_mkdir("scsi", NULL); if (!proc_scsi) goto err1; pde = create_proc_entry("scsi/scsi", 0, NULL); if (!pde) goto err2; pde->proc_fops = &proc_scsi_operations; return 0; err2: remove_proc_entry("scsi", NULL); err1: return -ENOMEM; }
/* * initialise the /proc/fs/cachefiles/ directory */ int __init cachefiles_proc_init(void) { _enter(""); if (!proc_mkdir("fs/cachefiles", NULL)) goto error_dir; if (!proc_create("fs/cachefiles/histogram", S_IFREG | 0444, NULL, &cachefiles_histogram_fops)) goto error_histogram; _leave(" = 0"); return 0; error_histogram: remove_proc_entry("fs/cachefiles", NULL); error_dir: _leave(" = -ENOMEM"); return -ENOMEM; }
/* * This needs to be done after sysctl_init, otherwise sys/ will be * overwritten. Actually, this shouldn't be in sys/ at all since * it isn't a sysctl, and it doesn't contain sysctl information. * We now locate it in /proc/cpu/alignment instead. */ static int __init alignment_init(void) { struct proc_dir_entry *dir, *res; dir = proc_mkdir("cpu", NULL); if (!dir) return -ENOMEM; res = proc_create_data("alignment", S_IWUSR | S_IRUGO, dir, &alignment_proc_fops, &se_usermode); if (!res) return -ENOMEM; res = proc_create_data("kernel_alignment", S_IWUSR | S_IRUGO, dir, &alignment_proc_fops, &se_kernmode_warn); if (!res) return -ENOMEM; return 0; }
static int __init acpi_battery_init (void) { int result = 0; ACPI_FUNCTION_TRACE("acpi_battery_init"); acpi_battery_dir = proc_mkdir(ACPI_BATTERY_CLASS, acpi_root_dir); if (!acpi_battery_dir) return_VALUE(-ENODEV); acpi_battery_dir->owner = THIS_MODULE; result = acpi_bus_register_driver(&acpi_battery_driver); if (result < 0) { remove_proc_entry(ACPI_BATTERY_CLASS, acpi_root_dir); return_VALUE(-ENODEV); } return_VALUE(0); }
int divert_dev_init(void) { init_waitqueue_head(&rd_queue); #ifdef CONFIG_PROC_FS isdn_proc_entry = proc_mkdir("isdn", init_net.proc_net); if (!isdn_proc_entry) return (-1); isdn_divert_entry = proc_create("divert", S_IFREG | S_IRUGO, isdn_proc_entry, &isdn_fops); if (!isdn_divert_entry) { remove_proc_entry("isdn", init_net.proc_net); return (-1); } #endif /* CONFIG_PROC_FS */ return (0); } /* divert_dev_init */
static void __init rtas_init(void) { struct proc_dir_entry *rtas_dir, *entry; rtas_dir = proc_mkdir("rtas", 0); if (!rtas_dir) { printk(KERN_ERR "Failed to create rtas proc directory\n"); } else { entry = create_proc_entry("error_log", S_IRUSR, rtas_dir); if (entry) entry->proc_fops = &proc_rtas_log_operations; else printk(KERN_ERR "Failed to create rtas/error_log proc entry\n"); } if (kernel_thread(rtasd, 0, CLONE_FS) < 0) printk(KERN_ERR "Failed to start RTAS daemon\n"); printk(KERN_ERR "RTAS daemon started\n"); }
void __init proc_root_init(void) { int err; proc_init_inodecache(); err = register_filesystem(&proc_fs_type); if (err) return; proc_mnt = kern_mount_data(&proc_fs_type, &init_pid_ns); err = PTR_ERR(proc_mnt); if (IS_ERR(proc_mnt)) { unregister_filesystem(&proc_fs_type); return; } proc_symlink("mounts", NULL, "self/mounts"); proc_net_init(); #ifdef CONFIG_SYSVIPC proc_mkdir("sysvipc", NULL); #endif proc_mkdir("fs", NULL); proc_mkdir("driver", NULL); proc_mkdir("fs/nfsd", NULL); /* somewhere for the nfsd filesystem to be mounted */ #if defined(CONFIG_SUN_OPENPROMFS) || defined(CONFIG_SUN_OPENPROMFS_MODULE) /* just give it a mountpoint */ proc_mkdir("openprom", NULL); #endif proc_tty_init(); #ifdef CONFIG_PROC_DEVICETREE proc_device_tree_init(); #endif proc_mkdir("bus", NULL); #if defined(CONFIG_MIPS_BRCM) proc_brcm = proc_mkdir("brcm", NULL); proc_brcm_init(proc_brcm); #endif proc_sys_init(); }
static int my_init (void) { proc_mydev = proc_mkdir(MYDEV,0); proc_hello = create_proc_entry(HELLO,0,proc_mydev); proc_hello->read_proc = read_hello; proc_hello->write_proc = write_hello; #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,29) proc_hello->owner = THIS_MODULE; #endif hello_data.proc_hello_value=kmalloc(PROC_HELLO_BUFLEN,GFP_KERNEL); hello_data.proc_hello_flag=0; hello_data.proc_hello_bitpos=0; // module init message printk(KERN_ALERT "2470:5.6: main initialized!\n"); return 0; }
int __init proc_demo_init(void){ printk("------------module init--------------------\n"); proc_entry_base = proc_mkdir(PROC_DIR_NAME, NULL); proc_bin2dec_entry = proc_create(PROC_BIN2DEC_NAME, 0666, proc_entry_base, &proc_bin2dec_ops); proc_readonly_entry = proc_create(PROC_READONLY_NAME, 0444, proc_entry_base, &proc_readonly_ops); if(!(proc_entry_base || proc_bin2dec_entry || proc_readonly_entry)){ return -1; } printk("------------module init finish--------------------\n"); return 0; }
static int __init psf_init(void) { int i; struct psf_entry *p; int rc; for (i = 0; i < ARRAY_SIZE(psf_table); i++) { p = &psf_table[i]; if (p->size == -1) { p->data = proc_mkdir(p->name, psf_parent(p)); BUG_ON(p->data == NULL); } else { rc = psf_create_file(p); if (rc < 0) return rc; } } return 0; }
static int __init proc_xm_init(void) { #ifdef CONFIG_PROC_FS struct proc_dir_entry *res; struct proc_dir_entry *proc_xm_dir = NULL; proc_xm_dir = proc_mkdir("xiaoqiang", NULL); res = proc_create("model", 0444, proc_xm_dir, &model_proc_fops); if (!res) return -ENOMEM; res = proc_create("reset", 0444, proc_xm_dir, &reset_proc_fops); if (!res) return -ENOMEM; #endif return 0; }
static int __net_init ipv6_proc_init_net(struct net *net) { if (!proc_create("sockstat6", S_IRUGO, net->proc_net, &sockstat6_seq_fops)) return -ENOMEM; if (!proc_create("snmp6", S_IRUGO, net->proc_net, &snmp6_seq_fops)) goto proc_snmp6_fail; net->mib.proc_net_devsnmp6 = proc_mkdir("dev_snmp6", net->proc_net); if (!net->mib.proc_net_devsnmp6) goto proc_dev_snmp6_fail; return 0; proc_dev_snmp6_fail: remove_proc_entry("snmp6", net->proc_net); proc_snmp6_fail: remove_proc_entry("sockstat6", net->proc_net); return -ENOMEM; }
void ide_proc_port_register_devices(ide_hwif_t *hwif) { struct proc_dir_entry *ent; struct proc_dir_entry *parent = hwif->proc; ide_drive_t *drive; char name[64]; int i; ide_port_for_each_dev(i, drive, hwif) { if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) continue; drive->proc = proc_mkdir(drive->name, parent); if (drive->proc) ide_add_proc_entries(drive->proc, generic_drive_entries, drive); sprintf(name, "ide%d/%s", (drive->name[2]-'a')/2, drive->name); ent = proc_symlink(drive->name, proc_ide_root, name); if (!ent) return; } }
static int __init acpi_fan_init(void) { int result = 0; #ifdef CONFIG_ACPI_PROCFS acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); if (!acpi_fan_dir) return -ENODEV; #endif result = acpi_bus_register_driver(&acpi_fan_driver); if (result < 0) { #ifdef CONFIG_ACPI_PROCFS remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); #endif return -ENODEV; } return 0; }
void proc_mali_register(void) { mali_pentry = proc_mkdir("mali", NULL); if (!mali_pentry) return; g_aee_workqueue = alloc_ordered_workqueue("mali_aeewp", WQ_FREEZABLE | WQ_MEM_RECLAIM); INIT_WORK(&g_aee_work, aee_Handle); proc_create("help", 0, mali_pentry, &kbasep_gpu_help_debugfs_fops); proc_create("memory_usage", 0, mali_pentry, &kbasep_gpu_memory_usage_debugfs_open); proc_create("utilization", 0, mali_pentry, &kbasep_gpu_utilization_debugfs_fops); proc_create("frequency", 0, mali_pentry, &kbasep_gpu_frequency_debugfs_fops); proc_create("dvfs_enable", S_IRUGO | S_IWUSR, mali_pentry, &kbasep_gpu_dvfs_enable_debugfs_fops); // proc_create("input_boost", S_IRUGO | S_IWUSR, mali_pentry, &kbasep_gpu_input_boost_debugfs_fops); // proc_create("dvfs_freq", S_IRUGO | S_IWUSR, mali_pentry, &kbasep_gpu_dvfs_freq_debugfs_fops); // proc_create("dvfs_threshold", S_IRUGO | S_IWUSR, mali_pentry, &kbasep_gpu_dvfs_threshold_debugfs_fops); // proc_create("dvfs_deferred_count", S_IRUGO | S_IWUSR, mali_pentry, &kbasep_gpu_dvfs_deferred_count_debugfs_fops); }
/* * rfs_proc_init */ static int rfs_proc_init(void) { /* * Create /proc/qrfs */ rfs_proc_entry = proc_mkdir("qrfs", NULL); if (!rfs_proc_entry) { RFS_ERROR("failed to register qrfs proc entry\n"); return -1; } rfs_debug_entry = proc_create("debug", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, rfs_proc_entry, &debug_proc_fops); rfs_enable_entry = proc_create("enable", S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, rfs_proc_entry, &enable_proc_fops); return 0; }
static void proc_mali_register(void) { struct proc_dir_entry *mt_elsuspend_entry = NULL; mali_pentry = proc_mkdir("mali", NULL); MALI_DEBUG_PRINT(1, ("[%s] pentry=%p\n", __FUNCTION__, mali_pentry)); if (!mali_pentry) return; proc_create("memory_usage", 0, mali_pentry, &proc_memoryusage_operations); proc_create("cur_freq", 0, mali_pentry, &proc_curfreq_operations); proc_create("utilization", 0, mali_pentry, &proc_utilization_operations); mt_elsuspend_entry = create_proc_entry("earlysuspend", S_IRUGO | S_IWUSR | S_IWGRP, mali_pentry); if (mt_elsuspend_entry) { mt_elsuspend_entry->read_proc = mali_early_suspend_debug_read; mt_elsuspend_entry->write_proc = mali_early_suspend_register_write; } }
static int __init icpld_proc_init(void) { int i; char nametemp[128]; proc_bus_cpld_dir = proc_mkdir("cpld", NULL); if (!proc_bus_cpld_dir) return -ENOMEM; for (i=0; i<CPLD_REG_COUNT; i++) { cpldEntry[i]=create_proc_entry (cpldRegNames[i].name, 0666, proc_bus_cpld_dir); if (!cpldEntry[i]) return -ENOMEM; cpldEntry[i]->nlink = 1; cpldEntry[i]->data = (void *)(&cpldRegNames[i].index); cpldEntry[i]->read_proc = icpld_read_proc; cpldEntry[i]->write_proc = icpld_write_proc; sprintf(nametemp,"%s_setbit",cpldRegNames[i].name); cpldEntrySetbit[i]=create_proc_entry (nametemp, 0666, proc_bus_cpld_dir); if (!cpldEntrySetbit[i]) return -ENOMEM; cpldEntrySetbit[i]->nlink = 1; cpldEntrySetbit[i]->data = (void *)(&cpldRegNames[i].index); cpldEntrySetbit[i]->write_proc = icpld_write_proc_setbit; sprintf(nametemp,"%s_clrbit",cpldRegNames[i].name); cpldEntryClrbit[i]=create_proc_entry (nametemp, 0666, proc_bus_cpld_dir); if (!cpldEntryClrbit[i]) return -ENOMEM; cpldEntryClrbit[i]->nlink = 1; cpldEntryClrbit[i]->data = (void *)(&cpldRegNames[i].index); cpldEntryClrbit[i]->write_proc = icpld_write_proc_clrbit; } return 0; }
/* * Process a node, adding entries for its children and its properties. */ void proc_device_tree_add_node(struct device_node *np, struct proc_dir_entry *de) { struct property *pp; struct proc_dir_entry *ent; struct device_node *child; const char *p; set_node_proc_entry(np, de); for (child = NULL; (child = of_get_next_child(np, child));) { /* Use everything after the last slash, or the full name */ p = strrchr(child->full_name, '/'); if (!p) p = child->full_name; else ++p; if (duplicate_name(de, p)) p = fixup_name(np, de, p); ent = proc_mkdir(p, de); if (ent == NULL) break; proc_device_tree_add_node(child, ent); } of_node_put(child); for (pp = np->properties; pp != NULL; pp = pp->next) { p = pp->name; if (strchr(p, '/')) continue; if (duplicate_name(de, p)) p = fixup_name(np, de, p); ent = __proc_device_tree_add_prop(de, pp, p); if (ent == NULL) break; } }
static int __init init_f2fs_fs(void) { int err; err = init_inodecache(); if (err) goto fail; err = create_node_manager_caches(); if (err) goto free_inodecache; err = create_gc_caches(); if (err) goto free_node_manager_caches; err = create_checkpoint_caches(); if (err) goto free_gc_caches; f2fs_kset = kset_create_and_add("f2fs", NULL, fs_kobj); if (!f2fs_kset) { err = -ENOMEM; goto free_checkpoint_caches; } err = register_filesystem(&f2fs_fs_type); if (err) goto free_kset; f2fs_create_root_stats(); f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); return 0; free_kset: kset_unregister(f2fs_kset); free_checkpoint_caches: destroy_checkpoint_caches(); free_gc_caches: destroy_gc_caches(); free_node_manager_caches: destroy_node_manager_caches(); free_inodecache: destroy_inodecache(); fail: return err; }
void __init mca_do_proc_init(void) { int i; struct proc_dir_entry *proc_mca; struct proc_dir_entry* node = NULL; struct mca_device *mca_dev; proc_mca = proc_mkdir("mca", NULL); create_proc_read_entry("pos",0,proc_mca,get_mca_info,NULL); create_proc_read_entry("machine",0,proc_mca,get_mca_machine_info,NULL); /* Initialize /proc/mca entries for existing adapters */ for(i = 0; i < MCA_NUMADAPTERS; i++) { enum MCA_AdapterStatus status; mca_dev = mca_find_device_by_slot(i); if(!mca_dev) continue; mca_dev->procfn = NULL; if(i < MCA_MAX_SLOT_NR) sprintf(mca_dev->procname,"slot%d", i+1); else if(i == MCA_INTEGVIDEO) sprintf(mca_dev->procname,"video"); else if(i == MCA_INTEGSCSI) sprintf(mca_dev->procname,"scsi"); else if(i == MCA_MOTHERBOARD) sprintf(mca_dev->procname,"planar"); status = mca_device_status(mca_dev); if (status != MCA_ADAPTER_NORMAL && status != MCA_ADAPTER_DISABLED) continue; node = create_proc_read_entry(mca_dev->procname, 0, proc_mca, mca_read_proc, (void *)mca_dev); if(node == NULL) { printk("Failed to allocate memory for MCA proc-entries!"); return; } } } /* mca_do_proc_init() */
void register_irq_proc(unsigned int irq, struct irq_desc *desc) { char name [MAX_NAMELEN]; struct proc_dir_entry *entry; if (!root_irq_dir || (desc->chip == &no_irq_chip) || desc->dir) return; memset(name, 0, MAX_NAMELEN); sprintf(name, "%d", irq); /* create /proc/irq/1234 */ desc->dir = proc_mkdir(name, root_irq_dir); #if USER_IRQ_ACCESS /* * Create handles for user-mode interrupt handlers * if the kernel hasn't already grabbed the IRQ */ //entry = create_proc_entry("irq", 0600, irq_dir[irq]); entry = create_proc_entry("irq", 0600, desc->dir); if (entry) { entry->data = (void *)(unsigned long)irq; entry->read_proc = NULL; entry->write_proc = NULL; entry->proc_fops = &irq_proc_file_operations; } #endif //USER_IRQ_ACCESS #ifdef CONFIG_SMP /* create /proc/irq/<irq>/smp_affinity */ proc_create_data("smp_affinity", 0600, desc->dir, &irq_affinity_proc_fops, (void *)(long)irq); #endif entry = create_proc_entry("spurious", 0444, desc->dir); if (entry) { entry->data = (void *)(long)irq; entry->read_proc = irq_spurious_read; } }
static int mt_golden_setting_init(void) { #if defined(CONFIG_MT_ENG_BUILD) #define GOLDEN_SETTING_BUF_SIZE (2 * PAGE_SIZE) unsigned int *buf; buf = kmalloc(GOLDEN_SETTING_BUF_SIZE, GFP_KERNEL); if (NULL != buf) { _golden_setting_init(&_golden, buf, GOLDEN_SETTING_BUF_SIZE); { struct proc_dir_entry *dir = NULL; int i; const struct { const char *name; const struct file_operations *fops; } entries[] = { PROC_ENTRY(golden_test), }; dir = proc_mkdir("golden", NULL); if (!dir) { clk_err("[%s]: fail to mkdir /proc/golden\n", __func__); EXIT_FUNC(FUNC_LV_API); return -ENOMEM; } for (i = 0; i < ARRAY_SIZE(entries); i++) { if (!proc_create(entries[i].name, S_IRUGO | S_IWUSR | S_IWGRP, dir, entries[i].fops)) clk_err("[%s]: fail to mkdir /proc/golden/%s\n", __func__, entries[i].name); } } } #endif // CONFIG_MT_ENG_BUILD return 0; }
int __init atalk_proc_init(void) { struct proc_dir_entry *p; int rc = -ENOMEM; atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net); if (!atalk_proc_dir) goto out; p = proc_create("interface", S_IRUGO, atalk_proc_dir, &atalk_seq_interface_fops); if (!p) goto out_interface; p = proc_create("route", S_IRUGO, atalk_proc_dir, &atalk_seq_route_fops); if (!p) goto out_route; p = proc_create("socket", S_IRUGO, atalk_proc_dir, &atalk_seq_socket_fops); if (!p) goto out_socket; p = proc_create("arp", S_IRUGO, atalk_proc_dir, &atalk_seq_arp_fops); if (!p) goto out_arp; rc = 0; out: return rc; out_arp: remove_proc_entry("socket", atalk_proc_dir); out_socket: remove_proc_entry("route", atalk_proc_dir); out_route: remove_proc_entry("interface", atalk_proc_dir); out_interface: remove_proc_entry("atalk", init_net.proc_net); goto out; }
static int sstore_proc_init(void) { int rv = 0; struct proc_dir_entry * sstore_proc_stats = NULL; struct proc_dir_entry * sstore_proc_data = NULL; /* Make /proc/sstore. */ sstore_proc_dir = proc_mkdir(DEV_NAME, NULL); if(sstore_proc_dir == NULL){ rv = -ENOMEM; goto proc_out; } /* Make /proc/sstore/stats. */ sstore_proc_stats = create_proc_read_entry(STATS_NAME, S_IRUSR, sstore_proc_dir, sstore_stats_read_proc, NULL); if(sstore_proc_stats == NULL){ rv = -ENOMEM; goto no_stats; } sstore_proc_stats->owner = THIS_MODULE; /* Make /proc/sstore/data. */ sstore_proc_data = create_proc_entry(DATA_NAME, S_IRUSR, sstore_proc_dir); if(sstore_proc_data == NULL){ rv = -ENOMEM; goto no_data; } sstore_proc_data->owner = THIS_MODULE; sstore_proc_data->proc_fops = &sstore_proc_data_fops; return 0; /* Evil goto error handling. */ no_data: remove_proc_entry(STATS_NAME, sstore_proc_dir); no_stats: remove_proc_entry(DEV_NAME, NULL); proc_out: return rv; }
int divert_dev_init(void) { init_waitqueue_head(&rd_queue); #ifdef CONFIG_PROC_FS isdn_proc_entry = proc_mkdir("net/isdn", NULL); if (!isdn_proc_entry) return (-1); isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); if (!isdn_divert_entry) { remove_proc_entry("net/isdn", NULL); return (-1); } isdn_divert_entry->proc_fops = &isdn_fops; isdn_divert_entry->owner = THIS_MODULE; #endif /* CONFIG_PROC_FS */ return (0); } /* divert_dev_init */
int __init wanrouter_proc_init(void) { struct proc_dir_entry *p; proc_router = proc_mkdir(ROUTER_NAME, init_net.proc_net); if (!proc_router) goto fail; p = proc_create("config", S_IRUGO, proc_router, &config_fops); if (!p) goto fail_config; p = proc_create("status", S_IRUGO, proc_router, &status_fops); if (!p) goto fail_stat; return 0; fail_stat: remove_proc_entry("config", proc_router); fail_config: remove_proc_entry(ROUTER_NAME, init_net.proc_net); fail: return -ENOMEM; }
static int __init procexample_module_init(void) { /* create a directory */ example_dir = proc_mkdir("example", NULL); if(example_dir == NULL) return -ENOMEM; //example_dir->owner = THIS_MODULE; /* create a file */ first_file = create_proc_entry("first", 0644, example_dir); if(first_file == NULL) { remove_proc_entry("example", NULL); return -ENOMEM; } first_file->data = kmalloc(strlen( "first file private data"), GFP_KERNEL); strcpy(first_file->data, "first file private data"); first_file->read_proc = read_first; first_file->write_proc = write_first; first_file->owner = THIS_MODULE; return 0; }