summaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2017-09-01 19:34:33 -0500
committerCorey Minyard <cminyard@mvista.com>2017-09-27 16:03:45 -0500
commit3fd32f9ec84f57ff6d86e762012d7626a9b31124 (patch)
tree09bf343e7ca3e613101c718601f16170f50df753 /drivers/char
parent31b0b0730ad2a813bf6b01c5f1f3629c09c73466 (diff)
ipmi: Convert IPMI GUID over to Linux guid_t
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index b5fc150e5128..1c8bef2e1dc1 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
@@ -560,7 +561,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);
@@ -2224,7 +2225,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;
@@ -2277,23 +2278,23 @@ retry_bmc_lock:
|| (!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. */
else
__scan_channels(intf, &id);
@@ -2328,7 +2329,7 @@ out:
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,
@@ -2345,7 +2346,7 @@ out_noprocessing:
*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);
@@ -2357,7 +2358,7 @@ out_noprocessing:
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);
}
@@ -2735,21 +2736,16 @@ 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,
- "%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]);
+ return snprintf(buf, 38, "%pUl\n", guid.b);
}
static DEVICE_ATTR(guid, S_IRUGO, guid_show, NULL);
@@ -2806,7 +2802,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;
@@ -2814,7 +2810,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;
@@ -2824,7 +2820,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;
@@ -2947,7 +2943,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;
@@ -3008,7 +3004,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";
@@ -3165,7 +3161,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.