From patchwork Sun Oct 13 09:55:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 11187335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9F1614ED for ; Sun, 13 Oct 2019 09:57:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA2FF206A3 for ; Sun, 13 Oct 2019 09:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570960644; bh=PTGfE6rg34JkW4EyQE873y0B+++yKeoya/IaJGIPNEo=; h=From:To:Cc:Subject:Date:List-ID:From; b=0kxnBrY3uhhnS246mau1n37XRZvUEVWrU9YHzGbWYZ7hskgHbsrFKqL5aSCMDHNez LQ8zSIkXipfmDKtbP/Nb/GSgmVrXaQid5XyPOjWDfpWmHdghmeGyBXqa1HOyo7VZ95 O7J57M3L9V79/Q6+1iAHtnqs7ZX7837zbjpU6azI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728621AbfJMJ5U (ORCPT ); Sun, 13 Oct 2019 05:57:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728543AbfJMJ5U (ORCPT ); Sun, 13 Oct 2019 05:57:20 -0400 Received: from localhost.localdomain (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 514C020673; Sun, 13 Oct 2019 09:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570960640; bh=PTGfE6rg34JkW4EyQE873y0B+++yKeoya/IaJGIPNEo=; h=From:To:Cc:Subject:Date:From; b=rrzJiJJgo/bdDE3lK6KJB+9lgNYjuucSLyfRI3XsD9iXpTXKS0wAUta8sy2ZENaOW t/bEVU9tWdtKscAKG9czclRFBN6GdOLQ38W6NqGUISWq8gcCJc++JLAxsA8hhy3HkF 45/9mWke30pIiTKtm8uBCF8s9o86zXMBE3wXJXus= From: jic23@kernel.org To: linux-iio@vger.kernel.org Cc: Jonathan Cameron , Tomasz Duszynski Subject: [PATCH] iio: chemical: sps30: Explicity truncate constant by masking Date: Sun, 13 Oct 2019 10:55:15 +0100 Message-Id: <20191013095515.1438147-1-jic23@kernel.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron When breaking up a constant to write to two 8 bit registers it isn't obvious to sparse that it was intentional. CHECK drivers/iio/chemical/sps30.c drivers/iio/chemical/sps30.c:120:30: warning: cast truncates bits from constant value (8004 becomes 4) So in the interests of minimising noisy warnings, let us add a mask. Signed-off-by: Jonathan Cameron Cc: Tomasz Duszynski Acked-by: Tomasz Duszynski --- drivers/iio/chemical/sps30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/chemical/sps30.c b/drivers/iio/chemical/sps30.c index edbb956e81e8..acb9f8ecbb3d 100644 --- a/drivers/iio/chemical/sps30.c +++ b/drivers/iio/chemical/sps30.c @@ -117,7 +117,7 @@ static int sps30_do_cmd(struct sps30_state *state, u16 cmd, u8 *data, int size) break; case SPS30_READ_AUTO_CLEANING_PERIOD: buf[0] = SPS30_AUTO_CLEANING_PERIOD >> 8; - buf[1] = (u8)SPS30_AUTO_CLEANING_PERIOD; + buf[1] = (u8)(SPS30_AUTO_CLEANING_PERIOD & 0xff); /* fall through */ case SPS30_READ_DATA_READY_FLAG: case SPS30_READ_DATA: