static 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; }
int 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; }
static int create_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; }
int 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; }
static 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; }
int 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; }
/* * 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; }
/* Callback from VMBUS subsystem when new channel created. */ static void hv_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); } }
struct 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; }
static 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; }
static 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; }
static 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; }
static 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; }
static 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; }
static 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; }
int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb) { struct Scsi_Host *host = acb->host; int error; error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr); if (error) { printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n
static 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; }
static 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; }
static 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); }
static 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; }
/** * 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; }
int pccard_sysfs_add_socket(struct device *dev) { int ret = 0; ret = sysfs_create_group(&dev->kobj, &socket_attrs); if (!ret) { ret = sysfs_create_bin_file(&dev->kobj, &pccard_cis_attr); if (ret) sysfs_remove_group(&dev->kobj, &socket_attrs); } return ret; }
static 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; }
static 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; }
void 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); }
int qedi_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; }
static 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; }
static 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; }
static 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; }
void 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); } }