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
6060 }
6161 EXPORT_SYMBOL(mdev_from_dev);
6262
63−uuid_le mdev_uuid(struct mdev_device *mdev)
63+const guid_t *mdev_uuid(struct mdev_device *mdev)
6464 {
65− return mdev->uuid;
65+ return &mdev->uuid;
6666 }
6767 EXPORT_SYMBOL(mdev_uuid);
6868
@@ -88,8 +88,7 @@ static void mdev_release_parent(struct kref *kref) · 19 unmodified lines
8888 put_device(dev);
8989 }
9090
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)
9392 {
9493 if (parent)
9594 kref_get(&parent->ref);
@@ -276,7 +275,8 @@ static void mdev_device_release(struct device *dev) · 180 unmodified lines
276275 kfree(mdev);
277276 }
278277
279−int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
278+int mdev_device_create(struct kobject *kobj,
279+ struct device *dev, const guid_t *uuid)
280280 {
281281 int ret;
282282 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
291291
292292 /* Check for duplicate */
293293 list_for_each_entry(tmp, &mdev_list, next) {
294− if (!uuid_le_cmp(tmp->uuid, uuid)) {
294+ if (guid_equal(&tmp->uuid, uuid)) {
295295 mutex_unlock(&mdev_list_lock);
296296 ret = -EEXIST;
297297 goto mdev_fail;
@@ -305,7 +305,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) · 7 unmodified lines
305305 goto mdev_fail;
306306 }
307307
308− memcpy(&mdev->uuid, &uuid, sizeof(uuid_le));
308+ guid_copy(&mdev->uuid, uuid);
309309 list_add(&mdev->next, &mdev_list);
310310 mutex_unlock(&mdev_list_lock);
311311
@@ -315,7 +315,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) · 3 unmodified lines
315315 mdev->dev.parent = dev;
316316 mdev->dev.bus = &mdev_bus_type;
317317 mdev->dev.release = mdev_device_release;
318− dev_set_name(&mdev->dev, "%pUl", uuid.b);
318+ dev_set_name(&mdev->dev, "%pUl", uuid);
319319
320320 ret = device_register(&mdev->dev);
321321 if (ret) {
drivers/vfio/mdev/mdev_private.h+3−2
@@ -28,7 +28,7 @@ struct mdev_parent { · 27 unmodified lines
2828 struct mdev_device {
2929 struct device dev;
3030 struct mdev_parent *parent;
31− uuid_le uuid;
31+ guid_t uuid;
3232 void *driver_data;
3333 struct kref ref;
3434 struct list_head next;
@@ -58,7 +58,8 @@ void parent_remove_sysfs_files(struct mdev_parent *parent); · 23 unmodified lines
5858 int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
5959 void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
6060
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);
6263 int mdev_device_remove(struct device *dev, bool force_remove);
6364
6465 #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
5555 const char *buf, size_t count)
5656 {
5757 char *str;
58− uuid_le uuid;
58+ guid_t uuid;
5959 int ret;
6060
6161 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
6565 if (!str)
6666 return -ENOMEM;
6767
68− ret = uuid_le_to_bin(str, &uuid);
68+ ret = guid_parse(str, &uuid);
6969 kfree(str);
7070 if (ret)
7171 return ret;
7272
73− ret = mdev_device_create(kobj, dev, uuid);
73+ ret = mdev_device_create(kobj, dev, &uuid);
7474 if (ret)
7575 return ret;
7676
include/linux/mdev.h+1−1
@@ -120,7 +120,7 @@ struct mdev_driver { · 119 unmodified lines
120120
121121 extern void *mdev_get_drvdata(struct mdev_device *mdev);
122122 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);
124124
125125 extern struct bus_type mdev_bus_type;
126126
samples/vfio-mdev/mtty.c+4−4
@@ -156,15 +156,15 @@ static const struct file_operations vd_fops = { · 155 unmodified lines
156156
157157 /* function prototypes */
158158
159−static int mtty_trigger_interrupt(uuid_le uuid);
159+static int mtty_trigger_interrupt(const guid_t *uuid);
160160
161161 /* 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)
163163 {
164164 struct mdev_state *mds;
165165
166166 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))
168168 return mds;
169169 }
170170
@@ -1032,7 +1032,7 @@ static int mtty_set_irqs(struct mdev_device *mdev, uint32_t flags, · 861 unmodified lines
10321032 return ret;
10331033 }
10341034
1035−static int mtty_trigger_interrupt(uuid_le uuid)
1035+static int mtty_trigger_interrupt(const guid_t *uuid)
10361036 {
10371037 int ret = -1;
10381038 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