summaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-01-10 09:25:32 -0500
committerSasha Levin <sashal@kernel.org>2019-02-14 20:45:23 -0500
commit593db80390cf40f1b9dcc790020d2edae87183fb (patch)
tree99aa63dd1bb0087ee29667543a61c9b9e165075a /drivers/hv
parent8834f5600cf3c8db365e18a3d5cac2c2780c81e5 (diff)
vmbus: Switch to use new generic UUID API
There are new types and helpers that are supposed to be used in new code. As a preparation to get rid of legacy types and API functions do the conversion here. Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Stephen Hemminger <sthemmin@microsoft.com> Cc: devel@linuxdriverproject.org Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/channel.c4
-rw-r--r--drivers/hv/channel_mgmt.c18
-rw-r--r--drivers/hv/hyperv_vmbus.h4
-rw-r--r--drivers/hv/vmbus_drv.c48
4 files changed, 30 insertions, 44 deletions
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index bea4c9850247..23381c41d087 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -282,8 +282,8 @@ int vmbus_open(struct vmbus_channel *newchannel,
282EXPORT_SYMBOL_GPL(vmbus_open); 282EXPORT_SYMBOL_GPL(vmbus_open);
283 283
284/* Used for Hyper-V Socket: a guest client's connect() to the host */ 284/* Used for Hyper-V Socket: a guest client's connect() to the host */
285int vmbus_send_tl_connect_request(const uuid_le *shv_guest_servie_id, 285int vmbus_send_tl_connect_request(const guid_t *shv_guest_servie_id,
286 const uuid_le *shv_host_servie_id) 286 const guid_t *shv_host_servie_id)
287{ 287{
288 struct vmbus_channel_tl_connect_request conn_msg; 288 struct vmbus_channel_tl_connect_request conn_msg;
289 int ret; 289 int ret;
diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
index d01689079e9b..62703b354d6d 100644
--- a/drivers/hv/channel_mgmt.c
+++ b/drivers/hv/channel_mgmt.c
@@ -141,7 +141,7 @@ static const struct vmbus_device vmbus_devs[] = {
141}; 141};
142 142
143static const struct { 143static const struct {
144 uuid_le guid; 144 guid_t guid;
145} vmbus_unsupported_devs[] = { 145} vmbus_unsupported_devs[] = {
146 { HV_AVMA1_GUID }, 146 { HV_AVMA1_GUID },
147 { HV_AVMA2_GUID }, 147 { HV_AVMA2_GUID },
@@ -171,26 +171,26 @@ static void vmbus_rescind_cleanup(struct vmbus_channel *channel)
171 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); 171 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
172} 172}
173 173
174static bool is_unsupported_vmbus_devs(const uuid_le *guid) 174static bool is_unsupported_vmbus_devs(const guid_t *guid)
175{ 175{
176 int i; 176 int i;
177 177
178 for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++) 178 for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++)
179 if (!uuid_le_cmp(*guid, vmbus_unsupported_devs[i].guid)) 179 if (guid_equal(guid, &vmbus_unsupported_devs[i].guid))
180 return true; 180 return true;
181 return false; 181 return false;
182} 182}
183 183
184static u16 hv_get_dev_type(const struct vmbus_channel *channel) 184static u16 hv_get_dev_type(const struct vmbus_channel *channel)
185{ 185{
186 const uuid_le *guid = &channel->offermsg.offer.if_type; 186 const guid_t *guid = &channel->offermsg.offer.if_type;
187 u16 i; 187 u16 i;
188 188
189 if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid)) 189 if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
190 return HV_UNKNOWN; 190 return HV_UNKNOWN;
191 191
192 for (i = HV_IDE; i < HV_UNKNOWN; i++) { 192 for (i = HV_IDE; i < HV_UNKNOWN; i++) {
193 if (!uuid_le_cmp(*guid, vmbus_devs[i].guid)) 193 if (guid_equal(guid, &vmbus_devs[i].guid))
194 return i; 194 return i;
195 } 195 }
196 pr_info("Unknown GUID: %pUl\n", guid); 196 pr_info("Unknown GUID: %pUl\n", guid);
@@ -561,10 +561,10 @@ static void vmbus_process_offer(struct vmbus_channel *newchannel)
561 atomic_dec(&vmbus_connection.offer_in_progress); 561 atomic_dec(&vmbus_connection.offer_in_progress);
562 562
563 list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) { 563 list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
564 if (!uuid_le_cmp(channel->offermsg.offer.if_type, 564 if (guid_equal(&channel->offermsg.offer.if_type,
565 newchannel->offermsg.offer.if_type) && 565 &newchannel->offermsg.offer.if_type) &&
566 !uuid_le_cmp(channel->offermsg.offer.if_instance, 566 guid_equal(&channel->offermsg.offer.if_instance,
567 newchannel->offermsg.offer.if_instance)) { 567 &newchannel->offermsg.offer.if_instance)) {
568 fnew = false; 568 fnew = false;
569 break; 569 break;
570 } 570 }
diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
index a1f6ce6e5974..cb86b133eb4d 100644
--- a/drivers/hv/hyperv_vmbus.h
+++ b/drivers/hv/hyperv_vmbus.h
@@ -312,8 +312,8 @@ extern const struct vmbus_channel_message_table_entry
312 312
313/* General vmbus interface */ 313/* General vmbus interface */
314 314
315struct hv_device *vmbus_device_create(const uuid_le *type, 315struct hv_device *vmbus_device_create(const guid_t *type,
316 const uuid_le *instance, 316 const guid_t *instance,
317 struct vmbus_channel *channel); 317 struct vmbus_channel *channel);
318 318
319int vmbus_device_register(struct hv_device *child_device_obj); 319int vmbus_device_register(struct hv_device *child_device_obj);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 403fee01572c..126c2de39e35 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -654,38 +654,28 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
654 return ret; 654 return ret;
655} 655}
656 656
657static const uuid_le null_guid;
658
659static inline bool is_null_guid(const uuid_le *guid)
660{
661 if (uuid_le_cmp(*guid, null_guid))
662 return false;
663 return true;
664}
665
666static const struct hv_vmbus_device_id * 657static const struct hv_vmbus_device_id *
667hv_vmbus_dev_match(const struct hv_vmbus_device_id *id, const uuid_le *guid) 658hv_vmbus_dev_match(const struct hv_vmbus_device_id *id, const guid_t *guid)
668
669{ 659{
670 if (id == NULL) 660 if (id == NULL)
671 return NULL; /* empty device table */ 661 return NULL; /* empty device table */
672 662
673 for (; !is_null_guid(&id->guid); id++) 663 for (; !guid_is_null(&id->guid); id++)
674 if (!uuid_le_cmp(id->guid, *guid)) 664 if (guid_equal(&id->guid, guid))
675 return id; 665 return id;
676 666
677 return NULL; 667 return NULL;
678} 668}
679 669
680static const struct hv_vmbus_device_id * 670static const struct hv_vmbus_device_id *
681hv_vmbus_dynid_match(struct hv_driver *drv, const uuid_le *guid) 671hv_vmbus_dynid_match(struct hv_driver *drv, const guid_t *guid)
682{ 672{
683 const struct hv_vmbus_device_id *id = NULL; 673 const struct hv_vmbus_device_id *id = NULL;
684 struct vmbus_dynid *dynid; 674 struct vmbus_dynid *dynid;
685 675
686 spin_lock(&drv->dynids.lock); 676 spin_lock(&drv->dynids.lock);
687 list_for_each_entry(dynid, &drv->dynids.list, node) { 677 list_for_each_entry(dynid, &drv->dynids.list, node) {
688 if (!uuid_le_cmp(dynid->id.guid, *guid)) { 678 if (guid_equal(&dynid->id.guid, guid)) {
689 id = &dynid->id; 679 id = &dynid->id;
690 break; 680 break;
691 } 681 }
@@ -695,9 +685,7 @@ hv_vmbus_dynid_match(struct hv_driver *drv, const uuid_le *guid)
695 return id; 685 return id;
696} 686}
697 687
698static const struct hv_vmbus_device_id vmbus_device_null = { 688static const struct hv_vmbus_device_id vmbus_device_null;
699 .guid = NULL_UUID_LE,
700};
701 689
702/* 690/*
703 * Return a matching hv_vmbus_device_id pointer. 691 * Return a matching hv_vmbus_device_id pointer.
@@ -706,7 +694,7 @@ static const struct hv_vmbus_device_id vmbus_device_null = {
706static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv, 694static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
707 struct hv_device *dev) 695 struct hv_device *dev)
708{ 696{
709 const uuid_le *guid = &dev->dev_type; 697 const guid_t *guid = &dev->dev_type;
710 const struct hv_vmbus_device_id *id; 698 const struct hv_vmbus_device_id *id;
711 699
712 /* When driver_override is set, only bind to the matching driver */ 700 /* When driver_override is set, only bind to the matching driver */
@@ -726,7 +714,7 @@ static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver *drv,
726} 714}
727 715
728/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */ 716/* vmbus_add_dynid - add a new device ID to this driver and re-probe devices */
729static int vmbus_add_dynid(struct hv_driver *drv, uuid_le *guid) 717static int vmbus_add_dynid(struct hv_driver *drv, guid_t *guid)
730{ 718{
731 struct vmbus_dynid *dynid; 719 struct vmbus_dynid *dynid;
732 720
@@ -764,10 +752,10 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf,
764 size_t count) 752 size_t count)
765{ 753{
766 struct hv_driver *drv = drv_to_hv_drv(driver); 754 struct hv_driver *drv = drv_to_hv_drv(driver);
767 uuid_le guid; 755 guid_t guid;
768 ssize_t retval; 756 ssize_t retval;
769 757
770 retval = uuid_le_to_bin(buf, &guid); 758 retval = guid_parse(buf, &guid);
771 if (retval) 759 if (retval)
772 return retval; 760 return retval;
773 761
@@ -791,10 +779,10 @@ static ssize_t remove_id_store(struct device_driver *driver, const char *buf,
791{ 779{
792 struct hv_driver *drv = drv_to_hv_drv(driver); 780 struct hv_driver *drv = drv_to_hv_drv(driver);
793 struct vmbus_dynid *dynid, *n; 781 struct vmbus_dynid *dynid, *n;
794 uuid_le guid; 782 guid_t guid;
795 ssize_t retval; 783 ssize_t retval;
796 784
797 retval = uuid_le_to_bin(buf, &guid); 785 retval = guid_parse(buf, &guid);
798 if (retval) 786 if (retval)
799 return retval; 787 return retval;
800 788
@@ -803,7 +791,7 @@ static ssize_t remove_id_store(struct device_driver *driver, const char *buf,
803 list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) { 791 list_for_each_entry_safe(dynid, n, &drv->dynids.list, node) {
804 struct hv_vmbus_device_id *id = &dynid->id; 792 struct hv_vmbus_device_id *id = &dynid->id;
805 793
806 if (!uuid_le_cmp(id->guid, guid)) { 794 if (guid_equal(&id->guid, &guid)) {
807 list_del(&dynid->node); 795 list_del(&dynid->node);
808 kfree(dynid); 796 kfree(dynid);
809 retval = count; 797 retval = count;
@@ -1556,8 +1544,8 @@ int vmbus_add_channel_kobj(struct hv_device *dev, struct vmbus_channel *channel)
1556 * vmbus_device_create - Creates and registers a new child device 1544 * vmbus_device_create - Creates and registers a new child device
1557 * on the vmbus. 1545 * on the vmbus.
1558 */ 1546 */
1559struct hv_device *vmbus_device_create(const uuid_le *type, 1547struct hv_device *vmbus_device_create(const guid_t *type,
1560 const uuid_le *instance, 1548 const guid_t *instance,
1561 struct vmbus_channel *channel) 1549 struct vmbus_channel *channel)
1562{ 1550{
1563 struct hv_device *child_device_obj; 1551 struct hv_device *child_device_obj;
@@ -1569,12 +1557,10 @@ struct hv_device *vmbus_device_create(const uuid_le *type,
1569 } 1557 }
1570 1558
1571 child_device_obj->channel = channel; 1559 child_device_obj->channel = channel;
1572 memcpy(&child_device_obj->dev_type, type, sizeof(uuid_le)); 1560 guid_copy(&child_device_obj->dev_type, type);
1573 memcpy(&child_device_obj->dev_instance, instance, 1561 guid_copy(&child_device_obj->dev_instance, instance);
1574 sizeof(uuid_le));
1575 child_device_obj->vendor_id = 0x1414; /* MSFT vendor ID */ 1562 child_device_obj->vendor_id = 0x1414; /* MSFT vendor ID */
1576 1563
1577
1578 return child_device_obj; 1564 return child_device_obj;
1579} 1565}
1580 1566