lkml.org 
[lkml]   [2021]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 03/10] vdpa: add vdpa_set_config() helper
Date
Let's add a function similar to vpda_get_config() to check the
'offset' and 'len' parameters, call the set_config() device callback,
and return the amount of bytes written.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
include/linux/vdpa.h | 2 ++
drivers/vdpa/vdpa.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+)

diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 8a679c98f8b1..562fcd14f4b5 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -334,6 +334,8 @@ static inline int vdpa_set_features(struct vdpa_device *vdev, u64 features)

int vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
void *buf, unsigned int len);
+int vdpa_set_config(struct vdpa_device *vdev, unsigned int offset,
+ const void *buf, unsigned int len);

/**
* vdpa_mgmtdev_ops - vdpa device ops
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index 9ed6c779c63c..825afc690a7e 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -86,6 +86,22 @@ int vdpa_get_config(struct vdpa_device *vdev, unsigned int offset,
}
EXPORT_SYMBOL_GPL(vdpa_get_config);

+int vdpa_set_config(struct vdpa_device *vdev, unsigned int offset,
+ const void *buf, unsigned int len)
+{
+ const struct vdpa_config_ops *ops = vdev->config;
+ int bytes_set;
+
+ bytes_set = vdpa_config_size_wrap(vdev, offset, len);
+ if (bytes_set <= 0)
+ return bytes_set;
+
+ ops->set_config(vdev, offset, buf, bytes_set);
+
+ return bytes_set;
+}
+EXPORT_SYMBOL_GPL(vdpa_set_config);
+
static void vdpa_release_dev(struct device *d)
{
struct vdpa_device *vdev = dev_to_vdpa(d);
--
2.29.2
\
 
 \ /
  Last update: 2021-02-17 11:36    [W:1.230 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site