From: Corey Minyard <cminy...@mvista.com> Signed-off-by: Corey Minyard <cminy...@mvista.com> --- drivers/char/ipmi/ipmi_msghandler.c | 49 +++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 23e9a02..7d02d7d 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -48,6 +48,7 @@ #include <linux/interrupt.h> #include <linux/moduleparam.h> #include <linux/workqueue.h> +#include <linux/uuid.h> #define PFX "IPMI message handler: " @@ -286,8 +287,8 @@ struct bmc_device { int dyn_id_set; unsigned long dyn_id_expiry; struct mutex dyn_mutex; /* Protects id, intfs, & dyn* */ - u8 guid[16]; - u8 fetch_guid[16]; + guid_t guid; + guid_t fetch_guid; int dyn_guid_set; struct kref usecount; struct work_struct remove_work; @@ -296,7 +297,7 @@ struct bmc_device { static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, struct ipmi_device_id *id, - bool *guid_set, u8 *guid); + bool *guid_set, guid_t *guid); /* * Various statistics for IPMI, these index stats[] in the ipmi_smi @@ -554,7 +555,7 @@ static void __get_guid(ipmi_smi_t intf); static void __ipmi_bmc_unregister(ipmi_smi_t intf); static int __ipmi_bmc_register(ipmi_smi_t intf, struct ipmi_device_id *id, - bool guid_set, u8 *guid, int intf_num); + bool guid_set, guid_t *guid, int intf_num); static int __scan_channels(ipmi_smi_t intf, struct ipmi_device_id *id); @@ -2218,7 +2219,7 @@ static int __get_device_id(ipmi_smi_t intf, struct bmc_device *bmc) */ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, struct ipmi_device_id *id, - bool *guid_set, u8 *guid, int intf_num) + bool *guid_set, guid_t *guid, int intf_num) { int rv = 0; int prev_dyn_id_set, prev_guid_set; @@ -2271,23 +2272,23 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, || (!prev_guid_set && bmc->dyn_guid_set) || (!prev_dyn_id_set && bmc->dyn_id_set) || (prev_guid_set && bmc->dyn_guid_set - && memcmp(bmc->guid, bmc->fetch_guid, 16)) + && !guid_equal(&bmc->guid, &bmc->fetch_guid)) || bmc->id.device_id != bmc->fetch_id.device_id || bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id || bmc->id.product_id != bmc->fetch_id.product_id) { struct ipmi_device_id id = bmc->fetch_id; int guid_set = bmc->dyn_guid_set; - u8 guid[16]; + guid_t guid; - memcpy(guid, bmc->fetch_guid, 16); + guid = bmc->fetch_guid; mutex_unlock(&bmc->dyn_mutex); __ipmi_bmc_unregister(intf); /* Fill in the temporary BMC for good measure. */ intf->bmc->id = id; intf->bmc->dyn_guid_set = guid_set; - memcpy(intf->bmc->guid, guid, 16); - if (__ipmi_bmc_register(intf, &id, guid_set, guid, intf_num)) + intf->bmc->guid = guid; + if (__ipmi_bmc_register(intf, &id, guid_set, &guid, intf_num)) need_waiter(intf); /* Retry later on an error. */ __scan_channels(intf, &id); @@ -2322,7 +2323,7 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, if (!rv) { bmc->id = bmc->fetch_id; if (bmc->dyn_guid_set) - memcpy(bmc->guid, bmc->fetch_guid, 16); + bmc->guid = bmc->fetch_guid; else if (prev_guid_set) /* * The guid used to be valid and it failed to fetch, @@ -2339,7 +2340,7 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, *guid_set = bmc->dyn_guid_set; if (guid && bmc->dyn_guid_set) - memcpy(guid, bmc->guid, 16); + *guid = bmc->guid; } mutex_unlock(&bmc->dyn_mutex); @@ -2351,7 +2352,7 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, struct ipmi_device_id *id, - bool *guid_set, u8 *guid) + bool *guid_set, guid_t *guid) { return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1); } @@ -2729,18 +2730,18 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, { struct bmc_device *bmc = to_bmc_device(dev); bool guid_set; - u8 guid[16]; + guid_t guid; int rv; - rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, guid); + rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, &guid); if (rv) return rv; if (!guid_set) return -ENOENT; - return snprintf(buf, 100, "%Lx%Lx\n", - (long long) guid[0], - (long long) guid[8]); + rv = guid_to_str(buf, 100, &guid); + strcpy(buf + rv, "\n"); + return rv + 1; } static DEVICE_ATTR(guid, S_IRUGO, guid_show, NULL); @@ -2797,7 +2798,7 @@ static const struct device_type bmc_device_type = { static int __find_bmc_guid(struct device *dev, void *data) { - unsigned char *guid = data; + guid_t *guid = data; struct bmc_device *bmc; int rv; @@ -2805,7 +2806,7 @@ static int __find_bmc_guid(struct device *dev, void *data) return 0; bmc = to_bmc_device(dev); - rv = bmc->dyn_guid_set && memcmp(bmc->guid, guid, 16) == 0; + rv = bmc->dyn_guid_set && guid_equal(&bmc->guid, guid); if (rv) rv = kref_get_unless_zero(&bmc->usecount); return rv; @@ -2815,7 +2816,7 @@ static int __find_bmc_guid(struct device *dev, void *data) * Returns with the bmc's usecount incremented, if it is non-NULL. */ static struct bmc_device *ipmi_find_bmc_guid(struct device_driver *drv, - unsigned char *guid) + guid_t *guid) { struct device *dev; struct bmc_device *bmc = NULL; @@ -2938,7 +2939,7 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf) */ static int __ipmi_bmc_register(ipmi_smi_t intf, struct ipmi_device_id *id, - bool guid_set, u8 *guid, int intf_num) + bool guid_set, guid_t *guid, int intf_num) { int rv; struct bmc_device *bmc = intf->bmc; @@ -2999,7 +3000,7 @@ static int __ipmi_bmc_register(ipmi_smi_t intf, bmc->id = *id; bmc->dyn_id_set = 1; bmc->dyn_guid_set = guid_set; - memcpy(bmc->guid, guid, 16); + bmc->guid = *guid; bmc->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY; bmc->pdev.name = "ipmi_bmc"; @@ -3156,7 +3157,7 @@ static void guid_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg) goto out; } - memcpy(bmc->fetch_guid, msg->msg.data + 1, 16); + memcpy(bmc->fetch_guid.b, msg->msg.data + 1, 16); /* * Make sure the guid data is available before setting * dyn_guid_set. -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openipmi-developer mailing list Openipmi-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openipmi-developer