From patchwork Mon Jul 12 06:10:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 472874 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2648715jao; Sun, 11 Jul 2021 23:31:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU4GrDIUhF97S9i9yqlEQyeiCD06OoiPKn8Lpep3QK4slOBWRW5nbAhxhBt8AIwe7zzays X-Received: by 2002:a17:906:3cc:: with SMTP id c12mr49456014eja.268.1626071473522; Sun, 11 Jul 2021 23:31:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071473; cv=none; d=google.com; s=arc-20160816; b=OmLqi4oLtkD6LQQUf+LxVn+Uclehl8yCGuamBth1tsuzjHFCCZynZe13xIBEArOEdW LrCSRWpyayVAewz3jAiKOmtyLmjV1h+gfAjrpUhMRcBH7i5H9l+5RmeRYx6zJ2Iz2Bl1 O5HpgSMmkcahn7CDUXe+HLtMJN97ummGfkGhncvWkPEyAjyEckohOTrDGpP+g2A62oT8 p5Cj+MmD2nzYCuOIwLbC7HRui8o2eiHDXN6LaO6fP9kVHAO+XRx7OJdgPFLjyzcfAxt1 f9Wz6PPVZJlVjddxEKoOe9dkW7yyW4zJ0kbfTu1tw5y/LMJzOECpfACiBTK/bq5hQ/fR 4s9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YZdJFagp2+/yPxhTKLcCl4N9CXy1gKulfNSTB2EPlnQ=; b=GZJQWkEduq5yUTpEiEbqePpLe6p5n13dHcpAZ8SxXZarrNf18pwpROCjImOZ0UOvqx KWdV+JAPQoefwGpyW5SDRlibe5efvEV8Rd50z4ZaQqXirnDGr5OxBrlyz5iy6V6qXw/A posYU8nmth88/EOjjE4NwazO8MBA8eBduX9F/8sfpncESDNMV6tOgviur4HctHultGZr BuFqorhu0Jo1j6gE6Wu3vrc5kePWVtINT4QpNuZ5EUr3TxxBF3cJ22PpqCLEUsdmlTbo MVU0VRskZQJSvw1q9AZwkEwndzAPGovTvQSzC7eGYiapJfiqBFeILXKt2llYlpg21NPG DVOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PPRMzTuN; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si16242569edx.272.2021.07.11.23.31.13; Sun, 11 Jul 2021 23:31:13 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PPRMzTuN; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235994AbhGLGd7 (ORCPT + 12 others); Mon, 12 Jul 2021 02:33:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:46660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234805AbhGLG2b (ORCPT ); Mon, 12 Jul 2021 02:28:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C600A61186; Mon, 12 Jul 2021 06:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071088; bh=mzcRiwKThN+67qPhgYTN8nZbLjTzWdkCoH98iH2CED8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PPRMzTuNEq7Xt9+O3BxRGfctnCw8voCd7fIOXxV8j4E7Sa03/u6eop16SqLFJlkgo Mm4IX1fs43+3aAM1SmsiDKn6Er5Y6ojWINHb0ezOQYlpADg66fJ2MfNAIhLwXMRxWe EUqKzl8gB8Y38h9v8uf6EISjQTCrb1/S9kk+DOJ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Stephan Gerhold , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 270/348] iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:54 +0200 Message-Id: <20210712060739.437839940@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit 06778d881f3798ce93ffbbbf801234292250b598 ] To make code more readable, use a structure to express the channel layout and ensure the timestamp is 8 byte aligned. Found during an audit of all calls of uses of iio_push_to_buffers_with_timestamp() Fixes: 13426454b649 ("iio: bmg160: Separate i2c and core driver") Signed-off-by: Jonathan Cameron Cc: Stephan Gerhold Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-11-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/gyro/bmg160_core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 428ddfc13acb..276bed47e8d6 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -96,7 +96,11 @@ struct bmg160_data { struct iio_trigger *motion_trig; struct iio_mount_matrix orientation; struct mutex mutex; - s16 buffer[8]; + /* Ensure naturally aligned timestamp */ + struct { + s16 chans[3]; + s64 timestamp __aligned(8); + } scan; u32 dps_range; int ev_enable_state; int slope_thres; @@ -880,12 +884,12 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p) mutex_lock(&data->mutex); ret = regmap_bulk_read(data->regmap, BMG160_REG_XOUT_L, - data->buffer, AXIS_MAX * 2); + data->scan.chans, AXIS_MAX * 2); mutex_unlock(&data->mutex); if (ret < 0) goto err; - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, pf->timestamp); err: iio_trigger_notify_done(indio_dev->trig);