Commit 39d3fb45 authored by Corey Minyard's avatar Corey Minyard

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: default avatarCorey Minyard <cminyard@mvista.com>
parent 1e5058ea
...@@ -273,14 +273,15 @@ struct bmc_device { ...@@ -273,14 +273,15 @@ 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 & dyn* fields */ struct mutex dyn_mutex; /* protects id & dyn* fields */
unsigned char guid[16]; u8 guid[16];
int guid_set; int guid_set;
struct kref usecount; struct kref usecount;
}; };
#define to_bmc_device(x) container_of((x), struct bmc_device, pdev.dev) #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, 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 * Various statistics for IPMI, these index stats[] in the ipmi_smi
...@@ -1220,7 +1221,7 @@ int ipmi_get_version(ipmi_user_t user, ...@@ -1220,7 +1221,7 @@ int ipmi_get_version(ipmi_user_t user,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(user->intf, NULL, &id); rv = bmc_get_device_id(user->intf, NULL, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2193,7 +2194,8 @@ static int __get_device_id(ipmi_smi_t intf, struct bmc_device *bmc) ...@@ -2193,7 +2194,8 @@ static int __get_device_id(ipmi_smi_t intf, struct bmc_device *bmc)
* this will always return good data; * this will always return good data;
*/ */
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 rv = 0; int rv = 0;
int prev_dyn_id_set; int prev_dyn_id_set;
...@@ -2247,6 +2249,12 @@ static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc, ...@@ -2247,6 +2249,12 @@ static int bmc_get_device_id(ipmi_smi_t intf, struct bmc_device *bmc,
if (id) if (id)
*id = bmc->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(&bmc->dyn_mutex);
mutex_unlock(&intf->bmc_reg_mutex); mutex_unlock(&intf->bmc_reg_mutex);
...@@ -2286,7 +2294,7 @@ static int smi_version_proc_show(struct seq_file *m, void *v) ...@@ -2286,7 +2294,7 @@ static int smi_version_proc_show(struct seq_file *m, void *v)
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(intf, NULL, &id); rv = bmc_get_device_id(intf, NULL, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2478,7 +2486,7 @@ static ssize_t device_id_show(struct device *dev, ...@@ -2478,7 +2486,7 @@ static ssize_t device_id_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2494,7 +2502,7 @@ static ssize_t provides_device_sdrs_show(struct device *dev, ...@@ -2494,7 +2502,7 @@ static ssize_t provides_device_sdrs_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2510,7 +2518,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr, ...@@ -2510,7 +2518,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2526,7 +2534,7 @@ static ssize_t firmware_revision_show(struct device *dev, ...@@ -2526,7 +2534,7 @@ static ssize_t firmware_revision_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2543,7 +2551,7 @@ static ssize_t ipmi_version_show(struct device *dev, ...@@ -2543,7 +2551,7 @@ static ssize_t ipmi_version_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2561,7 +2569,7 @@ static ssize_t add_dev_support_show(struct device *dev, ...@@ -2561,7 +2569,7 @@ static ssize_t add_dev_support_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2578,7 +2586,7 @@ static ssize_t manufacturer_id_show(struct device *dev, ...@@ -2578,7 +2586,7 @@ static ssize_t manufacturer_id_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2594,7 +2602,7 @@ static ssize_t product_id_show(struct device *dev, ...@@ -2594,7 +2602,7 @@ static ssize_t product_id_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2610,7 +2618,7 @@ static ssize_t aux_firmware_rev_show(struct device *dev, ...@@ -2610,7 +2618,7 @@ static ssize_t aux_firmware_rev_show(struct device *dev,
struct ipmi_device_id id; struct ipmi_device_id id;
int rv; int rv;
rv = bmc_get_device_id(NULL, bmc, &id); rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv) if (rv)
return rv; return rv;
...@@ -2626,13 +2634,22 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr, ...@@ -2626,13 +2634,22 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct bmc_device *bmc = to_bmc_device(dev); 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, 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", "%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], guid[3], guid[2], guid[1], guid[0],
bmc->guid[5], bmc->guid[4], bmc->guid[7], bmc->guid[6], guid[5], guid[4], guid[7], guid[6],
bmc->guid[8], bmc->guid[9], bmc->guid[10], bmc->guid[11], guid[8], guid[9], guid[10], guid[11],
bmc->guid[12], bmc->guid[13], bmc->guid[14], bmc->guid[15]); 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);
...@@ -2656,15 +2673,20 @@ static umode_t bmc_dev_attr_is_visible(struct kobject *kobj, ...@@ -2656,15 +2673,20 @@ static umode_t bmc_dev_attr_is_visible(struct kobject *kobj,
struct device *dev = kobj_to_dev(kobj); struct device *dev = kobj_to_dev(kobj);
struct bmc_device *bmc = to_bmc_device(dev); struct bmc_device *bmc = to_bmc_device(dev);
umode_t mode = attr->mode; umode_t mode = attr->mode;
struct ipmi_device_id id;
int rv; int rv;
if (attr == &dev_attr_aux_firmware_revision.attr) { 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; return (!rv && id.aux_firmware_revision_set) ? mode : 0;
} }
if (attr == &dev_attr_guid.attr) if (attr == &dev_attr_guid.attr) {
return bmc->guid_set ? mode : 0; bool guid_set;
rv = bmc_get_device_id(NULL, bmc, NULL, &guid_set, NULL);
return (!rv && guid_set) ? mode : 0;
}
return mode; return mode;
} }
...@@ -2685,11 +2707,20 @@ static const struct device_type bmc_device_type = { ...@@ -2685,11 +2707,20 @@ 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 *id = data; unsigned char *id = data;
struct bmc_device *bmc;
bool guid_set;
u8 guid[16];
int rv;
if (dev->type != &bmc_device_type) if (dev->type != &bmc_device_type)
return 0; 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 { ...@@ -2718,15 +2749,21 @@ struct prod_dev_id {
static int __find_bmc_prod_dev_id(struct device *dev, void *data) 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 bmc_device *bmc;
struct ipmi_device_id id;
int rv;
if (dev->type != &bmc_device_type) if (dev->type != &bmc_device_type)
return 0; return 0;
bmc = to_bmc_device(dev); bmc = to_bmc_device(dev);
return (bmc->id.product_id == id->product_id rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
&& bmc->id.device_id == id->device_id); 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, ...@@ -3219,7 +3256,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
get_guid(intf); get_guid(intf);
rv = bmc_get_device_id(intf, NULL, &id); rv = bmc_get_device_id(intf, NULL, &id, NULL, NULL);
if (rv) { if (rv) {
dev_err(si_dev, "Unable to get the device id: %d\n", rv); dev_err(si_dev, "Unable to get the device id: %d\n", rv);
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment