Skip to content

Commit 278bca7

Browse files
andy-shevAlex Williamson
authored andcommitted
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>
1 parent 8834f56 commit 278bca7

5 files changed

Lines changed: 19 additions & 18 deletions

File tree

‎drivers/vfio/mdev/mdev_core.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ struct mdev_device *mdev_from_dev(struct device *dev)
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)
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)
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)
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)
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)
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‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct mdev_parent {
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);
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‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static ssize_t create_store(struct kobject *kobj, struct device *dev,
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,
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‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct mdev_driver {
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‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ static const struct file_operations vd_fops = {
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,
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;

0 commit comments

Comments
 (0)