Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfio-mdev: 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: Kirti Wankhede <kwankhede@nvidia.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

Andy Shevchenko and committed by
Alex Williamson
278bca7f 8834f560

+19 -18
+8 -8
drivers/vfio/mdev/mdev_core.c
··· 60 60 } 61 61 EXPORT_SYMBOL(mdev_from_dev); 62 62 63 - uuid_le mdev_uuid(struct mdev_device *mdev) 63 + const guid_t *mdev_uuid(struct mdev_device *mdev) 64 64 { 65 - return mdev->uuid; 65 + return &mdev->uuid; 66 66 } 67 67 EXPORT_SYMBOL(mdev_uuid); 68 68 ··· 88 88 put_device(dev); 89 89 } 90 90 91 - static 92 - inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent) 91 + static inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent) 93 92 { 94 93 if (parent) 95 94 kref_get(&parent->ref); ··· 275 276 kfree(mdev); 276 277 } 277 278 278 - int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) 279 + int mdev_device_create(struct kobject *kobj, 280 + struct device *dev, const guid_t *uuid) 279 281 { 280 282 int ret; 281 283 struct mdev_device *mdev, *tmp; ··· 291 291 292 292 /* Check for duplicate */ 293 293 list_for_each_entry(tmp, &mdev_list, next) { 294 - if (!uuid_le_cmp(tmp->uuid, uuid)) { 294 + if (guid_equal(&tmp->uuid, uuid)) { 295 295 mutex_unlock(&mdev_list_lock); 296 296 ret = -EEXIST; 297 297 goto mdev_fail; ··· 305 305 goto mdev_fail; 306 306 } 307 307 308 - memcpy(&mdev->uuid, &uuid, sizeof(uuid_le)); 308 + guid_copy(&mdev->uuid, uuid); 309 309 list_add(&mdev->next, &mdev_list); 310 310 mutex_unlock(&mdev_list_lock); 311 311 ··· 315 315 mdev->dev.parent = dev; 316 316 mdev->dev.bus = &mdev_bus_type; 317 317 mdev->dev.release = mdev_device_release; 318 - dev_set_name(&mdev->dev, "%pUl", uuid.b); 318 + dev_set_name(&mdev->dev, "%pUl", uuid); 319 319 320 320 ret = device_register(&mdev->dev); 321 321 if (ret) {
+3 -2
drivers/vfio/mdev/mdev_private.h
··· 28 28 struct mdev_device { 29 29 struct device dev; 30 30 struct mdev_parent *parent; 31 - uuid_le uuid; 31 + guid_t uuid; 32 32 void *driver_data; 33 33 struct kref ref; 34 34 struct list_head next; ··· 58 58 int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type); 59 59 void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type); 60 60 61 - int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid); 61 + int mdev_device_create(struct kobject *kobj, 62 + struct device *dev, const guid_t *uuid); 62 63 int mdev_device_remove(struct device *dev, bool force_remove); 63 64 64 65 #endif /* MDEV_PRIVATE_H */
+3 -3
drivers/vfio/mdev/mdev_sysfs.c
··· 55 55 const char *buf, size_t count) 56 56 { 57 57 char *str; 58 - uuid_le uuid; 58 + guid_t uuid; 59 59 int ret; 60 60 61 61 if ((count < UUID_STRING_LEN) || (count > UUID_STRING_LEN + 1)) ··· 65 65 if (!str) 66 66 return -ENOMEM; 67 67 68 - ret = uuid_le_to_bin(str, &uuid); 68 + ret = guid_parse(str, &uuid); 69 69 kfree(str); 70 70 if (ret) 71 71 return ret; 72 72 73 - ret = mdev_device_create(kobj, dev, uuid); 73 + ret = mdev_device_create(kobj, dev, &uuid); 74 74 if (ret) 75 75 return ret; 76 76
+1 -1
include/linux/mdev.h
··· 120 120 121 121 extern void *mdev_get_drvdata(struct mdev_device *mdev); 122 122 extern void mdev_set_drvdata(struct mdev_device *mdev, void *data); 123 - extern uuid_le mdev_uuid(struct mdev_device *mdev); 123 + extern const guid_t *mdev_uuid(struct mdev_device *mdev); 124 124 125 125 extern struct bus_type mdev_bus_type; 126 126
+4 -4
samples/vfio-mdev/mtty.c
··· 156 156 157 157 /* function prototypes */ 158 158 159 - static int mtty_trigger_interrupt(uuid_le uuid); 159 + static int mtty_trigger_interrupt(const guid_t *uuid); 160 160 161 161 /* Helper functions */ 162 - static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid) 162 + static struct mdev_state *find_mdev_state_by_uuid(const guid_t *uuid) 163 163 { 164 164 struct mdev_state *mds; 165 165 166 166 list_for_each_entry(mds, &mdev_devices_list, next) { 167 - if (uuid_le_cmp(mdev_uuid(mds->mdev), uuid) == 0) 167 + if (guid_equal(mdev_uuid(mds->mdev), uuid)) 168 168 return mds; 169 169 } 170 170 ··· 1032 1032 return ret; 1033 1033 } 1034 1034 1035 - static int mtty_trigger_interrupt(uuid_le uuid) 1035 + static int mtty_trigger_interrupt(const guid_t *uuid) 1036 1036 { 1037 1037 int ret = -1; 1038 1038 struct mdev_state *mdev_state;