Loading drivers/char/ipmi/ipmi_msghandler.c +23 −27 Original line number Diff line number Diff line Loading @@ -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: " Loading Loading @@ -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; Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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_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); Loading Loading @@ -2328,7 +2329,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, Loading @@ -2345,7 +2346,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); Loading @@ -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, 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); } Loading Loading @@ -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); Loading Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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"; Loading Loading @@ -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. Loading Loading
drivers/char/ipmi/ipmi_msghandler.c +23 −27 Original line number Diff line number Diff line Loading @@ -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: " Loading Loading @@ -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; Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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_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); Loading Loading @@ -2328,7 +2329,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, Loading @@ -2345,7 +2346,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); Loading @@ -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, 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); } Loading Loading @@ -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); Loading Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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"; Loading Loading @@ -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. Loading