这篇教程C++ sysfs_create_bin_file函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中sysfs_create_bin_file函数的典型用法代码示例。如果您正苦于以下问题:C++ sysfs_create_bin_file函数的具体用法?C++ sysfs_create_bin_file怎么用?C++ sysfs_create_bin_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了sysfs_create_bin_file函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: dcdrbu_initstatic int __init dcdrbu_init(void){ int rc = 0; spin_lock_init(&rbu_data.lock); init_packet_head(); rbu_device = platform_device_register_simple("dell_rbu", -1, NULL, 0); if (!rbu_device) { printk(KERN_ERR "dell_rbu:%s:platform_device_register_simple " "failed/n", __FUNCTION__); return -EIO; } sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr); sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_packet_size_attr); rc = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG, "dell_rbu", &rbu_device->dev, &context, callbackfn_rbu); if (rc) printk(KERN_ERR "dell_rbu:%s:request_firmware_nowait" " failed %d/n", __FUNCTION__, rc); else rbu_data.entry_created = 1; return rc;}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:31,
示例2: arcmsr_alloc_sysfs_attrint arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb){ struct Scsi_Host *host = acb->host; int error; error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed/n"); goto error_bin_file_message_read; } error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed/n"); goto error_bin_file_message_write; } error = sysfs_create_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_clear_attr); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed/n"); goto error_bin_file_message_clear; } return 0;error_bin_file_message_clear: sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_write_attr);error_bin_file_message_write: sysfs_remove_bin_file(&host->shost_classdev.kobj, &arcmsr_sysfs_message_read_attr);error_bin_file_message_read: return error;}
开发者ID:xf739645524,项目名称:kernel-rhel5,代码行数:33,
示例3: create_efivars_bin_attributesstatic intcreate_efivars_bin_attributes(void){ struct bin_attribute *attr; int error; /* new_var */ attr = kzalloc(sizeof(*attr), GFP_KERNEL); if (!attr) return -ENOMEM; attr->attr.name = "new_var"; attr->attr.mode = 0200; attr->write = efivar_create; efivars_new_var = attr; /* del_var */ attr = kzalloc(sizeof(*attr), GFP_KERNEL); if (!attr) { error = -ENOMEM; goto out_free; } attr->attr.name = "del_var"; attr->attr.mode = 0200; attr->write = efivar_delete; efivars_del_var = attr; sysfs_bin_attr_init(efivars_new_var); sysfs_bin_attr_init(efivars_del_var); /* Register */ error = sysfs_create_bin_file(&efivars_kset->kobj, efivars_new_var); if (error) { printk(KERN_ERR "efivars: unable to create new_var sysfs file" " due to error %d/n", error); goto out_free; } error = sysfs_create_bin_file(&efivars_kset->kobj, efivars_del_var); if (error) { printk(KERN_ERR "efivars: unable to create del_var sysfs file" " due to error %d/n", error); sysfs_remove_bin_file(&efivars_kset->kobj, efivars_new_var); goto out_free; } return 0;out_free: kfree(efivars_del_var); efivars_del_var = NULL; kfree(efivars_new_var); efivars_new_var = NULL; return error;}
开发者ID:lorenzo-stoakes,项目名称:linux-historical,代码行数:54,
示例4: chp_add_cmg_attrint chp_add_cmg_attr(struct channel_path *chp){ int ret; ret = sysfs_create_bin_file(&chp->dev.kobj, &chp_measurement_chars_attr); if (ret) return ret; ret = sysfs_create_bin_file(&chp->dev.kobj, &chp_measurement_attr); if (ret) sysfs_remove_bin_file(&chp->dev.kobj, &chp_measurement_chars_attr); return ret;}
开发者ID:xf739645524,项目名称:kernel-rhel5,代码行数:14,
示例5: watch_fontdata_attr_initstatic int watch_fontdata_attr_init(struct lg4945_data *d){ d->watch.font_written_size = 0; d->watch.font_width = 0; d->watch.font_written_comp_size = COMP_FONTM_MAX_SIZE; d->watch.fontdata_size = MAX_WATCH_DATA_SIZE; d->watch.fontdata_comp_size = COMP_FONTM_MAX_SIZE; d->watch.ext_wdata.font_data = kzalloc(d->watch.fontdata_size, GFP_KERNEL); d->watch.ext_wdata.comp_buf = kzalloc(d->watch.fontdata_comp_size, GFP_KERNEL); if (d->watch.ext_wdata.font_data && d->watch.ext_wdata.comp_buf) { TOUCH_I("%s font_buffer(%d KB) malloc/n", __func__, d->watch.fontdata_size/1024); } else { TOUCH_E("%s font_buffer(%d KB) malloc failed/n", __func__, d->watch.fontdata_size/1024); return 1; } sysfs_bin_attr_init(&d->watch.fontdata_attr); d->watch.fontdata_attr.attr.name = "config_fontdata"; d->watch.fontdata_attr.attr.mode = S_IWUSR | S_IRUSR; d->watch.fontdata_attr.read = watch_access_read; d->watch.fontdata_attr.write = watch_access_write; d->watch.fontdata_attr.size = d->watch.fontdata_size; if (sysfs_create_bin_file(&d->kobj, &d->watch.fontdata_attr) < 0) TOUCH_E("Failed to create %s/n", d->watch.fontdata_attr.attr.name); return 0;}
开发者ID:KAsp3rd,项目名称:android_kernel_lge_msm8992,代码行数:32,
示例6: kgsl_device_snapshot_initint kgsl_device_snapshot_init(struct kgsl_device *device){ int ret; if (device->snapshot == NULL) device->snapshot = kzalloc(KGSL_SNAPSHOT_MEMSIZE, GFP_KERNEL); if (device->snapshot == NULL) return -ENOMEM; device->snapshot_maxsize = KGSL_SNAPSHOT_MEMSIZE; device->snapshot_timestamp = 0; ret = kobject_init_and_add(&device->snapshot_kobj, &ktype_snapshot, &device->dev->kobj, "snapshot"); if (ret) goto done; ret = sysfs_create_bin_file(&device->snapshot_kobj, &snapshot_attr); if (ret) goto done; ret = sysfs_create_file(&device->snapshot_kobj, &attr_trigger.attr); if (ret) goto done; ret = sysfs_create_file(&device->snapshot_kobj, &attr_timestamp.attr);done: return ret;}
开发者ID:faux123,项目名称:pantech_vega_racer_2_kernel,代码行数:31,
示例7: br_sysfs_addbr/* * Add entries in sysfs onto the existing network class device * for the bridge. * Adds a attribute group "bridge" containing tuning parameters. * Binary attribute containing the forward table * Sub directory to hold links to interfaces. * * Note: the ifobj exists only to be a subdirectory * to hold links. The ifobj exists in same data structure * as it's parent the bridge so reference counting works. */int br_sysfs_addbr(struct net_device *dev){ struct kobject *brobj = &dev->dev.kobj; struct net_bridge *br = netdev_priv(dev); int err; err = sysfs_create_group(brobj, &bridge_group); if (err) { pr_info("%s: can't create group %s/%s/n", __func__, dev->name, bridge_group.name); goto out1; } err = sysfs_create_bin_file(brobj, &bridge_forward); if (err) { pr_info("%s: can't create attribute file %s/%s/n", __func__, dev->name, bridge_forward.attr.name); goto out2; } br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj); if (!br->ifobj) { pr_info("%s: can't add kobject (directory) %s/%s/n", __func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR); goto out3; } return 0; out3: sysfs_remove_bin_file(&dev->dev.kobj, &bridge_forward); out2: sysfs_remove_group(&dev->dev.kobj, &bridge_group); out1: return err;}
开发者ID:AK101111,项目名称:linux,代码行数:46,
示例8: hv_uio_new_channel/* Callback from VMBUS subsystem when new channel created. */static voidhv_uio_new_channel(struct vmbus_channel *new_sc){ struct hv_device *hv_dev = new_sc->primary_channel->device_obj; struct device *device = &hv_dev->device; const size_t ring_bytes = HV_RING_SIZE * PAGE_SIZE; int ret; /* Create host communication ring */ ret = vmbus_open(new_sc, ring_bytes, ring_bytes, NULL, 0, hv_uio_channel_cb, new_sc); if (ret) { dev_err(device, "vmbus_open subchannel failed: %d/n", ret); return; } /* Disable interrupts on sub channel */ new_sc->inbound.ring_buffer->interrupt_mask = 1; set_channel_read_mode(new_sc, HV_CALL_ISR); ret = sysfs_create_bin_file(&new_sc->kobj, &ring_buffer_bin_attr); if (ret) { dev_err(device, "sysfs create ring bin file failed; %d/n", ret); vmbus_close(new_sc); }}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:27,
示例9: kzallocstruct sfi_table_attr __init *sfi_sysfs_install_table(u64 pa){ struct sfi_table_attr *tbl_attr; struct sfi_table_header *th; int ret; tbl_attr = kzalloc(sizeof(struct sfi_table_attr), GFP_KERNEL); if (!tbl_attr) return NULL; th = sfi_map_table(pa); if (!th || !th->sig[0]) { kfree(tbl_attr); return NULL; } sysfs_attr_init(&tbl_attr->attr.attr); memcpy(tbl_attr->name, th->sig, SFI_SIGNATURE_SIZE); tbl_attr->attr.size = 0; tbl_attr->attr.read = sfi_table_show; tbl_attr->attr.attr.name = tbl_attr->name; tbl_attr->attr.attr.mode = 0400; ret = sysfs_create_bin_file(tables_kobj, &tbl_attr->attr); if (ret) { kfree(tbl_attr); tbl_attr = NULL; } sfi_unmap_table(th); return tbl_attr;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:34,
示例10: ds1553_rtc_probestatic int ds1553_rtc_probe(struct platform_device *pdev){ struct rtc_device *rtc; struct resource *res; unsigned int cen, sec; struct rtc_plat_data *pdata; void __iomem *ioaddr; int ret = 0; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; if (!devm_request_mem_region(&pdev->dev, res->start, RTC_REG_SIZE, pdev->name)) return -EBUSY; ioaddr = devm_ioremap(&pdev->dev, res->start, RTC_REG_SIZE); if (!ioaddr) return -ENOMEM; pdata->ioaddr = ioaddr; pdata->irq = platform_get_irq(pdev, 0); /* turn RTC on if it was not on */ sec = readb(ioaddr + RTC_SECONDS); if (sec & RTC_STOP) { sec &= RTC_SECONDS_MASK; cen = readb(ioaddr + RTC_CENTURY) & RTC_CENTURY_MASK; writeb(RTC_WRITE, ioaddr + RTC_CONTROL); writeb(sec, ioaddr + RTC_SECONDS); writeb(cen & RTC_CENTURY_MASK, ioaddr + RTC_CONTROL); } if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_BLF) dev_warn(&pdev->dev, "voltage-low detected./n"); spin_lock_init(&pdata->lock); pdata->last_jiffies = jiffies; platform_set_drvdata(pdev, pdata); if (pdata->irq > 0) { writeb(0, ioaddr + RTC_INTERRUPTS); if (devm_request_irq(&pdev->dev, pdata->irq, ds1553_rtc_interrupt, 0, pdev->name, pdev) < 0) { dev_warn(&pdev->dev, "interrupt not available./n"); pdata->irq = 0; } } rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &ds1553_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) return PTR_ERR(rtc); pdata->rtc = rtc; ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); return ret;}
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:60,
示例11: ksysfs_initstatic int __init ksysfs_init(void){ int error; kernel_kobj = kobject_create_and_add("kernel", NULL); if (!kernel_kobj) { error = -ENOMEM; goto exit; } error = sysfs_create_group(kernel_kobj, &kernel_attr_group); if (error) goto kset_exit; sched_features_kobj = kobject_create_and_add("sched", kernel_kobj); error = sysfs_create_group(sched_features_kobj, &sched_features_attr_group); if (error) kobject_put(sched_features_kobj); if (notes_size > 0) { notes_attr.size = notes_size; error = sysfs_create_bin_file(kernel_kobj, ¬es_attr); if (error) goto group_exit; } return 0;group_exit: sysfs_remove_group(kernel_kobj, &kernel_attr_group);kset_exit: kobject_put(kernel_kobj);exit: return error;}
开发者ID:alexax66,项目名称:CM13_kernel_serranodsxx,代码行数:35,
示例12: create_sysfs_entriesstatic int __init create_sysfs_entries(void){ int err = 0;#define create_cpu_attr(name) / if (!err) / err = device_create_file(cpu_subsys.dev_root, &dev_attr_##name); create_cpu_attr(chip_width); create_cpu_attr(chip_height); create_cpu_attr(chip_serial); create_cpu_attr(chip_revision);#define create_hv_attr(name) / if (!err) / err = sysfs_create_file(hypervisor_kobj, &dev_attr_##name.attr); create_hv_attr(type); create_hv_attr(version); create_hv_attr(config_version); if (!err) err = sysfs_create_group(hypervisor_kobj, &board_attr_group); if (!err) { sysfs_bin_attr_init(&hvconfig_bin); hvconfig_bin.attr.name = "hvconfig"; hvconfig_bin.attr.mode = S_IRUGO; hvconfig_bin.read = hvconfig_bin_read; hvconfig_bin.size = PAGE_SIZE; err = sysfs_create_bin_file(hypervisor_kobj, &hvconfig_bin); } return err;}
开发者ID:0x000000FF,项目名称:Linux4Edison,代码行数:33,
示例13: ds1682_probestatic int ds1682_probe(struct i2c_client *client, const struct i2c_device_id *id){ int rc; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { dev_err(&client->dev, "i2c bus does not support the ds1682/n"); rc = -ENODEV; goto exit; } rc = sysfs_create_group(&client->dev.kobj, &ds1682_group); if (rc) goto exit; rc = sysfs_create_bin_file(&client->dev.kobj, &ds1682_eeprom_attr); if (rc) goto exit_bin_attr; return 0; exit_bin_attr: sysfs_remove_group(&client->dev.kobj, &ds1682_group); exit: return rc;}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:27,
示例14: tx4939_rtc_probestatic int __init tx4939_rtc_probe(struct platform_device *pdev){ struct rtc_device *rtc; struct tx4939rtc_plat_data *pdata; struct resource *res; int irq, ret; irq = platform_get_irq(pdev, 0); if (irq < 0) return -ENODEV; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; platform_set_drvdata(pdev, pdata); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); pdata->rtcreg = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(pdata->rtcreg)) return PTR_ERR(pdata->rtcreg); spin_lock_init(&pdata->lock); tx4939_rtc_cmd(pdata->rtcreg, TX4939_RTCCTL_COMMAND_NOP); if (devm_request_irq(&pdev->dev, irq, tx4939_rtc_interrupt, 0, pdev->name, &pdev->dev) < 0) return -EBUSY; rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &tx4939_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) return PTR_ERR(rtc); pdata->rtc = rtc; ret = sysfs_create_bin_file(&pdev->dev.kobj, &tx4939_rtc_nvram_attr); return ret;}
开发者ID:03199618,项目名称:linux,代码行数:34,
示例15: mykobj_initstatic int __init mykobj_init(void){ printk("kboj init/n"); int ret = 0; obj1 = kzalloc(sizeof(struct my_kobj),GFP_KERNEL); obj2 = kzalloc(sizeof(struct my_kobj), GFP_KERNEL); obj2->val = 2; my_type.release = obj_release; my_type.default_attrs = my_attrs; my_type.sysfs_ops = &my_sysfsops; kobject_init_and_add(&obj1->kobj, &my_type, NULL, "mykobj1"); kobject_init_and_add(&obj2->kobj, &my_type, &obj1->kobj, "mykobj2"); kobject_init_and_add(&obj3.kobj, &my_type, &obj2->kobj, "mykobj3"); ret = sysfs_create_file(&obj1->kobj, &length_attr); ret = sysfs_create_bin_file(&obj1->kobj, &bin_attri); ret = sysfs_create_link(&obj1->kobj, &obj3.kobj,"link_file"); return ret;}
开发者ID:Calabashes,项目名称:test,代码行数:26,
示例16: ds1742_rtc_probestatic int ds1742_rtc_probe(struct platform_device *pdev){ struct rtc_device *rtc; struct resource *res; unsigned int cen, sec; struct rtc_plat_data *pdata; void __iomem *ioaddr; int ret = 0; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ioaddr = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(ioaddr)) return PTR_ERR(ioaddr); pdata->ioaddr_nvram = ioaddr; pdata->size_nvram = resource_size(res) - RTC_SIZE; pdata->ioaddr_rtc = ioaddr + pdata->size_nvram; sysfs_bin_attr_init(&pdata->nvram_attr); pdata->nvram_attr.attr.name = "nvram"; pdata->nvram_attr.attr.mode = S_IRUGO | S_IWUSR; pdata->nvram_attr.read = ds1742_nvram_read; pdata->nvram_attr.write = ds1742_nvram_write; pdata->nvram_attr.size = pdata->size_nvram; /* turn RTC on if it was not on */ ioaddr = pdata->ioaddr_rtc; sec = readb(ioaddr + RTC_SECONDS); if (sec & RTC_STOP) { sec &= RTC_SECONDS_MASK; cen = readb(ioaddr + RTC_CENTURY) & RTC_CENTURY_MASK; writeb(RTC_WRITE, ioaddr + RTC_CONTROL); writeb(sec, ioaddr + RTC_SECONDS); writeb(cen & RTC_CENTURY_MASK, ioaddr + RTC_CONTROL); } if (!(readb(ioaddr + RTC_DAY) & RTC_BATT_FLAG)) dev_warn(&pdev->dev, "voltage-low detected./n"); pdata->last_jiffies = jiffies; platform_set_drvdata(pdev, pdata); rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &ds1742_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) return PTR_ERR(rtc); ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr); if (ret) dev_err(&pdev->dev, "Unable to create sysfs entry: %s/n", pdata->nvram_attr.attr.name); return 0;}
开发者ID:020gzh,项目名称:linux,代码行数:56,
示例17: dcdrbu_initstatic int __init dcdrbu_init(void){ int rc;#ifdef CONFIG_XEN if (!is_initial_xendomain()) return -ENODEV;#endif spin_lock_init(&rbu_data.lock); init_packet_head(); rbu_device = platform_device_register_simple("dell_rbu", -1, NULL, 0); if (IS_ERR(rbu_device)) { printk(KERN_ERR "dell_rbu:%s:platform_device_register_simple " "failed/n", __func__); return PTR_ERR(rbu_device); } rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_data_attr); if (rc) goto out_devreg; rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr); if (rc) goto out_data; rc = sysfs_create_bin_file(&rbu_device->dev.kobj, &rbu_packet_size_attr); if (rc) goto out_imtype; rbu_data.entry_created = 0; return 0;out_imtype: sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_image_type_attr);out_data: sysfs_remove_bin_file(&rbu_device->dev.kobj, &rbu_data_attr);out_devreg: platform_device_unregister(rbu_device); return rc;}
开发者ID:AsadRaza,项目名称:OCTEON-Linux,代码行数:42,
示例18: memconsole_initstatic int __init memconsole_init(void){ if (!dmi_check_system(memconsole_dmi_table)) return -ENODEV; if (!found_memconsole()) return -ENODEV; memconsole_bin_attr.size = memconsole_length; return sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);}
开发者ID:ChineseDr,项目名称:linux,代码行数:11,
示例19: rp5c01_rtc_probestatic int __init rp5c01_rtc_probe(struct platform_device *dev){ struct resource *res; struct rp5c01_priv *priv; struct rtc_device *rtc; int error; res = platform_get_resource(dev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->regs = ioremap(res->start, resource_size(res)); if (!priv->regs) { error = -ENOMEM; goto out_free_priv; } sysfs_bin_attr_init(&priv->nvram_attr); priv->nvram_attr.attr.name = "nvram"; priv->nvram_attr.attr.mode = S_IRUGO | S_IWUSR; priv->nvram_attr.read = rp5c01_nvram_read; priv->nvram_attr.write = rp5c01_nvram_write; priv->nvram_attr.size = RP5C01_MODE; spin_lock_init(&priv->lock); rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { error = PTR_ERR(rtc); goto out_unmap; } priv->rtc = rtc; platform_set_drvdata(dev, priv); error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr); if (error) goto out_unregister; return 0;out_unregister: rtc_device_unregister(rtc);out_unmap: iounmap(priv->regs);out_free_priv: kfree(priv); return error;}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:54,
示例20: flicker_sysfs_init/** * Sysfs registrations */int flicker_sysfs_init(void){ int rc = 0; int i; assert(NULL != g_pal); if(get_cpu_vendor() == CPU_VENDOR_INTEL) { assert(NULL != g_acmod); assert(NULL != g_mle_ptab); g_acmod_size = 0; } flicker_sysfs_data_state = IDLE; /* * Create a simple kobject with the name of "flicker", * located under /sys/kernel/ * * As this is a simple directory, no uevent will be sent to * userspace. That is why this function should not be used for * any type of dynamic kobjects, where the name and number are * not known ahead of time. */ flicker_kobj = kobject_create_and_add("flicker", kernel_kobj); if (!flicker_kobj) return -ENOMEM; /* reg other files and handle errors w/ nested gotos */ if((rc = sysfs_create_file(flicker_kobj, &attr_control.attr))) { error("Error [%d] registering flicker sysfs control", rc); return rc; } for (i = 0; flicker_bin_attrs[i]; i++) { rc = sysfs_create_bin_file(flicker_kobj, flicker_bin_attrs[i]); if (rc) { error("Error [%d] registering flicker sysfs binary file", rc); while (--i >= 0) sysfs_remove_bin_file(flicker_kobj, flicker_bin_attrs[i]); return rc; } } logit("flicker: sysfs entries registered successfully"); /* TODO: gracefully handle failure conditions and free kobj reference. */ //kobject_put(flicker_kobj); return rc;}
开发者ID:phoenix-frozen,项目名称:bottlecap,代码行数:57,
示例21: kzallocstatic struct elog_obj *create_elog_obj(uint64_t id, size_t size, uint64_t type){ struct elog_obj *elog; int rc; elog = kzalloc(sizeof(*elog), GFP_KERNEL); if (!elog) return NULL; elog->kobj.kset = elog_kset; kobject_init(&elog->kobj, &elog_ktype); sysfs_bin_attr_init(&elog->raw_attr); elog->raw_attr.attr.name = "raw"; elog->raw_attr.attr.mode = 0400; elog->raw_attr.size = size; elog->raw_attr.read = raw_attr_read; elog->id = id; elog->size = size; elog->type = type; elog->buffer = kzalloc(elog->size, GFP_KERNEL); if (elog->buffer) { rc = opal_read_elog(__pa(elog->buffer), elog->size, elog->id); if (rc != OPAL_SUCCESS) { pr_err("ELOG: log read failed for log-id=%llx/n", elog->id); kfree(elog->buffer); elog->buffer = NULL; } } rc = kobject_add(&elog->kobj, NULL, "0x%llx", id); if (rc) { kobject_put(&elog->kobj); return NULL; } rc = sysfs_create_bin_file(&elog->kobj, &elog->raw_attr); if (rc) { kobject_put(&elog->kobj); return NULL; } kobject_uevent(&elog->kobj, KOBJ_ADD); return elog;}
开发者ID:envieid0c,项目名称:kernel,代码行数:53,
示例22: stk_sysfs_create_bin_filesstatic int stk_sysfs_create_bin_files(struct kobject *kobj, struct bin_attribute **bin_attrs){ int err; while (*bin_attrs != NULL) { err = sysfs_create_bin_file(kobj, *bin_attrs); if (err) return err; bin_attrs++; } return 0;}
开发者ID:gcsuri,项目名称:linux-wetek-3.14.y,代码行数:12,
示例23: zorro_create_sysfs_dev_filesvoid zorro_create_sysfs_dev_files(struct zorro_dev *z){ struct device *dev = &z->dev; /* current configuration's attributes */ device_create_file(dev, &dev_attr_id); device_create_file(dev, &dev_attr_type); device_create_file(dev, &dev_attr_serial); device_create_file(dev, &dev_attr_slotaddr); device_create_file(dev, &dev_attr_slotsize); device_create_file(dev, &dev_attr_resource); sysfs_create_bin_file(&dev->kobj, &zorro_config_attr);}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:13,
示例24: qedi_create_sysfs_attrintqedi_create_sysfs_attr(struct Scsi_Host *shost, struct sysfs_bin_attrs *iter){ int ret = 0; for (; iter->name; iter++) { ret = sysfs_create_bin_file(&shost->shost_gendev.kobj, iter->attr); if (ret) pr_err("Unable to create sysfs %s attr, err(%d)./n", iter->name, ret); } return ret;}
开发者ID:forgivemyheart,项目名称:linux,代码行数:14,
示例25: create_filesstatic int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj, const struct attribute_group *grp, int update){ struct attribute *const* attr; struct bin_attribute *const* bin_attr; int error = 0, i; if (grp->attrs) { for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { umode_t mode = 0; /* * In update mode, we're changing the permissions or * visibility. Do this by first removing then * re-adding (if required) the file. */ if (update) sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name); if (grp->is_visible) { mode = grp->is_visible(kobj, *attr, i); if (!mode) continue; } error = sysfs_add_file_mode(dir_sd, *attr, SYSFS_KOBJ_ATTR, (*attr)->mode | mode); if (unlikely(error)) break; } if (error) { remove_files(dir_sd, kobj, grp); goto exit; } } if (grp->bin_attrs) { for (bin_attr = grp->bin_attrs; *bin_attr; bin_attr++) { if (update) sysfs_remove_bin_file(kobj, *bin_attr); error = sysfs_create_bin_file(kobj, *bin_attr); if (error) break; } if (error) remove_files(dir_sd, kobj, grp); }exit: return error;}
开发者ID:Cool-Joe,项目名称:imx23-audio,代码行数:50,
示例26: cvorg_dev_add_attributesstatic int cvorg_dev_add_attributes(struct cvorg *card){ struct cvorg_channel *channel; int ret; int i; for (i = 0; i < card->n_channels; i++) { channel = &card->channels[i]; memset(&channel->kobj, 0, sizeof(struct kobject)); ret = kobject_init_and_add(&channel->kobj, &ktype_cvorg_chan, &card->dev->kobj, "channel.%d", i); if (ret) goto error_channel; ret = sysfs_create_bin_file(&channel->kobj, &cvorg_chan_pll_attr); if(ret) goto error_pll; ret = sysfs_create_bin_file(&channel->kobj, &cvorg_chan_set_sequence_attr); if(ret) goto error_set_sequence; } return 0; error_set_sequence: sysfs_remove_bin_file(&channel->kobj, &cvorg_chan_pll_attr); error_pll: kobject_put(&channel->kobj); error_channel: for (i--; i >= 0; i--) { channel = &card->channels[i]; kobject_put(&channel->kobj); } return ret;}
开发者ID:GSI-CS-CO,项目名称:kernel_modules,代码行数:37,
示例27: pru_speak_probestatic int pru_speak_probe(struct platform_device *pdev){ int err; struct device *dev = &pdev->dev; printk(KERN_INFO "pru_speak probed/n"); err = device_create_file(dev, &dev_attr_pru_speak_sysfs); if (err != 0){ printk(KERN_INFO "sysfs file creation failed"); } err = sysfs_create_bin_file(&(dev->kobj), &pru_speak_bin_attr); if (err != 0){ printk(KERN_INFO "BIN FILE could not be created"); } return 0;}
开发者ID:MarkAYoder,项目名称:pruspeak,代码行数:15,
示例28: qla4_8xxx_alloc_sysfs_attrvoid qla4_8xxx_alloc_sysfs_attr(struct scsi_qla_host *ha){ struct Scsi_Host *host = ha->host; struct sysfs_entry *iter; int ret; for (iter = bin_file_entries; iter->name; iter++) { ret = sysfs_create_bin_file(&host->shost_gendev.kobj, iter->attr); if (ret) ql4_printk(KERN_ERR, ha, "Unable to create sysfs %s binary attribute (%d)./n", iter->name, ret); }}
开发者ID:3null,项目名称:fastsocket,代码行数:15,
注:本文中的sysfs_create_bin_file函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ sysfs_create_file函数代码示例 C++ sysfatal函数代码示例 |