Lines Matching refs:bmc

330 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
475 struct bmc_device *bmc; member
2504 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2509 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id); in bmc_device_id_handler()
2513 intf->bmc->cc = msg->msg.data[0]; in bmc_device_id_handler()
2514 intf->bmc->dyn_id_set = 0; in bmc_device_id_handler()
2521 intf->bmc->dyn_id_set = 1; in bmc_device_id_handler()
2556 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc) in __get_device_id() argument
2564 bmc->cc = 0; in __get_device_id()
2565 bmc->dyn_id_set = 2; in __get_device_id()
2571 wait_event(intf->waitq, bmc->dyn_id_set != 2); in __get_device_id()
2573 if (!bmc->dyn_id_set) { in __get_device_id()
2574 if (bmc->cc != IPMI_CC_NO_ERROR && in __get_device_id()
2579 bmc->cc); in __get_device_id()
2604 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in __bmc_get_device_id() argument
2613 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2615 if (list_empty(&bmc->intfs)) { in __bmc_get_device_id()
2616 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2619 intf = list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2622 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2624 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2625 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi, in __bmc_get_device_id()
2633 bmc = intf->bmc; in __bmc_get_device_id()
2634 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2640 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry))) in __bmc_get_device_id()
2643 prev_guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2646 prev_dyn_id_set = bmc->dyn_id_set; in __bmc_get_device_id()
2647 rv = __get_device_id(intf, bmc); in __bmc_get_device_id()
2656 || (!prev_guid_set && bmc->dyn_guid_set) in __bmc_get_device_id()
2657 || (!prev_dyn_id_set && bmc->dyn_id_set) in __bmc_get_device_id()
2658 || (prev_guid_set && bmc->dyn_guid_set in __bmc_get_device_id()
2659 && !guid_equal(&bmc->guid, &bmc->fetch_guid)) in __bmc_get_device_id()
2660 || bmc->id.device_id != bmc->fetch_id.device_id in __bmc_get_device_id()
2661 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id in __bmc_get_device_id()
2662 || bmc->id.product_id != bmc->fetch_id.product_id) { in __bmc_get_device_id()
2663 struct ipmi_device_id id = bmc->fetch_id; in __bmc_get_device_id()
2664 int guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2667 guid = bmc->fetch_guid; in __bmc_get_device_id()
2668 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2672 intf->bmc->id = id; in __bmc_get_device_id()
2673 intf->bmc->dyn_guid_set = guid_set; in __bmc_get_device_id()
2674 intf->bmc->guid = guid; in __bmc_get_device_id()
2688 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2693 bmc = intf->bmc; in __bmc_get_device_id()
2694 mutex_lock(&bmc->dyn_mutex); in __bmc_get_device_id()
2696 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id))) in __bmc_get_device_id()
2698 __scan_channels(intf, &bmc->fetch_id); in __bmc_get_device_id()
2700 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __bmc_get_device_id()
2705 bmc->dyn_id_set = prev_dyn_id_set; in __bmc_get_device_id()
2708 bmc->id = bmc->fetch_id; in __bmc_get_device_id()
2709 if (bmc->dyn_guid_set) in __bmc_get_device_id()
2710 bmc->guid = bmc->fetch_guid; in __bmc_get_device_id()
2716 bmc->dyn_guid_set = prev_guid_set; in __bmc_get_device_id()
2721 *id = bmc->id; in __bmc_get_device_id()
2724 *guid_set = bmc->dyn_guid_set; in __bmc_get_device_id()
2726 if (guid && bmc->dyn_guid_set) in __bmc_get_device_id()
2727 *guid = bmc->guid; in __bmc_get_device_id()
2730 mutex_unlock(&bmc->dyn_mutex); in __bmc_get_device_id()
2737 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, in bmc_get_device_id() argument
2741 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); in bmc_get_device_id()
2748 struct bmc_device *bmc = to_bmc_device(dev); in device_id_show() local
2752 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in device_id_show()
2764 struct bmc_device *bmc = to_bmc_device(dev); in provides_device_sdrs_show() local
2768 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in provides_device_sdrs_show()
2779 struct bmc_device *bmc = to_bmc_device(dev); in revision_show() local
2783 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in revision_show()
2795 struct bmc_device *bmc = to_bmc_device(dev); in firmware_revision_show() local
2799 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in firmware_revision_show()
2812 struct bmc_device *bmc = to_bmc_device(dev); in ipmi_version_show() local
2816 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in ipmi_version_show()
2830 struct bmc_device *bmc = to_bmc_device(dev); in add_dev_support_show() local
2834 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in add_dev_support_show()
2847 struct bmc_device *bmc = to_bmc_device(dev); in manufacturer_id_show() local
2851 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in manufacturer_id_show()
2863 struct bmc_device *bmc = to_bmc_device(dev); in product_id_show() local
2867 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in product_id_show()
2879 struct bmc_device *bmc = to_bmc_device(dev); in aux_firmware_rev_show() local
2883 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in aux_firmware_rev_show()
2898 struct bmc_device *bmc = to_bmc_device(dev); in guid_show() local
2903 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); in guid_show()
2931 struct bmc_device *bmc = to_bmc_device(dev); in bmc_dev_attr_is_visible() local
2938 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); in bmc_dev_attr_is_visible()
2944 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); in bmc_dev_attr_is_visible()
2967 struct bmc_device *bmc; in __find_bmc_guid() local
2973 bmc = to_bmc_device(dev); in __find_bmc_guid()
2974 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); in __find_bmc_guid()
2976 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_guid()
2987 struct bmc_device *bmc = NULL; in ipmi_find_bmc_guid() local
2991 bmc = to_bmc_device(dev); in ipmi_find_bmc_guid()
2994 return bmc; in ipmi_find_bmc_guid()
3005 struct bmc_device *bmc; in __find_bmc_prod_dev_id() local
3011 bmc = to_bmc_device(dev); in __find_bmc_prod_dev_id()
3012 rv = (bmc->id.product_id == cid->product_id in __find_bmc_prod_dev_id()
3013 && bmc->id.device_id == cid->device_id); in __find_bmc_prod_dev_id()
3015 rv = kref_get_unless_zero(&bmc->usecount); in __find_bmc_prod_dev_id()
3031 struct bmc_device *bmc = NULL; in ipmi_find_bmc_prod_dev_id() local
3035 bmc = to_bmc_device(dev); in ipmi_find_bmc_prod_dev_id()
3038 return bmc; in ipmi_find_bmc_prod_dev_id()
3051 struct bmc_device *bmc = container_of(work, struct bmc_device, in cleanup_bmc_work() local
3053 int id = bmc->pdev.id; /* Unregister overwrites id */ in cleanup_bmc_work()
3055 platform_device_unregister(&bmc->pdev); in cleanup_bmc_work()
3062 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount); in cleanup_bmc_device() local
3069 queue_work(remove_work_wq, &bmc->remove_work); in cleanup_bmc_device()
3077 struct bmc_device *bmc = intf->bmc; in __ipmi_bmc_unregister() local
3083 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name); in __ipmi_bmc_unregister()
3087 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
3089 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_unregister()
3090 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_unregister()
3091 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_unregister()
3110 struct bmc_device *bmc; in __ipmi_bmc_register() local
3139 bmc = old_bmc; in __ipmi_bmc_register()
3144 intf->bmc = old_bmc; in __ipmi_bmc_register()
3145 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3146 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3147 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3151 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3152 bmc->id.product_id, in __ipmi_bmc_register()
3153 bmc->id.device_id); in __ipmi_bmc_register()
3155 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL); in __ipmi_bmc_register()
3156 if (!bmc) { in __ipmi_bmc_register()
3160 INIT_LIST_HEAD(&bmc->intfs); in __ipmi_bmc_register()
3161 mutex_init(&bmc->dyn_mutex); in __ipmi_bmc_register()
3162 INIT_WORK(&bmc->remove_work, cleanup_bmc_work); in __ipmi_bmc_register()
3164 bmc->id = *id; in __ipmi_bmc_register()
3165 bmc->dyn_id_set = 1; in __ipmi_bmc_register()
3166 bmc->dyn_guid_set = guid_set; in __ipmi_bmc_register()
3167 bmc->guid = *guid; in __ipmi_bmc_register()
3168 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; in __ipmi_bmc_register()
3170 bmc->pdev.name = "ipmi_bmc"; in __ipmi_bmc_register()
3174 kfree(bmc); in __ipmi_bmc_register()
3178 bmc->pdev.dev.driver = &ipmidriver.driver; in __ipmi_bmc_register()
3179 bmc->pdev.id = rv; in __ipmi_bmc_register()
3180 bmc->pdev.dev.release = release_bmc_device; in __ipmi_bmc_register()
3181 bmc->pdev.dev.type = &bmc_device_type; in __ipmi_bmc_register()
3182 kref_init(&bmc->usecount); in __ipmi_bmc_register()
3184 intf->bmc = bmc; in __ipmi_bmc_register()
3185 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3186 list_add_tail(&intf->bmc_link, &bmc->intfs); in __ipmi_bmc_register()
3187 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3189 rv = platform_device_register(&bmc->pdev); in __ipmi_bmc_register()
3199 bmc->id.manufacturer_id, in __ipmi_bmc_register()
3200 bmc->id.product_id, in __ipmi_bmc_register()
3201 bmc->id.device_id); in __ipmi_bmc_register()
3208 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc"); in __ipmi_bmc_register()
3224 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj, in __ipmi_bmc_register()
3249 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3251 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3252 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3253 kref_put(&bmc->usecount, cleanup_bmc_device); in __ipmi_bmc_register()
3257 mutex_lock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3259 mutex_unlock(&bmc->dyn_mutex); in __ipmi_bmc_register()
3260 intf->bmc = &intf->tmp_bmc; in __ipmi_bmc_register()
3261 put_device(&bmc->pdev.dev); in __ipmi_bmc_register()
3295 struct bmc_device *bmc = intf->bmc; in guid_handler() local
3305 bmc->dyn_guid_set = 0; in guid_handler()
3310 bmc->dyn_guid_set = 0; in guid_handler()
3317 import_guid(&bmc->fetch_guid, msg->msg.data + 1); in guid_handler()
3323 bmc->dyn_guid_set = 1; in guid_handler()
3331 struct bmc_device *bmc = intf->bmc; in __get_guid() local
3333 bmc->dyn_guid_set = 2; in __get_guid()
3338 bmc->dyn_guid_set = 0; in __get_guid()
3340 wait_event(intf->waitq, bmc->dyn_guid_set != 2); in __get_guid()
3581 intf->bmc = &intf->tmp_bmc; in ipmi_add_smi()
3582 INIT_LIST_HEAD(&intf->bmc->intfs); in ipmi_add_smi()
3583 mutex_init(&intf->bmc->dyn_mutex); in ipmi_add_smi()