Commit 278bca7f authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Alex Williamson

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 8834f560
...@@ -60,9 +60,9 @@ struct mdev_device *mdev_from_dev(struct device *dev) ...@@ -60,9 +60,9 @@ struct mdev_device *mdev_from_dev(struct device *dev)
} }
EXPORT_SYMBOL(mdev_from_dev); EXPORT_SYMBOL(mdev_from_dev);
uuid_le mdev_uuid(struct mdev_device *mdev) const guid_t *mdev_uuid(struct mdev_device *mdev)
{ {
return mdev->uuid; return &mdev->uuid;
} }
EXPORT_SYMBOL(mdev_uuid); EXPORT_SYMBOL(mdev_uuid);
...@@ -88,8 +88,7 @@ static void mdev_release_parent(struct kref *kref) ...@@ -88,8 +88,7 @@ static void mdev_release_parent(struct kref *kref)
put_device(dev); put_device(dev);
} }
static static inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
{ {
if (parent) if (parent)
kref_get(&parent->ref); kref_get(&parent->ref);
...@@ -276,7 +275,8 @@ static void mdev_device_release(struct device *dev) ...@@ -276,7 +275,8 @@ static void mdev_device_release(struct device *dev)
kfree(mdev); kfree(mdev);
} }
int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) int mdev_device_create(struct kobject *kobj,
struct device *dev, const guid_t *uuid)
{ {
int ret; int ret;
struct mdev_device *mdev, *tmp; struct mdev_device *mdev, *tmp;
...@@ -291,7 +291,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) ...@@ -291,7 +291,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
/* Check for duplicate */ /* Check for duplicate */
list_for_each_entry(tmp, &mdev_list, next) { list_for_each_entry(tmp, &mdev_list, next) {
if (!uuid_le_cmp(tmp->uuid, uuid)) { if (guid_equal(&tmp->uuid, uuid)) {
mutex_unlock(&mdev_list_lock); mutex_unlock(&mdev_list_lock);
ret = -EEXIST; ret = -EEXIST;
goto mdev_fail; goto mdev_fail;
...@@ -305,7 +305,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) ...@@ -305,7 +305,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
goto mdev_fail; goto mdev_fail;
} }
memcpy(&mdev->uuid, &uuid, sizeof(uuid_le)); guid_copy(&mdev->uuid, uuid);
list_add(&mdev->next, &mdev_list); list_add(&mdev->next, &mdev_list);
mutex_unlock(&mdev_list_lock); mutex_unlock(&mdev_list_lock);
...@@ -315,7 +315,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid) ...@@ -315,7 +315,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
mdev->dev.parent = dev; mdev->dev.parent = dev;
mdev->dev.bus = &mdev_bus_type; mdev->dev.bus = &mdev_bus_type;
mdev->dev.release = mdev_device_release; mdev->dev.release = mdev_device_release;
dev_set_name(&mdev->dev, "%pUl", uuid.b); dev_set_name(&mdev->dev, "%pUl", uuid);
ret = device_register(&mdev->dev); ret = device_register(&mdev->dev);
if (ret) { if (ret) {
......
...@@ -28,7 +28,7 @@ struct mdev_parent { ...@@ -28,7 +28,7 @@ struct mdev_parent {
struct mdev_device { struct mdev_device {
struct device dev; struct device dev;
struct mdev_parent *parent; struct mdev_parent *parent;
uuid_le uuid; guid_t uuid;
void *driver_data; void *driver_data;
struct kref ref; struct kref ref;
struct list_head next; struct list_head next;
...@@ -58,7 +58,8 @@ void parent_remove_sysfs_files(struct mdev_parent *parent); ...@@ -58,7 +58,8 @@ void parent_remove_sysfs_files(struct mdev_parent *parent);
int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type); int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type); void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid); int mdev_device_create(struct kobject *kobj,
struct device *dev, const guid_t *uuid);
int mdev_device_remove(struct device *dev, bool force_remove); int mdev_device_remove(struct device *dev, bool force_remove);
#endif /* MDEV_PRIVATE_H */ #endif /* MDEV_PRIVATE_H */
...@@ -55,7 +55,7 @@ static ssize_t create_store(struct kobject *kobj, struct device *dev, ...@@ -55,7 +55,7 @@ static ssize_t create_store(struct kobject *kobj, struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
char *str; char *str;
uuid_le uuid; guid_t uuid;
int ret; int ret;
if ((count < UUID_STRING_LEN) || (count > UUID_STRING_LEN + 1)) 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, ...@@ -65,12 +65,12 @@ static ssize_t create_store(struct kobject *kobj, struct device *dev,
if (!str) if (!str)
return -ENOMEM; return -ENOMEM;
ret = uuid_le_to_bin(str, &uuid); ret = guid_parse(str, &uuid);
kfree(str); kfree(str);
if (ret) if (ret)
return ret; return ret;
ret = mdev_device_create(kobj, dev, uuid); ret = mdev_device_create(kobj, dev, &uuid);
if (ret) if (ret)
return ret; return ret;
......
...@@ -120,7 +120,7 @@ struct mdev_driver { ...@@ -120,7 +120,7 @@ struct mdev_driver {
extern void *mdev_get_drvdata(struct mdev_device *mdev); extern void *mdev_get_drvdata(struct mdev_device *mdev);
extern void mdev_set_drvdata(struct mdev_device *mdev, void *data); extern void mdev_set_drvdata(struct mdev_device *mdev, void *data);
extern uuid_le mdev_uuid(struct mdev_device *mdev); extern const guid_t *mdev_uuid(struct mdev_device *mdev);
extern struct bus_type mdev_bus_type; extern struct bus_type mdev_bus_type;
......
...@@ -156,15 +156,15 @@ static const struct file_operations vd_fops = { ...@@ -156,15 +156,15 @@ static const struct file_operations vd_fops = {
/* function prototypes */ /* function prototypes */
static int mtty_trigger_interrupt(uuid_le uuid); static int mtty_trigger_interrupt(const guid_t *uuid);
/* Helper functions */ /* Helper functions */
static struct mdev_state *find_mdev_state_by_uuid(uuid_le uuid) static struct mdev_state *find_mdev_state_by_uuid(const guid_t *uuid)
{ {
struct mdev_state *mds; struct mdev_state *mds;
list_for_each_entry(mds, &mdev_devices_list, next) { list_for_each_entry(mds, &mdev_devices_list, next) {
if (uuid_le_cmp(mdev_uuid(mds->mdev), uuid) == 0) if (guid_equal(mdev_uuid(mds->mdev), uuid))
return mds; return mds;
} }
...@@ -1032,7 +1032,7 @@ static int mtty_set_irqs(struct mdev_device *mdev, uint32_t flags, ...@@ -1032,7 +1032,7 @@ static int mtty_set_irqs(struct mdev_device *mdev, uint32_t flags,
return ret; return ret;
} }
static int mtty_trigger_interrupt(uuid_le uuid) static int mtty_trigger_interrupt(const guid_t *uuid)
{ {
int ret = -1; int ret = -1;
struct mdev_state *mdev_state; struct mdev_state *mdev_state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment