ipmi: Convert IPMI GUID over to Linux guid_t
Signed-off-by: Corey Minyard <cminyard@mvista.com>
This commit is contained in:
parent
31b0b0730a
commit
3fd32f9ec8
|
@ -48,6 +48,7 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
|
#include <linux/uuid.h>
|
||||||
|
|
||||||
#define PFX "IPMI message handler: "
|
#define PFX "IPMI message handler: "
|
||||||
|
|
||||||
|
@ -286,8 +287,8 @@ struct bmc_device {
|
||||||
int dyn_id_set;
|
int dyn_id_set;
|
||||||
unsigned long dyn_id_expiry;
|
unsigned long dyn_id_expiry;
|
||||||
struct mutex dyn_mutex; /* Protects id, intfs, & dyn* */
|
struct mutex dyn_mutex; /* Protects id, intfs, & dyn* */
|
||||||
u8 guid[16];
|
guid_t guid;
|
||||||
u8 fetch_guid[16];
|
guid_t fetch_guid;
|
||||||
int dyn_guid_set;
|
int dyn_guid_set;
|
||||||
struct kref usecount;
|
struct kref usecount;
|
||||||
struct work_struct remove_work;
|
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,
|
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);
|
bool *guid_set, guid_t *guid);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Various statistics for IPMI, these index stats[] in the ipmi_smi
|
* 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 void __ipmi_bmc_unregister(ipmi_smi_t intf);
|
||||||
static int __ipmi_bmc_register(ipmi_smi_t intf,
|
static int __ipmi_bmc_register(ipmi_smi_t intf,
|
||||||
struct ipmi_device_id *id,
|
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);
|
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,
|
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 intf_num)
|
bool *guid_set, guid_t *guid, int intf_num)
|
||||||
{
|
{
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
int prev_dyn_id_set, prev_guid_set;
|
int prev_dyn_id_set, prev_guid_set;
|
||||||
|
@ -2277,23 +2278,23 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
|
||||||
|| (!prev_guid_set && bmc->dyn_guid_set)
|
|| (!prev_guid_set && bmc->dyn_guid_set)
|
||||||
|| (!prev_dyn_id_set && bmc->dyn_id_set)
|
|| (!prev_dyn_id_set && bmc->dyn_id_set)
|
||||||
|| (prev_guid_set && bmc->dyn_guid_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.device_id != bmc->fetch_id.device_id
|
||||||
|| bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id
|
|| bmc->id.manufacturer_id != bmc->fetch_id.manufacturer_id
|
||||||
|| bmc->id.product_id != bmc->fetch_id.product_id) {
|
|| bmc->id.product_id != bmc->fetch_id.product_id) {
|
||||||
struct ipmi_device_id id = bmc->fetch_id;
|
struct ipmi_device_id id = bmc->fetch_id;
|
||||||
int guid_set = bmc->dyn_guid_set;
|
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);
|
mutex_unlock(&bmc->dyn_mutex);
|
||||||
|
|
||||||
__ipmi_bmc_unregister(intf);
|
__ipmi_bmc_unregister(intf);
|
||||||
/* Fill in the temporary BMC for good measure. */
|
/* Fill in the temporary BMC for good measure. */
|
||||||
intf->bmc->id = id;
|
intf->bmc->id = id;
|
||||||
intf->bmc->dyn_guid_set = guid_set;
|
intf->bmc->dyn_guid_set = guid_set;
|
||||||
memcpy(intf->bmc->guid, guid, 16);
|
intf->bmc->guid = guid;
|
||||||
if (__ipmi_bmc_register(intf, &id, guid_set, guid, intf_num))
|
if (__ipmi_bmc_register(intf, &id, guid_set, &guid, intf_num))
|
||||||
need_waiter(intf); /* Retry later on an error. */
|
need_waiter(intf); /* Retry later on an error. */
|
||||||
else
|
else
|
||||||
__scan_channels(intf, &id);
|
__scan_channels(intf, &id);
|
||||||
|
@ -2328,7 +2329,7 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
bmc->id = bmc->fetch_id;
|
bmc->id = bmc->fetch_id;
|
||||||
if (bmc->dyn_guid_set)
|
if (bmc->dyn_guid_set)
|
||||||
memcpy(bmc->guid, bmc->fetch_guid, 16);
|
bmc->guid = bmc->fetch_guid;
|
||||||
else if (prev_guid_set)
|
else if (prev_guid_set)
|
||||||
/*
|
/*
|
||||||
* The guid used to be valid and it failed to fetch,
|
* The guid used to be valid and it failed to fetch,
|
||||||
|
@ -2345,7 +2346,7 @@ static int __bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
|
||||||
*guid_set = bmc->dyn_guid_set;
|
*guid_set = bmc->dyn_guid_set;
|
||||||
|
|
||||||
if (guid && bmc->dyn_guid_set)
|
if (guid && bmc->dyn_guid_set)
|
||||||
memcpy(guid, bmc->guid, 16);
|
*guid = bmc->guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&bmc->dyn_mutex);
|
mutex_unlock(&bmc->dyn_mutex);
|
||||||
|
@ -2357,7 +2358,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,
|
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)
|
bool *guid_set, guid_t *guid)
|
||||||
{
|
{
|
||||||
return __bmc_get_device_id(intf, bmc, id, guid_set, guid, -1);
|
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);
|
struct bmc_device *bmc = to_bmc_device(dev);
|
||||||
bool guid_set;
|
bool guid_set;
|
||||||
u8 guid[16];
|
guid_t guid;
|
||||||
int rv;
|
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)
|
if (rv)
|
||||||
return rv;
|
return rv;
|
||||||
if (!guid_set)
|
if (!guid_set)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
return snprintf(buf, 100,
|
return snprintf(buf, 38, "%pUl\n", guid.b);
|
||||||
"%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);
|
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)
|
static int __find_bmc_guid(struct device *dev, void *data)
|
||||||
{
|
{
|
||||||
unsigned char *guid = data;
|
guid_t *guid = data;
|
||||||
struct bmc_device *bmc;
|
struct bmc_device *bmc;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
|
@ -2814,7 +2810,7 @@ static int __find_bmc_guid(struct device *dev, void *data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bmc = to_bmc_device(dev);
|
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)
|
if (rv)
|
||||||
rv = kref_get_unless_zero(&bmc->usecount);
|
rv = kref_get_unless_zero(&bmc->usecount);
|
||||||
return rv;
|
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.
|
* Returns with the bmc's usecount incremented, if it is non-NULL.
|
||||||
*/
|
*/
|
||||||
static struct bmc_device *ipmi_find_bmc_guid(struct device_driver *drv,
|
static struct bmc_device *ipmi_find_bmc_guid(struct device_driver *drv,
|
||||||
unsigned char *guid)
|
guid_t *guid)
|
||||||
{
|
{
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct bmc_device *bmc = NULL;
|
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,
|
static int __ipmi_bmc_register(ipmi_smi_t intf,
|
||||||
struct ipmi_device_id *id,
|
struct ipmi_device_id *id,
|
||||||
bool guid_set, u8 *guid, int intf_num)
|
bool guid_set, guid_t *guid, int intf_num)
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
struct bmc_device *bmc = intf->bmc;
|
struct bmc_device *bmc = intf->bmc;
|
||||||
|
@ -3008,7 +3004,7 @@ static int __ipmi_bmc_register(ipmi_smi_t intf,
|
||||||
bmc->id = *id;
|
bmc->id = *id;
|
||||||
bmc->dyn_id_set = 1;
|
bmc->dyn_id_set = 1;
|
||||||
bmc->dyn_guid_set = guid_set;
|
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->dyn_id_expiry = jiffies + IPMI_DYN_DEV_ID_EXPIRY;
|
||||||
|
|
||||||
bmc->pdev.name = "ipmi_bmc";
|
bmc->pdev.name = "ipmi_bmc";
|
||||||
|
@ -3165,7 +3161,7 @@ static void guid_handler(ipmi_smi_t intf, struct ipmi_recv_msg *msg)
|
||||||
goto out;
|
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
|
* Make sure the guid data is available before setting
|
||||||
* dyn_guid_set.
|
* dyn_guid_set.
|
||||||
|
|
Loading…
Reference in New Issue