From patchwork Mon Jul 19 14:50:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 479876 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4217903jao; Mon, 19 Jul 2021 08:12:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfUYgpuI3UEtePasC254trP2fxhQxdvg0dTw0NzyX17Uu23dHpRhLY6lc210Xfg0btof2C X-Received: by 2002:a17:907:7d9f:: with SMTP id oz31mr27332791ejc.366.1626707549287; Mon, 19 Jul 2021 08:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707549; cv=none; d=google.com; s=arc-20160816; b=Hlwxmrws208OUyNT8XicsuokbwJbQ/bnxJBvsRoU4zRDz8GAY4S7LgCu+ubxky7mSf 14FW9F7fWmM2p9TpmuWTaD3eMjqxblpv/H489VOQcgOWtr+8/Oo2f9Hgx4n2fOqKyzQL drZ9Sddrv5QyMFg6jvq/xUZ0xQu8UDMHEJ+e2B9XSIMdPMwFrWb8G8gx9yqisOn8YfrI 6/oSJ8ZoL9e+2+ve+3DjIYmGcZTUxMB8Mp6Y+fwwxslCf57ga+RFKbIXoLFIOJTsSmzA NRHx+I2qzWX3O0iT6jrYpsTA7cU04G+wz9gdMdooFCQty2G0VXzquFhyEIZxiiemosX1 lhXA== 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=vClsqNDZUk9FwRYZ0Qf/eSJEZ3mzjUhjJQBCCS4faH4=; b=pTWeCsqORDTaQCGtk3fmiu6qb22T7V6wf1STaJBWjkFv9FFHt+XOq1yqGWf5MYy0wc 7dKCXomwHuRILNWGcPRjg91bVk7ucNu94WBOWHshxJ49Sj28F9pYSsHmgJA8ylHKTUzX BWKm9rHz6kcXMYAkSAXYgvU0Bq81Gz+T416tsH/d+aNqJmWD4u0SDSp3dGUbCXr2GMqc ifvqPz+D4CNLOQxpe7K1CYG1LvX+UPpYECfUHnJy6P8+vGWQU0sY/BFExciXoB3Fgywv JU0He/qEeZFU9c3/5tZZwAUXhL74QQGimpKpYUOY0nUXTf9Md64adCmnTRSaUnauW9sr rxpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vN9hhGk4; 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 d26si20449114ejc.620.2021.07.19.08.12.29; Mon, 19 Jul 2021 08:12:29 -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=vN9hhGk4; 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 S245226AbhGSObY (ORCPT + 12 others); Mon, 19 Jul 2021 10:31:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:38648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244162AbhGSO3Z (ORCPT ); Mon, 19 Jul 2021 10:29:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CEA596113B; Mon, 19 Jul 2021 15:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707334; bh=xk/fJGCTC6q9pLxBS7KqfkGWjIADfU/VuEpkJ+iALSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vN9hhGk4xLAmXecaEI1DHZpgBF+l+ztCYk34jl0B+ExKndpHHE0ukmpr7Pu50E6Ds 6KB1uUhYzUAYO8g70xjNovvPNelQSDXB9N/swDZltbobU4z7w8orMhKq5ce6QRvq2h kX+G1yHEH6609PQZS0gLRJfjvrNy/r5kbsFMSo6A= 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 4.9 101/245] iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:43 +0200 Message-Id: <20210719144943.686012923@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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 b5a5517e3ce1..ec2830c16433 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -104,7 +104,11 @@ struct bmg160_data { struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; 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; @@ -874,12 +878,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);