From patchwork Mon Jul 19 14:50:18 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: 479911 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4228291jao; Mon, 19 Jul 2021 08:24:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLIfN+JusqWXsONdvEweRVaTuTun1V4v4TEndTaTMeUoQE1VU+oUfjdSGURERJdWeKDG6X X-Received: by 2002:a02:956a:: with SMTP id y97mr22177826jah.58.1626708180630; Mon, 19 Jul 2021 08:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626708180; cv=none; d=google.com; s=arc-20160816; b=mmdB6HKNotA/e8nLq/dFI7SmEs0VLFXzfpM097WCSXPn25CEouWAC3m5ywhlNtsZ4P jr8smU+iBVS+0Rq3p8Csbq9wuZMlMk/DuqAIkn4SuE7nCypLn9wZgr4tJKVDHwh+q/Wq oAHDWij8lwG1ClbFvuPo3a9wjChAaLBXtM5lkfVmHKI6znnJPFI7TbGCY4fGpqYr/nAs FS0DRvPihcANJUARfvLHCNhxpHXGQOL9I8h7CAhdIlxkRfdbd08kk97TO2IeJtD8UYqe v9T7s29hyeAe0xnkp40S5U9sz8qJfKIt3Ytzhp/66qI4nl+s97j/AnOVynm2e7Srwf6Q ZQYA== 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=rqJqM2oFnu2Hg9iMRmODAWPCnAVFzU2E3uHxulxEgltVj6bj80CUCD4JropE+pSxAI vJH1n9oHV/pGu7IuB4ZE28fWCECKkD3Z+6BUn//WljdA/yaPDW1gyanBD/kvkX8BPknE OnrlnK36rpO/Nymnn4B1XbOzouYt4qnOqoSfVTscHv5Ww4Rj3QxQYHxIR1LM00n70iDi yaU4qhK6HLHJ+mTquHeDcSSMA64nFrf+UvbDB5wfrVGZMWaJiaIr0KYD2kmEpS0hhYQf CU9dAbIazdaYg5MyTpse0XtRwdcMQJ5yZkNr0EZ76Zta0H93Y/UlVTocnCw4Mu8hnBZ1 8CXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2XnVt1H5; 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 g15si9692004iln.71.2021.07.19.08.23.00; Mon, 19 Jul 2021 08:23:00 -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=2XnVt1H5; 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 S245499AbhGSOmT (ORCPT + 12 others); Mon, 19 Jul 2021 10:42:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343703AbhGSOji (ORCPT ); Mon, 19 Jul 2021 10:39:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2829861376; Mon, 19 Jul 2021 15:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707972; bh=xk/fJGCTC6q9pLxBS7KqfkGWjIADfU/VuEpkJ+iALSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2XnVt1H5DIiWGrRYBfoH2ynZop+h9idEhjkkoGkAjt3E3paGEryTZIyPjG8k52Ri+ Tdf4ehFg9IHjKU8U3OCi2jlp2y6CUPFSriYOOJa4ojF2Elz0xm9AaX7jFjw1xdkCtT LeckfagQMdE0S2/CSAZcXOHV20IfEhaIJbwpAMNI= 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.14 129/315] iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 19 Jul 2021 16:50:18 +0200 Message-Id: <20210719144947.127051418@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.861561397@linuxfoundation.org> References: <20210719144942.861561397@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);