Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2348807pxa; Mon, 3 Aug 2020 14:01:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOEIuUWaw8fe401aBK1qsvH7V9oRjFRamRR3OdOf2uRL0HnepllEkzu60fPEnhi9UsjF2Q X-Received: by 2002:a17:906:2796:: with SMTP id j22mr19683120ejc.532.1596488509973; Mon, 03 Aug 2020 14:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596488509; cv=none; d=google.com; s=arc-20160816; b=cVqnNJsQKavA42XBFfyoUuCWayl1WS92K59ZRfOned4UpBB7VqW2AT57VeYt6cY3NG bTHQyxTWNIJz8zyLR6PK2MCl0m4s0oIMUpi/q3BHBh9h2BLdhDwJoH6CYjDZszuDqrhz Ml5KvoiB1AwyjSd3PhpGkum/LfhlNlO4dEJTCb+hYDyFWiqAKBm/Lpp59COBjcSYoeQz Qi6SbzuneGq4k9Kx8a/T241stEsSJHJ8tmfYqmc2KN+OhJ7XOfbK8Wh/8BVjy6KnQgDw isTISWFgMoAgAaBkrqx4DgqSFXBCJiUpODAi2a3IUeUqvynAYFnAn30cmMN0xWxENCx/ Br4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=kSRe7wmYN+c40TNuZd0aK8LNMOsV+g9hMYDNFujk/tc=; b=j/hpzw3W5kWGbBEBxLL0VlRr7xZjb36T1YfiXvXmsbs/Ol5y6J1Qgxv/zbCMHjI+Ja dq2lz749KFJ9S+VTpzphILfDCn3sgVI2eBY8djYgJtC1HlwSqcLfF8oTz/nmAqFVNhlw 1No1eRonaIeyykIQd5ihlb2mPor3aAY4RvV9Q71rolZyom0snaiCo9wF0v5+LChXe+1t TaarHxwR+53kU03U3KUfY9wUoT1xki73/UNDDEX0SmqEP+ScfBVc/rR9v01jVhgt6YFc awemBzd3Y/tGs7L964Yqy3GDCvvDXiltIEZLTfz1Wyyl/uMIqS4mSinMiSeomGGpnqtS X5Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z7L45UIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nm6si9365453ejb.336.2020.08.03.14.01.27; Mon, 03 Aug 2020 14:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Z7L45UIm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729246AbgHCVAe (ORCPT + 99 others); Mon, 3 Aug 2020 17:00:34 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:24595 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729227AbgHCVAc (ORCPT ); Mon, 3 Aug 2020 17:00:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596488431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kSRe7wmYN+c40TNuZd0aK8LNMOsV+g9hMYDNFujk/tc=; b=Z7L45UImsANHOJ6XYIgHL0LwrWcFBZfa/LcS2iVKWo4s6TgYYz9f8reyfmXW5l8r0zbagl dGLrvHGF5us/LiMD6ei3XR3Q/SmQ/iG0AMHF+OoJHent0+TAdihghS7ptqff6ooIAZBaHl cI51b6vjZYJDICiqb8A1YgHAV53jJyc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-RJBMDpefNeus1vtcarwh6Q-1; Mon, 03 Aug 2020 17:00:29 -0400 X-MC-Unique: RJBMDpefNeus1vtcarwh6Q-1 Received: by mail-qv1-f69.google.com with SMTP id d9so17704416qvl.10 for ; Mon, 03 Aug 2020 14:00:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kSRe7wmYN+c40TNuZd0aK8LNMOsV+g9hMYDNFujk/tc=; b=k8ZJotLGHFQtUFfZVQ0gt/VLVwBDI4PK7VtG//gldsWh77IvMsZfQYxE+H7XOPhYML nV9F9tJHgyc/BK9omMI5ZWKWBxjL8xPKnWYTuzetzW9/mWgt0DMP6qaOEWET6ZEgnc3h OZMsVzk+HbCscEQPU4DzRa6KVa4b47S1GWdSqwfsXtBbGpPJpjiCAqgt4eJgJCOw8S+i 37N+nb1DcZoedPsZtfXQiHLZ1tDP3rbG99kbsl9FocwqkSuREQPw2HEV8DDSD1f9GyRJ JVh5CmZiXoTexsOGDKuKZ+zEphooEuQ/T1IPx7d52wQBpxsoZ1hKPqQ/C0LtgpwTJI5D 00lQ== X-Gm-Message-State: AOAM5318cXaGOrSTFK7Pby/bQ9p/tGp+ISkAf0A8M9tUtNsZ7IO/qO8l 2ZoGOfny3EMjEgvGgBXzDRu4moeZUa1BZOqPYEsv4fHKh7vjVUF/gZuBlYveqSjTNw1jvFkVrDk OFxE7O/euS5V+E17WIpT8C2+2 X-Received: by 2002:aed:3203:: with SMTP id y3mr18662629qtd.376.1596488428499; Mon, 03 Aug 2020 14:00:28 -0700 (PDT) X-Received: by 2002:aed:3203:: with SMTP id y3mr18662607qtd.376.1596488428289; Mon, 03 Aug 2020 14:00:28 -0700 (PDT) Received: from redhat.com (bzq-79-177-102-128.red.bezeqint.net. [79.177.102.128]) by smtp.gmail.com with ESMTPSA id o37sm24591606qte.9.2020.08.03.14.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 14:00:27 -0700 (PDT) Date: Mon, 3 Aug 2020 17:00:24 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: virtualization@lists.linux-foundation.org, Jason Wang Subject: [PATCH v2 23/24] virtio_config: cread/write cleanup Message-ID: <20200803205814.540410-24-mst@redhat.com> References: <20200803205814.540410-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200803205814.540410-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use vars of the correct type instead of casting. Signed-off-by: Michael S. Tsirkin --- include/linux/virtio_config.h | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index c68f58f3bf34..5c3b02245ecd 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -444,53 +444,60 @@ static inline void virtio_cwrite8(struct virtio_device *vdev, static inline u16 virtio_cread16(struct virtio_device *vdev, unsigned int offset) { - u16 ret; + __virtio16 ret; might_sleep(); vdev->config->get(vdev, offset, &ret, sizeof(ret)); - return virtio16_to_cpu(vdev, (__force __virtio16)ret); + return virtio16_to_cpu(vdev, ret); } static inline void virtio_cwrite16(struct virtio_device *vdev, unsigned int offset, u16 val) { + __virtio16 v; + might_sleep(); - val = (__force u16)cpu_to_virtio16(vdev, val); - vdev->config->set(vdev, offset, &val, sizeof(val)); + v = cpu_to_virtio16(vdev, val); + vdev->config->set(vdev, offset, &v, sizeof(v)); } static inline u32 virtio_cread32(struct virtio_device *vdev, unsigned int offset) { - u32 ret; + __virtio32 ret; might_sleep(); vdev->config->get(vdev, offset, &ret, sizeof(ret)); - return virtio32_to_cpu(vdev, (__force __virtio32)ret); + return virtio32_to_cpu(vdev, ret); } static inline void virtio_cwrite32(struct virtio_device *vdev, unsigned int offset, u32 val) { + __virtio32 v; + might_sleep(); - val = (__force u32)cpu_to_virtio32(vdev, val); - vdev->config->set(vdev, offset, &val, sizeof(val)); + v = cpu_to_virtio32(vdev, val); + vdev->config->set(vdev, offset, &v, sizeof(v)); } static inline u64 virtio_cread64(struct virtio_device *vdev, unsigned int offset) { - u64 ret; + __virtio64 ret; + __virtio_cread_many(vdev, offset, &ret, 1, sizeof(ret)); - return virtio64_to_cpu(vdev, (__force __virtio64)ret); + return virtio64_to_cpu(vdev, ret); } static inline void virtio_cwrite64(struct virtio_device *vdev, unsigned int offset, u64 val) { + __virtio64 v; + might_sleep(); - val = (__force u64)cpu_to_virtio64(vdev, val); - vdev->config->set(vdev, offset, &val, sizeof(val)); + v = cpu_to_virtio64(vdev, val); + vdev->config->set(vdev, offset, &v, sizeof(v)); } /* Conditional config space accessors. */ -- MST