Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759169AbbBIA4e (ORCPT ); Sun, 8 Feb 2015 19:56:34 -0500 Received: from ozlabs.org ([103.22.144.67]:52295 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759132AbbBIA4c (ORCPT ); Sun, 8 Feb 2015 19:56:32 -0500 From: Rusty Russell To: "Michael S. Tsirkin" Cc: lkml , Amit Shah Subject: Re: [PATCH 5/5] virtio: don't require a config space on the console device. In-Reply-To: <20150208110336.GL3185@redhat.com> References: <1423199216-2094-1-git-send-email-rusty@rustcorp.com.au> <1423199216-2094-6-git-send-email-rusty@rustcorp.com.au> <20150208110336.GL3185@redhat.com> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Mon, 09 Feb 2015 10:26:29 +1030 Message-ID: <87bnl43qky.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2374 Lines: 63 "Michael S. Tsirkin" 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 >> --- >> 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 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; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/