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
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;
* 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;
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);
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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);
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;
}
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;
}
/*
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);
}
/*
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;