* [PATCH 1/3] virtio-console: Use virtio_config_val() for retrieving config
@ 2011-08-14 14:52 Sasha Levin
2011-08-14 14:52 ` [PATCH 2/3] virtio_config: Add virtio_config_val_len() Sasha Levin
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Sasha Levin @ 2011-08-14 14:52 UTC (permalink / raw)
To: linux-kernel
Cc: Sasha Levin, Amit Shah, Michael S. Tsirkin, Rusty Russell,
virtualization
This patch modifies virtio-console to use virtio_config_val() instead
of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
optional values from the config space.
Cc: Amit Shah <amit.shah@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
drivers/char/virtio_console.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index fb68b12..ed99f3b 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1675,13 +1675,11 @@ static int __devinit virtcons_probe(struct virtio_device *vdev)
multiport = false;
portdev->config.max_nr_ports = 1;
- if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) {
+ if (virtio_config_val(vdev, VIRTIO_CONSOLE_F_MULTIPORT,
+ offsetof(struct virtio_console_config,
+ max_nr_ports),
+ &portdev->config.max_nr_ports) == 0)
multiport = true;
- vdev->config->get(vdev, offsetof(struct virtio_console_config,
- max_nr_ports),
- &portdev->config.max_nr_ports,
- sizeof(portdev->config.max_nr_ports));
- }
err = init_vqs(portdev);
if (err < 0) {
--
1.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] virtio_config: Add virtio_config_val_len()
2011-08-14 14:52 [PATCH 1/3] virtio-console: Use virtio_config_val() for retrieving config Sasha Levin
@ 2011-08-14 14:52 ` Sasha Levin
2011-08-14 14:52 ` Sasha Levin
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-08-14 14:52 UTC (permalink / raw)
To: linux-kernel
Cc: Sasha Levin, Amit Shah, Michael S. Tsirkin, Rusty Russell,
virtualization
This patch adds virtio_config_val_len() which allows retrieving variable
length data from the virtio config space only if a specific feature is on.
Cc: Amit Shah <amit.shah@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
include/linux/virtio_config.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 39c88c5..add4790 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -155,6 +155,9 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
#define virtio_config_val(vdev, fbit, offset, v) \
virtio_config_buf((vdev), (fbit), (offset), (v), sizeof(*v))
+#define virtio_config_val_len(vdev, fbit, offset, v, len) \
+ virtio_config_buf((vdev), (fbit), (offset), (v), (len))
+
static inline int virtio_config_buf(struct virtio_device *vdev,
unsigned int fbit,
unsigned int offset,
--
1.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] virtio_config: Add virtio_config_val_len()
2011-08-14 14:52 [PATCH 1/3] virtio-console: Use virtio_config_val() for retrieving config Sasha Levin
2011-08-14 14:52 ` [PATCH 2/3] virtio_config: Add virtio_config_val_len() Sasha Levin
@ 2011-08-14 14:52 ` Sasha Levin
2011-08-14 14:52 ` [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config Sasha Levin
2011-08-14 14:52 ` Sasha Levin
3 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-08-14 14:52 UTC (permalink / raw)
To: linux-kernel; +Cc: Amit Shah, virtualization, Sasha Levin, Michael S. Tsirkin
This patch adds virtio_config_val_len() which allows retrieving variable
length data from the virtio config space only if a specific feature is on.
Cc: Amit Shah <amit.shah@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
include/linux/virtio_config.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 39c88c5..add4790 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -155,6 +155,9 @@ static inline bool virtio_has_feature(const struct virtio_device *vdev,
#define virtio_config_val(vdev, fbit, offset, v) \
virtio_config_buf((vdev), (fbit), (offset), (v), sizeof(*v))
+#define virtio_config_val_len(vdev, fbit, offset, v, len) \
+ virtio_config_buf((vdev), (fbit), (offset), (v), (len))
+
static inline int virtio_config_buf(struct virtio_device *vdev,
unsigned int fbit,
unsigned int offset,
--
1.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config
2011-08-14 14:52 [PATCH 1/3] virtio-console: Use virtio_config_val() for retrieving config Sasha Levin
2011-08-14 14:52 ` [PATCH 2/3] virtio_config: Add virtio_config_val_len() Sasha Levin
2011-08-14 14:52 ` Sasha Levin
@ 2011-08-14 14:52 ` Sasha Levin
2011-08-15 0:58 ` Rusty Russell
2011-08-15 0:58 ` Rusty Russell
2011-08-14 14:52 ` Sasha Levin
3 siblings, 2 replies; 7+ messages in thread
From: Sasha Levin @ 2011-08-14 14:52 UTC (permalink / raw)
To: linux-kernel
Cc: Sasha Levin, Amit Shah, Michael S. Tsirkin, Rusty Russell,
virtualization
This patch modifies virtio-net to use virtio_config_val() instead
of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
optional values from the config space.
Cc: Amit Shah <amit.shah@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
drivers/net/virtio_net.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0c7321c..878db50 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -902,12 +902,10 @@ static void virtnet_update_status(struct virtnet_info *vi)
{
u16 v;
- if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS))
- return;
-
- vi->vdev->config->get(vi->vdev,
+ if (virtio_config_val(vi->vdev, VIRTIO_NET_F_STATUS,
offsetof(struct virtio_net_config, status),
- &v, sizeof(v));
+ &v) < 0)
+ return;
/* Ignore unknown (future) status bits */
v &= VIRTIO_NET_S_LINK_UP;
@@ -982,11 +980,9 @@ static int virtnet_probe(struct virtio_device *vdev)
}
/* Configuration may specify what MAC to use. Otherwise random. */
- if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
- vdev->config->get(vdev,
+ if (virtio_config_val_len(vdev, VIRTIO_NET_F_MAC,
offsetof(struct virtio_net_config, mac),
- dev->dev_addr, dev->addr_len);
- } else
+ dev->dev_addr, dev->addr_len) < 0)
random_ether_addr(dev->dev_addr);
/* Set up our device-specific information */
--
1.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config
2011-08-14 14:52 [PATCH 1/3] virtio-console: Use virtio_config_val() for retrieving config Sasha Levin
` (2 preceding siblings ...)
2011-08-14 14:52 ` [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config Sasha Levin
@ 2011-08-14 14:52 ` Sasha Levin
3 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2011-08-14 14:52 UTC (permalink / raw)
To: linux-kernel; +Cc: Amit Shah, virtualization, Sasha Levin, Michael S. Tsirkin
This patch modifies virtio-net to use virtio_config_val() instead
of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
optional values from the config space.
Cc: Amit Shah <amit.shah@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
drivers/net/virtio_net.c | 14 +++++---------
1 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 0c7321c..878db50 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -902,12 +902,10 @@ static void virtnet_update_status(struct virtnet_info *vi)
{
u16 v;
- if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS))
- return;
-
- vi->vdev->config->get(vi->vdev,
+ if (virtio_config_val(vi->vdev, VIRTIO_NET_F_STATUS,
offsetof(struct virtio_net_config, status),
- &v, sizeof(v));
+ &v) < 0)
+ return;
/* Ignore unknown (future) status bits */
v &= VIRTIO_NET_S_LINK_UP;
@@ -982,11 +980,9 @@ static int virtnet_probe(struct virtio_device *vdev)
}
/* Configuration may specify what MAC to use. Otherwise random. */
- if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) {
- vdev->config->get(vdev,
+ if (virtio_config_val_len(vdev, VIRTIO_NET_F_MAC,
offsetof(struct virtio_net_config, mac),
- dev->dev_addr, dev->addr_len);
- } else
+ dev->dev_addr, dev->addr_len) < 0)
random_ether_addr(dev->dev_addr);
/* Set up our device-specific information */
--
1.7.6
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config
2011-08-14 14:52 ` [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config Sasha Levin
@ 2011-08-15 0:58 ` Rusty Russell
2011-08-15 0:58 ` Rusty Russell
1 sibling, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2011-08-15 0:58 UTC (permalink / raw)
To: Sasha Levin, linux-kernel
Cc: Sasha Levin, Amit Shah, Michael S. Tsirkin, virtualization
On Sun, 14 Aug 2011 17:52:33 +0300, Sasha Levin <levinsasha928@gmail.com> wrote:
> This patch modifies virtio-net to use virtio_config_val() instead
> of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
> optional values from the config space.
Thanks, all applied.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config
2011-08-14 14:52 ` [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config Sasha Levin
2011-08-15 0:58 ` Rusty Russell
@ 2011-08-15 0:58 ` Rusty Russell
1 sibling, 0 replies; 7+ messages in thread
From: Rusty Russell @ 2011-08-15 0:58 UTC (permalink / raw)
To: linux-kernel; +Cc: Amit Shah, virtualization, Sasha Levin, Michael S. Tsirkin
On Sun, 14 Aug 2011 17:52:33 +0300, Sasha Levin <levinsasha928@gmail.com> wrote:
> This patch modifies virtio-net to use virtio_config_val() instead
> of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve
> optional values from the config space.
Thanks, all applied.
Cheers,
Rusty.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-08-15 1:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-14 14:52 [PATCH 1/3] virtio-console: Use virtio_config_val() for retrieving config Sasha Levin
2011-08-14 14:52 ` [PATCH 2/3] virtio_config: Add virtio_config_val_len() Sasha Levin
2011-08-14 14:52 ` Sasha Levin
2011-08-14 14:52 ` [PATCH 3/3] virtio-net: Use virtio_config_val() for retrieving config Sasha Levin
2011-08-15 0:58 ` Rusty Russell
2011-08-15 0:58 ` Rusty Russell
2011-08-14 14:52 ` Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.