Received: by 10.223.185.116 with SMTP id b49csp805866wrg; Fri, 16 Feb 2018 07:29:19 -0800 (PST) X-Google-Smtp-Source: AH8x224hbB7EvsaG4G7uFCCfgkXvBrSrKKo3OkuP4v9FJrIe9uifN3VThcZfzwW0W45afwSNS3Hk X-Received: by 2002:a17:902:788e:: with SMTP id q14-v6mr6246977pll.396.1518794959159; Fri, 16 Feb 2018 07:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518794959; cv=none; d=google.com; s=arc-20160816; b=wQINHWSqN3AD0+bRs9B4Xs4ozn6Wkwovtf8+uT2lL1wBIygcbqOWqmWmi3W92PKIno JTtVAtrQ3F2bCXt4OSbN8aesLU3GmyvzZ965mt5tde7foL2BF6b2DQjPXcWXWYFOLL7Y MOJjK8x89kvWs10qMnQooYJD+Y5AZ97tP9mIBpl2AFmaHlI7TiiPN0bePbC77ruhQw1V dvVsUuA1ZuHdnM8XulKqNKAdUczx97J/Bu0aWNTuBhy7+o95JgWIpWlA/xy4D9zUaJwv QBGWKkPDUAFrUIP5SX3JcGoKiQ6t6AZrXw+R32wpZxfaWHBHfdLFVlFMi1/+fTtGTivT 3LhA== 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=QUsgVtuH2pJzn7wQS3NpeG9M2bh1c2RM71MH80/8PME=; b=ZvGeAgCVJP8+3asHjbSxF03okq/28S81OSpZt/FbUjdGeCuAwrUx1fF5o+fRGB5MYq thbZQw5zRAmzY1cT7ZAjeFkbMx/tpCsfiEsan7yV5lJQ1UZOoEc5fg0DLOwghlkN4jmm fHxzuvqB5qDHoY2ZSmv4axhPxmTjAsBsxEzuyx5EOuti2ek1UTZRjeyq3VgRfROtrAuK aH8XgFWmaUtHx/PnPP0dmrLXQ1qxVuCXglSPLd9AoWs3t+l9KW+ty1KyD3/Y0YTqatKc 7BPwtSLtEj4TzR+PX1Bk2Xz25wV4iVPukmkBrmT0bqy/jYHP/yWHaFzA4wAY9cEQP5Ch S6Wg== 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 b6si1948799pfl.14.2018.02.16.07.29.04; Fri, 16 Feb 2018 07:29:19 -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 S1163252AbeBOVdc (ORCPT + 99 others); Thu, 15 Feb 2018 16:33:32 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40068 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1162678AbeBOVda (ORCPT ); Thu, 15 Feb 2018 16:33:30 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62708406F970; Thu, 15 Feb 2018 21:33:30 +0000 (UTC) Received: from localhost (ovpn-112-19.ams2.redhat.com [10.36.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1260A101307D; Thu, 15 Feb 2018 21:33:29 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: linux-kernel@vger.kernel.org Cc: slp@redhat.com, bhe@redhat.com, mst@redhat.com, somlo@cmu.edu, xiaolong.ye@intel.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v15 03/11] fw_cfg: fix sparse warnings in fw_cfg_sel_endianness() Date: Thu, 15 Feb 2018 22:33:04 +0100 Message-Id: <20180215213312.29234-4-marcandre.lureau@redhat.com> In-Reply-To: <20180215213312.29234-1-marcandre.lureau@redhat.com> References: <20180215213312.29234-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.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Feb 2018 21:33:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 15 Feb 2018 21:33:30 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 42601a3eaed5..6164731a3c35 100644 --- a/drivers/firmware/qemu_fw_cfg.c +++ b/drivers/firmware/qemu_fw_cfg.c @@ -50,9 +50,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) */ @@ -74,7 +77,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