From patchwork Mon Jul 12 06:10:44 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: 472880 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp2649369jao; Sun, 11 Jul 2021 23:32:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoRMkPZDSwvejLiOLJQ8iWKk28YjlTaSMSW3XMreLdwu1yuW8MlNw32ms9b3xmmdEwvgYe X-Received: by 2002:a50:f0d4:: with SMTP id a20mr10630274edm.354.1626071420684; Sun, 11 Jul 2021 23:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071420; cv=none; d=google.com; s=arc-20160816; b=r/hE9sX6bJY9B0TQ6m8943/OkvWVCMccq89t2hJPdYoYtRohk2suUG7jWX6+c+WnaO RRnbPP3yQ4TDPfStbsICGnd6D95Lki+TgOH8FM3M6rt2ySpLJKZeXI7rrZ8guaODezWT T/Zp//0IYf4o4MkjiS6Kr3ma3LDJtB67jxZLMSKra5gnlsMBMZgZFhCrcutlJnwZdahi ksiKDCtInZXx4wp0nhCjryPy/oAEwBkuMJN/CQtkmLPiHDIanwXNfsm58oh4WCTt2LQR FUf82sggG1mZprqL9YMAZjvR1a3vnReAMjQNkTxsbPICzJwf6N4RCFkckB5Y4tOuEyWZ PuTA== 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=hQ4e5yIfv3xjLoAGtxUqjNmWW3vCbC0oed+qg1Iu/VM=; b=DPzXqG1EhjeOxwh59hoxvV7P+5vhyAHhoDbTFUmsEMgIg7tbD6xytuNSxu1LnwUM8b bdQ7etMcYmxAsnsa4xq79wgNhxwSlMbe3qr2Fo1NUZZn284t4MnIxInZJbaCnel4YAZj keYCnaywT52iK74ybnIi6zELOooqDk9nd38K7vnW7M3lr2cRpq0oZ42tue6DS0/4CizQ fHSbskUxcn5PGnUxiXwKDUo4ZnGDMvKg+z1OId/aMS79OeFPVbdzGVZsLz8L41D1l1u0 A+ZTyvJwEucOlY+47y2Z9QUuF+7QTkbq37rGozYAw+Kf23DCtIvZhUASymM3lL9QrPXS r1+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cF5NekA4; 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 bz6si16420285ejc.610.2021.07.11.23.30.20; Sun, 11 Jul 2021 23:30:20 -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=cF5NekA4; 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 S235922AbhGLGc5 (ORCPT + 12 others); Mon, 12 Jul 2021 02:32:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235858AbhGLG3g (ORCPT ); Mon, 12 Jul 2021 02:29:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11257611AF; Mon, 12 Jul 2021 06:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071165; bh=xougpzLdySV4jand12tnZxdIfNORjh8lOV4mlje6WPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cF5NekA4R/kD7rquDc8E8czUCNG2X0ngDETIJlRXiUb256VUrbOSQYgOBp4WqdfDu UFGow8/fWRvRPHVtOPQbXCEbFt8gN4fe0QIgDvdIWsbzNAtUQSh6oMWitghySU9OXu EZOBfEMrFo22YipCPZh7ssmrJqQxzgU7LZjDfuoA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Peter Meerwald , Andy Shevchenko , Sasha Levin Subject: [PATCH 5.4 260/348] iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp() Date: Mon, 12 Jul 2021 08:10:44 +0200 Message-Id: <20210712060737.645169845@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 fc36da3131a747a9367a05caf06de19be1bcc972 ] 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 this function. Fixes: b9a6a237ffc9 ("iio:bma180: Drop _update_scan_mode()") Signed-off-by: Jonathan Cameron Cc: Peter Meerwald Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20210501170121.512209-2-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/accel/bma180.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.30.2 diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 1574e4604a4f..aa301c606346 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -119,7 +119,11 @@ struct bma180_data { int scale; int bw; bool pmode; - u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */ + /* Ensure timestamp is naturally aligned */ + struct { + s16 chan[4]; + s64 timestamp __aligned(8); + } scan; }; enum bma180_chan { @@ -675,12 +679,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p) mutex_unlock(&data->mutex); goto err; } - ((s16 *)data->buff)[i++] = ret; + data->scan.chan[i++] = ret; } mutex_unlock(&data->mutex); - iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns); + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns); err: iio_trigger_notify_done(indio_dev->trig);