From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A665C433FC for ; Wed, 22 Jul 2020 15:53:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 751F62084D for ; Wed, 22 Jul 2020 15:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595433218; bh=JvD7nhY9VfGsfS8vJGMtYvEtmAxdoF7RxvdVp+w7rTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xqt2gM2OWTdYox/CsCqJjM1H4+9HIZbnFBiE65gcxrQX5WbbH6pLtVlQpYBGfGO+R AKvLLvtM1d5JaaE5G88jSXsfbnFHUDl2I3sFoo8ftk6vFyAXsPfNM1x+eOJergS3QI uYuZdz0Ry5Ay46PmLW7kTHNv4bLiG2zre2nUkqCc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730402AbgGVPxi (ORCPT ); Wed, 22 Jul 2020 11:53:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:35806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgGVPxh (ORCPT ); Wed, 22 Jul 2020 11:53:37 -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 4921B20771; Wed, 22 Jul 2020 15:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595433217; bh=JvD7nhY9VfGsfS8vJGMtYvEtmAxdoF7RxvdVp+w7rTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cthvhKvdMEUCcZT8TKwECACI+hVNwxe4KXAXAmG0+vuBNcenFADQsAEAL6RjRSVLa zz5OOowPMPZwGqtgAwH2BC16xi3b1eoKQR0e4JWtOmGGBbiSuaWulnSmVx7WQGB3lq ZR8lkamqBKE+NgiUF8daMnSLEjZLFDkBEPfkWSw8= From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Andy Shevchenko , Lars-Peter Clausen , Peter Meerwald , Jonathan Cameron Subject: [PATCH v3 19/27] iio:pressure:mpl3115 Force alignment of buffer Date: Wed, 22 Jul 2020 16:50:55 +0100 Message-Id: <20200722155103.979802-20-jic23@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200722155103.979802-1-jic23@kernel.org> References: <20200722155103.979802-1-jic23@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Whilst this is another case of the issue Lars reported with an array of elements of smaller than 8 bytes being passed to iio_push_to_buffers_with_timestamp, the solution here is a bit different from the other cases and relies on __aligned working on the stack (true since 4.6?) This one is unusual. We have to do an explicit memset each time as we are reading 3 bytes into a potential 4 byte channel which may sometimes be a 2 byte channel depending on what is enabled. As such, moving the buffer to the heap in the iio_priv structure doesn't save us much. We can't use a nice explicit structure on the stack either as the data channels have different storage sizes and are all separately controlled. Fixes: cc26ad455f57 ("iio: Add Freescale MPL3115A2 pressure / temperature sensor driver") Reported-by: Lars-Peter Clausen Cc: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/mpl3115.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index ccdb0b70e48c..8a481dbe808c 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -144,7 +144,8 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct mpl3115_data *data = iio_priv(indio_dev); - u8 buffer[16]; /* 32-bit channel + 16-bit channel + padding + ts */ + /* 32-bit channel + 16-bit channel + padding + ts */ + u8 buffer[16] __aligned(8); int ret, pos = 0; mutex_lock(&data->lock); -- 2.27.0