Lines Matching +full:module +full:- +full:instance
14 #include <linux/module.h>
35 return sprintf(data, "%u\n", ctl_info->log_ue); in edac_device_ctl_log_ue_show()
42 /* if parameter is zero, turn off flag, if non-zero turn on flag */ in edac_device_ctl_log_ue_store()
43 ctl_info->log_ue = (simple_strtoul(data, NULL, 0) != 0); in edac_device_ctl_log_ue_store()
52 return sprintf(data, "%u\n", ctl_info->log_ce); in edac_device_ctl_log_ce_show()
59 /* if parameter is zero, turn off flag, if non-zero turn on flag */ in edac_device_ctl_log_ce_store()
60 ctl_info->log_ce = (simple_strtoul(data, NULL, 0) != 0); in edac_device_ctl_log_ce_store()
69 return sprintf(data, "%u\n", ctl_info->panic_on_ue); in edac_device_ctl_panic_on_ue_show()
76 /* if parameter is zero, turn off flag, if non-zero turn on flag */ in edac_device_ctl_panic_on_ue_store()
77 ctl_info->panic_on_ue = (simple_strtoul(data, NULL, 0) != 0); in edac_device_ctl_panic_on_ue_store()
86 return sprintf(data, "%u\n", ctl_info->poll_msec); in edac_device_ctl_poll_msec_show()
95 /* get the value and enforce that it is non-zero, must be at least in edac_device_ctl_poll_msec_store()
123 if (ctl_info_attr->show) in edac_dev_ctl_info_show()
124 return ctl_info_attr->show(edac_dev, buffer); in edac_dev_ctl_info_show()
125 return -EIO; in edac_dev_ctl_info_show()
136 if (ctl_info_attr->store) in edac_dev_ctl_info_store()
137 return ctl_info_attr->store(edac_dev, buffer, count); in edac_dev_ctl_info_store()
138 return -EIO; in edac_dev_ctl_info_store()
184 * the reference count for the EDAC 'core' module is
194 * is called which then decrements the EDAC 'core' module.
195 * When the module reference count reaches zero then the
196 * module no longer has dependency on keeping the release
197 * function code in memory and module can be unloaded.
206 edac_dbg(4, "control index=%d\n", edac_dev->dev_idx); in edac_device_ctrl_master_release()
208 /* decrement the EDAC CORE module ref count */ in edac_device_ctrl_master_release()
209 module_put(edac_dev->owner); in edac_device_ctrl_master_release()
224 * perform the high level setup for the new edac_device instance
233 int err = -ENODEV; in edac_device_register_sysfs_main_kobj()
240 /* Point to the 'edac_subsys' this instance 'reports' to */ in edac_device_register_sysfs_main_kobj()
241 edac_dev->edac_subsys = edac_subsys; in edac_device_register_sysfs_main_kobj()
244 memset(&edac_dev->kobj, 0, sizeof(struct kobject)); in edac_device_register_sysfs_main_kobj()
246 /* Record which module 'owns' this control structure in edac_device_register_sysfs_main_kobj()
247 * and bump the ref count of the module in edac_device_register_sysfs_main_kobj()
249 edac_dev->owner = THIS_MODULE; in edac_device_register_sysfs_main_kobj()
251 if (!try_module_get(edac_dev->owner)) in edac_device_register_sysfs_main_kobj()
257 err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, in edac_device_register_sysfs_main_kobj()
258 &dev_root->kobj, "%s", edac_dev->name); in edac_device_register_sysfs_main_kobj()
263 edac_dev->name); in edac_device_register_sysfs_main_kobj()
266 kobject_uevent(&edac_dev->kobj, KOBJ_ADD); in edac_device_register_sysfs_main_kobj()
272 edac_dbg(4, "Registered '.../edac/%s' kobject\n", edac_dev->name); in edac_device_register_sysfs_main_kobj()
278 kobject_put(&edac_dev->kobj); in edac_device_register_sysfs_main_kobj()
279 module_put(edac_dev->owner); in edac_device_register_sysfs_main_kobj()
292 edac_dbg(4, "name of kobject is: %s\n", kobject_name(&dev->kobj)); in edac_device_unregister_sysfs_main_kobj()
298 * a) module_put() this module in edac_device_unregister_sysfs_main_kobj()
301 kobject_put(&dev->kobj); in edac_device_unregister_sysfs_main_kobj()
304 /* edac_dev -> instance information */
307 * Set of low-level instance attribute show functions
309 static ssize_t instance_ue_count_show(struct edac_device_instance *instance, in instance_ue_count_show() argument
312 return sprintf(data, "%u\n", instance->counters.ue_count); in instance_ue_count_show()
315 static ssize_t instance_ce_count_show(struct edac_device_instance *instance, in instance_ce_count_show() argument
318 return sprintf(data, "%u\n", instance->counters.ce_count); in instance_ce_count_show()
324 /* DEVICE instance kobject release() function */
327 struct edac_device_instance *instance; in edac_device_ctrl_instance_release() local
334 instance = to_instance(kobj); in edac_device_ctrl_instance_release()
335 kobject_put(&instance->ctl->kobj); in edac_device_ctrl_instance_release()
338 /* instance specific attribute structure */
345 /* Function to 'show' fields from the edac_dev 'instance' structure */
349 struct edac_device_instance *instance = to_instance(kobj); in edac_dev_instance_show() local
352 if (instance_attr->show) in edac_dev_instance_show()
353 return instance_attr->show(instance, buffer); in edac_dev_instance_show()
354 return -EIO; in edac_dev_instance_show()
357 /* Function to 'store' fields into the edac_dev 'instance' structure */
362 struct edac_device_instance *instance = to_instance(kobj); in edac_dev_instance_store() local
365 if (instance_attr->store) in edac_dev_instance_store()
366 return instance_attr->store(instance, buffer, count); in edac_dev_instance_store()
367 return -EIO; in edac_dev_instance_store()
370 /* edac_dev file operations for an 'instance' */
384 * Define attributes visible for the edac_device instance object
391 /* list of edac_dev 'instance' attributes */
399 /* The 'ktype' for each edac_dev 'instance' */
406 /* edac_dev -> instance -> block information */
413 * Set of low-level block attribute show functions
420 return sprintf(data, "%u\n", block->counters.ue_count); in block_ue_count_show()
428 return sprintf(data, "%u\n", block->counters.ce_count); in block_ce_count_show()
441 /* map from 'block kobj' to 'block->instance->controller->main_kobj' in edac_device_ctrl_block_release()
444 kobject_put(&block->instance->ctl->kobj); in edac_device_ctrl_block_release()
455 if (block_attr->show) in edac_dev_block_show()
456 return block_attr->show(kobj, attr, buffer); in edac_dev_block_show()
457 return -EIO; in edac_dev_block_show()
469 if (block_attr->store) in edac_dev_block_store()
470 return block_attr->store(kobj, attr, buffer, count); in edac_dev_block_store()
471 return -EIO; in edac_dev_block_store()
511 struct edac_device_instance *instance, in edac_device_create_block() argument
519 edac_dbg(4, "Instance '%s' inst_p=%p block '%s' block_p=%p\n", in edac_device_create_block()
520 instance->name, instance, block->name, block); in edac_device_create_block()
521 edac_dbg(4, "block kobj=%p block kobj->parent=%p\n", in edac_device_create_block()
522 &block->kobj, &block->kobj.parent); in edac_device_create_block()
525 memset(&block->kobj, 0, sizeof(struct kobject)); in edac_device_create_block()
528 * and this instance is dependent on the main in edac_device_create_block()
530 main_kobj = kobject_get(&edac_dev->kobj); in edac_device_create_block()
532 err = -ENODEV; in edac_device_create_block()
537 err = kobject_init_and_add(&block->kobj, &ktype_block_ctrl, in edac_device_create_block()
538 &instance->kobj, in edac_device_create_block()
539 "%s", block->name); in edac_device_create_block()
541 edac_dbg(1, "Failed to register instance '%s'\n", block->name); in edac_device_create_block()
543 err = -ENODEV; in edac_device_create_block()
550 sysfs_attrib = block->block_attributes; in edac_device_create_block()
551 if (sysfs_attrib && block->nr_attribs) { in edac_device_create_block()
552 for (i = 0; i < block->nr_attribs; i++, sysfs_attrib++) { in edac_device_create_block()
554 edac_dbg(4, "creating block attrib='%s' attrib->%p to kobj=%p\n", in edac_device_create_block()
555 sysfs_attrib->attr.name, in edac_device_create_block()
556 sysfs_attrib, &block->kobj); in edac_device_create_block()
559 err = sysfs_create_file(&block->kobj, in edac_device_create_block()
560 &sysfs_attrib->attr); in edac_device_create_block()
565 kobject_uevent(&block->kobj, KOBJ_ADD); in edac_device_create_block()
571 kobject_put(&block->kobj); in edac_device_create_block()
589 sysfs_attrib = block->block_attributes; in edac_device_delete_block()
590 if (sysfs_attrib && block->nr_attribs) { in edac_device_delete_block()
591 for (i = 0; i < block->nr_attribs; i++, sysfs_attrib++) { in edac_device_delete_block()
594 sysfs_remove_file(&block->kobj, in edac_device_delete_block()
602 kobject_put(&block->kobj); in edac_device_delete_block()
605 /* instance ctor/dtor code */
609 * create just one instance of an edac_device 'instance'
616 struct edac_device_instance *instance; in edac_device_create_instance() local
619 instance = &edac_dev->instances[idx]; in edac_device_create_instance()
621 /* Init the instance's kobject */ in edac_device_create_instance()
622 memset(&instance->kobj, 0, sizeof(struct kobject)); in edac_device_create_instance()
624 instance->ctl = edac_dev; in edac_device_create_instance()
627 * and this instance is dependent on the main in edac_device_create_instance()
629 main_kobj = kobject_get(&edac_dev->kobj); in edac_device_create_instance()
631 err = -ENODEV; in edac_device_create_instance()
635 /* Formally register this instance's kobject under the edac_device */ in edac_device_create_instance()
636 err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl, in edac_device_create_instance()
637 &edac_dev->kobj, "%s", instance->name); in edac_device_create_instance()
639 edac_dbg(2, "Failed to register instance '%s'\n", in edac_device_create_instance()
640 instance->name); in edac_device_create_instance()
645 edac_dbg(4, "now register '%d' blocks for instance %d\n", in edac_device_create_instance()
646 instance->nr_blocks, idx); in edac_device_create_instance()
648 /* register all blocks of this instance */ in edac_device_create_instance()
649 for (i = 0; i < instance->nr_blocks; i++) { in edac_device_create_instance()
650 err = edac_device_create_block(edac_dev, instance, in edac_device_create_instance()
651 &instance->blocks[i]); in edac_device_create_instance()
656 &instance->blocks[j]); in edac_device_create_instance()
660 kobject_uevent(&instance->kobj, KOBJ_ADD); in edac_device_create_instance()
662 edac_dbg(4, "Registered instance %d '%s' kobject\n", in edac_device_create_instance()
663 idx, instance->name); in edac_device_create_instance()
669 kobject_put(&instance->kobj); in edac_device_create_instance()
677 * remove an edac_device instance
682 struct edac_device_instance *instance; in edac_device_delete_instance() local
685 instance = &edac_dev->instances[idx]; in edac_device_delete_instance()
687 /* unregister all blocks in this instance */ in edac_device_delete_instance()
688 for (i = 0; i < instance->nr_blocks; i++) in edac_device_delete_instance()
689 edac_device_delete_block(edac_dev, &instance->blocks[i]); in edac_device_delete_instance()
691 /* unregister this instance's kobject, SEE: in edac_device_delete_instance()
694 kobject_put(&instance->kobj); in edac_device_delete_instance()
710 for (i = 0; i < edac_dev->nr_instances; i++) { in edac_device_create_instances()
732 for (i = 0; i < edac_dev->nr_instances; i++) in edac_device_delete_instances()
740 * add some attributes to this instance's main kobject
748 sysfs_attrib = edac_dev->sysfs_attributes; in edac_device_add_main_sysfs_attributes()
753 while (sysfs_attrib->attr.name != NULL) { in edac_device_add_main_sysfs_attributes()
754 err = sysfs_create_file(&edac_dev->kobj, in edac_device_add_main_sysfs_attributes()
769 * remove any attributes to this instance's main kobject
778 * removing each attribute listed from this device's instance's kobject in edac_device_remove_main_sysfs_attributes()
780 sysfs_attrib = edac_dev->sysfs_attributes; in edac_device_remove_main_sysfs_attributes()
782 while (sysfs_attrib->attr.name != NULL) { in edac_device_remove_main_sysfs_attributes()
783 sysfs_remove_file(&edac_dev->kobj, in edac_device_remove_main_sysfs_attributes()
795 * created. 'instance' and 'block' kobjects should be registered
807 struct kobject *edac_kobj = &edac_dev->kobj; in edac_device_create_sysfs()
809 edac_dbg(0, "idx=%d\n", edac_dev->dev_idx); in edac_device_create_sysfs()
822 &edac_dev->dev->kobj, EDAC_DEVICE_SYMLINK); in edac_device_create_sysfs()
828 /* Create the first level instance directories in edac_device_create_sysfs()
840 edac_dbg(4, "create-instances done, idx=%d\n", edac_dev->dev_idx); in edac_device_create_sysfs()
847 sysfs_remove_link(&edac_dev->kobj, EDAC_DEVICE_SYMLINK); in edac_device_create_sysfs()
869 sysfs_remove_link(&edac_dev->kobj, EDAC_DEVICE_SYMLINK); in edac_device_remove_sysfs()
871 /* walk the instance/block kobject tree, deconstructing it */ in edac_device_remove_sysfs()