Received: by 10.223.185.116 with SMTP id b49csp1798704wrg; Thu, 15 Feb 2018 01:35:28 -0800 (PST) X-Google-Smtp-Source: AH8x226oCp6p07+aZ8mFOok6XEnwuCavJpIxTYTIUI35aDJ+5u4ixb8KnZJ89h+au+E89SoSW/c6 X-Received: by 10.99.171.10 with SMTP id p10mr1709539pgf.176.1518687328411; Thu, 15 Feb 2018 01:35:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518687328; cv=none; d=google.com; s=arc-20160816; b=pJ5/HiOvmyM83qIlhxGPV2TzBYw5TUQI/t0SCF9w2ypO9KQ+ulxR+urWd117ZZaFtc HZAwYfw+rJmnsZwyk9HRnYBU/gp85iJWBBvB6OKSkFP86vOqJrI0PGDrr8XycZ3moEi+ Tc+thqOypt9HrmYcEZl6/wXnOUiz8ZbYBRNuHCtmuK4vVzGl9OrJhGmgiH6aCOhss/08 N9QN26Pn6vDvzs0N7vjzw5dgnqDw79CUU2rxZBymwG+UlQkwhrOhuq1jb7ieQdKX3//H AboVwu1p5hDUvHvQeaTf02rx1RjanGTSczVVMZAeUABGFMMc9q3kc3cnAkEiDPFvSvVO 68PQ== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :arc-authentication-results; bh=k5rgRqTqvcYzmKQ2ldK3Py/HfjnpZDpK6M/qJIrI46w=; b=C55n3tNbAoOLgto/lwtRfNOPNPoSDufi2asRbSKRknCn7Z8zlrTdvaoiQpSbcHMCRc OL/UJTQoUFkztg2U2QzOWV36v9ugOTS0pmH2+ePCgNXcGdHYS9v6sOArq3UugpxyY0Xd 4oSeSxPn44Ma/nTVFjWSuaVZ3CnDUmGTuH5xW3+Ax+uUQ4LdRRzErXraSIpxQwlU4dzn 1iiGC7gfzWKL5LG/yMOP8c0g+xk8cru83MSrGf/5kx13AApdZkoXdBTQZlWbmEWy+Xvx LBE6wNaEtCd71ZSiyYNTUz3X/7LW5VcXltrBearq15GwNIkCMwoWtsiBefHoYnvBF8pE taKw== 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 y11si3400644pgv.625.2018.02.15.01.35.13; Thu, 15 Feb 2018 01:35:28 -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 S1755197AbeBOJed convert rfc822-to-8bit (ORCPT + 99 others); Thu, 15 Feb 2018 04:34:33 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:41454 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754825AbeBOJea (ORCPT ); Thu, 15 Feb 2018 04:34:30 -0500 Received: by mail-qt0-f195.google.com with SMTP id a9so11099769qtj.8 for ; Thu, 15 Feb 2018 01:34:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6tlVletCTswO+lzXoJxgp87x3FW3E78Lg264CHDHgoQ=; b=BU+lnPo8GkzZAxjvwHOf/Z7zQq7vsZV1Y1ioDUa/L4g+ze9hzRebWzRsSp6C9AXliG eK7aoAy9wj3yEI+debo+D0SqUw6weNXnql4PfrKeb8SZrC26wfupyeAYESakDgJmgMvz QP1t4e98WX6iVKE2lTwC2UqlQ+N9NJOVAsBenZQgedh8mr/73qH7YhUJqjPTMk0HZzH6 kqBFQbvuf6IqpGSnEVm6oWeChrTujxbJlqOlD3dYyqB/epVRWhanzVR/yFG9i+alvWQd 8q6r+LYB2WS2Fehd2DEZs7tvR31dbovgNpne5jkZruH5J7wa8i0Ed9YYLEOkBkJqToKS eA9w== X-Gm-Message-State: APf1xPBZv0Eia2wf9Yya3mGo/QNlKSOTMviZcYIgr8LGsZ05DilXK6ww DTC+7QmQSf5FvKgr9nNIwPee/bGlJ68+VVb+uoitFw== X-Received: by 10.200.69.2 with SMTP id q2mr3161519qtn.167.1518687269314; Thu, 15 Feb 2018 01:34:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.146.213 with HTTP; Thu, 15 Feb 2018 01:34:28 -0800 (PST) In-Reply-To: <20180214224149-mutt-send-email-mst@kernel.org> References: <20180214141850.4017-1-marcandre.lureau@redhat.com> <20180214141850.4017-4-marcandre.lureau@redhat.com> <20180214224149-mutt-send-email-mst@kernel.org> From: Marc-Andre Lureau Date: Thu, 15 Feb 2018 10:34:28 +0100 Message-ID: Subject: Re: [PATCH v14 3/9] fw_cfg: fix sparse warnings in fw_cfg_sel_endianness() To: "Michael S. Tsirkin" Cc: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , Linux Kernel Mailing List , Baoquan He , Sergio Lopez Pascual , "Somlo, Gabriel" , xiaolong.ye@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 14, 2018 at 9:46 PM, Michael S. Tsirkin wrote: > On Wed, Feb 14, 2018 at 03:18:44PM +0100, Marc-André Lureau wrote: >> The function is used for both LE & BE target type, use __force casting. >> >> 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 | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c >> index 90f467232777..85e693287d87 100644 >> --- a/drivers/firmware/qemu_fw_cfg.c >> +++ b/drivers/firmware/qemu_fw_cfg.c >> @@ -52,7 +52,9 @@ static DEFINE_MUTEX(fw_cfg_dev_lock); >> /* pick appropriate endianness for selector key */ >> static inline u16 fw_cfg_sel_endianness(u16 key) >> { >> - return fw_cfg_is_mmio ? cpu_to_be16(key) : cpu_to_le16(key); >> + return fw_cfg_is_mmio ? >> + (u16 __force)cpu_to_be16(key) : >> + (u16 __force)cpu_to_le16(key); >> } >> >> /* read chunk of given fw_cfg blob (caller responsible for sanity-check) */ > > Well the caller does cpu_to_le16 on the result ... > All this makes my head spin. > > IMHO what you want is a wrapper that does iowrite and iowritebe > rather than __force. iowrite16(key) is the same as iowrite16(cpu_to_le16(key)) ? There is no iowrite16le()... Is this equivalent, and not introducing regressions? 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); > > >> -- >> 2.16.1.73.g5832b7e9f2