diff options
author | Corey Minyard <cminyard@mvista.com> | 2017-09-01 14:39:18 -0500 |
---|---|---|
committer | Corey Minyard <cminyard@mvista.com> | 2017-09-27 16:03:45 -0500 |
commit | 39d3fb456009d3619b90236cb8edf156932b1bd4 (patch) | |
tree | 0a96761201a166e3ac13bdf66317130134f497c5 /drivers/char/ipmi/ipmi_msghandler.c | |
parent | 1e5058ea21010883b1e1d288637f7390bb8d1c61 (diff) | |
download | linux-39d3fb456009d3619b90236cb8edf156932b1bd4.tar.gz linux-39d3fb456009d3619b90236cb8edf156932b1bd4.tar.bz2 linux-39d3fb456009d3619b90236cb8edf156932b1bd4.zip |
ipmi: Always fetch the guid through ipmi_get_device_id()
This is in preparation for making ipmi_get_device_id() dynamically
return the guid and device id.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 93 |
1 files changed, 65 insertions, 28 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index ee108be13348..9a6b048b1792 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -273,14 +273,15 @@ struct bmc_device { int dyn_id_set; unsigned long dyn_id_expiry; struct mutex dyn_mutex; /* protects id & dyn* fields */ - unsigned char guid[16]; + u8 guid[16]; int guid_set; struct kref usecount; }; #define to_bmc_device(x) container_of((x), struct bmc_device, pdev.dev) static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, - struct ipmi_device_id *id); + struct ipmi_device_id *id, + bool *guid_set, u8 *guid); /* * Various statistics for IPMI, these index stats[] in the ipmi_smi @@ -1220,7 +1221,7 @@ int ipmi_get_version(ipmi_user_t user, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(user->intf, NULL, &id); + rv = bmc_get_device_id(user->intf, NULL, &id, NULL, NULL); if (rv) return rv; @@ -2193,7 +2194,8 @@ static int __get_device_id(ipmi_smi_t intf, struct bmc_device *bmc) * this will always return good data; */ static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, - struct ipmi_device_id *id) + struct ipmi_device_id *id, + bool *guid_set, u8 *guid) { int rv = 0; int prev_dyn_id_set; @@ -2247,6 +2249,12 @@ out: if (id) *id = bmc->id; + if (guid_set) + *guid_set = bmc->guid_set; + + if (guid && bmc->guid_set) + memcpy(guid, bmc->guid, 16); + mutex_unlock(&bmc->dyn_mutex); mutex_unlock(&intf->bmc_reg_mutex); @@ -2286,7 +2294,7 @@ static int smi_version_proc_show(struct seq_file *m, void *v) struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(intf, NULL, &id); + rv = bmc_get_device_id(intf, NULL, &id, NULL, NULL); if (rv) return rv; @@ -2478,7 +2486,7 @@ static ssize_t device_id_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2494,7 +2502,7 @@ static ssize_t provides_device_sdrs_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2510,7 +2518,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2526,7 +2534,7 @@ static ssize_t firmware_revision_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2543,7 +2551,7 @@ static ssize_t ipmi_version_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2561,7 +2569,7 @@ static ssize_t add_dev_support_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2578,7 +2586,7 @@ static ssize_t manufacturer_id_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2594,7 +2602,7 @@ static ssize_t product_id_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2610,7 +2618,7 @@ static ssize_t aux_firmware_rev_show(struct device *dev, struct ipmi_device_id id; int rv; - rv = bmc_get_device_id(NULL, bmc, &id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); if (rv) return rv; @@ -2626,13 +2634,22 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, char *buf) { struct bmc_device *bmc = to_bmc_device(dev); + bool guid_set; + u8 guid[16]; + int rv; + + rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, guid); + if (rv) + return rv; + if (!guid_set) + return -ENOENT; return snprintf(buf, 100, - "%2.2x%2.2x%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", - bmc->guid[3], bmc->guid[2], bmc->guid[1], bmc->guid[0], - bmc->guid[5], bmc->guid[4], bmc->guid[7], bmc->guid[6], - bmc->guid[8], bmc->guid[9], bmc->guid[10], bmc->guid[11], - bmc->guid[12], bmc->guid[13], bmc->guid[14], bmc->guid[15]); + "%2.2x%2.2x%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", + guid[3], guid[2], guid[1], guid[0], + guid[5], guid[4], guid[7], guid[6], + guid[8], guid[9], guid[10], guid[11], + guid[12], guid[13], guid[14], guid[15]); } static DEVICE_ATTR(guid, S_IRUGO, guid_show, NULL); @@ -2656,15 +2673,20 @@ static umode_t bmc_dev_attr_is_visible(struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct bmc_device *bmc = to_bmc_device(dev); umode_t mode = attr->mode; - struct ipmi_device_id id; int rv; if (attr == &dev_attr_aux_firmware_revision.attr) { - rv = bmc_get_device_id(NULL, bmc, &id); + struct ipmi_device_id id; + + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); return (!rv && id.aux_firmware_revision_set) ? mode : 0; } - if (attr == &dev_attr_guid.attr) - return bmc->guid_set ? mode : 0; + if (attr == &dev_attr_guid.attr) { + bool guid_set; + + rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL); + return (!rv && guid_set) ? mode : 0; + } return mode; } @@ -2685,11 +2707,20 @@ static const struct device_type bmc_device_type = { static int __find_bmc_guid(struct device *dev, void *data) { unsigned char *id = data; + struct bmc_device *bmc; + bool guid_set; + u8 guid[16]; + int rv; if (dev->type != &bmc_device_type) return 0; - return memcmp(to_bmc_device(dev)->guid, id, 16) == 0; + bmc = to_bmc_device(dev); + rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, guid); + if (rv || !guid_set) + return 0; + + return memcmp(guid, id, 16) == 0; } /* @@ -2718,15 +2749,21 @@ struct prod_dev_id { static int __find_bmc_prod_dev_id(struct device *dev, void *data) { - struct prod_dev_id *id = data; + struct prod_dev_id *cid = data; struct bmc_device *bmc; + struct ipmi_device_id id; + int rv; if (dev->type != &bmc_device_type) return 0; bmc = to_bmc_device(dev); - return (bmc->id.product_id == id->product_id - && bmc->id.device_id == id->device_id); + rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL); + if (rv) + return 0; + + return (id.product_id == cid->product_id + && id.device_id == cid->device_id); } /* @@ -3219,7 +3256,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers, get_guid(intf); - rv = bmc_get_device_id(intf, NULL, &id); + rv = bmc_get_device_id(intf, NULL, &id, NULL, NULL); if (rv) { dev_err(si_dev, "Unable to get the device id: %d\n", rv); goto out; |