Received: by 10.223.185.116 with SMTP id b49csp6303909wrg; Wed, 28 Feb 2018 07:16:01 -0800 (PST) X-Google-Smtp-Source: AH8x226mOo64JG0DMUtrfTdHYlzdR0sN4kKp8kU4hFLEnkUuPRMkNZQhhKUz6Q18eKE4Pf1DER1Q X-Received: by 10.98.160.90 with SMTP id r87mr17855048pfe.151.1519830961631; Wed, 28 Feb 2018 07:16:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519830961; cv=none; d=google.com; s=arc-20160816; b=lakpabhh8AMqyfYigexpFc27l0FA6gCYkLKV94NwCZyizveCN/RN/SUEZmt9o4hC4R qqvVSTyLbb1rrBImPd0nEM6nIgw04g3S8h6hEmTySTay9Xri1G0AACJjSqQ5J874QEjd 4lkl1RAdZf6fX+qD+y0Ax2+K07Mh2XySEvpqW5fiValVThim8XcXMjlwnbdw85p5N1bi R0O108UtV0tGPvtCf0UE9oOZsGa67U2XZRCJJL5LzczKtwf2Pa0WIjeLyItrAlnMjwqs Gyk1RVeaTpCYWy7EAWr9SC+wH1Fio8GGt1rNl/Ewv5RPSdmEAN5sR1/dA+PnQcZroLqr LGXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=t7gctZXx2P3K7YAby4oLI3NGDOpW8kN5oQtbNzZVX8M=; b=MEBRK14zDQt88HtBurGwThNh+/Vs2Aohxpu3Vbfc5knoXPd4FcOR8viLPanEdcfg57 2pg+2Xs0Stk27dX+KbpNHYdWMi0k+3bLGvFdFUE9D60eZcQxzwSOfSIUX26mVqfsOgzi 94T7vO5n07DAkIPyZK1xveDJKcE59aLdC9mk7PE16zSsuLX9fSpzPWMNp75TTWoRS3cl DNlEM0P98kDi4xxUjDCiuwg+m4JDlRMA7sFqnTu8peWFlENZVwZThhqsNvxWCq8+FP3j 5vwP/q0dI3BpzY4/JNpA6NfNkGfxmZUvazo5KaSsuSaLu84LluKdXCng/SVIo4xikxnN bFOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9-v6si1453518pli.445.2018.02.28.07.15.47; Wed, 28 Feb 2018 07:16:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932299AbeB1POT (ORCPT + 99 others); Wed, 28 Feb 2018 10:14:19 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43212 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752777AbeB1PG0 (ORCPT ); Wed, 28 Feb 2018 10:06:26 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D13640FB650; Wed, 28 Feb 2018 15:06:26 +0000 (UTC) Received: from localhost (ovpn-112-57.ams2.redhat.com [10.36.112.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A3709C042; Wed, 28 Feb 2018 15:06:19 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: linux-kernel@vger.kernel.org Cc: arnd@arndb.de, bhe@redhat.com, slp@redhat.com, mst@redhat.com, somlo@cmu.edu, xiaolong.ye@intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v16 01/11] fw_cfg: fix sparse warnings in fw_cfg_sel_endianness() Date: Wed, 28 Feb 2018 16:06:05 +0100 Message-Id: <20180228150615.17317-2-marcandre.lureau@redhat.com> In-Reply-To: <20180228150615.17317-1-marcandre.lureau@redhat.com> References: <20180228150615.17317-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 28 Feb 2018 15:06:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 28 Feb 2018 15:06:26 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'marcandre.lureau@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dispatch to the appropriate iowrite() instead of casting restricted type to u16. - if fw_cfg_is_mmio: before: iowrite16(cpu_to_be16(key)) after: iowrite16be(key) - if !fw_cfg_is_mmio: before: iowrite16(cpu_to_le16(key)) after: iowrite16(key) which is equivalent on little-endian systems, where fw_cfg IO is supported. Fixes: $ make C=1 CF=-D__CHECK_ENDIAN__ drivers/firmware/qemu_fw_cfg.o drivers/firmware/qemu_fw_cfg.c:55:33: warning: restricted __be16 degrades to integer drivers/firmware/qemu_fw_cfg.c:55:52: warning: restricted __le16 degrades to integer Signed-off-by: Marc-André Lureau --- drivers/firmware/qemu_fw_cfg.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c index a41b572eeeb1..e7ea2b3b1d11 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -68,9 +68,12 @@ static void __iomem *fw_cfg_reg_data; static DEFINE_MUTEX(fw_cfg_dev_lock); /* pick appropriate endianness for selector key */ -static inline u16 fw_cfg_sel_endianness(u16 key) +static void fw_cfg_sel_endianness(u16 key) { - return fw_cfg_is_mmio ? cpu_to_be16(key) : cpu_to_le16(key); + if (fw_cfg_is_mmio) + iowrite16be(key, fw_cfg_reg_ctrl); + else + iowrite16(key, fw_cfg_reg_ctrl); } /* read chunk of given fw_cfg blob (caller responsible for sanity-check) */ @@ -92,7 +95,7 @@ static inline void fw_cfg_read_blob(u16 key, } mutex_lock(&fw_cfg_dev_lock); - iowrite16(fw_cfg_sel_endianness(key), fw_cfg_reg_ctrl); + fw_cfg_sel_endianness(key); while (pos-- > 0) ioread8(fw_cfg_reg_data); ioread8_rep(fw_cfg_reg_data, buf, count); -- 2.16.1.73.g5832b7e9f2