Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp218957yba; Wed, 8 May 2019 19:22:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwl1HdzjBECRkMqnQMp9/KMGTKM777liToOACRewC7mWT/i5/hghRey1tY0KTojMR1BkE4/ X-Received: by 2002:a62:ee04:: with SMTP id e4mr1483826pfi.232.1557368576949; Wed, 08 May 2019 19:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557368576; cv=none; d=google.com; s=arc-20160816; b=zpADF2VKNM+9WpLloaz/oFjpj7+nyzTDS5y753JfpOEN8PbhDtXRYf6dACqK5PStm3 zb10DyY/nwb2AZMPfcsJIMZ1JMYDubc0YFv/xUZAzqkFCjJtUkDEId8yn0OArgB+tuhh EtjJfePSL21yrs9DOhg94CjPaW1zEgzAz6bDDgDMAX2nfau5tpF1BR+YV/MmMxSeefN/ 5NOb5QWviVneSWEElozPeYEgebUKJhUVcMHMmKRcmJdOviHNorY6hYesZwd1jPYyJ45I SXN2NFkpikRxkHMwGbPk857C+gG+apAEkuyt2J+9QyIyYZ+L6eL+KCEML7/iD5NKZbuM uCNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=vhI3zFED2rEGDY1sjB2X0Va/HPF+BLOx8FK4C6k13tI=; b=y4BJtfOCqtrf2P+6COsHa72K47BPJBqoENry4bij3FXbsUfKGP//sDJYR2aZfw82MP xqL0bO+zWvWQgWYmcCoiVR68ahs6+eMM2MKOXoCprjq09CFBRRuxT27Jz1SpzZCKOwcP G7UUyGXwNLmvEjmNXJW1TbJ5LMI3lDda1eX8Cdp2HZIZFTVIvRq1BiTaEy5AXTOYQMDy janhsR+7XWmE1iKIguzsggdyOstoLHwR7Y6rOT/B1yq0gS8cYXAsmI6uOXSXVKRi9sNL dORd/nIrEmbTwwqNlxihPK0aAPfPrwrRlbCvn0nhB9yKGnjUQbT/PRZAvB+AmmxSNgSA FAUg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si1210732pgi.85.2019.05.08.19.22.40; Wed, 08 May 2019 19:22:56 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726649AbfEICUE (ORCPT + 99 others); Wed, 8 May 2019 22:20:04 -0400 Received: from www.osadl.org ([62.245.132.105]:60498 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725842AbfEICUD (ORCPT ); Wed, 8 May 2019 22:20:03 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x492JcKg005420; Thu, 9 May 2019 04:19:38 +0200 From: Nicholas Mc Guire To: Alessandro Zummo Cc: Alexandre Belloni , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] rtc: ds2404: use hw endiannes variable Date: Thu, 9 May 2019 04:13:55 +0200 Message-Id: <1557368035-6787-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-4.2 required=6.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Converting from hardware to host endiannes was done using reassignment to the same variable which makes sparse unhappy as it can not verify the endiannes handling properly. To allow sparse to verify endiannes handling an explicit __le32 is introduced. Note that this patch does not change the generated binary (x86_64 and ppc64 binary diff). Signed-off-by: Nicholas Mc Guire --- Problem located by an experimental coccinelle script to locate patters that make sparse unhappy (false positives): on little-endian x86_64 sparse complains about: drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 on big-endian ppc64 sparse complains about drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 drivers/rtc/rtc-ds2404.c:187:16: warning: cast to restricted __le32 Patch was compiletested with: x86_64_defconfig + RTC_DRV_DS2404=m ppc64_defconfig + RTC_DRV_DS2404=m in both cases applying the patch has no impact on the generated binary. Patch is against 5.1 (localversion-next is next-20190508) drivers/rtc/rtc-ds2404.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/rtc/rtc-ds2404.c b/drivers/rtc/rtc-ds2404.c index 1e9f429..9df0c44 100644 --- a/drivers/rtc/rtc-ds2404.c +++ b/drivers/rtc/rtc-ds2404.c @@ -182,9 +182,10 @@ static void ds2404_enable_osc(struct device *dev) static int ds2404_read_time(struct device *dev, struct rtc_time *dt) { unsigned long time = 0; + __le32 hw_time = 0; - ds2404_read_memory(dev, 0x203, 4, (u8 *)&time); - time = le32_to_cpu(time); + ds2404_read_memory(dev, 0x203, 4, (u8 *)&hw_time); + time = le32_to_cpu(hw_time); rtc_time64_to_tm(time, dt); return 0; -- 2.1.4