lkml.org 
[lkml]   [2015]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [PATCH 5/5] virtio: don't require a config space on the console device.
Date
"Michael S. Tsirkin" <mst@redhat.com> writes:
> On Fri, Feb 06, 2015 at 03:36:56PM +1030, Rusty Russell wrote:
>> Strictly, it's only needed when we have features (size or multiport).
>>
>> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>> ---
>> drivers/char/virtio_console.c | 12 ++++++++----
>> 1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
>> index 26afb56a8073..8f182b0015b5 100644
>> --- a/drivers/char/virtio_console.c
>> +++ b/drivers/char/virtio_console.c
>> @@ -1986,10 +1986,14 @@ static int virtcons_probe(struct virtio_device *vdev)
>> bool multiport;
>> bool early = early_put_chars != NULL;
>>
>> - if (!vdev->config->get) {
>> - dev_err(&vdev->dev, "%s failure: config access disabled\n",
>> - __func__);
>> - return -EINVAL;
>> + /* We only need a config space if features are offered */
>> + if (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)
>> + || virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) {
>> + if (!vdev->config->get) {
>
> I dislike nested ifs. How about
> if (!vdev->config->get && (
> (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)
> || virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT))

OK, fixed.

Thanks,
Rusty.

virtio: don't require a config space on the console device.

Strictly, it's only needed when we have features (size or multiport).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 26afb56a8073..fae2dbbf5745 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1986,7 +1986,10 @@ static int virtcons_probe(struct virtio_device *vdev)
bool multiport;
bool early = early_put_chars != NULL;

- if (!vdev->config->get) {
+ /* We only need a config space if features are offered */
+ if (!vdev->config->get &&
+ (virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)
+ || virtio_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT))) {
dev_err(&vdev->dev, "%s failure: config access disabled\n",
__func__);
return -EINVAL;

\
 
 \ /
  Last update: 2015-02-09 02:21    [W:0.074 / U:4.464 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site