Lines Matching refs:bmc
328 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
469 struct bmc_device *bmc;
2389 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id);
2393 intf->bmc->cc = msg->msg.data[0];
2394 intf->bmc->dyn_id_set = 0;
2401 intf->bmc->dyn_id_set = 1;
2436 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc)
2444 bmc->cc = 0;
2445 bmc->dyn_id_set = 2;
2451 wait_event(intf->waitq, bmc->dyn_id_set != 2);
2453 if (!bmc->dyn_id_set) {
2454 if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR
2455 || bmc->cc == IPMI_DEVICE_IN_INIT_ERR
2456 || bmc->cc == IPMI_NOT_IN_MY_STATE_ERR)
2460 "BMC returned 0x%2.2x, retry get bmc device id\n",
2461 bmc->cc);
2478 * Fetch the device id for the bmc/interface. You must pass in either
2479 * bmc or intf, this code will get the other one. If the data has
2486 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
2495 mutex_lock(&bmc->dyn_mutex);
2497 if (list_empty(&bmc->intfs)) {
2498 mutex_unlock(&bmc->dyn_mutex);
2501 intf = list_first_entry(&bmc->intfs, struct ipmi_smi,
2504 mutex_unlock(&bmc->dyn_mutex);
2506 mutex_lock(&bmc->dyn_mutex);
2507 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi,
2515 bmc = intf->bmc;
2516 mutex_lock(&bmc->dyn_mutex);
2522 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry)))
2525 prev_guid_set = bmc->dyn_guid_set;
2528 prev_dyn_id_set = bmc->dyn_id_set;
2529 rv = __get_device_id(intf, bmc);
2538 || (!prev_guid_set && bmc->dyn_guid_set)
2539 || (!prev_dyn_id_set && bmc->dyn_id_set)
2540 || (prev_guid_set && bmc->dyn_guid_set
2541 && !guid_equal(&bmc->guid, &bmc->fetch_guid))
2542 || bmc->id.device_id != bmc->fetch_id.device_id
2543 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id
2544 || bmc->id.product_id != bmc->fetch_id.product_id) {
2545 struct ipmi_device_id id = bmc->fetch_id;
2546 int guid_set = bmc->dyn_guid_set;
2549 guid = bmc->fetch_guid;
2550 mutex_unlock(&bmc->dyn_mutex);
2554 intf->bmc->id = id;
2555 intf->bmc->dyn_guid_set = guid_set;
2556 intf->bmc->guid = guid;
2570 mutex_lock(&bmc->dyn_mutex);
2575 bmc = intf->bmc;
2576 mutex_lock(&bmc->dyn_mutex);
2578 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id)))
2580 __scan_channels(intf, &bmc->fetch_id);
2582 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
2587 bmc->dyn_id_set = prev_dyn_id_set;
2590 bmc->id = bmc->fetch_id;
2591 if (bmc->dyn_guid_set)
2592 bmc->guid = bmc->fetch_guid;
2598 bmc->dyn_guid_set = prev_guid_set;
2603 *id = bmc->id;
2606 *guid_set = bmc->dyn_guid_set;
2608 if (guid && bmc->dyn_guid_set)
2609 *guid = bmc->guid;
2612 mutex_unlock(&bmc->dyn_mutex);
2619 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
2623 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1);
2630 struct bmc_device *bmc = to_bmc_device(dev);
2634 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2646 struct bmc_device *bmc = to_bmc_device(dev);
2650 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2661 struct bmc_device *bmc = to_bmc_device(dev);
2665 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2677 struct bmc_device *bmc = to_bmc_device(dev);
2681 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2694 struct bmc_device *bmc = to_bmc_device(dev);
2698 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2712 struct bmc_device *bmc = to_bmc_device(dev);
2716 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2729 struct bmc_device *bmc = to_bmc_device(dev);
2733 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2745 struct bmc_device *bmc = to_bmc_device(dev);
2749 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2761 struct bmc_device *bmc = to_bmc_device(dev);
2765 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2780 struct bmc_device *bmc = to_bmc_device(dev);
2785 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid);
2813 struct bmc_device *bmc = to_bmc_device(dev);
2820 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2826 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL);
2849 struct bmc_device *bmc;
2855 bmc = to_bmc_device(dev);
2856 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid);
2858 rv = kref_get_unless_zero(&bmc->usecount);
2863 * Returns with the bmc's usecount incremented, if it is non-NULL.
2869 struct bmc_device *bmc = NULL;
2873 bmc = to_bmc_device(dev);
2876 return bmc;
2887 struct bmc_device *bmc;
2893 bmc = to_bmc_device(dev);
2894 rv = (bmc->id.product_id == cid->product_id
2895 && bmc->id.device_id == cid->device_id);
2897 rv = kref_get_unless_zero(&bmc->usecount);
2902 * Returns with the bmc's usecount incremented, if it is non-NULL.
2913 struct bmc_device *bmc = NULL;
2917 bmc = to_bmc_device(dev);
2920 return bmc;
2933 struct bmc_device *bmc = container_of(work, struct bmc_device,
2935 int id = bmc->pdev.id; /* Unregister overwrites id */
2937 platform_device_unregister(&bmc->pdev);
2944 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount);
2951 queue_work(remove_work_wq, &bmc->remove_work);
2959 struct bmc_device *bmc = intf->bmc;
2964 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
2965 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name);
2969 mutex_lock(&bmc->dyn_mutex);
2971 mutex_unlock(&bmc->dyn_mutex);
2972 intf->bmc = &intf->tmp_bmc;
2973 kref_put(&bmc->usecount, cleanup_bmc_device);
2992 struct bmc_device *bmc;
3021 bmc = old_bmc;
3026 intf->bmc = old_bmc;
3027 mutex_lock(&bmc->dyn_mutex);
3028 list_add_tail(&intf->bmc_link, &bmc->intfs);
3029 mutex_unlock(&bmc->dyn_mutex);
3033 bmc->id.manufacturer_id,
3034 bmc->id.product_id,
3035 bmc->id.device_id);
3037 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL);
3038 if (!bmc) {
3042 INIT_LIST_HEAD(&bmc->intfs);
3043 mutex_init(&bmc->dyn_mutex);
3044 INIT_WORK(&bmc->remove_work, cleanup_bmc_work);
3046 bmc->id = *id;
3047 bmc->dyn_id_set = 1;
3048 bmc->dyn_guid_set = guid_set;
3049 bmc->guid = *guid;
3050 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
3052 bmc->pdev.name = "ipmi_bmc";
3056 kfree(bmc);
3060 bmc->pdev.dev.driver = &ipmidriver.driver;
3061 bmc->pdev.id = rv;
3062 bmc->pdev.dev.release = release_bmc_device;
3063 bmc->pdev.dev.type = &bmc_device_type;
3064 kref_init(&bmc->usecount);
3066 intf->bmc = bmc;
3067 mutex_lock(&bmc->dyn_mutex);
3068 list_add_tail(&intf->bmc_link, &bmc->intfs);
3069 mutex_unlock(&bmc->dyn_mutex);
3071 rv = platform_device_register(&bmc->pdev);
3074 "Unable to register bmc device: %d\n",
3081 bmc->id.manufacturer_id,
3082 bmc->id.product_id,
3083 bmc->id.device_id);
3087 * create symlink from system interface device to bmc device
3090 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc");
3092 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv);
3106 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj,
3109 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n",
3128 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
3131 mutex_lock(&bmc->dyn_mutex);
3133 mutex_unlock(&bmc->dyn_mutex);
3134 intf->bmc = &intf->tmp_bmc;
3135 kref_put(&bmc->usecount, cleanup_bmc_device);
3139 mutex_lock(&bmc->dyn_mutex);
3141 mutex_unlock(&bmc->dyn_mutex);
3142 intf->bmc = &intf->tmp_bmc;
3143 put_device(&bmc->pdev.dev);
3177 struct bmc_device *bmc = intf->bmc;
3187 bmc->dyn_guid_set = 0;
3192 bmc->dyn_guid_set = 0;
3199 import_guid(&bmc->fetch_guid, msg->msg.data + 1);
3205 bmc->dyn_guid_set = 1;
3213 struct bmc_device *bmc = intf->bmc;
3215 bmc->dyn_guid_set = 2;
3220 bmc->dyn_guid_set = 0;
3222 wait_event(intf->waitq, bmc->dyn_guid_set != 2);
3433 intf->bmc = &intf->tmp_bmc;
3434 INIT_LIST_HEAD(&intf->bmc->intfs);
3435 mutex_init(&intf->bmc->dyn_mutex);