Lines Matching refs:bmc

304 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
448 struct bmc_device *bmc;
2486 intf->bmc->dyn_id_set = 0;
2491 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id);
2495 intf->bmc->cc = msg->msg.data[0];
2496 intf->bmc->dyn_id_set = 0;
2503 intf->bmc->dyn_id_set = 1;
2538 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc)
2546 bmc->cc = 0;
2547 bmc->dyn_id_set = 2;
2553 wait_event(intf->waitq, bmc->dyn_id_set != 2);
2555 if (!bmc->dyn_id_set) {
2556 if (bmc->cc != IPMI_CC_NO_ERROR &&
2560 "BMC returned 0x%2.2x, retry get bmc device id\n",
2561 bmc->cc);
2578 * Fetch the device id for the bmc/interface. You must pass in either
2579 * bmc or intf, this code will get the other one. If the data has
2586 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
2595 mutex_lock(&bmc->dyn_mutex);
2597 if (list_empty(&bmc->intfs)) {
2598 mutex_unlock(&bmc->dyn_mutex);
2601 intf = list_first_entry(&bmc->intfs, struct ipmi_smi,
2604 mutex_unlock(&bmc->dyn_mutex);
2606 mutex_lock(&bmc->dyn_mutex);
2607 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi,
2615 bmc = intf->bmc;
2616 mutex_lock(&bmc->dyn_mutex);
2622 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry)))
2625 prev_guid_set = bmc->dyn_guid_set;
2628 prev_dyn_id_set = bmc->dyn_id_set;
2629 rv = __get_device_id(intf, bmc);
2638 || (!prev_guid_set && bmc->dyn_guid_set)
2639 || (!prev_dyn_id_set && bmc->dyn_id_set)
2640 || (prev_guid_set && bmc->dyn_guid_set
2641 && !guid_equal(&bmc->guid, &bmc->fetch_guid))
2642 || bmc->id.device_id != bmc->fetch_id.device_id
2643 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id
2644 || bmc->id.product_id != bmc->fetch_id.product_id) {
2645 struct ipmi_device_id id = bmc->fetch_id;
2646 int guid_set = bmc->dyn_guid_set;
2649 guid = bmc->fetch_guid;
2650 mutex_unlock(&bmc->dyn_mutex);
2654 intf->bmc->id = id;
2655 intf->bmc->dyn_guid_set = guid_set;
2656 intf->bmc->guid = guid;
2670 mutex_lock(&bmc->dyn_mutex);
2675 bmc = intf->bmc;
2676 mutex_lock(&bmc->dyn_mutex);
2678 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id)))
2680 __scan_channels(intf, &bmc->fetch_id);
2682 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
2687 bmc->dyn_id_set = prev_dyn_id_set;
2690 bmc->id = bmc->fetch_id;
2691 if (bmc->dyn_guid_set)
2692 bmc->guid = bmc->fetch_guid;
2698 bmc->dyn_guid_set = prev_guid_set;
2703 *id = bmc->id;
2706 *guid_set = bmc->dyn_guid_set;
2708 if (guid && bmc->dyn_guid_set)
2709 *guid = bmc->guid;
2712 mutex_unlock(&bmc->dyn_mutex);
2719 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
2723 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1);
2730 struct bmc_device *bmc = to_bmc_device(dev);
2734 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2746 struct bmc_device *bmc = to_bmc_device(dev);
2750 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);
2777 struct bmc_device *bmc = to_bmc_device(dev);
2781 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2794 struct bmc_device *bmc = to_bmc_device(dev);
2798 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2812 struct bmc_device *bmc = to_bmc_device(dev);
2816 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2829 struct bmc_device *bmc = to_bmc_device(dev);
2833 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2845 struct bmc_device *bmc = to_bmc_device(dev);
2849 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2861 struct bmc_device *bmc = to_bmc_device(dev);
2865 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2880 struct bmc_device *bmc = to_bmc_device(dev);
2885 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid);
2913 struct bmc_device *bmc = to_bmc_device(dev);
2920 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2926 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL);
2949 struct bmc_device *bmc;
2955 bmc = to_bmc_device(dev);
2956 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid);
2958 rv = kref_get_unless_zero(&bmc->usecount);
2963 * Returns with the bmc's usecount incremented, if it is non-NULL.
2969 struct bmc_device *bmc = NULL;
2973 bmc = to_bmc_device(dev);
2976 return bmc;
2987 struct bmc_device *bmc;
2993 bmc = to_bmc_device(dev);
2994 rv = (bmc->id.product_id == cid->product_id
2995 && bmc->id.device_id == cid->device_id);
2997 rv = kref_get_unless_zero(&bmc->usecount);
3002 * Returns with the bmc's usecount incremented, if it is non-NULL.
3013 struct bmc_device *bmc = NULL;
3017 bmc = to_bmc_device(dev);
3020 return bmc;
3033 struct bmc_device *bmc = container_of(work, struct bmc_device,
3035 int id = bmc->pdev.id; /* Unregister overwrites id */
3037 platform_device_unregister(&bmc->pdev);
3044 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount);
3051 queue_work(bmc_remove_work_wq, &bmc->remove_work);
3059 struct bmc_device *bmc = intf->bmc;
3064 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
3065 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name);
3069 mutex_lock(&bmc->dyn_mutex);
3071 mutex_unlock(&bmc->dyn_mutex);
3072 intf->bmc = &intf->tmp_bmc;
3073 kref_put(&bmc->usecount, cleanup_bmc_device);
3092 struct bmc_device *bmc;
3121 bmc = old_bmc;
3126 intf->bmc = old_bmc;
3127 mutex_lock(&bmc->dyn_mutex);
3128 list_add_tail(&intf->bmc_link, &bmc->intfs);
3129 mutex_unlock(&bmc->dyn_mutex);
3133 bmc->id.manufacturer_id,
3134 bmc->id.product_id,
3135 bmc->id.device_id);
3137 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL);
3138 if (!bmc) {
3142 INIT_LIST_HEAD(&bmc->intfs);
3143 mutex_init(&bmc->dyn_mutex);
3144 INIT_WORK(&bmc->remove_work, cleanup_bmc_work);
3146 bmc->id = *id;
3147 bmc->dyn_id_set = 1;
3148 bmc->dyn_guid_set = guid_set;
3149 bmc->guid = *guid;
3150 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
3152 bmc->pdev.name = "ipmi_bmc";
3156 kfree(bmc);
3160 bmc->pdev.dev.driver = &ipmidriver.driver;
3161 bmc->pdev.id = rv;
3162 bmc->pdev.dev.release = release_bmc_device;
3163 bmc->pdev.dev.type = &bmc_device_type;
3164 kref_init(&bmc->usecount);
3166 intf->bmc = bmc;
3167 mutex_lock(&bmc->dyn_mutex);
3168 list_add_tail(&intf->bmc_link, &bmc->intfs);
3169 mutex_unlock(&bmc->dyn_mutex);
3171 rv = platform_device_register(&bmc->pdev);
3174 "Unable to register bmc device: %d\n",
3181 bmc->id.manufacturer_id,
3182 bmc->id.product_id,
3183 bmc->id.device_id);
3187 * create symlink from system interface device to bmc device
3190 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc");
3192 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv);
3206 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj,
3209 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n",
3228 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
3231 mutex_lock(&bmc->dyn_mutex);
3233 mutex_unlock(&bmc->dyn_mutex);
3234 intf->bmc = &intf->tmp_bmc;
3235 kref_put(&bmc->usecount, cleanup_bmc_device);
3239 mutex_lock(&bmc->dyn_mutex);
3241 mutex_unlock(&bmc->dyn_mutex);
3242 intf->bmc = &intf->tmp_bmc;
3243 put_device(&bmc->pdev.dev);
3277 struct bmc_device *bmc = intf->bmc;
3287 bmc->dyn_guid_set = 0;
3292 bmc->dyn_guid_set = 0;
3299 import_guid(&bmc->fetch_guid, msg->msg.data + 1);
3305 bmc->dyn_guid_set = 1;
3313 struct bmc_device *bmc = intf->bmc;
3315 bmc->dyn_guid_set = 2;
3320 bmc->dyn_guid_set = 0;
3322 wait_event(intf->waitq, bmc->dyn_guid_set != 2);
3556 intf->bmc = &intf->tmp_bmc;
3557 INIT_LIST_HEAD(&intf->bmc->intfs);
3558 mutex_init(&intf->bmc->dyn_mutex);