From patchwork Tue Nov 22 08:10:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9440601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCE80605EE for ; Tue, 22 Nov 2016 08:11:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D237628448 for ; Tue, 22 Nov 2016 08:11:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C723C28451; Tue, 22 Nov 2016 08:11:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 74D8828448 for ; Tue, 22 Nov 2016 08:11:50 +0000 (UTC) Received: from localhost ([::1]:53926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c96BB-0006aD-BF for patchwork-qemu-devel@patchwork.kernel.org; Tue, 22 Nov 2016 03:11:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56611) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c96Ak-0006XN-MK for qemu-devel@nongnu.org; Tue, 22 Nov 2016 03:11:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c96Aj-0002Ut-F8 for qemu-devel@nongnu.org; Tue, 22 Nov 2016 03:11:22 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:26453) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1c96Ai-0002MV-Rx for qemu-devel@nongnu.org; Tue, 22 Nov 2016 03:11:21 -0500 Received: from 172.24.1.47 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.47]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DRC08144; Tue, 22 Nov 2016 16:10:50 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.235.1; Tue, 22 Nov 2016 16:10:41 +0800 From: Gonglei To: , , , , Date: Tue, 22 Nov 2016 16:10:22 +0800 Message-ID: <1479802223-121104-2-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.8.2.windows.1 In-Reply-To: <1479802223-121104-1-git-send-email-arei.gonglei@huawei.com> References: <1479802223-121104-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH v2 1/2] virtio: introduce little edian functions for virtio_cread/write# family X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pasic@linux.vnet.ibm.com, weidong.huang@huawei.com, claudio.fontana@huawei.com, mst@redhat.com, luonengjun@huawei.com, hanweidong@huawei.com, xin.zeng@intel.com, xuquan8@huawei.com, salvatore.benedetto@intel.com, Gonglei , stefanha@redhat.com, jianjay.zhou@huawei.com, cornelia.huck@de.ibm.com, longpeng2@huawei.com, arei.gonglei@hotmail.com, davem@davemloft.net, wu.wubin@huawei.com, herbert@gondor.apana.org.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Virtio modern devices are always little edian, let's introduce the LE functions for read/write configuration space for virtio modern devices, which avoid complaint by Sparse when we use the virtio_creaed/virtio_cwrite in VIRTIO_1 devices. Signed-off-by: Gonglei --- include/linux/virtio_config.h | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 26c155b..de05707 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -414,4 +414,49 @@ static inline void virtio_cwrite64(struct virtio_device *vdev, _r; \ }) +static inline __le16 virtio_cread16_le(struct virtio_device *vdev, + unsigned int offset) +{ + __le16 ret; + + vdev->config->get(vdev, offset, &ret, sizeof(ret)); + return ret; +} + +static inline void virtio_cwrite16_le(struct virtio_device *vdev, + unsigned int offset, __le16 val) +{ + vdev->config->set(vdev, offset, &val, sizeof(val)); +} + +static inline __le32 virtio_cread32_le(struct virtio_device *vdev, + unsigned int offset) +{ + __le32 ret; + + vdev->config->get(vdev, offset, &ret, sizeof(ret)); + return ret; +} + +static inline void virtio_cwrite32_le(struct virtio_device *vdev, + unsigned int offset, __le32 val) +{ + vdev->config->set(vdev, offset, &val, sizeof(val)); +} + +static inline __le64 virtio_cread64_le(struct virtio_device *vdev, + unsigned int offset) +{ + __le64 ret; + + __virtio_cread_many(vdev, offset, &ret, 1, sizeof(ret)); + return ret; +} + +static inline void virtio_cwrite64_le(struct virtio_device *vdev, + unsigned int offset, __le64 val) +{ + vdev->config->set(vdev, offset, &val, sizeof(val)); +} + #endif /* _LINUX_VIRTIO_CONFIG_H */