Lines Matching refs:bmc

335 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
474 struct bmc_device *bmc; member
2285 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2289 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2296 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2331 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2335 bmc->dyn_id_set = 2; in __get_device_id()
2343 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2345 if (!bmc->dyn_id_set) in __get_device_id()
2365 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2374 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2376 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2377 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2380 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2383 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2385 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2386 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2394 bmc = intf->bmc; in __bmc_get_device_id()
2395 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2401 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2404 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2407 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2408 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2417 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2418 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2419 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2420 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2421 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2422 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2423 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2424 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2425 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2428 guid = bmc->fetch_guid; in __bmc_get_device_id()
2429 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2433 intf->bmc->id = id; in __bmc_get_device_id()
2434 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2435 intf->bmc->guid = guid; in __bmc_get_device_id()
2449 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2454 bmc = intf->bmc; in __bmc_get_device_id()
2455 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2457 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2459 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2461 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2466 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2469 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2470 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2471 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2477 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2482 *id = bmc->id; in __bmc_get_device_id()
2485 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2487 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2488 *guid = bmc->guid; in __bmc_get_device_id()
2491 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2498 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2502 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2509 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2513 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2525 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2529 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2540 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2544 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2556 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2560 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2573 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2577 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2591 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2595 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2608 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2612 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2624 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2628 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2640 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2644 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2659 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2664 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2692 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2699 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2705 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2728 struct bmc_device *bmc; in __find_bmc_guid() local
2734 bmc = to_bmc_device(dev); in __find_bmc_guid()
2735 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2737 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2748 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2752 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2755 return bmc; in ipmi_find_bmc_guid()
2766 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
2772 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
2773 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
2774 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
2776 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
2792 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
2796 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
2799 return bmc; in ipmi_find_bmc_prod_dev_id()
2812 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
2814 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
2816 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
2823 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
2830 schedule_work(&bmc->remove_work); in cleanup_bmc_device()
2838 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
2844 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
2848 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2850 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
2851 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
2852 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
2871 struct bmc_device *bmc; in __ipmi_bmc_register() local
2900 bmc = old_bmc; in __ipmi_bmc_register()
2905 intf->bmc = old_bmc; in __ipmi_bmc_register()
2906 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
2907 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
2908 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
2913 bmc->id.manufacturer_id, in __ipmi_bmc_register()
2914 bmc->id.product_id, in __ipmi_bmc_register()
2915 bmc->id.device_id); in __ipmi_bmc_register()
2917 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
2918 if (!bmc) { in __ipmi_bmc_register()
2922 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
2923 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
2924 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
2926 bmc->id = *id; in __ipmi_bmc_register()
2927 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
2928 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
2929 bmc->guid = *guid; in __ipmi_bmc_register()
2930 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
2932 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
2937 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
2938 bmc->pdev.id = rv; in __ipmi_bmc_register()
2939 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
2940 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
2941 kref_init(&bmc->usecount); in __ipmi_bmc_register()
2943 intf->bmc = bmc; in __ipmi_bmc_register()
2944 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
2945 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
2946 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
2948 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
2958 bmc->id.manufacturer_id, in __ipmi_bmc_register()
2959 bmc->id.product_id, in __ipmi_bmc_register()
2960 bmc->id.device_id); in __ipmi_bmc_register()
2967 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
2984 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3011 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3013 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3014 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3015 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3019 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3021 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3022 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3023 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3057 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3067 bmc->dyn_guid_set = 0; in guid_handler()
3072 bmc->dyn_guid_set = 0; in guid_handler()
3079 memcpy(bmc->fetch_guid.b, msg->msg.data + 1, 16); in guid_handler()
3085 bmc->dyn_guid_set = 1; in guid_handler()
3093 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3095 bmc->dyn_guid_set = 2; in __get_guid()
3100 bmc->dyn_guid_set = 0; in __get_guid()
3102 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3320 intf->bmc = &intf->tmp_bmc; in ipmi_register_smi()
3321 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_register_smi()
3322 mutex_init(&intf->bmc->dyn_mutex); in ipmi_register_smi()