Lines Matching refs:bmc
341 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
480 struct bmc_device *bmc; member
2386 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2389 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2396 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2431 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2435 bmc->dyn_id_set = 2; in __get_device_id()
2443 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2445 if (!bmc->dyn_id_set) in __get_device_id()
2465 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2474 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2476 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2477 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2480 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2483 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2485 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2486 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2494 bmc = intf->bmc; in __bmc_get_device_id()
2495 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2501 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2504 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2507 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2508 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2517 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2518 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2519 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2520 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2521 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2522 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2523 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2524 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2525 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2528 guid = bmc->fetch_guid; in __bmc_get_device_id()
2529 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2533 intf->bmc->id = id; in __bmc_get_device_id()
2534 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2535 intf->bmc->guid = guid; in __bmc_get_device_id()
2549 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2554 bmc = intf->bmc; in __bmc_get_device_id()
2555 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2557 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2559 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2561 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2566 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2569 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2570 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2571 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2577 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2582 *id = bmc->id; in __bmc_get_device_id()
2585 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2587 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2588 *guid = bmc->guid; in __bmc_get_device_id()
2591 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2598 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2602 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2609 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2613 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2625 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2629 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2640 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2644 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2656 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2660 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2673 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2677 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2691 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2695 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2708 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2712 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2724 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2728 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2740 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2744 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2759 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2764 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2792 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2799 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2805 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2828 struct bmc_device *bmc; in __find_bmc_guid() local
2834 bmc = to_bmc_device(dev); in __find_bmc_guid()
2835 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2837 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2848 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2852 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2855 return bmc; in ipmi_find_bmc_guid()
2866 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
2872 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
2873 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
2874 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
2876 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
2892 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
2896 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
2899 return bmc; in ipmi_find_bmc_prod_dev_id()
2912 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
2914 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
2916 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
2923 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
2930 schedule_work(&bmc->remove_work); in cleanup_bmc_device()
2938 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
2944 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
2948 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2950 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2951 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
2952 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
2971 struct bmc_device *bmc; in __ipmi_bmc_register() local
3000 bmc = old_bmc; in __ipmi_bmc_register()
3005 intf->bmc = old_bmc; in __ipmi_bmc_register()
3006 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3007 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3008 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3012 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3013 bmc->id.product_id, in __ipmi_bmc_register()
3014 bmc->id.device_id); in __ipmi_bmc_register()
3016 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
3017 if (!bmc) { in __ipmi_bmc_register()
3021 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
3022 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
3023 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
3025 bmc->id = *id; in __ipmi_bmc_register()
3026 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
3027 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
3028 bmc->guid = *guid; in __ipmi_bmc_register()
3029 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
3031 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
3036 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
3037 bmc->pdev.id = rv; in __ipmi_bmc_register()
3038 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
3039 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
3040 kref_init(&bmc->usecount); in __ipmi_bmc_register()
3042 intf->bmc = bmc; in __ipmi_bmc_register()
3043 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3044 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3045 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3047 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
3057 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3058 bmc->id.product_id, in __ipmi_bmc_register()
3059 bmc->id.device_id); in __ipmi_bmc_register()
3066 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
3082 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3109 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3111 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3112 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3113 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3117 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3119 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3120 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3121 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3155 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3165 bmc->dyn_guid_set = 0; in guid_handler()
3170 bmc->dyn_guid_set = 0; in guid_handler()
3177 guid_copy(&bmc->fetch_guid, (guid_t *)(msg->msg.data + 1)); in guid_handler()
3183 bmc->dyn_guid_set = 1; in guid_handler()
3191 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3193 bmc->dyn_guid_set = 2; in __get_guid()
3198 bmc->dyn_guid_set = 0; in __get_guid()
3200 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3410 intf->bmc = &intf->tmp_bmc; in ipmi_register_smi()
3411 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_register_smi()
3412 mutex_init(&intf->bmc->dyn_mutex); in ipmi_register_smi()