Lines Matching refs:bmc

330 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
475 struct bmc_device *bmc;
2504 intf->bmc->dyn_id_set = 0;
2509 msg->msg.data, msg->msg.data_len, &intf->bmc->fetch_id);
2513 intf->bmc->cc = msg->msg.data[0];
2514 intf->bmc->dyn_id_set = 0;
2521 intf->bmc->dyn_id_set = 1;
2556 static int __get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc)
2564 bmc->cc = 0;
2565 bmc->dyn_id_set = 2;
2571 wait_event(intf->waitq, bmc->dyn_id_set != 2);
2573 if (!bmc->dyn_id_set) {
2574 if (bmc->cc != IPMI_CC_NO_ERROR &&
2578 "BMC returned 0x%2.2x, retry get bmc device id\n",
2579 bmc->cc);
2596 * Fetch the device id for the bmc/interface. You must pass in either
2597 * bmc or intf, this code will get the other one. If the data has
2604 static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
2613 mutex_lock(&bmc->dyn_mutex);
2615 if (list_empty(&bmc->intfs)) {
2616 mutex_unlock(&bmc->dyn_mutex);
2619 intf = list_first_entry(&bmc->intfs, struct ipmi_smi,
2622 mutex_unlock(&bmc->dyn_mutex);
2624 mutex_lock(&bmc->dyn_mutex);
2625 if (intf != list_first_entry(&bmc->intfs, struct ipmi_smi,
2633 bmc = intf->bmc;
2634 mutex_lock(&bmc->dyn_mutex);
2640 (bmc->dyn_id_set && time_is_after_jiffies(bmc->dyn_id_expiry)))
2643 prev_guid_set = bmc->dyn_guid_set;
2646 prev_dyn_id_set = bmc->dyn_id_set;
2647 rv = __get_device_id(intf, bmc);
2656 || (!prev_guid_set && bmc->dyn_guid_set)
2657 || (!prev_dyn_id_set && bmc->dyn_id_set)
2658 || (prev_guid_set && bmc->dyn_guid_set
2659 && !guid_equal(&bmc->guid, &bmc->fetch_guid))
2660 || bmc->id.device_id != bmc->fetch_id.device_id
2661 || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id
2662 || bmc->id.product_id != bmc->fetch_id.product_id) {
2663 struct ipmi_device_id id = bmc->fetch_id;
2664 int guid_set = bmc->dyn_guid_set;
2667 guid = bmc->fetch_guid;
2668 mutex_unlock(&bmc->dyn_mutex);
2672 intf->bmc->id = id;
2673 intf->bmc->dyn_guid_set = guid_set;
2674 intf->bmc->guid = guid;
2688 mutex_lock(&bmc->dyn_mutex);
2693 bmc = intf->bmc;
2694 mutex_lock(&bmc->dyn_mutex);
2696 } else if (memcmp(&bmc->fetch_id, &bmc->id, sizeof(bmc->id)))
2698 __scan_channels(intf, &bmc->fetch_id);
2700 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
2705 bmc->dyn_id_set = prev_dyn_id_set;
2708 bmc->id = bmc->fetch_id;
2709 if (bmc->dyn_guid_set)
2710 bmc->guid = bmc->fetch_guid;
2716 bmc->dyn_guid_set = prev_guid_set;
2721 *id = bmc->id;
2724 *guid_set = bmc->dyn_guid_set;
2726 if (guid && bmc->dyn_guid_set)
2727 *guid = bmc->guid;
2730 mutex_unlock(&bmc->dyn_mutex);
2737 static int bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,
2741 return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1);
2748 struct bmc_device *bmc = to_bmc_device(dev);
2752 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2764 struct bmc_device *bmc = to_bmc_device(dev);
2768 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2779 struct bmc_device *bmc = to_bmc_device(dev);
2783 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2795 struct bmc_device *bmc = to_bmc_device(dev);
2799 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);
2830 struct bmc_device *bmc = to_bmc_device(dev);
2834 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2847 struct bmc_device *bmc = to_bmc_device(dev);
2851 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2863 struct bmc_device *bmc = to_bmc_device(dev);
2867 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2879 struct bmc_device *bmc = to_bmc_device(dev);
2883 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2898 struct bmc_device *bmc = to_bmc_device(dev);
2903 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid);
2931 struct bmc_device *bmc = to_bmc_device(dev);
2938 rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
2944 rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL);
2967 struct bmc_device *bmc;
2973 bmc = to_bmc_device(dev);
2974 rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid);
2976 rv = kref_get_unless_zero(&bmc->usecount);
2981 * Returns with the bmc's usecount incremented, if it is non-NULL.
2987 struct bmc_device *bmc = NULL;
2991 bmc = to_bmc_device(dev);
2994 return bmc;
3005 struct bmc_device *bmc;
3011 bmc = to_bmc_device(dev);
3012 rv = (bmc->id.product_id == cid->product_id
3013 && bmc->id.device_id == cid->device_id);
3015 rv = kref_get_unless_zero(&bmc->usecount);
3020 * Returns with the bmc's usecount incremented, if it is non-NULL.
3031 struct bmc_device *bmc = NULL;
3035 bmc = to_bmc_device(dev);
3038 return bmc;
3051 struct bmc_device *bmc = container_of(work, struct bmc_device,
3053 int id = bmc->pdev.id; /* Unregister overwrites id */
3055 platform_device_unregister(&bmc->pdev);
3062 struct bmc_device *bmc = container_of(ref, struct bmc_device, usecount);
3069 queue_work(remove_work_wq, &bmc->remove_work);
3077 struct bmc_device *bmc = intf->bmc;
3082 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
3083 sysfs_remove_link(&bmc->pdev.dev.kobj, intf->my_dev_name);
3087 mutex_lock(&bmc->dyn_mutex);
3089 mutex_unlock(&bmc->dyn_mutex);
3090 intf->bmc = &intf->tmp_bmc;
3091 kref_put(&bmc->usecount, cleanup_bmc_device);
3110 struct bmc_device *bmc;
3139 bmc = old_bmc;
3144 intf->bmc = old_bmc;
3145 mutex_lock(&bmc->dyn_mutex);
3146 list_add_tail(&intf->bmc_link, &bmc->intfs);
3147 mutex_unlock(&bmc->dyn_mutex);
3151 bmc->id.manufacturer_id,
3152 bmc->id.product_id,
3153 bmc->id.device_id);
3155 bmc = kzalloc(sizeof(*bmc), GFP_KERNEL);
3156 if (!bmc) {
3160 INIT_LIST_HEAD(&bmc->intfs);
3161 mutex_init(&bmc->dyn_mutex);
3162 INIT_WORK(&bmc->remove_work, cleanup_bmc_work);
3164 bmc->id = *id;
3165 bmc->dyn_id_set = 1;
3166 bmc->dyn_guid_set = guid_set;
3167 bmc->guid = *guid;
3168 bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
3170 bmc->pdev.name = "ipmi_bmc";
3174 kfree(bmc);
3178 bmc->pdev.dev.driver = &ipmidriver.driver;
3179 bmc->pdev.id = rv;
3180 bmc->pdev.dev.release = release_bmc_device;
3181 bmc->pdev.dev.type = &bmc_device_type;
3182 kref_init(&bmc->usecount);
3184 intf->bmc = bmc;
3185 mutex_lock(&bmc->dyn_mutex);
3186 list_add_tail(&intf->bmc_link, &bmc->intfs);
3187 mutex_unlock(&bmc->dyn_mutex);
3189 rv = platform_device_register(&bmc->pdev);
3192 "Unable to register bmc device: %d\n",
3199 bmc->id.manufacturer_id,
3200 bmc->id.product_id,
3201 bmc->id.device_id);
3205 * create symlink from system interface device to bmc device
3208 rv = sysfs_create_link(&intf->si_dev->kobj, &bmc->pdev.dev.kobj, "bmc");
3210 dev_err(intf->si_dev, "Unable to create bmc symlink: %d\n", rv);
3224 rv = sysfs_create_link(&bmc->pdev.dev.kobj, &intf->si_dev->kobj,
3227 dev_err(intf->si_dev, "Unable to create symlink to bmc: %d\n",
3246 sysfs_remove_link(&intf->si_dev->kobj, "bmc");
3249 mutex_lock(&bmc->dyn_mutex);
3251 mutex_unlock(&bmc->dyn_mutex);
3252 intf->bmc = &intf->tmp_bmc;
3253 kref_put(&bmc->usecount, cleanup_bmc_device);
3257 mutex_lock(&bmc->dyn_mutex);
3259 mutex_unlock(&bmc->dyn_mutex);
3260 intf->bmc = &intf->tmp_bmc;
3261 put_device(&bmc->pdev.dev);
3295 struct bmc_device *bmc = intf->bmc;
3305 bmc->dyn_guid_set = 0;
3310 bmc->dyn_guid_set = 0;
3317 import_guid(&bmc->fetch_guid, msg->msg.data + 1);
3323 bmc->dyn_guid_set = 1;
3331 struct bmc_device *bmc = intf->bmc;
3333 bmc->dyn_guid_set = 2;
3338 bmc->dyn_guid_set = 0;
3340 wait_event(intf->waitq, bmc->dyn_guid_set != 2);
3581 intf->bmc = &intf->tmp_bmc;
3582 INIT_LIST_HEAD(&intf->bmc->intfs);
3583 mutex_init(&intf->bmc->dyn_mutex);