History

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.

Andy Shevchenko committed 7 years ago

Commit 278bca71 parent 8834f565 files · +19 −18Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t